Claimable.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. contract('Claimable', function(accounts) {
  2. var claimable;
  3. beforeEach(function() {
  4. return Claimable.new().then(function(deployed) {
  5. claimable = deployed;
  6. });
  7. });
  8. it("should have an owner", function(done) {
  9. return claimable.owner()
  10. .then(function(owner) {
  11. assert.isTrue(owner != 0);
  12. })
  13. .then(done)
  14. });
  15. it("changes pendingOwner after transfer", function(done) {
  16. var newOwner = accounts[1];
  17. return claimable.transfer(newOwner)
  18. .then(function() {
  19. return claimable.pendingOwner();
  20. })
  21. .then(function(pendingOwner) {
  22. assert.isTrue(pendingOwner === newOwner);
  23. })
  24. .then(done)
  25. });
  26. it("should prevent to claimOwnership from no pendingOwner", function(done) {
  27. return claimable.claimOwnership({from: accounts[2]})
  28. .then(function() {
  29. return claimable.owner();
  30. })
  31. .then(function(owner) {
  32. assert.isTrue(owner != accounts[2]);
  33. })
  34. .then(done)
  35. });
  36. it("should prevent non-owners from transfering" ,function(done) {
  37. return claimable.transfer(accounts[2], {from: accounts[2]})
  38. .then(function() {
  39. return claimable.pendingOwner();
  40. })
  41. .then(function(pendingOwner) {
  42. assert.isFalse(pendingOwner === accounts[2]);
  43. })
  44. .then(done)
  45. });
  46. describe("after initiating a transfer", function () {
  47. var newOwner;
  48. beforeEach(function () {
  49. newOwner = accounts[1];
  50. return claimable.transfer(newOwner);
  51. });
  52. it("changes allow pending owner to claim ownership", function(done) {
  53. return claimable.claimOwnership({from: newOwner})
  54. .then(function() {
  55. return claimable.owner();
  56. })
  57. .then(function(owner) {
  58. assert.isTrue(owner === newOwner);
  59. })
  60. .then(done)
  61. });
  62. });
  63. });