Do not mark proof as missing twice

This commit is contained in:
Mark Spanbroek 2021-10-21 10:32:29 +02:00
parent c3e85c675a
commit 23887f9190
2 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,7 @@ contract StorageContracts {
uint proofTimeout; // proof has to be submitted before this
uint proofMarker; // indicates when a proof is required
mapping(uint => bool) proofReceived; // whether proof for block was received
mapping(uint => bool) proofMissing; // whether proof for block was missing
uint missingProofs;
}
@ -221,6 +222,8 @@ contract StorageContracts {
isProofRequired(contractId, blocknumber),
"Proof was not required"
);
require(!c.proofMissing[blocknumber], "Proof already marked as missing");
c.proofMissing[blocknumber] = true;
c.missingProofs += 1;
}
}

View File

@ -338,6 +338,16 @@ describe("Storage Contracts", function () {
contracts.markProofAsMissing(id, blocknumber)
).to.be.revertedWith("Proof was not required")
})
it("does not mark proof as missing twice", async function () {
await mineUntilProofIsRequired(id)
let blocknumber = await minedBlockNumber()
await mineUntilProofTimeout()
await contracts.markProofAsMissing(id, blocknumber)
await expect(
contracts.markProofAsMissing(id, blocknumber)
).to.be.revertedWith("Proof already marked as missing")
})
})
})