claimBefore modifier removed on DelayedClaimable contract
This commit is contained in:
@ -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)
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user