You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
const assertRevert = require('./helpers/assertRevert');
|
|
|
|
var BasicTokenMock = artifacts.require('./mocks/BasicTokenMock.sol');
|
|
|
|
contract('BasicToken', function (accounts) {
|
|
it('should return the correct totalSupply after construction', async function () {
|
|
let token = await BasicTokenMock.new(accounts[0], 100);
|
|
let totalSupply = await token.totalSupply();
|
|
|
|
assert.equal(totalSupply, 100);
|
|
});
|
|
|
|
it('should return correct balances after transfer', async function () {
|
|
let token = await BasicTokenMock.new(accounts[0], 100);
|
|
await token.transfer(accounts[1], 100);
|
|
|
|
let firstAccountBalance = await token.balanceOf(accounts[0]);
|
|
assert.equal(firstAccountBalance, 0);
|
|
|
|
let secondAccountBalance = await token.balanceOf(accounts[1]);
|
|
assert.equal(secondAccountBalance, 100);
|
|
});
|
|
|
|
it('should throw an error when trying to transfer more than balance', async function () {
|
|
let token = await BasicTokenMock.new(accounts[0], 100);
|
|
try {
|
|
await token.transfer(accounts[1], 101);
|
|
assert.fail('should have thrown before');
|
|
} catch (error) {
|
|
assertRevert(error);
|
|
}
|
|
});
|
|
|
|
it('should throw an error when trying to transfer to 0x0', async function () {
|
|
let token = await BasicTokenMock.new(accounts[0], 100);
|
|
try {
|
|
await token.transfer(0x0, 100);
|
|
assert.fail('should have thrown before');
|
|
} catch (error) {
|
|
assertRevert(error);
|
|
}
|
|
});
|
|
});
|
|
|