Skip to main contentA-REX Core

تصميم النظام · 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.

معرّف المستند
AREX-TEST
الإصدار
2.0
التاريخ
2026-09-21
المصدر
docs/TESTING.md
متوفر بالإنجليزية فقط
يُنشر هذا المستند بالإنجليزية. فصول الورقة البيضاء والمخططات مترجمة؛ أما المواصفة المعيارية وأدلة تصميم النظام وسجلات القرارات فتبقى بالإنجليزية ليكون هناك نص مرجعي واحد.
FieldValue
Document IDAREX-TEST
Version2.0
Date2026-09-21
RelatedAREX-SDD-001 §12 (traceability matrix), AREX-AUD-001 §7 (coverage matrix)

Test layers

LayerLocationCovers
Standard / referencetest/standard/ARexToken.test.jsbatches, lineage, ERC-7943 enforcement, hook pipeline, conformance, upgrade authorization
Standard / hookstest/standard/DomainHooks.test.jsperishability, seasonal, delivery, traceability, sanctions TTL
Standard / extensionstest/standard/Extensions.test.jsprice oracle, carbon wrapper, parametric insurance
Documentation / guidetest/standard/ImplementationGuide.test.jsevery code block of the Implementation Guide and the example hooks in contracts/examples/, executed in order
Standard / invariantstest/standard/Invariants.test.jsseeded 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: CommodityPriceOracle numbers its rounds instead of bucketing block.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.