Browse Source

Does not allow to create bounty contract without address

Makoto Inoue 9 years ago
parent
commit
b6a5830047
3 changed files with 18 additions and 2 deletions
  1. 6 1
      contracts/Bounty.sol
  2. 0 1
      migrations/2_deploy_contracts.js
  3. 12 0
      test/Bounty.js

+ 6 - 1
contracts/Bounty.sol

@@ -28,7 +28,12 @@ contract Bounty is PullPayment, Killable {
     if (claimed) throw;
   }
 
-  function Bounty(address _factoryAddress){
+  modifier withAddress(address _address) {
+    if(_address == 0) throw;
+    _;
+  }
+
+  function Bounty(address _factoryAddress) withAddress(_factoryAddress){
     factoryAddress = _factoryAddress;
   }
 

+ 0 - 1
migrations/2_deploy_contracts.js

@@ -2,7 +2,6 @@ module.exports = function(deployer) {
   deployer.deploy(PullPaymentBid);
   deployer.deploy(BadArrayUse);
   deployer.deploy(ProofOfExistence);
-  deployer.deploy(Bounty);
   deployer.deploy(CrowdsaleTokenBounty);
   deployer.deploy(Ownable);
   deployer.deploy(LimitFunds);

+ 12 - 0
test/Bounty.js

@@ -33,6 +33,18 @@ contract('Bounty', function(accounts) {
       then(done);
   })
 
+  it("cannot create bounty without address", function(done){
+    var target = SecureTargetMock.deployed();
+    Bounty.new().
+      then(function(bounty){
+        throw {name : "NoThrowError", message : "should not come here"};
+      }).
+      catch(function(error){
+        assert.notEqual(error.name, "NoThrowError");
+      }).
+      then(done);
+  })
+
   it("empties itself when killed", function(done){
     var target = SecureTargetMock.deployed();
     var owner = accounts[0];