Skip to content

Commit a96f3e3

Browse files
committed
Make skill bridging on colony creation more reliable in tests
1 parent 22809d1 commit a96f3e3

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

scripts/mockBridgeMonitor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ class MockBridgeMonitor {
8282

8383
close() {} // eslint-disable-line class-methods-use-this
8484

85-
async bridgeSkipped() {
86-
const [bridge, messageId, encodedData] = this.skipped.shift();
85+
async bridgeSkipped(id = 0) {
86+
// remove the id'th element from the array
87+
const [bridge, messageId, encodedData] = this.skipped.splice(id, 1)[0];
8788
const [target, data, gasLimit, sender] = ethers.utils.defaultAbiCoder.decode(["address", "bytes", "uint256", "address"], encodedData);
8889
const tx = await bridge.execute(target, data, gasLimit, messageId, sender);
8990
await tx.wait();

test/cross-chain/cross-chain.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,21 @@ contract("Cross-chain", (accounts) => {
249249
}
250250

251251
beforeEach(async () => {
252-
const tx = await foreignBridge.setBridgeEnabled(true);
252+
let tx = await foreignBridge.setBridgeEnabled(true);
253253
await tx.wait();
254254
// Set up a colony on the home chain. That may or may not be the truffle chain...
255255
homeColony = await setupColony(homeColonyNetwork);
256-
257256
const p = bridgeMonitor.getPromiseForNextBridgedTransaction(2);
258257
foreignColony = await setupColony(foreignColonyNetwork);
259258
await p;
259+
260+
// It's possible these were bridged out of order, so check, and if so, bridge the second skill
261+
const bridgedSkillCount = await homeColonyNetwork.getBridgedSkillCounts(foreignChainId);
262+
const skillCount = await foreignColonyNetwork.getSkillCount();
263+
if (!bridgedSkillCount.eq(skillCount)) {
264+
tx = await homeColonyNetwork.addPendingSkill(homeBridge.address, skillCount, { gasLimit: 1000000 });
265+
await tx.wait();
266+
}
260267
});
261268

262269
afterEach(async () => {
@@ -790,7 +797,13 @@ contract("Cross-chain", (accounts) => {
790797
let p = bridgeMonitor.getPromiseForNextBridgedTransaction(2);
791798
const foreignColony2 = await setupColony(foreignColonyNetwork);
792799
await p;
793-
800+
// It's possible these were bridged out of order, so check, and if so, bridge the second skill
801+
const bridgedSkillCount = await homeColonyNetwork.getBridgedSkillCounts(foreignChainId);
802+
const skillCount = await foreignColonyNetwork.getSkillCount();
803+
if (!bridgedSkillCount.eq(skillCount)) {
804+
const tx = await homeColonyNetwork.addPendingSkill(homeBridge.address, skillCount, { gasLimit: 1000000 });
805+
await tx.wait();
806+
}
794807
let tx = await foreignBridge.setBridgeEnabled(false);
795808
await tx.wait();
796809
tx = await foreignColony.emitDomainReputationReward(1, accounts[0], "0x1338");
@@ -846,6 +859,14 @@ contract("Cross-chain", (accounts) => {
846859
const foreignColony2 = await setupColony(foreignColonyNetwork);
847860
await p;
848861

862+
// It's possible these were bridged out of order, so check, and if so, bridge the second skill
863+
const bridgedSkillCount = await homeColonyNetwork.getBridgedSkillCounts(foreignChainId);
864+
const skillCount = await foreignColonyNetwork.getSkillCount();
865+
if (!bridgedSkillCount.eq(skillCount)) {
866+
const tx = await homeColonyNetwork.addPendingSkill(homeBridge.address, skillCount, { gasLimit: 1000000 });
867+
await tx.wait();
868+
}
869+
849870
bridgeMonitor.skipCount = 1;
850871

851872
// Bridge skills

0 commit comments

Comments
 (0)