Reorganize tests and add library folder

This commit is contained in:
AugustoL
2018-01-17 15:33:42 -03:00
parent b0522b9c58
commit 4fbd44fd40
7 changed files with 15 additions and 15 deletions

View File

@ -0,0 +1,41 @@
import decodeLogs from '../helpers/decodeLogs';
const SimpleToken = artifacts.require('SimpleToken.sol');
contract('SimpleToken', accounts => {
let token;
const creator = accounts[0];
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 = 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));
});
});