feat(uxf): swap-roundtrip soak + demo playbook (#437) - #439
Merged
Conversation
Add the SWAP analog of the existing transfer / accounting / recovery trios: - manual-test-swap-roundtrip.sh — soak script asserting the propose → accept → deposit → completed flow on real testnet. Scenario A is the happy-path 50 UCT for 5 ETH atomic swap with integer-only smallest-unit net-delta assertions on all four legs (alice -50 UCT +5 ETH, bob +50 UCT -5 ETH) plus a poison-pill scan across every step log. Asymmetric faucet (alice 100 UCT only, bob 100 ETH only) is deliberate — there's no fallback liquidity that could mask a UCT/ETH cross-talk bug. Scenario B exercises `sphere swap reject --reason` (acceptor declines, both sides observe cancelled, no balance change). Scenario C exercises pre-announce `sphere swap cancel` (proposer rescinds; deposits_returned is false because the local-only branch was taken — the JSON output's cleanest signal that no escrow round-trip happened). Soak is parametrized by `SCENARIO=A|AB|ABC` (default AB) and `ESCROW=` (default `@escrow-testnet`); shares the same `KEEP=1` / `SWAP_TEST_DIR=` / `SUFFIX=` env contract as the other soaks. - docs/DEMO-PLAYBOOK-SWAP-ROUNDTRIP.md — presenter-friendly companion walking the same flow live in front of an audience (~20 min for A+B, ~14 min for A alone). Sections mirror the soak with talk tracks at each step, an at-a-glance table, an exit-code contract reference for `swap wait`, a 9-row failure-mode table, and a command quick-reference + presenter cheat sheet. Both artifacts depend on sphere-cli's swap-reject/swap-cancel/swap-wait commands shipped under sphere-sdk#437 — the playbook §0 documents the dependency check.
Pre-merge code-review findings on the soak + playbook:
- Soak Scenarios B and C's assert_grep patterns target the human
renderer's `key : value` form (unquoted), but the calls passed
`--json`, which produces double-quoted JSON keys instead. The
patterns never matched and both scenarios would always assert FAIL.
Drop `--json` from the swap-reject + swap-cancel calls — the soak
only needs presence checks, and the human renderer is what the
patterns are written against.
- Reversed stderr redirect on 7 sync calls (`2>&1 > file` instead of
`> file 2>&1`): the former duplicates stderr to the terminal then
redirects stdout to the file, so sync errors silently disappear.
Fix all seven (the two log-capturing ones at §4 and §6 plus the
five `>/dev/null` sites in Scenarios B and C).
- Add §2.5 escrow liveness pre-flight (`sphere swap ping $ESCROW`)
so an unreachable escrow surfaces as a clear "escrow not online"
message rather than the misleading "couldn't extract swap_id"
cascade at §3. Mirrors the pattern in
manual-test-accounting-roundtrip.sh.
- Add a load-bearing comment in §7 documenting the pipefail +
subshell + tee exit-code contract — easy to break under future
edits if the reader doesn't know why it works.
- Playbook §4 and §9 polling loops used `${SWAP:0:16}` against
`sphere swap list` output, but the list table only renders the
first 8 hex chars. The pattern would never match and presenters
following the playbook would loop the full 60s before the
proposal "appears". Same fix the soak already had.
Soak `bash -n` passes; 127/127 unit tests still green.
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.
Summary
Ships the SWAP analog of the existing transfer / accounting / recovery soak trios. Two artifacts:
manual-test-swap-roundtrip.sh— soak script asserting the full propose → accept → deposit → completed flow on real testnet.alice -50 UCT +5 ETH,bob +50 UCT -5 ETH) + poison-pill scan across every step log. Asymmetric faucet (alice 100 UCT only, bob 100 ETH only) is deliberate — no fallback liquidity that could mask a UCT/ETH cross-talk bug.sphere swap reject --reason "…". Both sides observecancelled+ verified no balance change.sphere swap cancelbefore counterparty accepts. Pre-announce branch —deposits_returned: falsein the JSON output is the cleanest signal that no escrow round-trip happened.SCENARIO=A|AB|ABC(defaultAB) andESCROW=(default@escrow-testnet); shares the sameKEEP=1/SWAP_TEST_DIR=/SUFFIX=env contract as the other soaks.docs/DEMO-PLAYBOOK-SWAP-ROUNDTRIP.md— presenter-friendly companion walking the same flow live in front of an audience (~20 min for A+B, ~14 min for A alone). Sections mirror the soak with talk tracks at each step, an at-a-glance table, an exit-code contract reference forswap wait, a 9-row failure-mode table, a command quick-reference + presenter cheat sheet.Dependency
Both artifacts depend on the three new CLI commands shipped by sphere-cli PR #44: `swap reject --reason`, `swap cancel --timeout` (state-aware), `swap wait`. The playbook's §0 dependency check documents how to confirm the running binary has them.
Test plan
Out of scope (per issue #437 §6)
Closes (the soak + playbook half of) #437.