Files
openzeppelin-contracts/test/examples/SimpleToken.test.js
Nicolás Venturo 4544df47da All tests now use account names, and dont use accounts[0] (except ERC… (#1137)
* All tests now use account names, and dont use accounts[0] (except ERC721)

* Added account names to some missing contracts.
2018-08-02 16:55:31 -03:00

41 lines
1.2 KiB
JavaScript

const { decodeLogs } = require('../helpers/decodeLogs');
const SimpleToken = artifacts.require('SimpleToken');
contract('SimpleToken', function ([_, creator]) {
let token;
beforeEach(async function () {
token = await SimpleToken.new({ from: creator });
});
it('has a name', async function () {
const name = await token.name();
assert.equal(name, 'SimpleToken');
});
it('has a symbol', async function () {
const symbol = await token.symbol();
assert.equal(symbol, 'SIM');
});
it('has 18 decimals', async function () {
const decimals = await token.decimals();
assert(decimals.eq(18));
});
it('assigns the initial total supply to the creator', async function () {
const totalSupply = await token.totalSupply();
const creatorBalance = await token.balanceOf(creator);
assert(creatorBalance.eq(totalSupply));
const receipt = await web3.eth.getTransactionReceipt(token.transactionHash);
const logs = decodeLogs(receipt.logs, SimpleToken, token.address);
assert.equal(logs.length, 1);
assert.equal(logs[0].event, 'Transfer');
assert.equal(logs[0].args.from.valueOf(), 0x0);
assert.equal(logs[0].args.to.valueOf(), creator);
assert(logs[0].args.value.eq(totalSupply));
});
});