mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-01-12 23:35:49 +00:00
fix: ensure requestStorage() reverts if maxSlotloss > slots (#140)
This commit is contained in:
parent
8b3761c1a7
commit
e62ebf6b0e
@ -95,6 +95,10 @@ contract Marketplace is Proofs, StateRetrieval, Endian {
|
|||||||
request.expiry > 0 && request.expiry < request.ask.duration,
|
request.expiry > 0 && request.expiry < request.ask.duration,
|
||||||
"Expiry not in range"
|
"Expiry not in range"
|
||||||
);
|
);
|
||||||
|
require(
|
||||||
|
request.ask.maxSlotLoss <= request.ask.slots,
|
||||||
|
"maxSlotLoss exceeds slots"
|
||||||
|
);
|
||||||
|
|
||||||
_requests[id] = request;
|
_requests[id] = request;
|
||||||
_requestContexts[id].endsAt = block.timestamp + request.ask.duration;
|
_requestContexts[id].endsAt = block.timestamp + request.ask.duration;
|
||||||
|
@ -185,6 +185,13 @@ describe("Marketplace", function () {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("is rejected when maxSlotLoss exceeds slots", async function () {
|
||||||
|
request.ask.maxSlotLoss = request.ask.slots + 1
|
||||||
|
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
|
||||||
|
"maxSlotLoss exceeds slots"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it("rejects resubmission of request", async function () {
|
it("rejects resubmission of request", async function () {
|
||||||
await token.approve(marketplace.address, price(request) * 2)
|
await token.approve(marketplace.address, price(request) * 2)
|
||||||
await marketplace.requestStorage(request)
|
await marketplace.requestStorage(request)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user