Add internal functions _getInitializedVersion and _isInitializing (#3598)
This commit is contained in:
committed by
GitHub
parent
397c946141
commit
26cf47a2be
@ -20,6 +20,10 @@ contract('Initializable', function (accounts) {
|
||||
it('initializer has not run', async function () {
|
||||
expect(await this.contract.initializerRan()).to.equal(false);
|
||||
});
|
||||
|
||||
it('_initializing returns false before initialization', async function () {
|
||||
expect(await this.contract.isInitializing()).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('after initialize', function () {
|
||||
@ -31,6 +35,10 @@ contract('Initializable', function (accounts) {
|
||||
expect(await this.contract.initializerRan()).to.equal(true);
|
||||
});
|
||||
|
||||
it('_initializing returns false after initialization', async function () {
|
||||
expect(await this.contract.isInitializing()).to.equal(false);
|
||||
});
|
||||
|
||||
it('initializer does not run again', async function () {
|
||||
await expectRevert(this.contract.initialize(), 'Initializable: contract is already initialized');
|
||||
});
|
||||
@ -101,6 +109,13 @@ contract('Initializable', function (accounts) {
|
||||
expect(await this.contract.counter()).to.be.bignumber.equal('2');
|
||||
});
|
||||
|
||||
it('_getInitializedVersion returns right version', async function () {
|
||||
await this.contract.initialize();
|
||||
expect(await this.contract.getInitializedVersion()).to.be.bignumber.equal('1');
|
||||
await this.contract.reinitialize(12);
|
||||
expect(await this.contract.getInitializedVersion()).to.be.bignumber.equal('12');
|
||||
});
|
||||
|
||||
describe('contract locking', function () {
|
||||
it('prevents initialization', async function () {
|
||||
await this.contract.disableInitializers();
|
||||
|
||||
Reference in New Issue
Block a user