Claimable.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. contract('Claimable', function(accounts) {
  2. var 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.transfer(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.transfer(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(function () {
  29. newOwner = accounts[1];
  30. return claimable.transfer(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. });