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:
| Component | Framework / Runner | Test Count | Pass Rate |
|---|---|---|---|
slasettle-vault Contracts | cargo test --workspace | 72 passed | 100% |
@slasettle/sdk Library | Vitest | 89 passed | 100% |
apps/web Operations Console | Vitest + React Testing Library | 277 passed | 100% |
indexer Service | Node Test Runner (node --test) | 69 passed | 100% |
watcher Daemon | Go testing Package | 88 passed | 100% |
| Total Automated Tests | 595 passed | 100% |
Running Test Suites Locally
1. Smart Contracts (slasettle-vault)
cd slasettle-vault
cargo test --workspaceCovers: Contract state machines, authorization boundaries, error propagation, duplicate vote rejections, quorum calculation, edge-case arithmetic, and SAC token escrow.
2. TypeScript SDK (packages/sdk)
pnpm --filter @slasettle/sdk testCovers: 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)
pnpm --filter @slasettle/web testCovers: 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)
cd indexer
npm testCovers: Real SQLite/D1 event persistence, chronological event processing, cursor-based pagination, REST endpoint routing, and CORS header enforcement.
5. Watcher Daemon (watcher)
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:
- Zero Quorum Rejection (
create_sla):create_slaenforces0 < quorum_threshold <= watcher_count. Becausevotes_down < quorum_thresholdis evaluated with unsigned integers, a threshold of 0 would allow settlement with zero votes. Invalid values returnError::InvalidQuorum(code 11); the Vault tests cover the bounds.
- Zero-Balance Withdrawal Rejection (
withdraw_remaining_bond):- Repeated calls to withdraw on an emptied bond return
Error::InvalidAmountrather than wasting transaction fees and emitting empty events. Covered insla_vaulttests.
- Repeated calls to withdraw on an emptied bond return
- Indexer Chronological Event Processing:
indexertests verify that batch events containingregister_watcher,remove_watcher, and re-registration apply strictly in chronological order rather than grouping by event type.
- Cross-Deployment SLA-ID Collision (
indexer/src/db/cutover-collision.test.ts):slas.sla_idis the sole primary key, with no column distinguishing which contract deployment an SLA belongs to. Since every freshly initializedsla_vaultstartsNextSlaIdat 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). Seeapps/docs/developers/v0.2-cutover.md.
- Watcher
i128/vecScVal Decoding (watcher/internal/contract/contract_internal_test.go):- The watcher's generic Soroban value decoder had no case for
i128(used bySLAConfig.bond_amount/penalty_per_breach) orvec(used bySLAStatus's unit-enum encoding), so every liveget_slaread 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 negativei128value.
- The watcher's generic Soroban value decoder had no case for
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.1release builds: registrye433b7e36580889b1a2aa94570ed7adee7e9048d4d211a10031ffcfa8fc53171, vault23ea6cdc28a11883fd5979c06fcdea3b3f68a5b2aa9f0bace855de0149d8ac79. - 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.