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.
42 lines
1.3 KiB
42 lines
1.3 KiB
7 years ago
|
const { expectThrow } = require('../helpers/expectThrow');
|
||
7 years ago
|
const { EVMRevert } = require('../helpers/EVMRevert');
|
||
7 years ago
|
|
||
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||
|
|
||
|
require('chai')
|
||
|
.should();
|
||
|
|
||
7 years ago
|
function shouldBehaveLikeOwnable (owner, [anyone]) {
|
||
7 years ago
|
describe('as an ownable', function () {
|
||
|
it('should have an owner', async function () {
|
||
7 years ago
|
(await this.ownable.owner()).should.eq(owner);
|
||
7 years ago
|
});
|
||
|
|
||
|
it('changes owner after transfer', async function () {
|
||
7 years ago
|
await this.ownable.transferOwnership(anyone, { from: owner });
|
||
|
(await this.ownable.owner()).should.eq(anyone);
|
||
7 years ago
|
});
|
||
|
|
||
|
it('should prevent non-owners from transfering', async function () {
|
||
7 years ago
|
await expectThrow(this.ownable.transferOwnership(anyone, { from: anyone }), EVMRevert);
|
||
7 years ago
|
});
|
||
|
|
||
|
it('should guard ownership against stuck state', async function () {
|
||
7 years ago
|
await expectThrow(this.ownable.transferOwnership(null, { from: owner }), EVMRevert);
|
||
7 years ago
|
});
|
||
|
|
||
|
it('loses owner after renouncement', async function () {
|
||
7 years ago
|
await this.ownable.renounceOwnership({ from: owner });
|
||
|
(await this.ownable.owner()).should.eq(ZERO_ADDRESS);
|
||
7 years ago
|
});
|
||
|
|
||
|
it('should prevent non-owners from renouncement', async function () {
|
||
7 years ago
|
await expectThrow(this.ownable.renounceOwnership({ from: anyone }), EVMRevert);
|
||
7 years ago
|
});
|
||
|
});
|
||
7 years ago
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
shouldBehaveLikeOwnable,
|
||
7 years ago
|
};
|