-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Leonard
authored and
Robert Leonard
committed
Jun 25, 2024
1 parent
ff2a218
commit 401a96e
Showing
8 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
gatekeeper-cli/src/test/integration/change-network-authority.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { BaseProvider } from "@ethersproject/providers"; | ||
import * as dotenv from "dotenv"; | ||
import { ethers, utils, Wallet } from "ethers"; | ||
import {runCommand} from '@oclif/test' | ||
import { BNB_TESTNET_CONTRACT_ADDRESSES, createRandomString, FOUNDRY_DEFAULT_WALLET_ONE, FOUNDRY_DEFAULT_WALLET_TWO, GatewayNetworkClient } from "../../utils"; | ||
import assert = require('assert'); | ||
import { GatewayNetworkClass } from "@identity.com/gateway-evm-ts-client/dist/service/GatewayNetwork"; | ||
|
||
dotenv.config(); | ||
|
||
describe("Command: Transfer network authority", function () { | ||
let provider: BaseProvider; | ||
let testWallet: Wallet; | ||
let newPrimaryAuthority: Wallet; | ||
let networkClient: GatewayNetworkClass; | ||
|
||
before("Initialize wallet", async function () { | ||
this.timeout(20000); | ||
provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:8545"); // Test run against local node forked | ||
|
||
testWallet = FOUNDRY_DEFAULT_WALLET_ONE.connect(provider); | ||
newPrimaryAuthority = FOUNDRY_DEFAULT_WALLET_TWO.connect(provider); | ||
networkClient = GatewayNetworkClient(testWallet, BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork) | ||
}); | ||
|
||
it("transfer network authority", async function () { | ||
const networkName = createRandomString(4) | ||
await runCommand([ | ||
"create-gatekeeper-network", | ||
networkName, | ||
`${testWallet.address}`, | ||
"a-test-network", | ||
'0', | ||
`0`, | ||
`0x0000000000000000000000000000000000000000`, | ||
`--privateKey=${testWallet.privateKey}`, | ||
`--gatewayNetworkAddress=${BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork}`, | ||
`--chain=localhost` | ||
]) | ||
|
||
const result = await runCommand([ | ||
"transfer-network-authority", | ||
newPrimaryAuthority.address, | ||
networkName, | ||
`--privateKey=${testWallet.privateKey}`, | ||
`--gatewayNetworkAddress=${BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork}`, | ||
`--chain=localhost` | ||
]) | ||
|
||
console.log(`output: ${result.stdout}`) | ||
|
||
assert.equal(result.error, undefined, "No errors should occur when creating network") | ||
|
||
const resultTwo = await runCommand([ | ||
"claim-network-authority", | ||
networkName, | ||
`--privateKey=${newPrimaryAuthority.privateKey}`, | ||
`--gatewayNetworkAddress=${BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork}`, | ||
`--chain=localhost` | ||
]) | ||
|
||
console.log(`output: ${result.stdout}`) | ||
|
||
assert.equal(resultTwo.error, undefined, "No errors should occur when creating network") | ||
|
||
const networkId = await networkClient.getNetworkId(networkName); | ||
const answer = await networkClient.getNetwork(networkId.toString()); | ||
|
||
assert.equal(answer.primaryAuthority, newPrimaryAuthority.address, "networkId should be non zero") | ||
}) | ||
}) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { BaseProvider } from "@ethersproject/providers"; | ||
import * as dotenv from "dotenv"; | ||
import { ethers, utils, Wallet } from "ethers"; | ||
import {runCommand} from '@oclif/test' | ||
import { BNB_TESTNET_CONTRACT_ADDRESSES, createRandomString, FOUNDRY_DEFAULT_WALLET_ONE, GatewayNetworkClient } from "../../utils"; | ||
import assert = require('assert'); | ||
import { GatewayNetworkClass } from "@identity.com/gateway-evm-ts-client/dist/service/GatewayNetwork"; | ||
|
||
dotenv.config(); | ||
|
||
describe("Command: Remove gatekeeper from network", function () { | ||
let provider: BaseProvider; | ||
let testWallet: Wallet; | ||
let gatekeeper: Wallet; | ||
let networkClient: GatewayNetworkClass; | ||
|
||
before("Initialize wallet", async function () { | ||
this.timeout(20000); | ||
provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:8545"); // Test run against local node forked | ||
|
||
testWallet = FOUNDRY_DEFAULT_WALLET_ONE.connect(provider); | ||
gatekeeper = Wallet.createRandom(); | ||
networkClient = GatewayNetworkClient(testWallet, BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork) | ||
}); | ||
|
||
it("remove gatekeeper from network", async function () { | ||
const networkName = createRandomString(8) | ||
await runCommand([ | ||
"create-gatekeeper-network", | ||
networkName, | ||
`${testWallet.address}`, | ||
"a-test-network", | ||
'0', | ||
`0`, | ||
`0x0000000000000000000000000000000000000000`, | ||
`--privateKey=${testWallet.privateKey}`, | ||
`--gatewayNetworkAddress=${BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork}`, | ||
`--chain=localhost` | ||
]) | ||
|
||
await runCommand([ | ||
"add-gatekeeper", | ||
gatekeeper.address, | ||
networkName, | ||
`--privateKey=${testWallet.privateKey}`, | ||
`--gatewayNetworkAddress=${BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork}`, | ||
`--chain=localhost` | ||
]) | ||
|
||
const result = await runCommand([ | ||
"remove-gatekeeper", | ||
gatekeeper.address, | ||
networkName, | ||
`--privateKey=${testWallet.privateKey}`, | ||
`--gatewayNetworkAddress=${BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork}`, | ||
`--chain=localhost` | ||
]) | ||
|
||
console.log(`output: ${result.stdout}`) | ||
|
||
assert.equal(result.error, undefined, "No errors should occur when creating network") | ||
|
||
const answer = await networkClient.isGatekeeper(utils.formatBytes32String(networkName), gatekeeper.address); | ||
|
||
assert.equal(answer, false, "gatekeeper should be removed") | ||
}) | ||
}) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters