Skip to content

Commit

Permalink
Fix tests with bumped VotingReputation version
Browse files Browse the repository at this point in the history
  • Loading branch information
area committed Jul 18, 2024
1 parent 386371d commit 4c3eac5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions helpers/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,28 @@ exports.upgradeColonyOnceThenToLatest = async function (colony) {
await exports.setStorageSlot(colony, "0x2", newSlotValue);
};

exports.upgradeExtensionOnceThenToLatest = async function (extension) {
// Same logic as above, but for extensions
const currentVersion = await extension.version();
const colonyAddress = await extension.getColony();
const colony = await IColony.at(colonyAddress);
const extensionIdentifier = await extension.identifier();
await colony.upgradeExtension(extensionIdentifier, currentVersion.addn(1));

const networkAddress = await colony.getColonyNetwork();
const colonyNetwork = await IColonyNetwork.at(networkAddress);
let newestVersion = 100;
let newestResolver = ethers.constants.AddressZero;
while (newestResolver === ethers.constants.AddressZero) {
newestResolver = await colonyNetwork.getExtensionResolver(extensionIdentifier, newestVersion);
newestVersion -= 1;
}

const existingSlot = await exports.web3GetStorageAt(extension.address, 2);
const newSlotValue = existingSlot.slice(0, 26) + newestResolver.slice(2);
await exports.setStorageSlot(extension, "0x2", newSlotValue);
};

exports.isMainnet = async function isMainnet() {
const chainId = await exports.web3GetChainId();
return chainId === MAINNET_CHAINID || chainId === FORKED_MAINNET_CHAINID;
Expand Down
6 changes: 4 additions & 2 deletions test/extensions/voting-rep.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const {
expectEvent,
getTokenArgs,
getBlockTime,
upgradeExtensionOnceThenToLatest,
} = require("../../helpers/test-helper");

const { setupRandomColony, getMetaTransactionParameters, fundColonyWithTokens } = require("../../helpers/test-data-generator");
Expand Down Expand Up @@ -2833,8 +2834,9 @@ contract("Voting Reputation", (accounts) => {
// This function as written would also need updating every version, but is infinitely more
// upgradeable
async function upgradeFromV9ToLatest(colonyInTest) {
await colonyInTest.upgradeExtension(VOTING_REPUTATION, 10);
await colonyInTest.upgradeExtension(VOTING_REPUTATION, 11);
const extensionAddress = await colonyNetwork.getExtensionInstallation(VOTING_REPUTATION, colonyInTest.address);
const extension = await IVotingReputation.at(extensionAddress);
await upgradeExtensionOnceThenToLatest(extension);
}

beforeEach(async () => {
Expand Down

0 comments on commit 4c3eac5

Please sign in to comment.