From 2ae8f26f6a185907fcead90a4233c67c175c7491 Mon Sep 17 00:00:00 2001 From: Ana Julia Date: Thu, 3 Aug 2023 22:25:38 -0300 Subject: [PATCH] Add generic tests for vouchers --- test/upgrade/2.2.1-2.3.0.js | 43 +++++++++++++++++++++++++++++++++++-- test/util/upgrade.js | 2 +- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/test/upgrade/2.2.1-2.3.0.js b/test/upgrade/2.2.1-2.3.0.js index 48d9fae68..7b197a821 100644 --- a/test/upgrade/2.2.1-2.3.0.js +++ b/test/upgrade/2.2.1-2.3.0.js @@ -44,9 +44,18 @@ const { } = require("../util/utils"); const { limits: protocolLimits } = require("../../scripts/config/protocol-parameters.js"); -const { deploySuite, populateProtocolContract, getProtocolContractState, revertState } = require("../util/upgrade"); +const { + deploySuite, + populateProtocolContract, + getProtocolContractState, + revertState, + getStorageLayout, + getVoucherContractState, + populateVoucherContract, +} = require("../util/upgrade"); const { deployMockTokens } = require("../../scripts/util/deploy-mock-tokens"); const { getGenericContext } = require("./01_generic"); +const { getGenericContext: getGenericContextVoucher } = require("./clients/01_generic"); const { oneWeek, oneMonth, VOUCHER_NAME, VOUCHER_SYMBOL } = require("../util/constants"); const version = "2.3.0"; @@ -108,6 +117,7 @@ describe("[@skip-on-coverage] After facet upgrade, everything is still operation // Add twin handler back contractsBefore.twinHandler = twinHandler; + console.log("contractsBefore", contractsBefore.configHandler); // Get current protocol state, which serves as the reference // We assume that this state is a true one, relying on our unit and integration tests @@ -293,6 +303,33 @@ describe("[@skip-on-coverage] After facet upgrade, everything is still operation includeTests ) ); + + const preUpgradeStorageLayout = await getStorageLayout("BosonVoucher"); + const preUpgradeEntitiesVoucher = await populateVoucherContract( + deployer, + protocolDiamondAddress, + contractsAfter, + mockContracts, + undefined, // no existing entities + "2.2.1" + ); + + const voucherContractState = await getVoucherContractState(preUpgradeEntities); + + context( + "Generic tests on Voucher", + getGenericContextVoucher( + deployer, + protocolDiamondAddress, + contractsAfter, + mockContracts, + voucherContractState, + preUpgradeEntitiesVoucher, + preUpgradeStorageLayout, + snapshot + ) + ); + // } catch (err) { // // revert to latest version of scripts and contracts // revertState(); @@ -1330,7 +1367,7 @@ describe("[@skip-on-coverage] After facet upgrade, everything is still operation it("commit exactly at offer expiration timestamp", async function () { const { offers, buyers } = preUpgradeEntities; - const { offer } = offers[1]; //offer 0 has a condition + const { offer, offerDates } = offers[1]; //offer 0 has a condition const { wallet: buyer } = buyers[0]; const { mockToken } = mockContracts; @@ -1339,6 +1376,8 @@ describe("[@skip-on-coverage] After facet upgrade, everything is still operation // allow the protocol to transfer the buyer's tokens await mockToken.connect(buyer).approve(protocolDiamondAddress, offer.price); + await setNextBlockTimestamp(Number(offerDates.validUntil)); + // Commit to offer, retrieving the event await expect(exchangeHandler.connect(buyer).commitToOffer(buyer.address, offer.id)).to.emit( exchangeHandler, diff --git a/test/util/upgrade.js b/test/util/upgrade.js index d2da5aae0..a6a223af1 100644 --- a/test/util/upgrade.js +++ b/test/util/upgrade.js @@ -756,7 +756,7 @@ async function getProtocolContractState( getOfferContractState(offerHandler, offers), getExchangeContractState(exchangeHandler, exchanges), getBundleContractState(bundleHandler, bundles), - configHandler ? getConfigContractState(configHandler, isBefore) : Promise.resolve({}), + getConfigContractState(configHandler, isBefore), getDisputeContractState(disputeHandler, exchanges), getFundsContractState(fundsHandler, { DRs, sellers, buyers, agents }, isBefore), getGroupContractState(groupHandler, groups),