Bounty.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. contract('Bounty', function(accounts) {
  2. it("can create bounty contract with factory address", function(done){
  3. var target = SecureTargetMock.deployed();
  4. SimpleTokenBounty.new(target.address).
  5. then(function(bounty){
  6. return bounty.factoryAddress.call()
  7. }).
  8. then(function(address){
  9. assert.equal(address, target.address)
  10. }).
  11. then(done);
  12. })
  13. it("can call checkInvariant for SecureTargetMock", function(done){
  14. var bounty;
  15. var targetFactory = SecureTargetFactory.deployed();
  16. SimpleTokenBounty.new(targetFactory.address).
  17. then(function(_bounty) {
  18. bounty = _bounty;
  19. return bounty.createTarget();
  20. }).
  21. then(function() {
  22. return bounty.checkInvariant.call()
  23. }).
  24. then(function(result) {
  25. assert.isTrue(result);
  26. }).
  27. then(done);
  28. })
  29. it("can call checkInvariant for InsecureTargetMock", function(done){
  30. var bounty;
  31. var targetFactory = InsecureTargetFactory.deployed();
  32. SimpleTokenBounty.new(targetFactory.address).
  33. then(function(_bounty) {
  34. bounty = _bounty;
  35. return bounty.createTarget();
  36. }).
  37. then(function() {
  38. return bounty.checkInvariant.call()
  39. }).
  40. then(function(result) {
  41. assert.isFalse(result);
  42. }).
  43. then(done);
  44. })
  45. });