Add killable to bounty
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
pragma solidity ^0.4.0;
|
pragma solidity ^0.4.0;
|
||||||
import '../PullPayment.sol';
|
import '../PullPayment.sol';
|
||||||
|
import '../Killable.sol';
|
||||||
/*
|
/*
|
||||||
* Bounty
|
* Bounty
|
||||||
* This bounty will pay out if you can cause a SimpleToken's balance
|
* This bounty will pay out if you can cause a SimpleToken's balance
|
||||||
@ -16,7 +16,7 @@ contract Target {
|
|||||||
function checkInvariant() returns(bool);
|
function checkInvariant() returns(bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract SimpleTokenBounty is PullPayment {
|
contract SimpleTokenBounty is PullPayment, Killable {
|
||||||
Target target;
|
Target target;
|
||||||
bool public claimed;
|
bool public claimed;
|
||||||
address public factoryAddress;
|
address public factoryAddress;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ var sendReward = function(sender, receiver, value){
|
|||||||
}
|
}
|
||||||
|
|
||||||
contract('Bounty', function(accounts) {
|
contract('Bounty', function(accounts) {
|
||||||
it("can create bounty contract with factory address", function(done){
|
it("creates bounty contract with factory address", function(done){
|
||||||
var target = SecureTargetMock.deployed();
|
var target = SecureTargetMock.deployed();
|
||||||
|
|
||||||
SimpleTokenBounty.new(target.address).
|
SimpleTokenBounty.new(target.address).
|
||||||
@ -33,6 +33,25 @@ contract('Bounty', function(accounts) {
|
|||||||
then(done);
|
then(done);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("ends", function(done){
|
||||||
|
var target = SecureTargetMock.deployed();
|
||||||
|
var owner = accounts[0];
|
||||||
|
var reward = web3.toWei(1, "ether");
|
||||||
|
var bounty;
|
||||||
|
SimpleTokenBounty.new(target.address).
|
||||||
|
then(function(_bounty){
|
||||||
|
bounty = _bounty;
|
||||||
|
sendReward(owner, bounty.address, reward);
|
||||||
|
assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber())
|
||||||
|
return bounty.kill()
|
||||||
|
}).
|
||||||
|
then(function(){
|
||||||
|
assert.equal(0, web3.eth.getBalance(bounty.address).toNumber())
|
||||||
|
}).
|
||||||
|
then(done);
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
describe("SecureTargetMock", function(){
|
describe("SecureTargetMock", function(){
|
||||||
it("checkInvariant returns true", function(done){
|
it("checkInvariant returns true", function(done){
|
||||||
var targetFactory = SecureTargetFactory.deployed();
|
var targetFactory = SecureTargetFactory.deployed();
|
||||||
|
|||||||
Reference in New Issue
Block a user