Skip to main content

Testing

The contracts package tests both the Solidity contracts and the TypeScript deployment scripts. This page shows the layout and the commands to run each, as defined in packages/ats/contracts/package.json.

Test layout​

test/
├── contracts/
│ └── integration/ # Solidity contract tests (run by `npm test`)
├── scripts/
│ ├── unit/ # deployment-script unit tests (no network)
│ └── integration/ # deployment-script integration tests
├── fixtures/ # shared test fixtures (ctx, deploy, tokens)
└── helpers/ # shared test helpers

Running tests​

From the monorepo root (recommended):

npm run ats:contracts:test

From packages/ats/contracts/:

CommandWhat it runs
npm testContract integration tests and all script tests.
npm run test:parallelThe same set, in parallel.
npm run test:contractsAll contract tests via Hardhat.
npm run test:scriptsAll deployment-script tests.
npm run test:scripts:unitScript unit tests only (no network).
npm run test:scripts:integrationScript integration tests only.
npm run test:factoryThe Factory test suite.
npm run test:resolverThe BusinessLogicResolver test suite.
npm run test:coverageContract coverage over test/contracts/integration.

The test:scripts* and coverage commands also have :parallel / :coverage variants — see package.json for the full list.

First run

After building, just run npm test (or npm run ats:contracts:test from the monorepo root) to verify everything passes. The :coverage / :parallel variants are mainly for CI — you don't need them locally.

Testing deployment recovery​

The deployment scripts can inject failures so you can exercise the checkpoint and resume path without a real network error. Failure injection is driven by the CHECKPOINT_TEST_FAIL_AT environment variable and lives in scripts/infrastructure/testing/failureInjection.ts; the resume behaviour is covered by test/scripts/integration/checkpointResumability.test.ts.

TimeTravel facets​

For time-dependent features (scheduled tasks, coupons, maturity), local and test networks can deploy TimeTravel facet variants that let tests advance time. Enable them with USE_TIMETRAVEL=true when deploying to a local/test network. Never use them on testnet or mainnet.