Skip to content

Testing & Verification ​

SLASettle maintains automated test suites across every layer of the architecture, spanning Rust smart contracts, TypeScript SDK, Next.js web application, Cloudflare Workers indexer, and Go watcher daemon.

Automated Test Coverage Summary ​

Across both repositories, 595 automated tests pass with zero failures:

ComponentFramework / RunnerTest CountPass Rate
slasettle-vault Contractscargo test --workspace72 passed100%
@slasettle/sdk LibraryVitest89 passed100%
apps/web Operations ConsoleVitest + React Testing Library277 passed100%
indexer ServiceNode Test Runner (node --test)69 passed100%
watcher DaemonGo testing Package88 passed100%
Total Automated Tests595 passed100%

Running Test Suites Locally ​

1. Smart Contracts (slasettle-vault) ​

bash
cd slasettle-vault
cargo test --workspace

Covers: Contract state machines, authorization boundaries, error propagation, duplicate vote rejections, quorum calculation, edge-case arithmetic, and SAC token escrow.

2. TypeScript SDK (packages/sdk) ​

bash
pnpm --filter @slasettle/sdk test

Covers: Missing and invalid environment configuration, transaction envelope building for all 5 write operations, response shape parsing, BigInt conversions, and simulation mocks.

3. Web Console (apps/web) ​

bash
pnpm --filter @slasettle/web test

Covers: Wallet connection state, network mismatch gating, SLA creation validation, top-up modal flows, confirmation dialogs, quorum progress meters, and transaction status banners across 26 test files.

4. Event Indexer (indexer) ​

bash
cd indexer
npm test

Covers: Real SQLite/D1 event persistence, chronological event processing, cursor-based pagination, REST endpoint routing, and CORS header enforcement.

5. Watcher Daemon (watcher) ​

bash
cd watcher
go test -v ./...

Covers: HTTP probing timeouts, status code evaluators, local scheduling/pacing, endpoint commitment hashing and validation, bounded network retry, duplicate check bypass, and contract RPC interaction wrappers (including GetCurrentRound and GetSlaEndpointHash).


Key Historical Regression Tests ​

The test suite explicitly encodes regressions discovered during engineering:

  1. Zero Quorum Rejection (create_sla):
    • create_sla enforces 0 < quorum_threshold <= watcher_count. Because votes_down < quorum_threshold is evaluated with unsigned integers, a threshold of 0 would allow settlement with zero votes. Invalid values return Error::InvalidQuorum (code 11); the Vault tests cover the bounds.
  2. Zero-Balance Withdrawal Rejection (withdraw_remaining_bond):
    • Repeated calls to withdraw on an emptied bond return Error::InvalidAmount rather than wasting transaction fees and emitting empty events. Covered in sla_vault tests.
  3. Indexer Chronological Event Processing:
    • indexer tests verify that batch events containing register_watcher, remove_watcher, and re-registration apply strictly in chronological order rather than grouping by event type.
  4. Cross-Deployment SLA-ID Collision (indexer/src/db/cutover-collision.test.ts):
    • slas.sla_id is the sole primary key, with no column distinguishing which contract deployment an SLA belongs to. Since every freshly initialized sla_vault starts NextSlaId at 0, these tests prove that reusing one D1 across a v0.1/v0.2 cutover silently drops the newer deployment's SLA row and mixes both deployments' checks under the same (sla_id, round_id). See apps/docs/developers/v0.2-cutover.md.
  5. Watcher i128/vec ScVal Decoding (watcher/internal/contract/contract_internal_test.go):
    • The watcher's generic Soroban value decoder had no case for i128 (used by SLAConfig.bond_amount/penalty_per_breach) or vec (used by SLAStatus's unit-enum encoding), so every live get_sla read failed outright. Found live against the deployed GREEN v0.2 contracts during lifecycle testing; fixed and covered with regression tests against real encoded ScVals, including a negative i128 value.

Live Stellar Testnet Verification ​

In addition to local unit and integration tests:

  • Protocol 29 v0.2 WASM Parity: Contract WASM bytecode deployed to Testnet matches the soroban-sdk 29.0.1 release builds: registry e433b7e36580889b1a2aa94570ed7adee7e9048d4d211a10031ffcfa8fc53171, vault 23ea6cdc28a11883fd5979c06fcdea3b3f68a5b2aa9f0bace855de0149d8ac79.
  • Freighter Browser Verification: The v0.2 lifecycle was executed and confirmed on Testnet using Freighter on GREEN SLA #0.
  • Permissionless Settlement: Real on-chain settlements have been executed where external keeper accounts triggered penalty payments directly to beneficiaries upon quorum formation.