From ed67b2338fcb5c45ba7af0e76b5397f811ac6c6b Mon Sep 17 00:00:00 2001 From: Klemen <64400885+zajck@users.noreply.github.com> Date: Fri, 16 Feb 2024 17:11:32 +0100 Subject: [PATCH] Price discovery offers must have 0 initial price (#909) * Update solidity code * Unit tests --- contracts/domain/BosonErrors.sol | 2 ++ .../handlers/IBosonOfferHandler.sol | 2 ++ .../handlers/IBosonOrchestrationHandler.sol | 16 ++++++++++ contracts/protocol/bases/OfferBase.sol | 5 +++ .../protocol/facets/OfferHandlerFacet.sol | 2 ++ .../facets/OrchestrationHandlerFacet1.sol | 16 ++++++++++ scripts/config/revert-reasons.js | 1 + test/protocol/OfferHandlerTest.js | 32 +++++++++++++++++++ test/protocol/OrchestrationHandlerTest.js | 23 +++++++++++++ 9 files changed, 99 insertions(+) diff --git a/contracts/domain/BosonErrors.sol b/contracts/domain/BosonErrors.sol index 24b12d0f9..f20c718f7 100644 --- a/contracts/domain/BosonErrors.sol +++ b/contracts/domain/BosonErrors.sol @@ -174,6 +174,8 @@ interface BosonErrors { error InvalidRoyaltyInfo(); // Trying to change the default recipient address (treasury) error WrongDefaultRecipient(); + // Price discovery offer has non zero price + error InvalidPriceDiscoveryPrice(); // Group related // Group does not exist diff --git a/contracts/interfaces/handlers/IBosonOfferHandler.sol b/contracts/interfaces/handlers/IBosonOfferHandler.sol index 48433f830..0b2e30d45 100644 --- a/contracts/interfaces/handlers/IBosonOfferHandler.sol +++ b/contracts/interfaces/handlers/IBosonOfferHandler.sol @@ -31,6 +31,7 @@ interface IBosonOfferHandler is BosonErrors, IBosonOfferEvents { * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -81,6 +82,7 @@ interface IBosonOfferHandler is BosonErrors, IBosonOfferEvents { * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list diff --git a/contracts/interfaces/handlers/IBosonOrchestrationHandler.sol b/contracts/interfaces/handlers/IBosonOrchestrationHandler.sol index d27180257..002ae0851 100644 --- a/contracts/interfaces/handlers/IBosonOrchestrationHandler.sol +++ b/contracts/interfaces/handlers/IBosonOrchestrationHandler.sol @@ -91,6 +91,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -170,6 +171,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -232,6 +234,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -290,6 +293,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -349,6 +353,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -409,6 +414,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -471,6 +477,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -537,6 +544,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -606,6 +614,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -677,6 +686,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -767,6 +777,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -852,6 +863,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -939,6 +951,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -1032,6 +1045,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -1127,6 +1141,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -1225,6 +1240,7 @@ interface IBosonOrchestrationHandler is * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list diff --git a/contracts/protocol/bases/OfferBase.sol b/contracts/protocol/bases/OfferBase.sol index 5549ba3b9..c21d66bb9 100644 --- a/contracts/protocol/bases/OfferBase.sol +++ b/contracts/protocol/bases/OfferBase.sol @@ -30,6 +30,7 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents { * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -96,6 +97,7 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents { * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -147,6 +149,9 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents { // quantity must be greater than zero if (_offer.quantityAvailable == 0) revert InvalidQuantityAvailable(); + // If offer is of the discovery type, price must be zero + if (_offer.priceType == PriceType.Discovery && _offer.price != 0) revert InvalidPriceDiscoveryPrice(); + DisputeResolutionTerms memory disputeResolutionTerms; OfferFees storage offerFees = fetchOfferFees(_offer.id); { diff --git a/contracts/protocol/facets/OfferHandlerFacet.sol b/contracts/protocol/facets/OfferHandlerFacet.sol index 6668e6a23..4a2c4000e 100644 --- a/contracts/protocol/facets/OfferHandlerFacet.sol +++ b/contracts/protocol/facets/OfferHandlerFacet.sol @@ -38,6 +38,7 @@ contract OfferHandlerFacet is IBosonOfferHandler, OfferBase { * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -90,6 +91,7 @@ contract OfferHandlerFacet is IBosonOfferHandler, OfferBase { * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list diff --git a/contracts/protocol/facets/OrchestrationHandlerFacet1.sol b/contracts/protocol/facets/OrchestrationHandlerFacet1.sol index 95ef017ae..64a648f63 100644 --- a/contracts/protocol/facets/OrchestrationHandlerFacet1.sol +++ b/contracts/protocol/facets/OrchestrationHandlerFacet1.sol @@ -64,6 +64,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -144,6 +145,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -219,6 +221,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -291,6 +294,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -360,6 +364,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -428,6 +433,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -493,6 +499,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -565,6 +572,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -645,6 +653,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -731,6 +740,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -831,6 +841,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -927,6 +938,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -1026,6 +1038,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -1130,6 +1143,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -1237,6 +1251,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list @@ -1347,6 +1362,7 @@ contract OrchestrationHandlerFacet1 is PausableBase, SellerBase, OfferBase, Grou * - Resolution period is not between the minimum and the maximum resolution period * - Voided is set to true * - Available quantity is set to zero + * - Offer type is discovery and the price is not set to zero * - Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver * - Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver * - Seller is not on dispute resolver's seller allow list diff --git a/scripts/config/revert-reasons.js b/scripts/config/revert-reasons.js index 2e6a1b58f..3b537d146 100644 --- a/scripts/config/revert-reasons.js +++ b/scripts/config/revert-reasons.js @@ -52,6 +52,7 @@ exports.RevertReasons = { NO_SUCH_COLLECTION: "NoSuchCollection", INVALID_ROYALTY_RECIPIENT: "InvalidRoyaltyRecipient", INVALID_ROYALTY_PERCENTAGE: "InvalidRoyaltyPercentage", + INVALID_PRICE_DISCOVERY_PRICE: "InvalidPriceDiscoveryPrice", // Group related NO_SUCH_GROUP: "NoSuchGroup", diff --git a/test/protocol/OfferHandlerTest.js b/test/protocol/OfferHandlerTest.js index bfa0a9bff..403bbed1c 100644 --- a/test/protocol/OfferHandlerTest.js +++ b/test/protocol/OfferHandlerTest.js @@ -37,6 +37,7 @@ const { accountId, } = require("../util/mock"); const { encodeBytes32String } = require("ethers"); +const PriceType = require("../../scripts/domain/PriceType.js"); /** * Test the Boson Offer Handler interface @@ -867,6 +868,18 @@ describe("IBosonOfferHandler", function () { ).to.revertedWithCustomError(bosonErrors, RevertReasons.INVALID_QUANTITY_AVAILABLE); }); + it("Offer type is discovery and the price is not set to zero", async function () { + // Set offer type to discovery + offer.priceType = PriceType.Discovery; + + // Attempt to Create an offer, expecting revert + await expect( + offerHandler + .connect(assistant) + .createOffer(offer, offerDates, offerDurations, disputeResolver.id, agentId, offerFeeLimit) + ).to.revertedWithCustomError(bosonErrors, RevertReasons.INVALID_PRICE_DISCOVERY_PRICE); + }); + it("Dispute resolver wallet is not registered", async function () { // Set some address that is not registered as a dispute resolver disputeResolver.id = "16"; @@ -2948,6 +2961,25 @@ describe("IBosonOfferHandler", function () { ).to.revertedWithCustomError(bosonErrors, RevertReasons.INVALID_QUANTITY_AVAILABLE); }); + it("For some offer, offer type is discovery and the price is not set to zero", async function () { + // Set offer type to discovery + offers[2].priceType = PriceType.Discovery; + + // Attempt to Create an offer, expecting revert + await expect( + offerHandler + .connect(assistant) + .createOfferBatch( + offers, + offerDatesList, + offerDurationsList, + disputeResolverIds, + agentIds, + offerFeeLimits + ) + ).to.revertedWithCustomError(bosonErrors, RevertReasons.INVALID_PRICE_DISCOVERY_PRICE); + }); + it("For some offer, dispute resolver wallet is not registered", async function () { // Set some address that is not registered as a dispute resolver disputeResolverIds[1] = "16"; diff --git a/test/protocol/OrchestrationHandlerTest.js b/test/protocol/OrchestrationHandlerTest.js index 2b76a1a15..ff8156c4c 100644 --- a/test/protocol/OrchestrationHandlerTest.js +++ b/test/protocol/OrchestrationHandlerTest.js @@ -6,6 +6,7 @@ const Seller = require("../../scripts/domain/Seller"); const Offer = require("../../scripts/domain/Offer"); const OfferDates = require("../../scripts/domain/OfferDates"); const OfferDurations = require("../../scripts/domain/OfferDurations"); +const PriceType = require("../../scripts/domain/PriceType.js"); const Group = require("../../scripts/domain/Group"); const Condition = require("../../scripts/domain/Condition"); const EvaluationMethod = require("../../scripts/domain/EvaluationMethod"); @@ -2071,6 +2072,28 @@ describe("IBosonOrchestrationHandler", function () { ).to.revertedWithCustomError(bosonErrors, RevertReasons.INVALID_QUANTITY_AVAILABLE); }); + it("Offer type is discovery and the price is not set to zero", async function () { + // Set offer type to discovery + offer.priceType = PriceType.Discovery; + + // Attempt to create a seller and an offer, expecting revert + await expect( + orchestrationHandler + .connect(assistant) + .createSellerAndOffer( + seller, + offer, + offerDates, + offerDurations, + disputeResolver.id, + emptyAuthToken, + voucherInitValues, + agentId, + offerFeeLimit + ) + ).to.revertedWithCustomError(bosonErrors, RevertReasons.INVALID_PRICE_DISCOVERY_PRICE); + }); + it("Dispute resolver wallet is not registered", async function () { // Set some address that is not registered as a dispute resolver disputeResolver.id = "16";