Claimable.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. const { assertRevert } = require('../helpers/assertRevert');
  2. const Claimable = artifacts.require('Claimable');
  3. contract('Claimable', function ([_, owner, newOwner, anyone]) {
  4. let claimable;
  5. beforeEach(async function () {
  6. claimable = await Claimable.new();
  7. });
  8. it('changes pendingOwner after transfer', async function () {
  9. await claimable.transferOwnership(newOwner);
  10. const pendingOwner = await claimable.pendingOwner();
  11. assert.isTrue(pendingOwner === newOwner);
  12. });
  13. it('should prevent to claimOwnership from anyone', async function () {
  14. await assertRevert(claimable.claimOwnership({ from: anyone }));
  15. });
  16. it('should prevent non-owners from transfering', async function () {
  17. await assertRevert(claimable.transferOwnership(anyone, { from: anyone }));
  18. });
  19. describe('after initiating a transfer', function () {
  20. beforeEach(async function () {
  21. await claimable.transferOwnership(newOwner);
  22. });
  23. it('changes allow pending owner to claim ownership', async function () {
  24. await claimable.claimOwnership({ from: newOwner });
  25. assert.isTrue((await claimable.owner()) === newOwner);
  26. });
  27. });
  28. });