diff --git a/contracts/bounties/SimpleTokenBounty.sol b/contracts/Bounty.sol similarity index 73% rename from contracts/bounties/SimpleTokenBounty.sol rename to contracts/Bounty.sol index 2ea9854fd..19a2effdf 100644 --- a/contracts/bounties/SimpleTokenBounty.sol +++ b/contracts/Bounty.sol @@ -1,11 +1,11 @@ pragma solidity ^0.4.0; -import '../PullPayment.sol'; -import '../Killable.sol'; +import './PullPayment.sol'; +import './Killable.sol'; + /* * Bounty - * This bounty will pay out if you can cause a SimpleToken's balance - * to be lower than its totalSupply, which would mean that it doesn't - * have sufficient ether for everyone to withdraw. + * This bounty will pay out to a researcher if he/she breaks invariant logic of + * the contract you bet reward against. */ contract Factory { @@ -16,7 +16,7 @@ contract Target { function checkInvariant() returns(bool); } -contract SimpleTokenBounty is PullPayment, Killable { +contract Bounty is PullPayment, Killable { Target target; bool public claimed; address public factoryAddress; @@ -28,7 +28,7 @@ contract SimpleTokenBounty is PullPayment, Killable { if (claimed) throw; } - function SimpleTokenBounty(address _factoryAddress){ + function Bounty(address _factoryAddress){ factoryAddress = _factoryAddress; } diff --git a/contracts/bounties/CrowdsaleTokenBounty.sol b/contracts/bounties/CrowdsaleTokenBounty.sol deleted file mode 100644 index 814720745..000000000 --- a/contracts/bounties/CrowdsaleTokenBounty.sol +++ /dev/null @@ -1,38 +0,0 @@ -pragma solidity ^0.4.0; -import '../PullPayment.sol'; -import '../token/CrowdsaleToken.sol'; - -/* - * Bounty - * This bounty will pay out if you can cause a CrowdsaleToken's balance - * to be lower than its totalSupply, which would mean that it doesn't - * have sufficient ether for everyone to withdraw. - */ -contract CrowdsaleTokenBounty is PullPayment { - - bool public claimed; - mapping(address => address) public researchers; - - function() { - if (claimed) throw; - } - - function createTarget() returns(CrowdsaleToken) { - CrowdsaleToken target = new CrowdsaleToken(); - researchers[target] = msg.sender; - return target; - } - - function claim(CrowdsaleToken target) { - address researcher = researchers[target]; - if (researcher == 0) throw; - // Check CrowdsaleToken contract invariants - // Customize this to the specifics of your contract - if (target.totalSupply() == target.balance) { - throw; - } - asyncSend(researcher, this.balance); - claimed = true; - } - -} diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 67672b289..c43e3ebb8 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -2,7 +2,7 @@ module.exports = function(deployer) { deployer.deploy(PullPaymentBid); deployer.deploy(BadArrayUse); deployer.deploy(ProofOfExistence); - deployer.deploy(SimpleTokenBounty); + deployer.deploy(Bounty); deployer.deploy(CrowdsaleTokenBounty); deployer.deploy(Ownable); deployer.deploy(LimitFunds); diff --git a/test/Bounty.js b/test/Bounty.js index c4b5598e2..3fc00e5d0 100644 --- a/test/Bounty.js +++ b/test/Bounty.js @@ -10,7 +10,7 @@ contract('Bounty', function(accounts) { it("creates bounty contract with factory address", function(done){ var target = SecureTargetMock.deployed(); - SimpleTokenBounty.new(target.address). + Bounty.new(target.address). then(function(bounty){ return bounty.factoryAddress.call() }). @@ -25,7 +25,7 @@ contract('Bounty', function(accounts) { var owner = accounts[0]; var reward = web3.toWei(1, "ether"); - SimpleTokenBounty.new(target.address). + Bounty.new(target.address). then(function(bounty){ sendReward(owner, bounty.address, reward); assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber()) @@ -38,7 +38,7 @@ contract('Bounty', function(accounts) { var owner = accounts[0]; var reward = web3.toWei(1, "ether"); var bounty; - SimpleTokenBounty.new(target.address). + Bounty.new(target.address). then(function(_bounty){ bounty = _bounty; sendReward(owner, bounty.address, reward); @@ -55,7 +55,7 @@ contract('Bounty', function(accounts) { it("checkInvariant returns true", function(done){ var targetFactory = SecureTargetFactory.deployed(); var bounty; - SimpleTokenBounty.new(targetFactory.address). + Bounty.new(targetFactory.address). then(function(_bounty) { bounty = _bounty; return bounty.createTarget(); @@ -75,7 +75,7 @@ contract('Bounty', function(accounts) { var researcher = accounts[1]; var reward = web3.toWei(1, "ether"); - SimpleTokenBounty.new(targetFactory.address). + Bounty.new(targetFactory.address). then(function(bounty) { var event = bounty.TargetCreated({}); event.watch(function(err, result) { @@ -108,7 +108,7 @@ contract('Bounty', function(accounts) { it("checkInvariant returns false", function(done){ var targetFactory = InsecureTargetFactory.deployed(); var bounty; - SimpleTokenBounty.new(targetFactory.address). + Bounty.new(targetFactory.address). then(function(_bounty) { bounty = _bounty; return bounty.createTarget(); @@ -128,7 +128,7 @@ contract('Bounty', function(accounts) { var researcher = accounts[1]; var reward = web3.toWei(1, "ether"); - SimpleTokenBounty.new(targetFactory.address). + Bounty.new(targetFactory.address). then(function(bounty) { var event = bounty.TargetCreated({}); event.watch(function(err, result) {