Only host can call start on a contract

This commit is contained in:
Mark Spanbroek 2021-11-04 09:53:01 +01:00
parent 376962322d
commit 6de82709ca
2 changed files with 12 additions and 1 deletions

View File

@ -45,7 +45,12 @@ contract Storage is Contracts, Proofs, Stakes {
);
}
function startContract(bytes32 id) public {
modifier onlyHost(bytes32 id) {
require(msg.sender == host(id), "Only host can call this function");
_;
}
function startContract(bytes32 id) public onlyHost(id) {
_expectProofs(id, proofPeriod(id), proofTimeout(id), duration(id));
}

View File

@ -67,6 +67,12 @@ describe("Storage", function () {
await storage.connect(host).startContract(id)
expect(await storage.proofEnd(id)).to.be.gt(0)
})
it("can only be done by the host", async function () {
await expect(
storage.connect(client).startContract(id)
).to.be.revertedWith("Only host can call this function")
})
})
})