Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
42
test/presets/ERC20PresetFixedSupply.test.js
Normal file
42
test/presets/ERC20PresetFixedSupply.test.js
Normal file
@ -0,0 +1,42 @@
|
||||
const { BN, constants, expectEvent } = require('@openzeppelin/test-helpers');
|
||||
const { ZERO_ADDRESS } = constants;
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
const ERC20PresetFixedSupply = artifacts.require('ERC20PresetFixedSupply');
|
||||
|
||||
contract('ERC20PresetFixedSupply', function (accounts) {
|
||||
const [deployer, owner] = accounts;
|
||||
|
||||
const name = 'PresetFixedSupply';
|
||||
const symbol = 'PFS';
|
||||
|
||||
const initialSupply = new BN('50000');
|
||||
const amount = new BN('10000');
|
||||
|
||||
before(async function () {
|
||||
this.token = await ERC20PresetFixedSupply.new(name, symbol, initialSupply, owner, { from: deployer });
|
||||
});
|
||||
|
||||
it('deployer has the balance equal to initial supply', async function () {
|
||||
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(initialSupply);
|
||||
});
|
||||
|
||||
it('total supply is equal to initial supply', async function () {
|
||||
expect(await this.token.totalSupply()).to.be.bignumber.equal(initialSupply);
|
||||
});
|
||||
|
||||
describe('burning', function () {
|
||||
it('holders can burn their tokens', async function () {
|
||||
const remainingBalance = initialSupply.sub(amount);
|
||||
const receipt = await this.token.burn(amount, { from: owner });
|
||||
expectEvent(receipt, 'Transfer', { from: owner, to: ZERO_ADDRESS, value: amount });
|
||||
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(remainingBalance);
|
||||
});
|
||||
|
||||
it('decrements totalSupply', async function () {
|
||||
const expectedSupply = initialSupply.sub(amount);
|
||||
expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply);
|
||||
});
|
||||
});
|
||||
});
|
||||
49
test/presets/ERC777PresetFixedSupply.test.js
Normal file
49
test/presets/ERC777PresetFixedSupply.test.js
Normal file
@ -0,0 +1,49 @@
|
||||
const { BN, singletons } = require('@openzeppelin/test-helpers');
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
const ERC777PresetFixedSupply = artifacts.require('ERC777PresetFixedSupply');
|
||||
|
||||
contract('ERC777PresetFixedSupply', function (accounts) {
|
||||
const [registryFunder, owner, defaultOperatorA, defaultOperatorB, anyone] = accounts;
|
||||
|
||||
const initialSupply = new BN('10000');
|
||||
const name = 'ERC777Preset';
|
||||
const symbol = '777P';
|
||||
|
||||
const defaultOperators = [defaultOperatorA, defaultOperatorB];
|
||||
|
||||
before(async function () {
|
||||
await singletons.ERC1820Registry(registryFunder);
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
this.token = await ERC777PresetFixedSupply.new(name, symbol, defaultOperators, initialSupply, owner);
|
||||
});
|
||||
|
||||
it('returns the name', async function () {
|
||||
expect(await this.token.name()).to.equal(name);
|
||||
});
|
||||
|
||||
it('returns the symbol', async function () {
|
||||
expect(await this.token.symbol()).to.equal(symbol);
|
||||
});
|
||||
|
||||
it('returns the default operators', async function () {
|
||||
expect(await this.token.defaultOperators()).to.deep.equal(defaultOperators);
|
||||
});
|
||||
|
||||
it('default operators are operators for all accounts', async function () {
|
||||
for (const operator of defaultOperators) {
|
||||
expect(await this.token.isOperatorFor(operator, anyone)).to.equal(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('returns the total supply equal to initial supply', async function () {
|
||||
expect(await this.token.totalSupply()).to.be.bignumber.equal(initialSupply);
|
||||
});
|
||||
|
||||
it('returns the balance of owner equal to initial supply', async function () {
|
||||
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(initialSupply);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user