[marketplace] add list of active requests

This commit is contained in:
Eric Mastro 2022-10-25 13:00:48 +11:00
parent e97583befd
commit b2f9e07c56
No known key found for this signature in database
GPG Key ID: 141E3048D95A4E63
2 changed files with 11 additions and 0 deletions

View File

@ -15,6 +15,7 @@ contract Marketplace is Collateral, Proofs {
mapping(RequestId => Request) private requests;
mapping(RequestId => RequestContext) private requestContexts;
mapping(SlotId => Slot) private slots;
mapping(address => RequestId[]) private activeRequests;
constructor(
IERC20 _token,
@ -30,6 +31,10 @@ contract Marketplace is Collateral, Proofs {
collateral = _collateral;
}
function myRequests() public view returns (RequestId[] memory) {
return activeRequests[msg.sender];
}
function requestStorage(Request calldata request)
public
marketplaceInvariant

View File

@ -84,6 +84,12 @@ describe("Marketplace", function () {
.withArgs(requestId(request), askToArray(request.ask))
})
it("adds request to list of active requests", async function () {
await token.approve(marketplace.address, price(request))
await marketplace.requestStorage(request)
expect(await marketplace.myRequests()).to.deep.equal([requestId(request)])
})
it("rejects request with invalid client address", async function () {
let invalid = { ...request, client: host.address }
await token.approve(marketplace.address, price(invalid))