'how to deal with contract versions and test smart contracts for upgrade compatibility
I try to use OpenZeppelin SDK to make my contracts upgradeable using the SimpleProxy approach. I need to test my contracts for upgrade compatibility (e.g prevent mistakes about unstructured storage during upgrading the contracts to a new version). According to OpenZeppelin docs, I can write these types of tests by something like this
const { deployProxy, upgradeProxy } = require('@openzeppelin/truffle-upgrades');
const Box = artifacts.require('Box');
const BoxV2 = artifacts.require('BoxV2');
describe('upgrades', () => {
it('works', async () => {
const box = await deployProxy(Box, [42]);
const box2 = await upgradeProxy(box.address, BoxV2);
const value = await box2.value();
assert.equal(value.toString(), '42');
});
});
But in the above code, I must import both versions and this means I need to add the version number to the end of the contract's name and create a copy whenever I want to upgrade the contract. But what if I want to only modify the old contract and use a version control system like git?
If this is not possible, how to deal with these versions and files? when I want to upgrade a contract, need to update all of the imports and parent contracts for every child contract? If I want to put the latest version of each contract in a separate directory, do I need to update all import paths whenever upgrading a contract?
Sorry for my bad English.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
