Skip to content

Commit

Permalink
also test storage layout of implementation during upgrade (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannbarbie authored and eezcjkr committed Jan 25, 2019
1 parent eec6444 commit d97b62f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contracts/mocks/BridgeMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ import "../Adminable.sol";

contract BridgeMock is Adminable {
address public operator;
uint256 public value;

function setOperator(address _operator) public ifAdmin {
operator = _operator;
}

function setValue(uint256 _value) public {
value = _value;
}
}
7 changes: 7 additions & 0 deletions test/minGov.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ contract('MinGov', (accounts) => {
});

it('should allow to upgrade bridge', async () => {
const someVal = 1234;
// set storage befor upgrade
await bridge.setValue(someVal);
// deploy new contract
const proxy = await AdminableProxy.at(bridge.address);
const newBridgeLogic = await Bridge.new();
Expand All @@ -133,11 +136,15 @@ contract('MinGov', (accounts) => {
const data = await proxy.contract.methods.upgradeTo(newBridgeLogic.address).encodeABI();
await gov.propose(bridge.address, data);
await gov.finalize();
const newBridge = await Bridge.at(proxy.address);

// check value after
const imp = '0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3';
const logicAddr = await web3.eth.getStorageAt(proxy.address, imp);
assert.equal(logicAddr.toLowerCase(), newBridgeLogic.address.toLowerCase());
// check storage still matches
const val = await newBridge.value();
assert.equal(someVal, val.toNumber());
});

it('should allow to transfer into new governance', async () => {
Expand Down

0 comments on commit d97b62f

Please sign in to comment.