[marketplace] add list of active requests
This commit is contained in:
parent
e97583befd
commit
b2f9e07c56
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue