diff --git a/helpers/test-helper.js b/helpers/test-helper.js index 9565e9bdf3..ffe4736595 100644 --- a/helpers/test-helper.js +++ b/helpers/test-helper.js @@ -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; diff --git a/test/extensions/voting-rep.js b/test/extensions/voting-rep.js index f0788f9707..d3c1cd6c2f 100644 --- a/test/extensions/voting-rep.js +++ b/test/extensions/voting-rep.js @@ -34,6 +34,7 @@ const { expectEvent, getTokenArgs, getBlockTime, + upgradeExtensionOnceThenToLatest, } = require("../../helpers/test-helper"); const { setupRandomColony, getMetaTransactionParameters, fundColonyWithTokens } = require("../../helpers/test-data-generator"); @@ -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 () => {