Restructure test

pull/35/head
Makoto Inoue 8 years ago
parent 14b8496247
commit df0c2defc8
  1. 69
      test/Bounty.js

@ -1,6 +1,7 @@
contract('Bounty', function(accounts) { contract('Bounty', function(accounts) {
it("can create bounty contract with factory address", function(done){ it("can create bounty contract with factory address", function(done){
var target = SecureTargetMock.deployed(); var target = SecureTargetMock.deployed();
SimpleTokenBounty.new(target.address). SimpleTokenBounty.new(target.address).
then(function(bounty){ then(function(bounty){
return bounty.factoryAddress.call() return bounty.factoryAddress.call()
@ -11,37 +12,45 @@ contract('Bounty', function(accounts) {
then(done); then(done);
}) })
it("can call checkInvariant for SecureTargetMock", function(done){ describe("SecureTargetMock", function(){
var bounty; before(function(){
var targetFactory = SecureTargetFactory.deployed(); targetFactory = SecureTargetFactory.deployed();
SimpleTokenBounty.new(targetFactory.address). })
then(function(_bounty) {
bounty = _bounty; it("checkInvariant returns true", function(done){
return bounty.createTarget(); SimpleTokenBounty.new(targetFactory.address).
}). then(function(_bounty) {
then(function() { bounty = _bounty;
return bounty.checkInvariant.call() return bounty.createTarget();
}). }).
then(function(result) { then(function() {
assert.isTrue(result); return bounty.checkInvariant.call()
}). }).
then(done); then(function(result) {
assert.isTrue(result);
}).
then(done);
})
}) })
it("can call checkInvariant for InsecureTargetMock", function(done){ describe("InsecureTargetMock", function(){
var bounty; before(function(){
var targetFactory = InsecureTargetFactory.deployed(); targetFactory = InsecureTargetFactory.deployed();
SimpleTokenBounty.new(targetFactory.address). })
then(function(_bounty) {
bounty = _bounty; it("checkInvariant returns false", function(done){
return bounty.createTarget(); SimpleTokenBounty.new(targetFactory.address).
}). then(function(_bounty) {
then(function() { bounty = _bounty;
return bounty.checkInvariant.call() return bounty.createTarget();
}). }).
then(function(result) { then(function() {
assert.isFalse(result); return bounty.checkInvariant.call()
}). }).
then(done); then(function(result) {
assert.isFalse(result);
}).
then(done);
})
}) })
}); });

Loading…
Cancel
Save