Ownable.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. contract('Ownable', function(accounts) {
  2. let ownable;
  3. beforeEach(async function() {
  4. ownable = await Ownable.new();
  5. });
  6. it("should have an owner", async function() {
  7. let owner = await ownable.owner();
  8. assert.isTrue(owner != 0);
  9. });
  10. it("changes owner after transfer", async function() {
  11. let other = accounts[1];
  12. let transfer = await ownable.transfer(other);
  13. let owner = await ownable.owner();
  14. assert.isTrue(owner === other);
  15. });
  16. it("should prevent non-owners from transfering", async function() {
  17. let other = accounts[2];
  18. let transfer = await ownable.transfer(other, {from: accounts[2]});
  19. let owner = await ownable.owner();
  20. assert.isFalse(owner === other);
  21. });
  22. it("should guard ownership against stuck state", async function() {
  23. let ownable = Ownable.deployed();
  24. let originalOwner = await ownable.owner();
  25. let transfer = await ownable.transfer(null, {from: originalOwner});
  26. let newOwner = await ownable.owner();
  27. assert.equal(originalOwner, newOwner);
  28. });
  29. });