2018-09-04 21:19:27 +00:00
|
|
|
const Utils = require('../utils/testUtils');
|
|
|
|
const TestToken = require('Embark/contracts/TestToken');
|
|
|
|
const ERC20TokenSpec = require('./abstract/erc20tokenspec');
|
2018-05-19 20:00:16 +00:00
|
|
|
|
2018-09-04 21:19:27 +00:00
|
|
|
config({
|
|
|
|
contracts: {
|
|
|
|
"TestToken": {
|
|
|
|
},
|
|
|
|
...ERC20TokenSpec.config.contracts
|
|
|
|
}
|
|
|
|
});
|
2018-05-13 20:54:05 +00:00
|
|
|
|
2018-09-04 21:19:27 +00:00
|
|
|
contract("TestToken", function() {
|
|
|
|
this.timeout(0);
|
|
|
|
var accounts;
|
2018-05-13 00:16:18 +00:00
|
|
|
before(function(done) {
|
2018-09-04 21:19:27 +00:00
|
|
|
web3.eth.getAccounts().then(function (res) {
|
|
|
|
accounts = res;
|
|
|
|
done();
|
2018-05-13 20:54:05 +00:00
|
|
|
});
|
2018-05-13 00:16:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should increase totalSupply in mint", async function() {
|
2018-05-13 20:54:05 +00:00
|
|
|
let initialSupply = await TestToken.methods.totalSupply().call();
|
2018-09-04 21:19:27 +00:00
|
|
|
await TestToken.methods.mint(100).send();
|
2018-05-13 00:16:18 +00:00
|
|
|
let result = await TestToken.methods.totalSupply().call();
|
2018-05-13 20:54:05 +00:00
|
|
|
assert.equal(result, +initialSupply+100);
|
2018-05-13 00:16:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should increase accountBalance in mint", async function() {
|
2018-09-04 21:19:27 +00:00
|
|
|
let initialBalance = await TestToken.methods.balanceOf(accounts[0]).call();
|
|
|
|
await TestToken.methods.mint(100).send({from: accounts[0]});
|
|
|
|
let result = await TestToken.methods.balanceOf(accounts[0]).call();
|
2018-05-13 00:16:18 +00:00
|
|
|
assert.equal(result, +initialBalance+100);
|
|
|
|
});
|
2018-09-04 21:19:27 +00:00
|
|
|
|
|
|
|
it("should burn account supply", async function() {
|
|
|
|
let initialBalance = await TestToken.methods.balanceOf(accounts[0]).call();
|
|
|
|
await TestToken.methods.transfer(Utils.zeroAddress, initialBalance).send({from: accounts[0]});
|
|
|
|
assert.equal(await TestToken.methods.totalSupply().call(), 0);
|
|
|
|
assert.equal(await TestToken.methods.balanceOf(accounts[0]).call(), 0);
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should mint balances for ERC20TokenSpec", async function() {
|
|
|
|
let initialBalance = 7 * 10 ^ 18;
|
2018-05-19 20:00:16 +00:00
|
|
|
for(i=0;i<accounts.length;i++){
|
2018-09-04 21:19:27 +00:00
|
|
|
await TestToken.methods.mint(initialBalance).send({from: accounts[i]})
|
|
|
|
assert.equal(await TestToken.methods.balanceOf(accounts[i]).call(), initialBalance);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
ERC20TokenSpec.Test(TestToken);
|
|
|
|
|
|
|
|
|
2018-05-13 00:16:18 +00:00
|
|
|
});
|