Files
tokenizer/tokenizerRendu/code/test/FGC42Forge.ts
2026-10-20 15:09:41 +02:00

46 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Tests d’intégration Hardhat 3 (chaîne simulée locale) pour le contrat FGC42Forge.
* Complète la revue de code : vérifie le comportement BEP-20 attendu avant / après deploy testnet.
*/
import { expect } from "chai";
import { network } from "hardhat";
// Connexion réseau Hardhat 3 (équivalent Ethers pour deploy et appels de contrat).
const { ethers } = await network.create();
// Supply attendue : 1 million de jetons avec 18 décimales (unités minimales on-chain).
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");
// Métadonnées imposées par le constructeur Solidity.
expect(await token.name()).to.equal("FGC42Forge");
expect(await token.symbol()).to.equal("FG42");
expect(await token.decimals()).to.equal(18n);
// Toute la supply doit exister et être détenue par le compte qui a déployé.
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);
// Conservation de la masse monétaire : totalSupply inchangé, soldes déplacés.
expect(await token.balanceOf(recipient.address)).to.equal(amount);
expect(await token.balanceOf(deployer.address)).to.equal(
INITIAL_SUPPLY - amount,
);
});
});