endprojetnobonus
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import { expect } from "chai"; // pour les assertions
|
||||
import { network } from "hardhat"; // pour les tests
|
||||
/**
|
||||
* 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 () {
|
||||
@@ -10,9 +16,12 @@ describe("FGC42Forge", 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);
|
||||
@@ -27,9 +36,10 @@ describe("FGC42Forge", function () {
|
||||
.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,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user