Skip to content

Contract test coverage

Contract behavior is checked at two levels:

  • native Sway tests cover deterministic arithmetic and boundary helpers;
  • test/integration/ contains isolated, named per-contract suites plus a cross-contract end-to-end suite. Together they deploy all six production contracts and a test-only legacy-bid storage fixture to local Fuel nodes and check calls, storage, balances, ownership, time, proxy forwarding, oracle failures, and exact revert reasons.

test/contract-coverage.test.ts is the drift guard. It fails when an implemented contract method is not invoked by the local-node suites or when a new named guard lacks an exact negative assertion. The current suite has 17 native Sway tests and 4 coverage-drift checks, while the integration assertion count is reported directly by Bun.

Inventory

ContractImplemented methodsrequire statementsCovered scenarios
Vault2433Lifecycle, oracle, accounting and admin paths
Bond Market V22553Asks, buy orders, filters, fees and proxy paths
Legacy Bond Market1216Listings, purchases, fees and admin paths
Owned Proxy68Ownership, target validation and upgrades
Test Assets/SRC-2093Metadata, supply, faucet and owner minting
Mock Simplified Oracle30Empty, set, read and clear states
Total79113

Every reachable named rejection is asserted by its exact reason. Failed calls are followed by state or balance checks where state could otherwise have changed, including position counts, NFT ownership, buy-order budget, strategy liabilities, fees, and lifecycle status.

Invariant-only and compatibility guards

The following guards cannot be reached from a fresh deployment without breaking an asset-supply invariant or introducing a purpose-built reentrant contract. They remain checked by source drift and are not represented as a normal user transaction:

  • Vault REENTRANCY: requires a malicious configured oracle callback; the production oracle ID is immutable.
  • Legacy and V2 ALREADY_LISTED: the only position NFT is already escrowed, so a caller cannot supply the second required NFT.
  • V2 create_bid checks after POSITION_BIDS_DISABLED, including its paused and USDC checks, are unreachable because the unconditional disable guard runs first. Legacy bid cancellation, acceptance, expiration, authorization, timing, NFT validation, self-trade rejection, refunds, and settlement are tested by seeding pre-upgrade proxy storage with the test-only implementation.
  • V2 bid CANCEL_ASK_FIRST: an ask already escrows the sole NFT needed to call accept_bid.
  • V2 buy-order CANCEL_ASK_FIRST and POSITION_NOT_ACTIVE: an ask or inactive Vault position no longer leaves the seller with the sole active position NFT required by fill_buy_order.
  • V2 REENTRANCY: requires a purpose-built malicious Vault callback; the production Vault ID is immutable.

These are intentionally listed rather than mislabeled as exercised. The method-level manifest in test/contract-guard-coverage.json distinguishes each exercised guard from each invariant-only guard and fails CI on source drift.

Commands

Use the Fuel toolchain compatible with fuels@0.101.1 (forc 0.68.1 and fuel-core 0.43.1):

bash
bun run contracts:test
bun run test:integration
bun test
bun run typecheck

Managed custody · Testnet preview · Audit pending