Fix flaky tests

By ensuring that there's enough blocks left
for submitting a proof.
This commit is contained in:
Mark Spanbroek 2022-03-10 13:35:41 +01:00 committed by markspanbroek
parent f8ddc4a2f6
commit 3fd7c756d9
4 changed files with 18 additions and 1 deletions

View File

@ -75,6 +75,10 @@ contract Proofs {
return uint8(pointer);
}
function _getPointer(bytes32 id) internal view returns (uint8) {
return _getPointer(id, currentPeriod());
}
function _getChallenge(uint8 pointer) internal view returns (bytes32) {
bytes32 hash = blockhash(block.number - 1 - pointer);
assert(uint256(hash) != 0);

View File

@ -68,6 +68,10 @@ contract Storage is Collateral, Marketplace, Proofs {
return _getChallenge(contractId);
}
function getPointer(bytes32 id) public view returns (uint8) {
return _getPointer(id);
}
function submitProof(bytes32 contractId, bool proof) public {
_submitProof(contractId, proof);
}

View File

@ -48,6 +48,10 @@ contract TestProofs is Proofs {
return _getChallenge(id);
}
function getPointer(bytes32 id) public view returns (uint8) {
return _getPointer(id);
}
function submitProof(bytes32 id, bool proof) public {
_submitProof(id, proof);
}

View File

@ -107,7 +107,12 @@ describe("Proofs", function () {
async function waitUntilProofIsRequired(id) {
await advanceTimeTo(periodEnd(periodOf(await currentTime())))
while (!(await proofs.isProofRequired(id))) {
while (
!(
(await proofs.isProofRequired(id)) &&
(await proofs.getPointer(id)) < 250
)
) {
await advanceTime(period)
}
}