From e8262f7c4b34cb79715a50fcbfab92c0a0541c2f Mon Sep 17 00:00:00 2001 From: Makoto Inoue Date: Wed, 26 Oct 2016 22:38:20 +0100 Subject: [PATCH] Make default function payable --- contracts/bounties/SimpleTokenBounty.sol | 2 +- test/Bounty.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/contracts/bounties/SimpleTokenBounty.sol b/contracts/bounties/SimpleTokenBounty.sol index 8fbb2f426..c7ff55c46 100644 --- a/contracts/bounties/SimpleTokenBounty.sol +++ b/contracts/bounties/SimpleTokenBounty.sol @@ -22,7 +22,7 @@ contract SimpleTokenBounty is PullPayment { address public factoryAddress; mapping(address => address) public researchers; - function() { + function() payable { if (claimed) throw; } diff --git a/test/Bounty.js b/test/Bounty.js index cd73a18c4..863657014 100644 --- a/test/Bounty.js +++ b/test/Bounty.js @@ -1,7 +1,11 @@ contract('Bounty', function(accounts) { + before(function(){ + owner = accounts[0]; + researcher = accounts[1]; + }) + it("can create bounty contract with factory address", function(done){ var target = SecureTargetMock.deployed(); - SimpleTokenBounty.new(target.address). then(function(bounty){ return bounty.factoryAddress.call() @@ -12,6 +16,22 @@ contract('Bounty', function(accounts) { then(done); }) + it("sets reward", function(done){ + var target = SecureTargetMock.deployed(); + var reward = web3.toWei(1, "ether"); + var bounty; + SimpleTokenBounty.new(target.address). + then(function(bounty){ + web3.eth.sendTransaction({ + from:owner, + to:bounty.address, + value: reward + }) + assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber()) + }). + then(done); + }) + describe("SecureTargetMock", function(){ before(function(){ targetFactory = SecureTargetFactory.deployed();