Skip to content

Commit

Permalink
Merge pull request OpenZeppelin#323 from pooleja/fix/ownable_error
Browse files Browse the repository at this point in the history
Fix/ownable error - Silent transferOwnership Failure
  • Loading branch information
frangio authored Jul 22, 2017
2 parents 6317d9e + bf308f6 commit b4653f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 2 additions & 3 deletions contracts/ownership/Ownable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ contract Ownable {
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
require(newOwner != address(0));
owner = newOwner;
}

}
12 changes: 7 additions & 5 deletions test/Ownable.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ contract('Ownable', function(accounts) {

it('should guard ownership against stuck state', async function() {
let originalOwner = await ownable.owner();
await ownable.transferOwnership(null, {from: originalOwner});
let newOwner = await ownable.owner();

assert.equal(originalOwner, newOwner);
try {
await ownable.transferOwnership(null, {from: originalOwner});
assert.fail();
} catch(error) {
assertJump(error);
}
});

});
});

0 comments on commit b4653f6

Please # to comment.