add check prevening ownables from getting stuck

This commit is contained in:
Steve Ellis
2016-11-13 15:55:06 -05:00
parent a3362f7216
commit 5f6b7f9301
2 changed files with 17 additions and 1 deletions

View File

@ -17,7 +17,7 @@ contract Ownable {
}
function transfer(address newOwner) onlyOwner {
owner = newOwner;
if (newOwner != address(0)) owner = newOwner;
}
}

View File

@ -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);
});
});
});