Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
});

});
});