From 423cec41e366db504f18a3c050108d92cc68bbdb Mon Sep 17 00:00:00 2001 From: AugustoL Date: Wed, 7 Dec 2016 18:32:42 -0300 Subject: [PATCH] claimBefore modifier removed on DelayedClaimable contract --- contracts/DelayedClaimable.sol | 8 ++------ test/DelayedClaimble.js | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/contracts/DelayedClaimable.sol b/contracts/DelayedClaimable.sol index 8739f3307..51a4a58af 100644 --- a/contracts/DelayedClaimable.sol +++ b/contracts/DelayedClaimable.sol @@ -10,16 +10,12 @@ import './Claimable.sol'; contract DelayedClaimable is Ownable, Claimable { uint public claimBeforeBlock; - modifier claimBefore() { - if (block.number < claimBeforeBlock) - _; - } - function setClaimBefore(uint _claimBeforeBlock) onlyOwner { claimBeforeBlock = _claimBeforeBlock; } - function claimOwnership() onlyPendingOwner claimBefore { + function claimOwnership() onlyPendingOwner { + if (block.number > claimBeforeBlock) throw; owner = pendingOwner; pendingOwner = 0x0; claimBeforeBlock = 0; diff --git a/test/DelayedClaimble.js b/test/DelayedClaimble.js index f2b7d0b71..b97e097f2 100644 --- a/test/DelayedClaimble.js +++ b/test/DelayedClaimble.js @@ -8,8 +8,7 @@ contract('DelayedClaimable', function(accounts) { }); it("changes pendingOwner after transfer succesful", function(done) { - var newOwner = accounts[2]; - return delayedClaimable.transfer(newOwner) + return delayedClaimable.transfer(accounts[2]) .then(function(){ return delayedClaimable.setClaimBefore(1000) }) @@ -21,21 +20,20 @@ contract('DelayedClaimable', function(accounts) { return delayedClaimable.pendingOwner(); }) .then(function(pendingOwner) { - assert.isTrue(pendingOwner === newOwner); - return delayedClaimable.claimOwnership({from: newOwner}); + assert.isTrue(pendingOwner === accounts[2]); + return delayedClaimable.claimOwnership({from: accounts[2]}); }) .then(function() { return delayedClaimable.owner(); }) .then(function(owner) { - assert.isTrue(owner === newOwner); + assert.isTrue(owner === accounts[2]); }) .then(done) }); it("changes pendingOwner after transfer fails", function(done) { - var newOwner = accounts[1]; - return delayedClaimable.transfer(newOwner) + return delayedClaimable.transfer(accounts[1]) .then(function(){ return delayedClaimable.setClaimBefore(1) }) @@ -47,14 +45,17 @@ contract('DelayedClaimable', function(accounts) { return delayedClaimable.pendingOwner(); }) .then(function(pendingOwner) { - assert.isTrue(pendingOwner === newOwner); - return delayedClaimable.claimOwnership({from: newOwner}); + assert.isTrue(pendingOwner === accounts[1]); + return delayedClaimable.claimOwnership({from: accounts[1]}); + }) + .catch(function(error) { + if (error.message.search('invalid JUMP') == -1) throw error }) .then(function() { return delayedClaimable.owner(); }) .then(function(owner) { - assert.isTrue(owner != newOwner); + assert.isTrue(owner != accounts[1]); }) .then(done) });