Host stake is locked up when contract is created
This commit is contained in:
parent
d49c75a74b
commit
65c3cacb66
|
@ -29,6 +29,7 @@ contract Storage is Contracts, Proofs, Stakes {
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
require(_stake(_host) >= stakeAmount, "Insufficient stake");
|
require(_stake(_host) >= stakeAmount, "Insufficient stake");
|
||||||
|
_lockStake(_host);
|
||||||
bytes32 id = _newContract(
|
bytes32 id = _newContract(
|
||||||
_duration,
|
_duration,
|
||||||
_size,
|
_size,
|
||||||
|
@ -114,4 +115,8 @@ contract Storage is Contracts, Proofs, Stakes {
|
||||||
function increaseStake(uint amount) public {
|
function increaseStake(uint amount) public {
|
||||||
_increaseStake(amount);
|
_increaseStake(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function withdrawStake() public {
|
||||||
|
_withdrawStake();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,12 @@ describe("Storage", function () {
|
||||||
expect(await storage.proofPeriod(id)).to.equal(request.proofPeriod)
|
expect(await storage.proofPeriod(id)).to.equal(request.proofPeriod)
|
||||||
expect(await storage.proofTimeout(id)).to.equal(request.proofTimeout)
|
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 () {
|
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: unlock stake at end of contract
|
||||||
// TODO: payment when new contract
|
// TODO: payment when new contract
|
||||||
// TODO: contract start and timeout
|
// TODO: contract start and timeout
|
||||||
|
|
Loading…
Reference in New Issue