diff --git a/contracts/Ownable.sol b/contracts/Ownable.sol index 6da95fb74..2998fa403 100644 --- a/contracts/Ownable.sol +++ b/contracts/Ownable.sol @@ -17,7 +17,7 @@ contract Ownable { } function transfer(address newOwner) onlyOwner { - owner = newOwner; + if (newOwner != address(0)) owner = newOwner; } } diff --git a/test/Ownable.js b/test/Ownable.js index 83ae4b93e..8d9c51083 100644 --- a/test/Ownable.js +++ b/test/Ownable.js @@ -34,4 +34,20 @@ contract('Ownable', function(accounts) { .then(done) }); + it("should guard ownership against stuck state" ,function(done) { + var ownable = Ownable.deployed(); + + return ownable.owner() + .then(function (originalOwner) { + return ownable.transfer(null, {from: originalOwner}) + .then(function() { + return ownable.owner(); + }) + .then(function(newOwner) { + assert.equal(originalOwner, newOwner); + }) + .then(done); + }); + }); + });