Host stake is locked up when contract is created

This commit is contained in:
Mark Spanbroek 2021-11-02 12:50:06 +01:00
parent d49c75a74b
commit 65c3cacb66
2 changed files with 11 additions and 1 deletions

View File

@ -29,6 +29,7 @@ contract Storage is Contracts, Proofs, Stakes {
public
{
require(_stake(_host) >= stakeAmount, "Insufficient stake");
_lockStake(_host);
bytes32 id = _newContract(
_duration,
_size,
@ -114,4 +115,8 @@ contract Storage is Contracts, Proofs, Stakes {
function increaseStake(uint amount) public {
_increaseStake(amount);
}
function withdrawStake() public {
_withdrawStake();
}
}

View File

@ -58,6 +58,12 @@ describe("Storage", function () {
expect(await storage.proofPeriod(id)).to.equal(request.proofPeriod)
expect(await storage.proofTimeout(id)).to.equal(request.proofTimeout)
})
it("locks up host stake", async function () {
await expect(
storage.connect(host).withdrawStake()
).to.be.revertedWith("Stake locked")
})
})
it("doesn't create contract when insufficient stake", async function () {
@ -81,7 +87,6 @@ describe("Storage", function () {
})
})
// TODO: lock up stake when new contract
// TODO: unlock stake at end of contract
// TODO: payment when new contract
// TODO: contract start and timeout