Merge pull request #65 from se3000/ownable_guard

add check prevening ownables from getting stuck
pull/71/head
Manuel Aráoz 8 years ago committed by GitHub
commit 3207996777
  1. 2
      contracts/Ownable.sol
  2. 16
      test/Ownable.js

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

@ -39,4 +39,20 @@ contract('Ownable', function(accounts) {
.then(done) .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);
});
});
}); });

Loading…
Cancel
Save