fix: ensure requestStorage() reverts if maxSlotloss > slots (#140)

This commit is contained in:
r4bbit 2024-08-05 10:58:51 +02:00 committed by GitHub
parent 8b3761c1a7
commit e62ebf6b0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -95,6 +95,10 @@ contract Marketplace is Proofs, StateRetrieval, Endian {
request.expiry > 0 && request.expiry < request.ask.duration,
"Expiry not in range"
);
require(
request.ask.maxSlotLoss <= request.ask.slots,
"maxSlotLoss exceeds slots"
);
_requests[id] = request;
_requestContexts[id].endsAt = block.timestamp + request.ask.duration;

View File

@ -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 () {
await token.approve(marketplace.address, price(request) * 2)
await marketplace.requestStorage(request)