Skip to content

Commit 9640e3b

Browse files
committed
cmd/loop: add session recording guide
1 parent c300918 commit 9640e3b

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Session Recording Notes (Loop CLI)
2+
3+
## How to record sessions
4+
- Use the local CLI binary: `/home/user/bin/loop`.
5+
- Always include `--network regtest` **after** the main command and subcommands so it does not become part of the session filename.
6+
- Record with `LOOP_SESSION_RECORD=true`, e.g.:
7+
- `LOOP_SESSION_RECORD=true /home/user/bin/loop quote out --network regtest 500000`
8+
- After recording several related commands, group the resulting JSON files into a subdir under `cmd/loop/testdata/sessions/`.
9+
10+
## Control panel HTTP server (regtest helpers)
11+
Base URL: `http://127.0.0.1:12345`
12+
- Implementation: [httpcmd](https://github.com/starius/httpcmd/)
13+
- Config: [control panel config](https://gist.github.com/starius/6604ffe27f51d55f4cf715b4202637dd)
14+
- `/mine`:
15+
- Mines a block. Returns JSON with `exit_code`, `stdout`, `stderr`, `duration`, `timed_out`.
16+
- `/deposit`:
17+
- Sends a deposit to the client static address. Returns JSON with a `txid` on success.
18+
- May fail with insufficient funds unless blocks have been mined first.
19+
- `/reservation`:
20+
- Opens a reservation for instant out. Returns JSON with reservation details (id, amount, state, etc.).
21+
- `/loop-log`:
22+
- Returns loopd logs (text). Use a tail filter when inspecting.
23+
- `/loop-server-log`:
24+
- Returns loop server logs (text). Use a tail filter when inspecting.
25+
- Tip: The response is JSON with a large `stdout` field; extract first, then tail:
26+
- `curl -s http://127.0.0.1:12345/loop-server-log | jq -r '.stdout' > /tmp/loop-server-log.txt`
27+
- `tail -n 50 /tmp/loop-server-log.txt`
28+
29+
## Useful regtest flow observations
30+
- Deposits may be unconfirmed for a few blocks; mine multiple blocks to move a deposit into `DEPOSITED`.
31+
- After making a deposit, `loop static summary` reflects unconfirmed + confirmed values; `loop static listdeposits` lists confirmed deposits.
32+
- Reservations should be opened (via `/reservation`) before `instantout`; list them with `loop reservations list`.
33+
- `instantout` uses interactive selection; `ALL` then `y` works for a simple scenario:
34+
- `printf "ALL\ny\n" | LOOP_SESSION_RECORD=true /home/user/bin/loop instantout --network regtest`
35+
36+
## Coverage notes (high-level)
37+
- Sessions were recorded for: terms, getinfo, quote in/out, listauth, fetchl402, getparams, setrule (error + success), suggestswaps (error + success), reservations list, instantout, listinstantouts, static withdraw/listwithdrawals/listswaps, listswaps, swapinfo, loop out (forced), abandon swap (help path), plus existing static-loop-in/basic-swaps.
38+
- Some paths are intentionally skipped for now:
39+
- `stop` (would shut down loopd; replay expects a real gRPC conn).
40+
- Asset quote paths (`getAssetAmt`, `unmarshalFixedPoint`) require tapd/asset quotes.
41+
- Real dialer/macaroon path handling (`extractPathArgs`, `readMacaroon`, `getClientConn`) aren’t exercised by replay.
42+
43+
44+
## Replay stability notes
45+
- Session replay now clones the CLI command tree per run, so flag state (`IsSet`) does not leak between sessions.
46+
- Historical warning: earlier replays could have sticky flags across runs; if you see odd ordering-dependent failures, re-check that the replay uses the cloned command path.
47+
48+
## Session coverage map
49+
| Subdir | Commands / scenarios |
50+
| --- | --- |
51+
| `basic-swaps/` | `loop out` (success), `loop in` (success), `loop monitor` |
52+
| `getinfo/` | `loop getinfo` |
53+
| `instantout/` | `loop reservations list`, `loop instantout` (ALL + confirm), `loop instantout` (channel flag), `loop instantout` (select index), `loop instantout` (no confirmed reservations), `loop instantout` (cancel), `loop instantout` (invalid selection), `loop listinstantouts` |
54+
| `l402/` | `loop listauth`, `loop fetchl402` |
55+
| `liquidity/` | `loop getparams`, `loop setparams` (no flags, feepercent, conflict, many flags/categories, destaddr, account, includeallpeers; includes error cases), `loop setrule` (missing threshold, no args, incoming/outgoing/type in/out, clear), `loop suggestswaps` (error + success) |
56+
| `loopin/` | `loop in` (invalid amount), `loop in` (external + conf_target error), `loop in` (route_hints + private error), `loop in` (external cancel + verbose, last_hop/amt flag), `loop in` (external force) |
57+
| `loopout/` | `loop out` (forced success), `loop out` (invalid amount), `loop out` (addr + account error), `loop out` (invalid account address type), `loop out` (amt flag + channel + max routing fee + payment timeout), `loop out` (addr flag), `loop out` (positional addr), `loop out` (account + account_addr_type) |
58+
| `misc/` | `loop terms` |
59+
| `quote/` | `loop quote out` (success + verbose), `loop quote in` (help + verbose), `loop quote out` (help), `loop quote in` (deposit_outpoint success), `loop quote in` (positional + last_hop) |
60+
| `static/` | `loop static withdraw` (no selection error), `loop static withdraw` (invalid utxo), `loop static withdraw` (all success), `loop static withdraw` (utxo + dest_addr success), `loop static listwithdrawals`, `loop static listswaps` |
61+
| `static-loop-in/` | `loop static new`, `loop static` (help), `loop static listunspent` (incl alias), `loop static listdeposits`, `loop static summary`, `loop static in` (multiple args/flags cases), `loop static in` (duplicate outpoints), `loop static in` (positional low amount error), `loop static in` (positional + last_hop + payment_timeout), `loop static in` (all cancel) |
62+
| `static-filters/` | `loop static listdeposits --filter ...` for each state (deposited/withdrawing/withdrawn/looping_in/looped_in/publish_expired_deposit/sweep_htlc_timeout/htlc_timeout_swept/wait_for_expiry_sweep/expired/failed) |
63+
| `swaps/` | `loop listswaps` (success + conflicting filters + loop_out_only filters + loop_in_only), `loop swapinfo` (success + invalid id + id flag errors), `loop abandonswap` (help + invalid id + success) |
64+
65+
## Missing / not covered yet
66+
- `loop stop` (would terminate loopd; replay expects a live gRPC server).
67+
- Docs generators: `loop man`, `loop markdown` (handled in a separate docs pipeline).
68+
- Asset/tapd scenarios (explicitly out of scope for now).

0 commit comments

Comments
 (0)