becrypto/test/coin.test.js
2023-11-28 11:14:31 +08:00

41 lines
1.1 KiB
JavaScript

const { expect } = require("chai");
const {
BN,
constants,
expectEvent,
expectRevert,
} = require("@openzeppelin/test-helpers");
const BECoin = artifacts.require("tokens/erc20/FT");
contract("BECoin", ([owner, other]) => {
const amount = new BN(10000);
beforeEach(async () => {
this.coin = await BECoin.new('CEG', 'CEG', 0);
await this.coin.mint(owner, amount);
});
it("reverts when transferring tokens to the zero address", async () => {
// Conditions that trigger a require statement can be precisely tested
await expectRevert(
this.coin.transfer(constants.ZERO_ADDRESS, amount),
"ERC20: transfer to the zero address"
);
});
it("should emit Transfer event", async () => {
const receipt = await this.coin.transfer(other, amount);
expectEvent(receipt, "Transfer", {
from: owner,
to: other,
value: amount,
});
});
it("should send coin correctly", async () => {
await this.coin.transfer(other, amount);
expect(await this.coin.balanceOf(other)).to.be.bignumber.equal(amount);
});
});