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 f10aa66
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 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
23 changes: 10 additions & 13 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 @@ -71,7 +65,10 @@ async function migrate(env) {

console.log(`Checking out contracts on version ${tag}`);
shell.exec(`rm -rf contracts/*`);
shell.exec(`git checkout ${tag} contracts`);
shell.exec(`git checkout ${tag} contracts package.json package-lock.json`);

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

console.log("Compiling contracts");
await hre.run("clean");
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
10 changes: 4 additions & 6 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 @@ -159,8 +157,7 @@ async function deploySuite(deployer, newVersion) {
const mockTwinTokens = [mockTwin721_1, mockTwin721_2];

if (isOldOZVersion) {
// If reference commit is old version, we need to revert to target version
shell.exec(`git checkout ${versionTags.newVersion} package.json package-lock.json`);
shell.exec(`git checkout ${tag} package.json package-lock.json`);
shell.exec("npm i");
}

Expand Down Expand Up @@ -1826,8 +1823,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 f10aa66

Please sign in to comment.