Emit event when offer is selected
This commit is contained in:
parent
05fbd244e2
commit
c835ac1cc4
|
@ -81,6 +81,8 @@ contract Marketplace is Collateral {
|
|||
funds.sent += difference;
|
||||
funds.balance -= difference;
|
||||
token.transfer(request.client, difference);
|
||||
|
||||
emit OfferSelected(id);
|
||||
}
|
||||
|
||||
struct Request {
|
||||
|
@ -108,6 +110,7 @@ contract Marketplace is Collateral {
|
|||
|
||||
event StorageRequested(bytes32 id, Request request);
|
||||
event StorageOffered(bytes32 id, Offer offer);
|
||||
event OfferSelected(bytes32 id);
|
||||
|
||||
modifier marketplaceInvariant() {
|
||||
MarketplaceFunds memory oldFunds = funds;
|
||||
|
|
|
@ -163,6 +163,12 @@ describe("Marketplace", function () {
|
|||
switchAccount(client)
|
||||
})
|
||||
|
||||
it("emits event when offer is selected", async function () {
|
||||
await expect(marketplace.selectOffer(offerId(offer)))
|
||||
.to.emit(marketplace, "OfferSelected")
|
||||
.withArgs(offerId(offer))
|
||||
})
|
||||
|
||||
it("returns price difference to client", async function () {
|
||||
let difference = request.maxPrice - offer.price
|
||||
let before = await token.balanceOf(client.address)
|
||||
|
|
Loading…
Reference in New Issue