From 14b8496247cf8e96625fc1eaf439ad376db494d1 Mon Sep 17 00:00:00 2001 From: Makoto Inoue Date: Wed, 26 Oct 2016 19:34:08 +0100 Subject: [PATCH] Pass factory address to bounty --- contracts/test-helpers/InsecureTargetMock.sol | 2 +- contracts/test-helpers/SecureTargetMock.sol | 2 +- migrations/2_deploy_contracts.js | 4 ++-- test/Bounty.js | 24 +++++++++++-------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/contracts/test-helpers/InsecureTargetMock.sol b/contracts/test-helpers/InsecureTargetMock.sol index 8b85b6eb9..0db1ee180 100644 --- a/contracts/test-helpers/InsecureTargetMock.sol +++ b/contracts/test-helpers/InsecureTargetMock.sol @@ -6,7 +6,7 @@ contract InsecureTargetMock { } } -contract Deployer { +contract InsecureTargetFactory { function deployContract() returns (address) { return new InsecureTargetMock(); } diff --git a/contracts/test-helpers/SecureTargetMock.sol b/contracts/test-helpers/SecureTargetMock.sol index 382c4b53d..4c7da0093 100644 --- a/contracts/test-helpers/SecureTargetMock.sol +++ b/contracts/test-helpers/SecureTargetMock.sol @@ -6,7 +6,7 @@ contract SecureTargetMock { } } -contract Deployer { +contract SecureTargetFactory { function deployContract() returns (address) { return new SecureTargetMock(); } diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 504e92353..67672b289 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -7,7 +7,7 @@ module.exports = function(deployer) { deployer.deploy(Ownable); deployer.deploy(LimitFunds); if(deployer.network == 'test'){ - deployer.deploy(SecureTargetMock); - deployer.deploy(InsecureTargetMock); + deployer.deploy(SecureTargetFactory); + deployer.deploy(InsecureTargetFactory); }; }; diff --git a/test/Bounty.js b/test/Bounty.js index e66dbf7a9..19b43db4e 100644 --- a/test/Bounty.js +++ b/test/Bounty.js @@ -11,17 +11,17 @@ contract('Bounty', function(accounts) { then(done); }) - it.only("can call checkInvariant for SecureTargetMock", function(done){ + it("can call checkInvariant for SecureTargetMock", function(done){ var bounty; - var target = SecureTargetMock.deployed(); - SimpleTokenBounty.new(target.address). + var targetFactory = SecureTargetFactory.deployed(); + SimpleTokenBounty.new(targetFactory.address). then(function(_bounty) { bounty = _bounty; - return bounty.createTarget.sendTransaction({gas:200000}); + return bounty.createTarget(); + }). + then(function() { + return bounty.checkInvariant.call() }). - // then(function() { - // return bounty.checkInvariant.call() - // }). then(function(result) { assert.isTrue(result); }). @@ -29,9 +29,13 @@ contract('Bounty', function(accounts) { }) it("can call checkInvariant for InsecureTargetMock", function(done){ - var bounty = SimpleTokenBounty.deployed(); - var target = InsecureTargetMock.deployed(); - bounty.createTarget(target.address). + var bounty; + var targetFactory = InsecureTargetFactory.deployed(); + SimpleTokenBounty.new(targetFactory.address). + then(function(_bounty) { + bounty = _bounty; + return bounty.createTarget(); + }). then(function() { return bounty.checkInvariant.call() }).