Conception du système · AREX-TEST
Testing
Use Node.js 20 or 22 LTS with npm; the committed package lock.json is the source of truth for dependency versions. Newer Node majors may print Hardhat support warnings.
- Identifiant du document
- AREX-TEST
- Version
- 2.0
- Date
- 2026-09-21
- Source
- docs/TESTING.md
| Field | Value |
|---|---|
| Document ID | AREX-TEST |
| Version | 2.0 |
| Date | 2026-09-21 |
| Related | AREX-SDD-001 §12 (traceability matrix), AREX-AUD-001 §7 (coverage matrix) |
Test layers
| Layer | Location | Covers |
|---|---|---|
| Standard / reference | test/standard/ARexToken.test.js | batches, lineage, ERC-7943 enforcement, hook pipeline, conformance, upgrade authorization |
| Standard / hooks | test/standard/DomainHooks.test.js | perishability, seasonal, delivery, traceability, sanctions TTL |
| Standard / extensions | test/standard/Extensions.test.js | price oracle, carbon wrapper, parametric insurance |
| Documentation / guide | test/standard/ImplementationGuide.test.js | every code block of the Implementation Guide and the example hooks in contracts/examples/, executed in order |
| Standard / invariants | test/standard/Invariants.test.js | seeded random operation sequences; supply conservation, terminal status, canTransfer ⇔ outcome, lock |
Commands
npm ci # reproducible install (OpenZeppelin 5.3.0 pinned)
npm test # everything (test/standard)
npx hardhat test test/standard/ARexToken.test.js
AREX_INVARIANT_STEPS=2000 AREX_INVARIANT_SEED=7 npx hardhat test test/standard/Invariants.test.js
npx hardhat run scripts/gas-report-standard.js
npm run docs:check # guide blocks == executed test, examples == compiled contracts, names and paths exist
npm run coverage
Use Node.js 20 or 22 LTS with npm; the committed package-lock.json is the source of truth for dependency versions. Newer Node majors may print Hardhat support warnings.
Determinism rules
- Tests that advance chain time restore a snapshot in
after()so they do not leak into other files (takeSnapshot/restore). - No test depends on wall-clock time:
CommodityPriceOraclenumbers its rounds instead of bucketingblock.timestamp, and the seasonal tests set the block time explicitly. - The invariant test is seeded (
AREX_INVARIANT_SEED); a failure is reproducible with the same seed and step count.
What tests establish
Repeatable evidence of implemented behaviour in the Hardhat environment. They do not establish absence of vulnerabilities, regulatory compliance, correctness of off-chain data, economic safety, production gas viability across chains, or storage compatibility of future upgrades beyond the OpenZeppelin plugin validation.
Before production
- Third-party audit (package:
AUDIT-READINESS.md). - Fork tests on every target chain.
- Worst-case batch gas benchmarks with the production hook set.
- Upgrade rehearsal against a mainnet fork with the plugin's
validateUpgrade.