Skip to content

Feature: Soroban Contract Test Suite And Cargo Test CI Gate #420

Description

@YaronZaki

Labels / Complexity: testing, ci, soroban, rust · Extremely High — 500

Context

The Soroban contracts are effectively untested and CI cannot catch regressions in them. The only #[cfg(test)] module in the workspace is the common crate's proptest suite (quantara/soroban/contracts/common/src/math.rs); vault, looping, liquidation, and rewards (quantara/soroban/contracts/*/src/lib.rs) have no unit tests at all, even though they contain financial logic (vault balances, liquidation discount curves, looping position counters).

The CI workflow .github/workflows/soroban.yml runs cargo fmt, cargo clippy, cargo deny, and cargo build --target wasm32-unknown-unknown --release, but has no cargo test job. A change that breaks a contract's behaviour today passes CI silently. Property-based and fuzz tooling already exists in the repo (proptest in common/Cargo.toml, plus fuzz/ harnesses under looping, vault, and rewards), so the patterns and dependencies are in place and only need to be applied to the contract entry points.

Goal

Give each contract a deterministic unit/property test suite covering its entry points and edge cases, and wire cargo test into the Soroban CI workflow so regressions are caught on every PR.

Scope

1. Vault tests

Cover deposit/withdraw round-trips, insufficient-balance withdrawal, and (once arithmetic is fixed) overflow behaviour, using Env::default() and storage assertions.

2. Looping tests

Cover open_position counter monotonicity, leverage-range validation, and close behaviour once implemented.

3. Liquidation tests

Cover initialize idempotency, start_auction duplicate rejection, the discount curve at start/end/mid, and bid/expire state transitions.

4. Rewards tests

Cover accrue/claim accounting and pending-reset behaviour.

5. CI gate

Add a cargo test job (host target, not wasm) to .github/workflows/soroban.yml, after fmt/clippy and before or alongside build.

Downstream impact

No ABI change. The only CI change is the new cargo test job in .github/workflows/soroban.yml. If tests reveal contract bugs, those fixes may touch entry points, but the test suite itself is additive.

Acceptance criteria

Tests

  • Each of vault, looping, liquidation, and rewards has a #[cfg(test)] suite covering the cases listed above.
  • cd quantara/soroban/contracts && cargo test passes.

CI

  • .github/workflows/soroban.yml runs cargo test on pull requests and fails the check on regression.

Out of scope

Do not add fuzz targets or property-based test infrastructure in this issue (the fuzz harnesses already exist); only deterministic unit tests and the CI gate.

Getting started

Files in scope: quantara/soroban/contracts/{vault,looping,liquidation,rewards}/src/lib.rs, .github/workflows/soroban.yml. Verify with:

cd quantara/soroban/contracts
cargo test
cargo build --target wasm32-unknown-unknown --release

Good first files to read: quantara/soroban/contracts/common/src/math.rs (the existing proptest style), quantara/soroban/contracts/vault/src/lib.rs, .github/workflows/soroban.yml.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignciImported from PRODUCTION_ISSUES.mdrustImported from PRODUCTION_ISSUES.mdsorobanImported from PRODUCTION_ISSUES.mdtesting

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions