test(funding): saga idempotency/retry/resume coverage (closes #84 gap)#86
Merged
Conversation
Add pg-backed tests (#[sqlx::test], #[ignore]) for FundingService driving StubExchange — closes the test gap from #84 before FUNDING_ENABLED can be flipped: - happy_path: quote→execute→REFRESHED, futures balance + capital updated, spot_order_call_count == 1, transfer_call_count == 1. - idempotent_convert_no_double_execute: re-running execute on a terminal saga does not re-place orders/transfers (counts unchanged). - resume_after_crash_post_converted: transfer failure leaves saga mid-flight; re-execute reaches REFRESHED without re-converting. - expired_quote_rejected (ttl=0) and dust_skipped. Gated by cfg(all(test, feature = "postgres")) so the no-postgres CI build is unaffected. Verified locally: 5 passed against Postgres 16. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
948d510 to
29d0092
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the test gap flagged in #84: the funding saga's idempotency / retry / resume behavior is now covered. This is the agreed blocker before
FUNDING_ENABLEDcan be flipped on.Tests (
robsond/src/funding/tests.rs)pg-backed, using
#[sqlx::test(migrations = "../migrations")]+#[ignore = "Requires DATABASE_URL"](the repo's existing pattern), driving the realFundingServiceagainstStubExchange:happy_pathREFRESHED; futures balance + engine capital updated;spot_order_call_count == 1,transfer_call_count == 1idempotent_convert_no_double_executeexecuteon a terminal saga does not re-place spot orders or re-transfer (counts unchanged)resume_after_crash_post_convertedexecute(worker resume) reachesREFRESHEDwithout re-convertingexpired_quote_rejectedquote_ttl_secs = 0→ execute fails/FAILED, no spot order placeddust_skippeddust_usdtbalance excluded from quote + conversionsGating & CI
The module is
#[cfg(all(test, feature = "postgres"))], so the no-postgres CI test build is unaffected (these are#[ignore]and don't run in CI — same as the existing pg tests indaemon.rs/robson-store).Verification (run by me, not the executor)
Against an ephemeral Postgres 16:
Diff is test-only (
funding/tests.rs+332,funding/mod.rs+3);stub.rsunchanged (the*_call_countgetters already exist on main).🤖 Generated with Claude Code