Using modifier to check block on delayedClaimable, tests fixed

pull/78/head
AugustoL 8 years ago
parent 0aa4d02044
commit 85a4013f49
  1. 9
      contracts/DelayedClaimable.sol
  2. 8
      test/DelayedClaimble.js

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

@ -22,7 +22,9 @@ contract('DelayedClaimable', function(accounts) {
}) })
.then(function(pendingOwner) { .then(function(pendingOwner) {
assert.isTrue(pendingOwner === newOwner); assert.isTrue(pendingOwner === newOwner);
delayedClaimable.claimOwnership({from: newOwner}); return delayedClaimable.claimOwnership({from: newOwner});
})
.then(function() {
return delayedClaimable.owner(); return delayedClaimable.owner();
}) })
.then(function(owner) { .then(function(owner) {
@ -46,7 +48,9 @@ contract('DelayedClaimable', function(accounts) {
}) })
.then(function(pendingOwner) { .then(function(pendingOwner) {
assert.isTrue(pendingOwner === newOwner); assert.isTrue(pendingOwner === newOwner);
// delayedClaimable.claimOwnership({from: newOwner}); Uncomment to break the test. return delayedClaimable.claimOwnership({from: newOwner});
})
.then(function() {
return delayedClaimable.owner(); return delayedClaimable.owner();
}) })
.then(function(owner) { .then(function(owner) {

Loading…
Cancel
Save