Skip to content

Commit

Permalink
added upgrade single contract
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsam4 committed Sep 8, 2018
1 parent 4a00d4a commit 4b93eb7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .solcover.js
@@ -1,4 +1,3 @@
module.exports = {
skipFiles: ['imports', 'mocks'],
deepSkip: true
skipFiles: ['imports']
};
8 changes: 8 additions & 0 deletions contracts/Master.sol
Expand Up @@ -99,6 +99,14 @@ contract Master is Ownable {
changeAllAddress();
}

/// @dev upgrades a single contract
function upgradeContract(bytes2 _contractsName, address _contractsAddress) public {
require(isAuth());
allContractVersions[versionDates.length - 1][_contractsName] = _contractsAddress;
changeMasterAddress(address(this));
changeAllAddress();
}

/// @dev sets dAppTokenProxy address
/// @param _dAppTokenProxy token proxy address
function setDAppTokenProxy(address _dAppTokenProxy) public {
Expand Down
17 changes: 12 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test/08_Master.js
Expand Up @@ -139,6 +139,18 @@ contract('Master', function([owner, notOwner]) {
assert.equal(b.toNumber() + 10, b2.toNumber() - b1.toNumber());
});

it('Should upgrade contract', async function() {
this.timeout(100000);
const poo = await Pool.new();
await ms.upgradeContract('PL', poo.address);
assert(
await ms.getLatestAddress('PL'),
poo.address,
'contract not upgraded'
);
await catchRevert(ms.upgradeContract('PL', owner, { from: notOwner }));
});

it('Should add new contract', async function() {
this.timeout(100000);
// Will throw once owner's permissions are removed. will need to create proposal then.
Expand Down

0 comments on commit 4b93eb7

Please sign in to comment.