diff --git a/contracts/protocol/clients/voucher/BosonVoucher.sol b/contracts/protocol/clients/voucher/BosonVoucher.sol index 4b3b99a4c..635710945 100644 --- a/contracts/protocol/clients/voucher/BosonVoucher.sol +++ b/contracts/protocol/clients/voucher/BosonVoucher.sol @@ -220,7 +220,7 @@ contract BosonVoucherBase is IBosonVoucher, BeaconClientBase, OwnableUpgradeable // Make sure that offer is not expired or voided (Offer memory offer, OfferDates memory offerDates) = getBosonOffer(_offerId); - require(!offer.voided && (offerDates.validUntil > block.timestamp), OFFER_EXPIRED_OR_VOIDED); + require(!offer.voided && (block.timestamp <= offerDates.validUntil), OFFER_EXPIRED_OR_VOIDED); // Get the first token to mint uint256 start = range.start + range.minted; @@ -276,7 +276,7 @@ contract BosonVoucherBase is IBosonVoucher, BeaconClientBase, OwnableUpgradeable // Make sure that offer is either expired or voided (Offer memory offer, OfferDates memory offerDates) = getBosonOffer(_offerId); - require(offer.voided || (offerDates.validUntil <= block.timestamp), OFFER_STILL_VALID); + require(offer.voided || (block.timestamp > offerDates.validUntil), OFFER_STILL_VALID); // Get the first token to burn uint256 start = (range.lastBurnedTokenId == 0) ? range.start : (range.lastBurnedTokenId + 1); @@ -314,7 +314,7 @@ contract BosonVoucherBase is IBosonVoucher, BeaconClientBase, OwnableUpgradeable function getAvailablePreMints(uint256 _offerId) external view returns (uint256 count) { // If offer is expired or voided, return 0 (Offer memory offer, OfferDates memory offerDates) = getBosonOffer(_offerId); - if (offer.voided || (offerDates.validUntil <= block.timestamp)) { + if (offer.voided || (block.timestamp > offerDates.validUntil)) { return 0; } diff --git a/contracts/protocol/facets/ExchangeHandlerFacet.sol b/contracts/protocol/facets/ExchangeHandlerFacet.sol index ea510f7ce..01dca6bab 100644 --- a/contracts/protocol/facets/ExchangeHandlerFacet.sol +++ b/contracts/protocol/facets/ExchangeHandlerFacet.sol @@ -235,7 +235,6 @@ contract ExchangeHandlerFacet is IBosonExchangeHandler, BuyerBase, DisputeBase { * Issues a voucher to the buyer address for non preminted offers. * * Reverts if: - * - Offer has been voided * - Offer has expired * - Offer is not yet available for commits * - Offer's quantity available is zero [for non preminted offers] @@ -266,7 +265,7 @@ contract ExchangeHandlerFacet is IBosonExchangeHandler, BuyerBase, DisputeBase { // Make sure offer is available, and isn't void, expired, or sold out OfferDates storage offerDates = fetchOfferDates(_offerId); require(block.timestamp >= offerDates.validFrom, OFFER_NOT_AVAILABLE); - require(block.timestamp < offerDates.validUntil, OFFER_HAS_EXPIRED); + require(block.timestamp <= offerDates.validUntil, OFFER_HAS_EXPIRED); if (!_isPreminted) { // For non-preminted offers, quantityAvailable must be greater than zero, since it gets decremented diff --git a/test/protocol/ExchangeHandlerTest.js b/test/protocol/ExchangeHandlerTest.js index ad9f9e61c..ac936dc95 100644 --- a/test/protocol/ExchangeHandlerTest.js +++ b/test/protocol/ExchangeHandlerTest.js @@ -854,7 +854,7 @@ describe("IBosonExchangeHandler", function () { it("offer has expired", async function () { // Go past offer expiration date - await setNextBlockTimestamp(Number(offerDates.validUntil)); + await setNextBlockTimestamp(Number(offerDates.validUntil) + 1); // Attempt to commit to the expired offer, expecting revert await expect( @@ -1355,7 +1355,7 @@ describe("IBosonExchangeHandler", function () { it("offer has expired", async function () { // Go past offer expiration date - await setNextBlockTimestamp(Number(offerDates.validUntil)); + await setNextBlockTimestamp(Number(offerDates.validUntil) + 1); // Attempt to commit to the expired offer, expecting revert await expect( @@ -2118,7 +2118,7 @@ describe("IBosonExchangeHandler", function () { it("offer has expired", async function () { // Go past offer expiration date - await setNextBlockTimestamp(Number(offerDates.validUntil)); + await setNextBlockTimestamp(Number(offerDates.validUntil) + 1); // Attempt to commit to the expired offer, expecting revert await expect( diff --git a/test/protocol/clients/BosonVoucherTest.js b/test/protocol/clients/BosonVoucherTest.js index e80ca2f73..523a9c362 100644 --- a/test/protocol/clients/BosonVoucherTest.js +++ b/test/protocol/clients/BosonVoucherTest.js @@ -957,7 +957,7 @@ describe("IBosonVoucher", function () { it("Should be 0 if offer is expired", async function () { // Skip to after offer expiry - await setNextBlockTimestamp(Number(offerDates.validUntil), true); + await setNextBlockTimestamp(Number(BigInt(offerDates.validUntil) + 1n), true); // Get available premints from contract let availablePremints = await bosonVoucher.getAvailablePreMints(offerId); @@ -1382,7 +1382,7 @@ describe("IBosonVoucher", function () { }); context("Transfer of a preminted voucher when owner is assistant", async function () { - let voucherRedeemableFrom, voucherValid, offerValid; + let voucherRedeemableFrom, voucherValid; beforeEach(async function () { exchangeId = offerId = "1"; @@ -1398,7 +1398,6 @@ describe("IBosonVoucher", function () { voucherRedeemableFrom = offerDates.voucherRedeemableFrom; voucherValid = offerDurations.voucherValid; - offerValid = offerDates.validUntil; }); it("Should emit a Transfer event", async function () { @@ -1554,7 +1553,7 @@ describe("IBosonVoucher", function () { it("Transfer preminted voucher, where offer has expired", async function () { // Skip past offer expiry - await setNextBlockTimestamp(Number(offerValid)); + await setNextBlockTimestamp(Number(BigInt(offerDates.validUntil) + 1n)); // Transfer should fail, since protocol reverts await expect(