Skip to content

Commit

Permalink
Add generic tests for vouchers
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Aug 4, 2023
1 parent 7b31d24 commit 2ae8f26
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
43 changes: 41 additions & 2 deletions test/upgrade/2.2.1-2.3.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/util/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 2ae8f26

Please sign in to comment.