Skip to content

Commit

Permalink
Try to pin down spotty miner test
Browse files Browse the repository at this point in the history
  • Loading branch information
area committed Apr 8, 2024
1 parent d81142a commit 92f496c
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ hre.__SOLIDITY_COVERAGE_RUNNING
await forwardTimeTo(parseInt(goodEntry.lastResponseTimestamp, 10));
await noEventSeen(repCycleEthers, "JustificationRootHashConfirmed");

await forwardTime(CHALLENGE_RESPONSE_WINDOW_DURATION + 1, this);
await forwardTimeTo(parseInt(goodEntry.lastResponseTimestamp, 10) + CHALLENGE_RESPONSE_WINDOW_DURATION + 1, this);

const reputationMinerClient2 = new ReputationMinerClient({
loader,
Expand All @@ -875,7 +875,10 @@ hre.__SOLIDITY_COVERAGE_RUNNING
await goodClientConfirmedJRH;

// Now cleanup

// I think there was an issue here on CI where sometimes, we would happen to be eligible to
// invalidate the bad hash immediately after confirming the JRH due to things being slow and
// using 'forwardTime'. That would cause this event to fire before the promise was set up, and
// the test to fail. I've replace the forwardTimes with forwardTimeTo to try and fix this.
const goodClientInvalidateOpponent = new Promise(function (resolve, reject) {
repCycleEthers.on("HashInvalidated", async (_hash, _nLeaves, _jrh, event) => {
if (_hash === badRootHash && _nLeaves.eq(badNLeaves) && _jrh === badJrh) {
Expand All @@ -890,7 +893,7 @@ hre.__SOLIDITY_COVERAGE_RUNNING
}, 30000);
});

await forwardTime(CHALLENGE_RESPONSE_WINDOW_DURATION + 1, this);
await forwardTimeTo(parseInt(goodEntry.lastResponseTimestamp, 10) + CHALLENGE_RESPONSE_WINDOW_DURATION * 2 + 1, this);

// Good client should now realise it can timeout bad submission
await goodClientInvalidateOpponent;
Expand Down

0 comments on commit 92f496c

Please sign in to comment.