claimBefore modifier removed on DelayedClaimable contract

pull/78/head
AugustoL 8 years ago
parent c7eb6736ee
commit 423cec41e3
  1. 8
      contracts/DelayedClaimable.sol
  2. 21
      test/DelayedClaimble.js

@ -10,16 +10,12 @@ import './Claimable.sol';
contract DelayedClaimable is Ownable, Claimable { contract DelayedClaimable is Ownable, Claimable {
uint public claimBeforeBlock; uint public claimBeforeBlock;
modifier claimBefore() {
if (block.number < claimBeforeBlock)
_;
}
function setClaimBefore(uint _claimBeforeBlock) onlyOwner { function setClaimBefore(uint _claimBeforeBlock) onlyOwner {
claimBeforeBlock = _claimBeforeBlock; claimBeforeBlock = _claimBeforeBlock;
} }
function claimOwnership() onlyPendingOwner claimBefore { function claimOwnership() onlyPendingOwner {
if (block.number > claimBeforeBlock) throw;
owner = pendingOwner; owner = pendingOwner;
pendingOwner = 0x0; pendingOwner = 0x0;
claimBeforeBlock = 0; claimBeforeBlock = 0;

@ -8,8 +8,7 @@ contract('DelayedClaimable', function(accounts) {
}); });
it("changes pendingOwner after transfer succesful", function(done) { it("changes pendingOwner after transfer succesful", function(done) {
var newOwner = accounts[2]; return delayedClaimable.transfer(accounts[2])
return delayedClaimable.transfer(newOwner)
.then(function(){ .then(function(){
return delayedClaimable.setClaimBefore(1000) return delayedClaimable.setClaimBefore(1000)
}) })
@ -21,21 +20,20 @@ contract('DelayedClaimable', function(accounts) {
return delayedClaimable.pendingOwner(); return delayedClaimable.pendingOwner();
}) })
.then(function(pendingOwner) { .then(function(pendingOwner) {
assert.isTrue(pendingOwner === newOwner); assert.isTrue(pendingOwner === accounts[2]);
return delayedClaimable.claimOwnership({from: newOwner}); return delayedClaimable.claimOwnership({from: accounts[2]});
}) })
.then(function() { .then(function() {
return delayedClaimable.owner(); return delayedClaimable.owner();
}) })
.then(function(owner) { .then(function(owner) {
assert.isTrue(owner === newOwner); assert.isTrue(owner === accounts[2]);
}) })
.then(done) .then(done)
}); });
it("changes pendingOwner after transfer fails", function(done) { it("changes pendingOwner after transfer fails", function(done) {
var newOwner = accounts[1]; return delayedClaimable.transfer(accounts[1])
return delayedClaimable.transfer(newOwner)
.then(function(){ .then(function(){
return delayedClaimable.setClaimBefore(1) return delayedClaimable.setClaimBefore(1)
}) })
@ -47,14 +45,17 @@ contract('DelayedClaimable', function(accounts) {
return delayedClaimable.pendingOwner(); return delayedClaimable.pendingOwner();
}) })
.then(function(pendingOwner) { .then(function(pendingOwner) {
assert.isTrue(pendingOwner === newOwner); assert.isTrue(pendingOwner === accounts[1]);
return delayedClaimable.claimOwnership({from: newOwner}); return delayedClaimable.claimOwnership({from: accounts[1]});
})
.catch(function(error) {
if (error.message.search('invalid JUMP') == -1) throw error
}) })
.then(function() { .then(function() {
return delayedClaimable.owner(); return delayedClaimable.owner();
}) })
.then(function(owner) { .then(function(owner) {
assert.isTrue(owner != newOwner); assert.isTrue(owner != accounts[1]);
}) })
.then(done) .then(done)
}); });

Loading…
Cancel
Save