Skip to content

Commit

Permalink
Fixing upgrate test
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Jun 12, 2023
1 parent 8cba2d4 commit 89a2629
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module.exports = {
solidity: {
compilers: [
{
version: "0.8.18",
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
Expand All @@ -157,7 +157,7 @@ module.exports = {
},
},
{
version: "0.8.9",
version: "0.8.18",
settings: {
optimizer: {
enabled: true,
Expand Down
21 changes: 9 additions & 12 deletions scripts/migrations/migrate_2.2.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const ethers = hre.ethers;
const network = hre.network.name;
const { getStateModifyingFunctionsHashes } = require("../../scripts/util/diamond-utils.js");
const tag = "v2.2.1";
const version = "2.2.1";

const config = {
addOrUpgrade: [
Expand Down Expand Up @@ -35,23 +34,13 @@ async function migrate(env) {
throw new Error("Local changes found. Please stash them before upgrading");
}

if (env != "upgrade-test") {
console.log("Installing dependencies");
shell.exec(`npm install`);
}

const { chainId } = await ethers.provider.getNetwork();
const contractsFile = readContracts(chainId, network, env);

if (contractsFile?.protocolVersion != "2.2.0") {
throw new Error("Current contract version must be 2.2.0");
}

let contracts = contractsFile?.contracts;

// Get addresses of currently deployed contracts
const protocolAddress = contracts.find((c) => c.name === "ProtocolDiamond")?.address;

// Checking old version contracts to get selectors to remove
console.log("Checking out contracts on version 2.2.0");
shell.exec(`rm -rf contracts/*`);
Expand All @@ -61,6 +50,11 @@ async function migrate(env) {
await hre.run("clean");
await hre.run("compile");

let contracts = contractsFile?.contracts;

// Get addresses of currently deployed contracts
const protocolAddress = contracts.find((c) => c.name === "ProtocolDiamond")?.address;

const getFunctionHashesClosure = getStateModifyingFunctionsHashes(
["SellerHandlerFacet", "OrchestrationHandlerFacet1"],
undefined,
Expand All @@ -73,6 +67,9 @@ async function migrate(env) {
shell.exec(`rm -rf contracts/*`);
shell.exec(`git checkout ${tag} contracts`);

console.log("Installing dependencies");
shell.exec(`npm install`);

console.log("Compiling contracts");
await hre.run("clean");
await hre.run("compile");
Expand All @@ -81,7 +78,7 @@ async function migrate(env) {
await hre.run("upgrade-facets", {
env,
facetConfig: JSON.stringify(config),
newVersion: version,
newVersion: tag,
});

const selectorsToAdd = await getFunctionHashesClosure();
Expand Down
1 change: 0 additions & 1 deletion test/upgrade/00_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ const tagsByVersion = {
"2.2.1": {
oldVersion: "v2.2.0",
newVersion: "v2.2.1",
deployScript: "v2.2.0",
},
};

Expand Down
7 changes: 3 additions & 4 deletions test/util/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ async function deploySuite(deployer, newVersion) {
shell.exec(`git checkout ${scriptsTag} scripts`);
}

shell.exec(`npx hardhat compile`);

const isOldOZVersion = ["v2.0", "v2.1", "v2.2"].some((v) => tag.startsWith(v));
if (isOldOZVersion) {
// Temporary install old OZ contracts
Expand Down Expand Up @@ -1826,8 +1824,9 @@ async function getVoucherContractState({ bosonVouchers, exchanges, sellers, buye
}

function revertState() {
shell.exec(`git checkout HEAD`);
shell.exec(`git reset HEAD`);
shell.exec(`rm -rf contracts/* scripts/*`);
shell.exec(`git checkout HEAD contracts scripts`);
shell.exec(`git reset HEAD contracts scripts`);
}

async function getDisputeResolver(accountHandler, value, { getBy }) {
Expand Down

0 comments on commit 89a2629

Please sign in to comment.