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.
44 lines
1.5 KiB
44 lines
1.5 KiB
7 years ago
|
const assertRevert = require('./helpers/assertRevert');
|
||
8 years ago
|
|
||
7 years ago
|
var BasicTokenMock = artifacts.require('./helpers/BasicTokenMock.sol');
|
||
8 years ago
|
|
||
7 years ago
|
contract('BasicToken', function (accounts) {
|
||
|
it('should return the correct totalSupply after construction', async function () {
|
||
8 years ago
|
let token = await BasicTokenMock.new(accounts[0], 100);
|
||
|
let totalSupply = await token.totalSupply();
|
||
8 years ago
|
|
||
8 years ago
|
assert.equal(totalSupply, 100);
|
||
7 years ago
|
});
|
||
8 years ago
|
|
||
7 years ago
|
it('should return correct balances after transfer', async function () {
|
||
8 years ago
|
let token = await BasicTokenMock.new(accounts[0], 100);
|
||
|
let transfer = await token.transfer(accounts[1], 100);
|
||
8 years ago
|
|
||
8 years ago
|
let firstAccountBalance = await token.balanceOf(accounts[0]);
|
||
|
assert.equal(firstAccountBalance, 0);
|
||
8 years ago
|
|
||
8 years ago
|
let secondAccountBalance = await token.balanceOf(accounts[1]);
|
||
|
assert.equal(secondAccountBalance, 100);
|
||
8 years ago
|
});
|
||
|
|
||
7 years ago
|
it('should throw an error when trying to transfer more than balance', async function () {
|
||
8 years ago
|
let token = await BasicTokenMock.new(accounts[0], 100);
|
||
|
try {
|
||
|
let transfer = await token.transfer(accounts[1], 101);
|
||
8 years ago
|
assert.fail('should have thrown before');
|
||
7 years ago
|
} catch (error) {
|
||
7 years ago
|
assertRevert(error);
|
||
7 years ago
|
}
|
||
8 years ago
|
});
|
||
|
|
||
7 years ago
|
it('should throw an error when trying to transfer to 0x0', async function () {
|
||
8 years ago
|
let token = await BasicTokenMock.new(accounts[0], 100);
|
||
8 years ago
|
try {
|
||
|
let transfer = await token.transfer(0x0, 100);
|
||
|
assert.fail('should have thrown before');
|
||
7 years ago
|
} catch (error) {
|
||
7 years ago
|
assertRevert(error);
|
||
8 years ago
|
}
|
||
8 years ago
|
});
|
||
8 years ago
|
});
|