Merge tag 'v2.1.1' of github.com:OpenZeppelin/openzeppelin-solidity

v2.1.1
This commit is contained in:
Francisco Giordano
2019-01-18 15:33:51 -03:00
237 changed files with 8562 additions and 4937 deletions

View File

@ -1,45 +1,36 @@
const { decodeLogs } = require('../helpers/decodeLogs');
const expectEvent = require('../helpers/expectEvent');
const { ZERO_ADDRESS } = require('../helpers/constants');
const SimpleToken = artifacts.require('SimpleTokenMock');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
require('../helpers/setup');
contract('SimpleToken', function ([_, creator]) {
let token;
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
beforeEach(async function () {
token = await SimpleToken.new({ from: creator });
this.token = await SimpleToken.new({ from: creator });
});
it('has a name', async function () {
(await token.name()).should.equal('SimpleToken');
(await this.token.name()).should.equal('SimpleToken');
});
it('has a symbol', async function () {
(await token.symbol()).should.equal('SIM');
(await this.token.symbol()).should.equal('SIM');
});
it('has 18 decimals', async function () {
(await token.decimals()).should.be.bignumber.equal(18);
(await this.token.decimals()).should.be.bignumber.equal(18);
});
it('assigns the initial total supply to the creator', async function () {
const totalSupply = await token.totalSupply();
const creatorBalance = await token.balanceOf(creator);
const totalSupply = await this.token.totalSupply();
const creatorBalance = await this.token.balanceOf(creator);
creatorBalance.should.be.bignumber.equal(totalSupply);
const receipt = await web3.eth.getTransactionReceipt(token.transactionHash);
const logs = decodeLogs(receipt.logs, SimpleToken, token.address);
logs.length.should.equal(1);
logs[0].event.should.equal('Transfer');
logs[0].args.from.valueOf().should.equal(ZERO_ADDRESS);
logs[0].args.to.valueOf().should.equal(creator);
logs[0].args.value.should.be.bignumber.equal(totalSupply);
await expectEvent.inConstruction(this.token, 'Transfer', {
from: ZERO_ADDRESS,
to: creator,
value: totalSupply,
});
});
});