ERC721 deploy ready fixes (#2192)
* Add baseURI to ERC721MinterPauser constructor * Add tokenURI to mint * Remove tokenId and tokenURI from ERC721 deploy ready * Rename ERC721MinterPauser to ERC721MinterAutoID, remove Pausable mechanisms * Restore pausing to ERC721 * Rename deploy ready to presets * Rename ERC721 preset
This commit is contained in:
@ -5,9 +5,9 @@ const { ZERO_ADDRESS } = constants;
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
const ERC20MinterPauser = contract.fromArtifact('ERC20MinterPauser');
|
||||
const ERC20PresetMinterPauser = contract.fromArtifact('ERC20PresetMinterPauser');
|
||||
|
||||
describe('ERC20MinterPauser', function () {
|
||||
describe('ERC20PresetMinterPauser', function () {
|
||||
const [ deployer, other ] = accounts;
|
||||
|
||||
const name = 'MinterPauserToken';
|
||||
@ -20,7 +20,7 @@ describe('ERC20MinterPauser', function () {
|
||||
const PAUSER_ROLE = web3.utils.soliditySha3('PAUSER_ROLE');
|
||||
|
||||
beforeEach(async function () {
|
||||
this.token = await ERC20MinterPauser.new(name, symbol, { from: deployer });
|
||||
this.token = await ERC20PresetMinterPauser.new(name, symbol, { from: deployer });
|
||||
});
|
||||
|
||||
it('deployer has the default admin role', async function () {
|
||||
@ -54,7 +54,7 @@ describe('ERC20MinterPauser', function () {
|
||||
it('other accounts cannot mint tokens', async function () {
|
||||
await expectRevert(
|
||||
this.token.mint(other, amount, { from: other }),
|
||||
'ERC20MinterPauser: must have minter role to mint'
|
||||
'ERC20PresetMinterPauser: must have minter role to mint'
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -86,7 +86,7 @@ describe('ERC20MinterPauser', function () {
|
||||
});
|
||||
|
||||
it('other accounts cannot pause', async function () {
|
||||
await expectRevert(this.token.pause({ from: other }), 'ERC20MinterPauser: must have pauser role to pause');
|
||||
await expectRevert(this.token.pause({ from: other }), 'ERC20PresetMinterPauser: must have pauser role to pause');
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,22 +5,32 @@ const { ZERO_ADDRESS } = constants;
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
const ERC721MinterPauser = contract.fromArtifact('ERC721MinterPauser');
|
||||
const ERC721PresetMinterPauserAutoId = contract.fromArtifact('ERC721PresetMinterPauserAutoId');
|
||||
|
||||
describe('ERC721MinterPauser', function () {
|
||||
describe('ERC721PresetMinterPauserAutoId', function () {
|
||||
const [ deployer, other ] = accounts;
|
||||
|
||||
const name = 'MinterPauserToken';
|
||||
const symbol = 'DRT';
|
||||
|
||||
const tokenId = new BN('1337');
|
||||
const name = 'MinterAutoIDToken';
|
||||
const symbol = 'MAIT';
|
||||
const baseURI = 'my.app/';
|
||||
|
||||
const DEFAULT_ADMIN_ROLE = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
||||
const MINTER_ROLE = web3.utils.soliditySha3('MINTER_ROLE');
|
||||
const PAUSER_ROLE = web3.utils.soliditySha3('PAUSER_ROLE');
|
||||
|
||||
beforeEach(async function () {
|
||||
this.token = await ERC721MinterPauser.new(name, symbol, { from: deployer });
|
||||
this.token = await ERC721PresetMinterPauserAutoId.new(name, symbol, baseURI, { from: deployer });
|
||||
});
|
||||
|
||||
it('token has correct name', async function () {
|
||||
expect(await this.token.name()).to.equal(name);
|
||||
});
|
||||
|
||||
it('token has correct symbol', async function () {
|
||||
expect(await this.token.symbol()).to.equal(symbol);
|
||||
});
|
||||
|
||||
it('token has correct base URI', async function () {
|
||||
expect(await this.token.baseURI()).to.equal(baseURI);
|
||||
});
|
||||
|
||||
it('deployer has the default admin role', async function () {
|
||||
@ -33,29 +43,27 @@ describe('ERC721MinterPauser', function () {
|
||||
expect(await this.token.getRoleMember(MINTER_ROLE, 0)).to.equal(deployer);
|
||||
});
|
||||
|
||||
it('deployer has the pauser role', async function () {
|
||||
expect(await this.token.getRoleMemberCount(PAUSER_ROLE)).to.be.bignumber.equal('1');
|
||||
expect(await this.token.getRoleMember(PAUSER_ROLE, 0)).to.equal(deployer);
|
||||
});
|
||||
|
||||
it('minter and pauser role admin is the default admin', async function () {
|
||||
it('minter role admin is the default admin', async function () {
|
||||
expect(await this.token.getRoleAdmin(MINTER_ROLE)).to.equal(DEFAULT_ADMIN_ROLE);
|
||||
expect(await this.token.getRoleAdmin(PAUSER_ROLE)).to.equal(DEFAULT_ADMIN_ROLE);
|
||||
});
|
||||
|
||||
describe('minting', function () {
|
||||
it('deployer can mint tokens', async function () {
|
||||
const receipt = await this.token.mint(other, tokenId, { from: deployer });
|
||||
const tokenId = new BN('0');
|
||||
|
||||
const receipt = await this.token.mint(other, { from: deployer });
|
||||
expectEvent(receipt, 'Transfer', { from: ZERO_ADDRESS, to: other, tokenId });
|
||||
|
||||
expect(await this.token.balanceOf(other)).to.be.bignumber.equal('1');
|
||||
expect(await this.token.ownerOf(tokenId)).to.equal(other);
|
||||
|
||||
expect(await this.token.tokenURI(tokenId)).to.equal(baseURI + tokenId);
|
||||
});
|
||||
|
||||
it('other accounts cannot mint tokens', async function () {
|
||||
await expectRevert(
|
||||
this.token.mint(other, tokenId, { from: other }),
|
||||
'ERC721MinterPauser: must have minter role to mint'
|
||||
this.token.mint(other, { from: other }),
|
||||
'ERC721PresetMinterPauserAutoId: must have minter role to mint'
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -81,19 +89,24 @@ describe('ERC721MinterPauser', function () {
|
||||
await this.token.pause({ from: deployer });
|
||||
|
||||
await expectRevert(
|
||||
this.token.mint(other, tokenId, { from: deployer }),
|
||||
this.token.mint(other, { from: deployer }),
|
||||
'ERC721Pausable: token transfer while paused'
|
||||
);
|
||||
});
|
||||
|
||||
it('other accounts cannot pause', async function () {
|
||||
await expectRevert(this.token.pause({ from: other }), 'ERC721MinterPauser: must have pauser role to pause');
|
||||
await expectRevert(
|
||||
this.token.pause({ from: other }),
|
||||
'ERC721PresetMinterPauserAutoId: must have pauser role to pause'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('burning', function () {
|
||||
it('holders can burn their tokens', async function () {
|
||||
await this.token.mint(other, tokenId, { from: deployer });
|
||||
const tokenId = new BN('0');
|
||||
|
||||
await this.token.mint(other, { from: deployer });
|
||||
|
||||
const receipt = await this.token.burn(tokenId, { from: other });
|
||||
|
||||
Reference in New Issue
Block a user