Skip to content

Commit cf3e414

Browse files
committed
Use events, not loop to find CoinMachine version
1 parent 538e516 commit cf3e414

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/contracts-network/colony-arbitrary-transactions.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ contract("Colony Arbitrary Transactions", (accounts) => {
207207
it("should not be able to make arbitrary transactions to the colony's own extensions", async () => {
208208
const COIN_MACHINE = soliditySha3("CoinMachine");
209209

210-
let coinMachineVersion = 0;
211-
let coinMachineResolverAddress = ethers.constants.AddressZero;
212-
213-
while (coinMachineResolverAddress === ethers.constants.AddressZero) {
214-
coinMachineVersion += 1;
215-
coinMachineResolverAddress = await colonyNetwork.getExtensionResolver(COIN_MACHINE, coinMachineVersion);
216-
}
217-
await colony.installExtension(COIN_MACHINE, coinMachineVersion);
210+
const ethersProvider = new ethers.providers.JsonRpcProvider(web3.currentProvider.host);
211+
const ethersColonyNetwork = new ethers.Contract(colonyNetwork.address, colonyNetwork.abi, ethersProvider);
212+
213+
const eventFilter = ethersColonyNetwork.filters.ExtensionAddedToNetwork(COIN_MACHINE);
214+
const events = await ethersColonyNetwork.queryFilter(eventFilter, 0);
215+
const log = await ethersColonyNetwork.interface.parseLog(events[0]);
216+
217+
await colony.installExtension(COIN_MACHINE, log.args.version);
218218

219219
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
220220
const coinMachine = await CoinMachine.at(coinMachineAddress);

0 commit comments

Comments
 (0)