Claimable.js 1.5 KB

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