Skip to content

test(stablecoin): add stateful user journey coverage - #367

Open
3esmit wants to merge 7 commits into
feat/stablecoin-module-permissionless-pokesfrom
feat/stablecoin-module-user-journeys
Open

3esmit wants to merge 7 commits into
feat/stablecoin-module-permissionless-pokesfrom
feat/stablecoin-module-user-journeys

Conversation

@3esmit

@3esmit 3esmit commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Problem

The stablecoin module stack exposes global-state reads, redemption-rate quotes, and permissionless refresh plans. Existing tests cover individual API mappings, but do not exercise the account state transitions a user or keeper sees across several calls.

This PR adds stateful user-history coverage. Each journey keeps protocol parameters, the stability-fee accumulator, redemption-price state, oracle data, and clock data in memory. It builds a transaction plan through the public FFI API, decodes the serialized instruction, executes the native stablecoin handler, and feeds the post-state into the next read.

Journeys

  • Startup with missing global accounts, followed by initialized decoders, projections, and a ready quote.
  • Fee projection followed by accumulator-only persistence and a same-time no-op repeat.
  • Successive controller quotes and updates, including persisted controller state and equivalence between combined refresh and standalone operations.
  • Recovery from stale-oracle, zero-price, and too-soon blockers through fee-only refreshes, repair, and retry, including exact boundary checks.
  • Rechecking a previously ready quote after another keeper changes state and the oracle becomes stale, then completing a fresh retry.
  • Recovery from malformed callers, missing accounts, wrong owners, and malformed account bytes without mutating state, followed by a valid execution.
  • Long idle periods across the compounding clamp, refresh after idle, and exact u128/i128 boundary serialization.

Implementation

  • Added modules/stablecoin/ffi/src/api/journeys.rs with seven end-to-end user-history tests at the FFI/native-program seam.
  • Added the native stablecoin program as a test-only dependency of stablecoin_ffi.
  • Added an optional C++ module journey target linked to the production stablecoin_ffi library; the existing mock-based module suite remains unchanged.
  • The production-FFI journey drives real module reads, projections, quotes, serialized submissions, and rereads through the account store.
  • Preserved one commit per journey:
    • 078f5b6c startup global-state journey
    • 31406961 fee accrual journey
    • 3c836760 controller update journey
    • 8c74fed5 blocked update recovery
    • 2a5a784f stale quote retry
    • 2bccf9b2 account recovery journey
    • 39ccef34 long idle journey

Stacked on #340, following #339, #338, #333, and #332.

Validation

  • RISC0_DEV_MODE=1 cargo +1.94.0 test --workspace --exclude integration_tests
  • RISC0_DEV_MODE=1 cargo +1.94.0 test -p integration_tests
  • RISC0_DEV_MODE=1 cargo +1.94.0 test -p stablecoin_ffi
  • RISC0_DEV_MODE=1 cargo +1.94.0 test -p stablecoin_program
  • RISC0_SKIP_BUILD=1 cargo +1.94.0 clippy --workspace --all-targets -- -D warnings
  • cargo +nightly fmt --all -- --check
  • taplo fmt --check .
  • Tracked guest IDL regeneration and diff
  • nix build path:.#stablecoin-module-tests --no-link -L
  • nix build path:.#stablecoin-module --no-link -L

Copilot AI lite review requested due to automatic review settings September 14, 2026 14:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@3esmit
3esmit added this pull request to stack #337 September 14, 2026 14:16
@3esmit
3esmit force-pushed the feat/stablecoin-module-user-journeys branch 2 times, most recently from c0ede1f to c3ee697 Compare September 14, 2026 14:36
@3esmit
3esmit force-pushed the feat/stablecoin-module-user-journeys branch from c3ee697 to 39ccef3 Compare September 14, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants