Commit e9cf6dfb by Francisco Giordano Committed by GitHub

Merge pull request #323 from pooleja/fix/ownable_error

Fix/ownable error - Silent transferOwnership Failure
parents 4d91118d 64787b1a
...@@ -33,9 +33,8 @@ contract Ownable { ...@@ -33,9 +33,8 @@ contract Ownable {
* @param newOwner The address to transfer ownership to. * @param newOwner The address to transfer ownership to.
*/ */
function transferOwnership(address newOwner) onlyOwner { function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) { require(newOwner != address(0));
owner = newOwner; owner = newOwner;
} }
}
} }
...@@ -36,10 +36,12 @@ contract('Ownable', function(accounts) { ...@@ -36,10 +36,12 @@ contract('Ownable', function(accounts) {
it('should guard ownership against stuck state', async function() { it('should guard ownership against stuck state', async function() {
let originalOwner = await ownable.owner(); let originalOwner = await ownable.owner();
try {
await ownable.transferOwnership(null, {from: originalOwner}); await ownable.transferOwnership(null, {from: originalOwner});
let newOwner = await ownable.owner(); assert.fail();
} catch(error) {
assert.equal(originalOwner, newOwner); assertJump(error);
}
}); });
}); });
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment