Tests: expand coverage for oracle, window, limits, and policies #2

Closed
opened 2026-04-20 12:17:58 +00:00 by PlasticDigits · 7 comments
PlasticDigits commented 2026-04-20 12:17:58 +00:00 (Migrated from gitlab.com)

Summary

Increase automated test coverage so invariants and business rules are verified in CI, not only via manual QA.

Current gaps

  • ust1-oracle and ust1-window crates have no in-crate unit tests (integration tests exist only in ust1-integration-tests).
  • Integration test today: single deposit + withdraw round-trip at initial oracle rate; does not cover UpdateRate, throttle, daily cap, pause, governance, or limit failures.
  • ust1-common already has proptest for math/oracle policy; contracts need analogous cw-multi-test scenarios.

Proposed work (checklist)

  • Oracle (ust1-oracle): cw-multi-test — UpdateRate success/failure for monotonicity, 4h throttle, UTC daily +2% cap, pause, unauthorized sender; governance operator rotation + two-step governance.
  • Window (ust1-window): cw-multi-test — per-tx and rolling 24h limit hits; pause; invalid cw20 sender; Withdraw below min_vfdusd_out; insufficient contract vFDUSD balance.
  • Integration: optional combined flows after oracle rate bumps (still within cap).
  • CI: optional nightly or manual job for LocalTerra + deploy smoke (defer if too heavy).

Acceptance criteria

  • New tests reference documented INV-* ids in names or comments where applicable.
  • cargo test passes; no new clippy warnings (-D warnings).
## Summary Increase automated test coverage so invariants and business rules are verified in CI, not only via manual QA. ## Current gaps - `ust1-oracle` and `ust1-window` crates have **no in-crate unit tests** (integration tests exist only in `ust1-integration-tests`). - Integration test today: single **deposit + withdraw** round-trip at initial oracle rate; does not cover `UpdateRate`, throttle, daily cap, pause, governance, or limit failures. - `ust1-common` already has proptest for math/oracle policy; contracts need analogous **cw-multi-test** scenarios. ## Proposed work (checklist) - [ ] **Oracle (`ust1-oracle`)**: cw-multi-test — `UpdateRate` success/failure for monotonicity, 4h throttle, UTC daily +2% cap, pause, unauthorized sender; governance operator rotation + two-step governance. - [ ] **Window (`ust1-window`)**: cw-multi-test — per-tx and rolling 24h limit hits; pause; invalid cw20 sender; `Withdraw` below `min_vfdusd_out`; insufficient contract vFDUSD balance. - [ ] **Integration**: optional combined flows after oracle rate bumps (still within cap). - [ ] **CI**: optional nightly or manual job for LocalTerra + deploy smoke (defer if too heavy). ## Acceptance criteria - New tests reference documented **INV-*** ids in names or comments where applicable. - `cargo test` passes; no new clippy warnings (`-D warnings`).
PlasticDigits commented 2026-04-21 03:50:38 +00:00 (Migrated from gitlab.com)

mentioned in commit e974c5db03

mentioned in commit e974c5db035a591b34b68980a961e0fdf773afc5
PlasticDigits commented 2026-04-21 03:50:45 +00:00 (Migrated from gitlab.com)

Issue #2 implementation (merged to main)

Work for expanded automated coverage was implemented on branch issue/2-test-coverage (git worktree), rebased onto latest main, and merged. Pushed: commit e974c5d.

What was added

  • ust1-oracle: New src/multitest.rs (8 cw-multi-test cases) covering INV-ORACLE-THROTTLE-001, INV-ORACLE-DAILY-001, and INV-ORACLE-MONO-001 via contract paths, plus pause, non-operator UpdateRate, operator rotation, and two-step governance.
  • ust1-window: New src/multitest.rs (6 cases) for INV-LIMIT-001 (per-tx and rolling 24h), pause, invalid CW20 sender, withdraw below min_vfdusd_out, and insufficient contract vFDUSD on withdraw.
  • ust1-integration-tests: deposit_after_oracle_rate_bump_within_daily_cap and oracle_second_update_same_day_respects_throttle for combined oracle + window flows (rebased alongside existing effective_swap_query_matches_oracle_and_window_config from main).

cargo test and cargo clippy --all-targets -- -D warnings pass.


@brouie — could you review and confirm this matches what you want for QA coverage? Leaving this issue open until you sign off.

## Issue #2 implementation (merged to `main`) Work for expanded automated coverage was implemented on branch `issue/2-test-coverage` (git worktree), rebased onto latest `main`, and merged. Pushed: commit `e974c5d`. ### What was added - **`ust1-oracle`**: New `src/multitest.rs` (8 cw-multi-test cases) covering **INV-ORACLE-THROTTLE-001**, **INV-ORACLE-DAILY-001**, and **INV-ORACLE-MONO-001** via contract paths, plus pause, non-operator `UpdateRate`, operator rotation, and two-step governance. - **`ust1-window`**: New `src/multitest.rs` (6 cases) for **INV-LIMIT-001** (per-tx and rolling 24h), pause, invalid CW20 sender, withdraw below `min_vfdusd_out`, and insufficient contract vFDUSD on withdraw. - **`ust1-integration-tests`**: `deposit_after_oracle_rate_bump_within_daily_cap` and `oracle_second_update_same_day_respects_throttle` for combined oracle + window flows (rebased alongside existing `effective_swap_query_matches_oracle_and_window_config` from main). `cargo test` and `cargo clippy --all-targets -- -D warnings` pass. --- @brouie — could you review and confirm this matches what you want for QA coverage? Leaving this issue **open** until you sign off.
Brouie commented 2026-04-21 08:22:53 +00:00 (Migrated from gitlab.com)

mentioned in issue #1

mentioned in issue #1
Brouie commented 2026-04-21 08:26:20 +00:00 (Migrated from gitlab.com)

@PlasticDigits verified on current main — the proposed work in this checklist is already implemented.

Checklist status

Oracle cw-multi-test (contracts/ust1-oracle/src/multitest.rs — 8/8 pass):

  • Monotonicity (success + reject): inv_oracle_mono_update_success_within_cap, inv_oracle_mono_decrease_rejected ✅
  • 4h throttle: inv_oracle_throttle_second_update_too_soon ✅
  • UTC daily +2% cap: inv_oracle_daily_cap_exceeded_same_utc_day ✅
  • Pause: inv_oracle_pause_blocks_operator_update ✅
  • Unauthorized sender: inv_oracle_unauthorized_update_not_operator ✅
  • Governance operator rotation: governance_rotates_oracle_operator ✅
  • Two-step governance: governance_two_step_transfer ✅

Window cw-multi-test (contracts/ust1-window/src/multitest.rs — 6/6 pass):

  • Per-tx limit: inv_limit_001_per_tx_exceeded ✅
  • Rolling 24h limit: inv_limit_001_rolling_24h_exceeded ✅
  • Pause: paused_blocks_cw20_flow ✅
  • Invalid cw20 sender: invalid_cw20_sender_rejected ✅
  • Withdraw below min_vfdusd_out: withdraw_below_min_vfdusd_out_rejected ✅
  • Insufficient contract vFDUSD: withdraw_insufficient_vfdusd_in_window ✅

Integration (tests/src/integration_tests.rs):

  • Combined flow after oracle rate bumps: integration_tests.rs:358 (INV-ORACLE-DAILY-001 + INV-SWAP-001) ✅
  • Post-throttle second update: integration_tests.rs:445 (INV-ORACLE-THROTTLE-001) ✅

CI: nightly/manual LocalTerra deploy smoke — marked "defer if too heavy" in the issue, still deferred.

Acceptance criteria

  • INV-* ids in test names or comments: ✅ every test uses inv_* prefix or tagged INV-LIMIT-001 in module comment
  • cargo test --workspace passes: 28/28, 0 failures (verified today)
  • No new clippy warnings: not re-run this session — recommend one CI run to confirm -D warnings still clean

Single remaining gap (minor)

From the review in #1: INV-SWAP-002 (reverse: UST1 → vFDUSD) is documented in math.rs module comments but has no unit test tagged INV-SWAP-002 specifically. ust1_after_fee_to_vfdusd is exercised via withdraw multitest + prop_fee_never_inverts, but a direct formula-verification test on known vectors (mirror of inv_swap_001_fee_reduces_output) would be tidy. Low priority — adding to this issue's scope rather than filing separately.

Happy for you to either add the INV-SWAP-002 vector test in a trivial MR and close this, or close now with that note parked as "nice to have" followup.

@PlasticDigits verified on current main — the proposed work in this checklist is already implemented. ## Checklist status **Oracle cw-multi-test** (`contracts/ust1-oracle/src/multitest.rs` — 8/8 pass): - Monotonicity (success + reject): `inv_oracle_mono_update_success_within_cap`, `inv_oracle_mono_decrease_rejected` ✅ - 4h throttle: `inv_oracle_throttle_second_update_too_soon` ✅ - UTC daily +2% cap: `inv_oracle_daily_cap_exceeded_same_utc_day` ✅ - Pause: `inv_oracle_pause_blocks_operator_update` ✅ - Unauthorized sender: `inv_oracle_unauthorized_update_not_operator` ✅ - Governance operator rotation: `governance_rotates_oracle_operator` ✅ - Two-step governance: `governance_two_step_transfer` ✅ **Window cw-multi-test** (`contracts/ust1-window/src/multitest.rs` — 6/6 pass): - Per-tx limit: `inv_limit_001_per_tx_exceeded` ✅ - Rolling 24h limit: `inv_limit_001_rolling_24h_exceeded` ✅ - Pause: `paused_blocks_cw20_flow` ✅ - Invalid cw20 sender: `invalid_cw20_sender_rejected` ✅ - Withdraw below min_vfdusd_out: `withdraw_below_min_vfdusd_out_rejected` ✅ - Insufficient contract vFDUSD: `withdraw_insufficient_vfdusd_in_window` ✅ **Integration** (`tests/src/integration_tests.rs`): - Combined flow after oracle rate bumps: `integration_tests.rs:358` (INV-ORACLE-DAILY-001 + INV-SWAP-001) ✅ - Post-throttle second update: `integration_tests.rs:445` (INV-ORACLE-THROTTLE-001) ✅ **CI**: nightly/manual LocalTerra deploy smoke — marked "defer if too heavy" in the issue, still deferred. ## Acceptance criteria - INV-* ids in test names or comments: ✅ every test uses `inv_*` prefix or tagged INV-LIMIT-001 in module comment - `cargo test --workspace` passes: **28/28, 0 failures** (verified today) - No new clippy warnings: not re-run this session — recommend one CI run to confirm `-D warnings` still clean ## Single remaining gap (minor) From the review in #1: **INV-SWAP-002 (reverse: UST1 → vFDUSD)** is documented in `math.rs` module comments but has no unit test tagged INV-SWAP-002 specifically. `ust1_after_fee_to_vfdusd` is exercised via withdraw multitest + `prop_fee_never_inverts`, but a direct formula-verification test on known vectors (mirror of `inv_swap_001_fee_reduces_output`) would be tidy. Low priority — adding to this issue's scope rather than filing separately. Happy for you to either add the INV-SWAP-002 vector test in a trivial MR and close this, or close now with that note parked as "nice to have" followup.
Brouie commented 2026-04-22 03:42:40 +00:00 (Migrated from gitlab.com)

mentioned in issue #18

mentioned in issue #18
Brouie commented 2026-04-22 03:43:03 +00:00 (Migrated from gitlab.com)

@PlasticDigits closing per today's dev review. All original checklist items (oracle cw-multi-test, window cw-multi-test, integration combined flows) are implemented. The INV-SWAP-002 vector test followup is now tracked as #18.

@PlasticDigits closing per today's dev review. All original checklist items (oracle cw-multi-test, window cw-multi-test, integration combined flows) are implemented. The INV-SWAP-002 vector test followup is now tracked as #18.
Brouie (Migrated from gitlab.com) closed this issue 2026-04-22 03:43:05 +00:00
PlasticDigits commented 2026-08-08 06:01:29 +00:00 (Migrated from gitlab.com)

mentioned in issue #27

mentioned in issue #27
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code/ust1-window#2
No description provided.