DelayedClaimable.test.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const { assertRevert } = require('../helpers/assertRevert');
  2. const DelayedClaimable = artifacts.require('DelayedClaimable');
  3. contract('DelayedClaimable', function (accounts) {
  4. beforeEach(async function () {
  5. this.delayedClaimable = await DelayedClaimable.new();
  6. });
  7. it('can set claim blocks', async function () {
  8. await this.delayedClaimable.transferOwnership(accounts[2]);
  9. await this.delayedClaimable.setLimits(0, 1000);
  10. const end = await this.delayedClaimable.end();
  11. assert.equal(end, 1000);
  12. const start = await this.delayedClaimable.start();
  13. assert.equal(start, 0);
  14. });
  15. it('changes pendingOwner after transfer successful', async function () {
  16. await this.delayedClaimable.transferOwnership(accounts[2]);
  17. await this.delayedClaimable.setLimits(0, 1000);
  18. const end = await this.delayedClaimable.end();
  19. assert.equal(end, 1000);
  20. const start = await this.delayedClaimable.start();
  21. assert.equal(start, 0);
  22. const pendingOwner = await this.delayedClaimable.pendingOwner();
  23. assert.equal(pendingOwner, accounts[2]);
  24. await this.delayedClaimable.claimOwnership({ from: accounts[2] });
  25. const owner = await this.delayedClaimable.owner();
  26. assert.equal(owner, accounts[2]);
  27. });
  28. it('changes pendingOwner after transfer fails', async function () {
  29. await this.delayedClaimable.transferOwnership(accounts[1]);
  30. await this.delayedClaimable.setLimits(100, 110);
  31. const end = await this.delayedClaimable.end();
  32. assert.equal(end, 110);
  33. const start = await this.delayedClaimable.start();
  34. assert.equal(start, 100);
  35. const pendingOwner = await this.delayedClaimable.pendingOwner();
  36. assert.equal(pendingOwner, accounts[1]);
  37. await assertRevert(this.delayedClaimable.claimOwnership({ from: accounts[1] }));
  38. const owner = await this.delayedClaimable.owner();
  39. assert.isTrue(owner !== accounts[1]);
  40. });
  41. it('set end and start invalid values fail', async function () {
  42. await this.delayedClaimable.transferOwnership(accounts[1]);
  43. await assertRevert(this.delayedClaimable.setLimits(1001, 1000));
  44. });
  45. });