Claimable.test.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. const { assertRevert } = require('../helpers/assertRevert');
  2. var Claimable = artifacts.require('Claimable');
  3. contract('Claimable', function (accounts) {
  4. let claimable;
  5. beforeEach(async function () {
  6. claimable = await Claimable.new();
  7. });
  8. it('should have an owner', async function () {
  9. let owner = await claimable.owner();
  10. assert.isTrue(owner !== 0);
  11. });
  12. it('changes pendingOwner after transfer', async function () {
  13. let newOwner = accounts[1];
  14. await claimable.transferOwnership(newOwner);
  15. let pendingOwner = await claimable.pendingOwner();
  16. assert.isTrue(pendingOwner === newOwner);
  17. });
  18. it('should prevent to claimOwnership from no pendingOwner', async function () {
  19. await assertRevert(claimable.claimOwnership({ from: accounts[2] }));
  20. });
  21. it('should prevent non-owners from transfering', async function () {
  22. const other = accounts[2];
  23. const owner = await claimable.owner.call();
  24. assert.isTrue(owner !== other);
  25. await assertRevert(claimable.transferOwnership(other, { from: other }));
  26. });
  27. describe('after initiating a transfer', function () {
  28. let newOwner;
  29. beforeEach(async function () {
  30. newOwner = accounts[1];
  31. await claimable.transferOwnership(newOwner);
  32. });
  33. it('changes allow pending owner to claim ownership', async function () {
  34. await claimable.claimOwnership({ from: newOwner });
  35. let owner = await claimable.owner();
  36. assert.isTrue(owner === newOwner);
  37. });
  38. });
  39. });