/
BasicToken.js
35 lines (25 loc) · 1.08 KB
/
BasicToken.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const assertJump = require('./helpers/assertJump');
var BasicTokenMock = artifacts.require("./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);
let transfer = 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 {
let transfer = await token.transfer(accounts[1], 101);
} catch(error) {
assertJump(error);
}
});
});