fix tests

This commit is contained in:
Ricardo Guilherme Schmidt 2018-05-13 17:54:05 -03:00
parent b2c07c63f7
commit eab0c133d1

View File

@ -1,34 +1,34 @@
describe("TestToken", function() { describe("TestToken", async function() {
this.timeout(0); this.timeout(0);
var accountsArr; var accountsArr;
before(function(done) { before(function(done) {
this.timeout(0); this.timeout(0);
var contractsConfig = { var contractsConfig = {
"TestToken": { "TestToken": {
} }
}; };
EmbarkSpec.deployAll(contractsConfig, (accounts) => { accountsArr = accounts; done() }); EmbarkSpec.deployAll(contractsConfig, async function(accounts) {
accountsArr = accounts
for(i=0;i<accountsArr.length;i++) {
await TestToken.methods.mint(7 * 10 ^ 18).send({from: accountsArr[i]})
}
done()
}); });
it("should start totalSupply 0", async function() {
let result = await TestToken.methods.totalSupply().call();
assert.equal(result, 0);
}); });
it("should increase totalSupply in mint", async function() { it("should increase totalSupply in mint", async function() {
let initialSupply = await TestToken.methods.balanceOf(accountsArr[0]).call(); let initialSupply = await TestToken.methods.totalSupply().call();
await TestToken.methods.mint(100).send({from: accountsArr[0]}); await TestToken.methods.mint(100).send({from: accountsArr[0]});
let result = await TestToken.methods.totalSupply().call(); let result = await TestToken.methods.totalSupply().call();
assert.equal(result, 100); assert.equal(result, +initialSupply+100);
}); });
it("should increase accountBalance in mint", async function() { it("should increase accountBalance in mint", async function() {
let initialBalance = await TestToken.methods.balanceOf(accountsArr[0]).call(); let initialBalance = await TestToken.methods.balanceOf(accountsArr[0]).call();
await TestToken.methods.mint(100).send({from: accountsArr[0]}); await TestToken.methods.mint(100).send({from: accountsArr[0]});
let result = await TestToken.methods.totalSupply().call(); let result = await TestToken.methods.balanceOf(accountsArr[0]).call();
assert.equal(result, +initialBalance+100); assert.equal(result, +initialBalance+100);
}); });
}); });