35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { expect } from "chai"; // pour les assertions
|
|
import { network } from "hardhat"; // pour les tests
|
|
|
|
const { ethers } = await network.create();
|
|
|
|
const INITIAL_SUPPLY = 1_000_000n * 10n ** 18n;
|
|
|
|
describe("FGC42Forge", function () {
|
|
it("expose le nom, le symbole et la supply fixe au déployeur", async function () {
|
|
const [deployer] = await ethers.getSigners();
|
|
const token = await ethers.deployContract("FGC42Forge");
|
|
|
|
expect(await token.name()).to.equal("FGC42Forge");
|
|
expect(await token.symbol()).to.equal("FG42");
|
|
expect(await token.decimals()).to.equal(18n);
|
|
expect(await token.totalSupply()).to.equal(INITIAL_SUPPLY);
|
|
expect(await token.balanceOf(deployer.address)).to.equal(INITIAL_SUPPLY);
|
|
expect(await token.owner()).to.equal(deployer.address);
|
|
});
|
|
|
|
it("permet un transfer ERC-20 classique", async function () {
|
|
const [deployer, recipient] = await ethers.getSigners();
|
|
const token = await ethers.deployContract("FGC42Forge");
|
|
|
|
const amount = 1_000n * 10n ** 18n;
|
|
await expect(token.transfer(recipient.address, amount))
|
|
.to.emit(token, "Transfer")
|
|
.withArgs(deployer.address, recipient.address, amount);
|
|
|
|
expect(await token.balanceOf(recipient.address)).to.equal(amount);
|
|
expect(await token.balanceOf(deployer.address)).to.equal(
|
|
INITIAL_SUPPLY - amount,
|
|
);
|
|
});
|
|
}); |