Skip to content

Commit

Permalink
fix: check expiration is before request end (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau authored Dec 5, 2023
1 parent b625f0d commit 87461f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contracts/Marketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ contract Marketplace is Proofs, StateRetrieval {
require(_requests[id].client == address(0), "Request already exists");

_requests[id] = request;
_requestContexts[id].endsAt = block.timestamp + request.ask.duration;
uint256 requestEnd = block.timestamp + request.ask.duration;
require(requestEnd > request.expiry, "Request end before expiry");
_requestContexts[id].endsAt = requestEnd;

_addToMyRequests(request.client, id);

Expand Down
8 changes: 8 additions & 0 deletions test/Marketplace.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ describe("Marketplace", function () {
)
})

it("rejects request when expiry is after request end", async function () {
request.expiry = await currentTime() + request.ask.duration + hours(1)
await token.approve(marketplace.address, price(request))
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
"Request end before expiry"
)
})

it("rejects resubmission of request", async function () {
await token.approve(marketplace.address, price(request) * 2)
await marketplace.requestStorage(request)
Expand Down

0 comments on commit 87461f6

Please sign in to comment.