Claimable.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. var Claimable = artifacts.require('../contracts/ownership/Claimable.sol');
  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. claimable.claimOwnership({from: accounts[2]});
  20. let owner = await claimable.owner();
  21. assert.isTrue(owner !== accounts[2]);
  22. });
  23. it('should prevent non-owners from transfering', async function() {
  24. await claimable.transferOwnership(accounts[2], {from: accounts[2]});
  25. let pendingOwner = await claimable.pendingOwner();
  26. assert.isFalse(pendingOwner === accounts[2]);
  27. });
  28. describe('after initiating a transfer', function () {
  29. let newOwner;
  30. beforeEach(async function () {
  31. newOwner = accounts[1];
  32. await claimable.transferOwnership(newOwner);
  33. });
  34. it('changes allow pending owner to claim ownership', async function() {
  35. await claimable.claimOwnership({from: newOwner});
  36. let owner = await claimable.owner();
  37. assert.isTrue(owner === newOwner);
  38. });
  39. });
  40. });