pull/35/head
Makoto Inoue 8 years ago
parent 8e7c7d54b1
commit 48badda96f
  1. 8
      contracts/bounties/SimpleTokenBounty.sol
  2. 2
      contracts/test-helpers/InsecureTargetMock.sol
  3. 2
      contracts/test-helpers/SecureTargetMock.sol
  4. 8
      test/Bounty.js

@ -9,7 +9,7 @@ import '../PullPayment.sol';
*/ */
contract Target { contract Target {
function checkInvarient() returns(bool); function checkInvariant() returns(bool);
} }
contract Bounty is PullPayment { contract Bounty is PullPayment {
@ -27,15 +27,15 @@ contract Bounty is PullPayment {
return target; return target;
} }
function checkInvarient() returns(bool){ function checkInvariant() returns(bool){
return target.checkInvarient(); return target.checkInvariant();
} }
function claim(Target target) { function claim(Target target) {
address researcher = researchers[target]; address researcher = researchers[target];
if (researcher == 0) throw; if (researcher == 0) throw;
// Check Target contract invariants // Check Target contract invariants
if (!target.checkInvarient()) { if (!target.checkInvariant()) {
throw; throw;
} }
asyncSend(researcher, this.balance); asyncSend(researcher, this.balance);

@ -1,7 +1,7 @@
pragma solidity ^0.4.0; pragma solidity ^0.4.0;
contract InsecureTargetMock { contract InsecureTargetMock {
function checkInvarient() returns(bool){ function checkInvariant() returns(bool){
return false; return false;
} }
} }

@ -1,7 +1,7 @@
pragma solidity ^0.4.0; pragma solidity ^0.4.0;
contract SecureTargetMock { contract SecureTargetMock {
function checkInvarient() returns(bool){ function checkInvariant() returns(bool){
return true; return true;
} }
} }

@ -1,10 +1,10 @@
contract('Bounty', function(accounts) { contract('Bounty', function(accounts) {
it("can call checkInvarient for InsecureTargetMock", function(done){ it("can call checkInvariant for InsecureTargetMock", function(done){
var bounty = Bounty.deployed(); var bounty = Bounty.deployed();
var target = SecureTargetMock.deployed(); var target = SecureTargetMock.deployed();
bounty.createTarget(target.address). bounty.createTarget(target.address).
then(function() { then(function() {
return bounty.checkInvarient.call() return bounty.checkInvariant.call()
}). }).
then(function(result) { then(function(result) {
assert.isTrue(result); assert.isTrue(result);
@ -12,12 +12,12 @@ contract('Bounty', function(accounts) {
then(done); then(done);
}) })
it("can call checkInvarient for InsecureTargetMock", function(done){ it("can call checkInvariant for InsecureTargetMock", function(done){
var bounty = Bounty.deployed(); var bounty = Bounty.deployed();
var target = InsecureTargetMock.deployed(); var target = InsecureTargetMock.deployed();
bounty.createTarget(target.address). bounty.createTarget(target.address).
then(function() { then(function() {
return bounty.checkInvarient.call() return bounty.checkInvariant.call()
}). }).
then(function(result) { then(function(result) {
assert.isFalse(result); assert.isFalse(result);

Loading…
Cancel
Save