Add tests to extend code coverage (#2586)

This commit is contained in:
Hadrien Croubois
2021-03-15 17:01:47 +01:00
committed by GitHub
parent d5194725b7
commit cd443f0d5b
8 changed files with 91 additions and 11 deletions

View File

@ -120,6 +120,15 @@ contract('ERC1155PresetMinterPauser', function (accounts) {
'ERC1155PresetMinterPauser: must have pauser role to pause',
);
});
it('other accounts cannot unpause', async function () {
await this.token.pause({ from: deployer });
await expectRevert(
this.token.unpause({ from: other }),
'ERC1155PresetMinterPauser: must have pauser role to unpause',
);
});
});
describe('burning', function () {

View File

@ -84,7 +84,19 @@ contract('ERC20PresetMinterPauser', function (accounts) {
});
it('other accounts cannot pause', async function () {
await expectRevert(this.token.pause({ from: other }), 'ERC20PresetMinterPauser: must have pauser role to pause');
await expectRevert(
this.token.pause({ from: other }),
'ERC20PresetMinterPauser: must have pauser role to pause',
);
});
it('other accounts cannot unpause', async function () {
await this.token.pause({ from: deployer });
await expectRevert(
this.token.unpause({ from: other }),
'ERC20PresetMinterPauser: must have pauser role to unpause',
);
});
});

View File

@ -73,6 +73,15 @@ contract('ERC721URIStorage', function (accounts) {
expect(await this.token.tokenURI(firstTokenId)).to.be.equal(baseURI + firstTokenId);
});
it('tokens without URI can be burnt ', async function () {
await this.token.burn(firstTokenId, { from: owner });
expect(await this.token.exists(firstTokenId)).to.equal(false);
await expectRevert(
this.token.tokenURI(firstTokenId), 'ERC721URIStorage: URI query for nonexistent token',
);
});
it('tokens with URI can be burnt ', async function () {
await this.token.setTokenURI(firstTokenId, sampleUri);

View File

@ -97,6 +97,15 @@ contract('ERC721PresetMinterPauserAutoId', function (accounts) {
'ERC721PresetMinterPauserAutoId: must have pauser role to pause',
);
});
it('other accounts cannot unpause', async function () {
await this.token.pause({ from: deployer });
await expectRevert(
this.token.unpause({ from: other }),
'ERC721PresetMinterPauserAutoId: must have pauser role to unpause',
);
});
});
describe('burning', function () {