Fix flaky tests
By ensuring that there's enough blocks left for submitting a proof.
This commit is contained in:
parent
f8ddc4a2f6
commit
3fd7c756d9
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue