Claimable.js 1.6 KB

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