Skip to content

Commit

Permalink
correctly toggle preprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
zajck committed Aug 7, 2023
1 parent 7f4d2b7 commit 52fe42e
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions test/protocol/ProtocolInitializationHandlerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,24 +683,27 @@ describe("ProtocolInitializationHandler", async function () {
voucherBeacon: await beacon.getAddress(),
};

let doPreprocess = true; // Due to "hardhat-preprocessor" way of caching, we need a workaround to toggle preprocessing on and off
// Make initial deployment (simulate v2.2.1)
// The new config initialization deploys the same voucher proxy as initV2_3_0, which makes the initV2_3_0 test fail
// One way to approach would be to checkout the contracts from the previous tag.
// Instead, we will just comment out the voucher proxy initialization in the config handler with preprocess
hre.config.preprocess = {
eachLine: () => ({
transform: (line) => {
if (
line.includes("address beaconProxy = address(new BeaconClientProxy{ salt: VOUCHER_PROXY_SALT }());")
) {
// comment out the proxy deployment
line = "//" + line;
} else if (line.includes("setBeaconProxyAddress(beaconProxy)")) {
// set beacon proxy from config, not the deployed one
line = line.replace(
"setBeaconProxyAddress(beaconProxy)",
"setBeaconProxyAddress(_addresses.beaconProxy)"
);
if (doPreprocess) {
if (
line.includes("address beaconProxy = address(new BeaconClientProxy{ salt: VOUCHER_PROXY_SALT }());")
) {
// comment out the proxy deployment
line = "//" + line;
} else if (line.includes("setBeaconProxyAddress(beaconProxy)")) {
// set beacon proxy from config, not the deployed one
line = line.replace(
"setBeaconProxyAddress(beaconProxy)",
"setBeaconProxyAddress(_addresses.beaconProxy)"
);
}
}
return line;
},
Expand All @@ -724,10 +727,9 @@ describe("ProtocolInitializationHandler", async function () {
await accountHandler.connect(rando).createSeller(seller, emptyAuthToken, voucherInitValues);

// Deploy v2.3.0 facets
// Remove preprocess
hre.config.preprocess = {};
// Compile old version
await hre.run("compile");
// Skip preprocessing and compile new version
doPreprocess = false;
await hre.run("compile", { force: true });

[{ contract: deployedProtocolInitializationHandlerFacet }, { contract: configHandler }] =
await deployProtocolFacets(
Expand Down

0 comments on commit 52fe42e

Please sign in to comment.