Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Commit

Permalink
Merge 42fe870 into 7e4b309
Browse files Browse the repository at this point in the history
  • Loading branch information
facuspagnuolo committed Jul 3, 2018
2 parents 7e4b309 + 42fe870 commit 1d164bb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Expand Up @@ -6,7 +6,7 @@ import "./ImplementationDirectory.sol";
* @title FreezableImplementationDirectory
* @dev Implementation directory which can be made irreversibly immutable by the owner.
*/
contract FreezableImplementationDirectory is ImplementationDirectory {
contract FreezableImplementationDirectory is ImplementationDirectory {
/// @dev Mutability state of the directory.
bool public frozen;

Expand Down Expand Up @@ -35,4 +35,13 @@ import "./ImplementationDirectory.sol";
function setImplementation(string contractName, address implementation) public whenNotFrozen {
super.setImplementation(contractName, implementation);
}

/**
* @dev Unsets the implementation of a contract.
* It overrides the parent function to prevent it from running if the directory is frozen.
* @param contractName Name of the contract.
*/
function unsetImplementation(string contractName) public whenNotFrozen {
super.unsetImplementation(contractName);
}
}
Expand Up @@ -70,4 +70,20 @@ contract('FreezableImplementationDirectory', ([_, owner, anotherAddress]) => {
})
})
})

describe('unsetImplementation', function () {
describe('when it is not frozen', function () {
shouldBehaveLikeImplementationDirectory(owner, anotherAddress)
})

describe('when it is frozen', function () {
beforeEach(async function () {
await this.directory.freeze({ from: owner })
})

it('reverts', async function () {
await assertRevert(this.directory.unsetImplementation('ERC721', { from: owner }))
})
})
})
})

0 comments on commit 1d164bb

Please sign in to comment.