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.
This commit is contained in:
Nicolás Venturo
2018-08-02 16:55:31 -03:00
committed by GitHub
parent f49721576f
commit 4544df47da
41 changed files with 210 additions and 300 deletions

View File

@ -3,24 +3,24 @@ const { expectThrow } = require('../helpers/expectThrow');
const CanReclaimToken = artifacts.require('CanReclaimToken');
const BasicTokenMock = artifacts.require('BasicTokenMock');
contract('CanReclaimToken', function (accounts) {
contract('CanReclaimToken', function ([_, owner, anyone]) {
let token = null;
let canReclaimToken = null;
beforeEach(async function () {
// Create contract and token
token = await BasicTokenMock.new(accounts[0], 100);
canReclaimToken = await CanReclaimToken.new();
token = await BasicTokenMock.new(owner, 100, { from: owner });
canReclaimToken = await CanReclaimToken.new({ from: owner });
// Force token into contract
await token.transfer(canReclaimToken.address, 10);
await token.transfer(canReclaimToken.address, 10, { from: owner });
const startBalance = await token.balanceOf(canReclaimToken.address);
assert.equal(startBalance, 10);
});
it('should allow owner to reclaim tokens', async function () {
const ownerStartBalance = await token.balanceOf(accounts[0]);
await canReclaimToken.reclaimToken(token.address);
const ownerFinalBalance = await token.balanceOf(accounts[0]);
const ownerStartBalance = await token.balanceOf(owner);
await canReclaimToken.reclaimToken(token.address, { from: owner });
const ownerFinalBalance = await token.balanceOf(owner);
const finalBalance = await token.balanceOf(canReclaimToken.address);
assert.equal(finalBalance, 0);
assert.equal(ownerFinalBalance - ownerStartBalance, 10);
@ -28,7 +28,7 @@ contract('CanReclaimToken', function (accounts) {
it('should allow only owner to reclaim tokens', async function () {
await expectThrow(
canReclaimToken.reclaimToken(token.address, { from: accounts[1] }),
canReclaimToken.reclaimToken(token.address, { from: anyone })
);
});
});