Only host can call start on a contract
This commit is contained in:
parent
376962322d
commit
6de82709ca
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue