LimitBalance.js 881 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. contract('LimitBalance', function(accounts) {
  2. var lb;
  3. beforeEach(function() {
  4. return LimitBalanceMock.new().then(function(deployed) {
  5. lb = deployed;
  6. });
  7. });
  8. var LIMIT = 1000;
  9. it("should expose limit", function(done) {
  10. return lb.limit()
  11. .then(function(limit) {
  12. assert.equal(limit, LIMIT);
  13. })
  14. .then(done)
  15. });
  16. it("should allow sending below limit", function(done) {
  17. var amount = 1;
  18. return lb.limitedDeposit({value: amount})
  19. .then(function() {
  20. assert.equal(web3.eth.getBalance(lb.address), amount);
  21. })
  22. .then(done)
  23. });
  24. it("shouldnt allow sending above limit", function(done) {
  25. var amount = 1100;
  26. return lb.limitedDeposit({value: amount})
  27. .catch(function(error) {
  28. if (error.message.search('invalid JUMP') == -1) throw error
  29. })
  30. .then(done)
  31. });
  32. });