Skip to content

Commit

Permalink
testcase mint new token
Browse files Browse the repository at this point in the history
  • Loading branch information
quangdangfit committed Apr 16, 2021
1 parent 9cb3af0 commit cf62535
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions test/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,27 @@ contract("Token", (accounts) => {
}));
})

it('only owner can mint token', async () => {
let i = {
mint_account: account1,
amount: web3.utils.toWei("10"),
}

await u.assertRevert(token.mint(i.amount, {
from: i.mint_account
}));
})

it('burn token', async () => {
let i = {
burnt_account: account1,
owner: root,
amount: web3.utils.toWei("10"),
}

await u.assertRevert(token.burn(i.burnt_account, i.amount, {
await token.burn(i.burnt_account, i.amount, {
from: i.owner
}));
});

let o = {
total_supply: 1999999990 * (10 ** 18),
Expand All @@ -145,5 +156,34 @@ contract("Token", (accounts) => {
eq(o.total_supply, parseInt(total_supply));
eq(o.burnt_balance, parseInt(burnt_balance));
})

it('mint token', async () => {
let i = {
owner: root,
amount: web3.utils.toWei("10"),
}

await token.mint(i.amount, {
from: i.owner
});

let o = {
total_supply: 2000000000 * (10 ** 18),
owner_balance: 2000000000 * (10 ** 18),
}

let owner_balance = await token.balanceOf(i.owner, {
from: root
});

let total_supply = await token.totalSupply({
from: root
});


eq(o.total_supply, parseInt(total_supply));
eq(o.owner_balance, parseInt(owner_balance));
})

})
})

0 comments on commit cf62535

Please sign in to comment.