mirror of openzeppelin-contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
openzeppelin-contracts/test/Ownable.js

38 lines
1.0 KiB

contract('Ownable', function(accounts) {
let ownable;
beforeEach(async function() {
ownable = await Ownable.new();
});
it("should have an owner", async function() {
let owner = await ownable.owner();
assert.isTrue(owner != 0);
});
it("changes owner after transfer", async function() {
let other = accounts[1];
let transfer = await ownable.transfer(other);
let owner = await ownable.owner();
assert.isTrue(owner === other);
});
it("should prevent non-owners from transfering", async function() {
let other = accounts[2];
let transfer = await ownable.transfer(other, {from: accounts[2]});
let owner = await ownable.owner();
assert.isFalse(owner === other);
});
it("should guard ownership against stuck state", async function() {
let ownable = Ownable.deployed();
let originalOwner = await ownable.owner();
let transfer = await ownable.transfer(null, {from: originalOwner});
let newOwner = await ownable.owner();
assert.equal(originalOwner, newOwner);
});
});