Allow events to be filtered by request id

This commit is contained in:
Mark Spanbroek 2022-02-21 14:18:28 +01:00 committed by markspanbroek
parent c835ac1cc4
commit 7e7134b99d
2 changed files with 7 additions and 7 deletions

View File

@ -56,7 +56,7 @@ contract Marketplace is Collateral {
_lock(msg.sender, offer.requestId);
emit StorageOffered(id, offer);
emit StorageOffered(id, offer, offer.requestId);
}
function selectOffer(bytes32 id) public marketplaceInvariant {
@ -82,7 +82,7 @@ contract Marketplace is Collateral {
funds.balance -= difference;
token.transfer(request.client, difference);
emit OfferSelected(id);
emit OfferSelected(id, offer.requestId);
}
struct Request {
@ -108,9 +108,9 @@ contract Marketplace is Collateral {
uint256 expiry;
}
event StorageRequested(bytes32 id, Request request);
event StorageOffered(bytes32 id, Offer offer);
event OfferSelected(bytes32 id);
event StorageRequested(bytes32 requestId, Request request);
event StorageOffered(bytes32 offerId, Offer offer, bytes32 indexed requestId);
event OfferSelected(bytes32 offerId, bytes32 indexed requestId);
modifier marketplaceInvariant() {
MarketplaceFunds memory oldFunds = funds;

View File

@ -88,7 +88,7 @@ describe("Marketplace", function () {
it("emits event when storage is offered", async function () {
await expect(marketplace.offerStorage(offer))
.to.emit(marketplace, "StorageOffered")
.withArgs(offerId(offer), offerToArray(offer))
.withArgs(offerId(offer), offerToArray(offer), requestId(request))
})
it("locks collateral of host", async function () {
@ -166,7 +166,7 @@ describe("Marketplace", function () {
it("emits event when offer is selected", async function () {
await expect(marketplace.selectOffer(offerId(offer)))
.to.emit(marketplace, "OfferSelected")
.withArgs(offerId(offer))
.withArgs(offerId(offer), requestId(request))
})
it("returns price difference to client", async function () {