DelayedClaimable.test.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const { assertRevert } = require('../helpers/assertRevert');
  2. const DelayedClaimable = artifacts.require('DelayedClaimable');
  3. contract('DelayedClaimable', function ([_, owner, newOwner]) {
  4. beforeEach(async function () {
  5. this.delayedClaimable = await DelayedClaimable.new({ from: owner });
  6. });
  7. it('can set claim blocks', async function () {
  8. await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
  9. await this.delayedClaimable.setLimits(0, 1000, { from: owner });
  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(newOwner, { from: owner });
  17. await this.delayedClaimable.setLimits(0, 1000, { from: owner });
  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. assert.equal((await this.delayedClaimable.pendingOwner()), newOwner);
  23. await this.delayedClaimable.claimOwnership({ from: newOwner });
  24. assert.equal((await this.delayedClaimable.owner()), newOwner);
  25. });
  26. it('changes pendingOwner after transfer fails', async function () {
  27. await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
  28. await this.delayedClaimable.setLimits(100, 110, { from: owner });
  29. const end = await this.delayedClaimable.end();
  30. assert.equal(end, 110);
  31. const start = await this.delayedClaimable.start();
  32. assert.equal(start, 100);
  33. assert.equal((await this.delayedClaimable.pendingOwner()), newOwner);
  34. await assertRevert(this.delayedClaimable.claimOwnership({ from: newOwner }));
  35. assert.isTrue((await this.delayedClaimable.owner()) !== newOwner);
  36. });
  37. it('set end and start invalid values fail', async function () {
  38. await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
  39. await assertRevert(this.delayedClaimable.setLimits(1001, 1000, { from: owner }));
  40. });
  41. });