Repository navigation
test: drive jade flows with an emulator - #2052
Conversation
Verified: JadeEmulatorTransportTest and JadeTransportTest pass; dev debug on an emulator paired, verified and signed a send against the jade emulator
Adds a journey for each hardware__jade_* error the app can reach, for signing on the device and for a passphrase wallet. Keeps the Found step's wrong PIN message while the next scan finds the same Jade, and closes the emulator socket when a connect fails. Verified: just compile, just test and just lint pass
A closed emulator socket now reports the Jade as disconnected, as a USB detach or dropped Bluetooth link does, so the next request reconnects instead of reusing a dead session. Verified: just compile, just test and just lint pass; on an emulator a send signed after the Jade emulator restarted under the app
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds a debug-only TCP connection to the Jade emulator and nine journeys covering pairing, receiving, signing and Jade error messages.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Jade scan] --> B{Debug emulator enabled?}
B -- Yes --> C[Check TCP endpoint]
C --> D[Offer Jade Emulator]
D --> E[Open socket and exchange bytes]
E --> F{Socket disconnected?}
F -- Yes --> G[Emit external disconnect]
G --> H[Clear live Jade session]
B -- No --> I[USB and Bluetooth only]
Reviews (1) · Last reviewed commit: "fix: reconnect the jade emulator after i..." · Reviewed by Greptile |
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Adds a debug-only TCP transport to the Jade emulator, routes tcp: paths to it, reports a closed socket as an external disconnect, keeps the Found step's connect error when the same Jade is shown again, and adds journeys J1 to J9. Reviewed 9f5af34, full tier, static: per the repo's agent rules an automated review does not build the Android branch here, so this rests on the code and on CI.
What I checked, and 6 candidates I ruled out
Read in full: JadeEmulatorTransport.kt, the JadeTransport.kt diff with scanDevices, the USB and BLE close/read paths and emitExternalDisconnect, HwConnectViewModel.kt (onFoundRoute, onConnectClick, onConnectFailed, startSearching), the three test files, build.gradle.kts build config fields.
Call sites traced: JadeRepo.observeExternalDisconnects, disconnect, disconnectStaleSession, cancelPendingConnection, findKnownDeviceCandidates (hasUsbPermission filter), HardwareSheet Found route.
Journeys: every testTag the nine Jade journeys assert exists in app/src/main (literal or through the Tab-, Suggestion-, AssetButton- builders).
CI: build-and-test, lint, detekt, build-local green; e2e and compose-ui still running at review time.
Ruled out
- Emulator reachable in a release build:
JADE_EMULATORis forced tofalsefor every non-debug variant, andisEmulatorPathis gated on it, so atcp:path falls through to the USB branch there. - Emulator dropped by the USB permission filter on reconnect:
hasUsbPermissionreturns true for an emulator path before touchingUsbManager. - Stale connect error kept on a later visit:
onConnectClick,startSearchingandcancelConnectall clearerrorMessage; only a re-entry of Found for the samefoundDeviceIdkeeps it, whichHwConnectViewModelTestpins both ways. - Scan probe fighting an open session:
scanDevicesskips the probe while a socket for the path is held. - A user close during an in-flight read emitted as an external disconnect: possible (the emulator path never adds to
userInitiatedCloseSet), but debug-only andobserveExternalDisconnectsdrops it onceconnectedis cleared; below the posting tier. - Chunk size: the emulator path gets
MAX_CHUNK_SIZE(509), the same as serial USB.
Merge confidence: 4/5, no findings, but e2e was still running and the branch was not built here.
Reviewer model: Claude Opus 5.5
Reasoning effort: Not exposed (this review session does not report its reasoning setting)
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR at 9f5af34, re-reviewed after explicit full review request.
2 actionable findings — resolve or provide an evidence-backed rebuttal.
No defects were identified in the production code changes (app/build.gradle.kts, JadeEmulatorTransport, JadeTransport, and HwConnectViewModel.onFoundRoute): JADE_EMULATOR is forced false in release builds, the TCP transport respects QEMU's single-client constraint by skipping reachability probes while open, clamps soTimeout to avoid blocking indefinitely, and routes DISCONNECTED results through socket close and emitExternalDisconnect. HwConnectViewModel.onFoundRoute preserves an existing connect error only when reopening the same foundDeviceId, while retry, cancel, dismiss, and different-device paths clear it. One LOW defect was found in the new jade-psbt-too-large.xml journey setup command.
Compatibility and parity checks (read-only comparison sources, not full reviews):
- Dependency synonymdev/bitkit-docker#45 at ff07520 (compatibility contracts only:
jade-emulatorport, CLI subcommands, environment variables, interactive button sequences, and recipes):10.0.2.2:30121routing,scripts/jade-emulatorcommands/env vars, and button sequences match. Two discrepancies were noted:journeys/hardware-wallet/jade-psbt-too-large.xmlomits periodic mining during the 200-send loop (reported as a finding), and the PR #2052 Setup section references./start.sh, whereasbitkit-dockerstarts withdocker compose up -d(asjourneys/hardware-wallet/README.mdalready states). - Twin synonymdev/bitkit-ios#1441 at 428cff5 (scoped to Jade emulator transport and the 9 journeys): transport behavior and journey specs align aside from documented platform differences (
jade-device-locked.xmlexpects Android's busy toast vs iOS PIN re-prompt, and Android'sHwConnectViewModelerror-preservation fix). The iOS copy ofjade-psbt-too-large.xmlhas the same unmined 200-send loop.
Validation and limitations: CI build-and-test passed on 9f5af34; local Gradle unit test execution was unavailable in this review environment due to a missing Android SDK. Unit tests cover emulator read-side disconnect (JadeTransportTest), while write-side IOException disconnect reporting in JadeTransport.writeChunk was verified by source analysis only.
Recommended before device testing
- Update the setup command in
journeys/hardware-wallet/jade-psbt-too-large.xmlto mine every 20 sends soJ6can fund 200 UTXOs on a freshbitkit-dockerstack. - Clarify step 1 of the PR QA Setup to run
docker compose up -dinstead of./start.shinbitkit-docker.
Device testing: not performed in this review. The 9 new journeys (J1–J9) remain to be run against an Android emulator or device with synonymdev/bitkit-docker#45; physical USB and BLE transports remain outside emulator coverage.
Earlier findings reconciled at this revision: 1 still present.
Findings
- [LOW] Mine periodically in jade-psbt-too-large.xml setup to avoid Bitcoin Core's 25-tx mempool chain limit — inline at
journeys/hardware-wallet/jade-psbt-too-large.xml:8. - [MEDIUM] Fix J5 uninitialized Jade error mismatch against Android output — inline at
journeys/hardware-wallet/jade-uninitialized.xml:18. Still present from an earlier unpublished review.
Reviewer model: gemini-4-neon
Reasoning effort: high
jvsena42
left a comment
There was a problem hiding this comment.
Code scan at 9f5af34: no HIGH/MEDIUM from me. One LOW, inline.
I reviewed this as a hardware-wallet signing change despite the test: label: it adds JadeEmulatorTransport to app/src/main, routes JadeTransport through it, changes the build config, and changes the Found step for every vendor (HwConnectViewModel.onFoundRoute), with a fixed changelog fragment.
Checked and clean:
- Release exposure:
JADE_EMULATORis forcedfalseunlessvariant.buildType == "debug"(app/build.gradle.kts:446-450), and onlydebug/releasebuild types exist. With it false,isEmulatorPath/scanDevicesreturn early and everyJadeTransportbranch falls through to the unchanged BLE/USB calls. Host/port come only from build-timeJADE_EMULATOR_URL; nothing from a path, scan result, deeplink or stored device can redirect the socket. No workflow sets the flag. - Real USB/BLE Jade: the
JadeTransportdiff is additive branches in front of unchanged calls;closeAllConnectionsadds a no-opcloseAll()on an empty map. onFoundRoutekeepingerrorMessagefor the samefoundDeviceId: retry (onConnectClick), new search (startSearching), success (onConnected), Cancel/Back (sheet dispose →resetState()) and a different device all clear it. No stale-error path.- Journeys: all asserted tags and quoted strings exist at head; J3, J6, J7, J8, J9 traced through the code. J5 is piotr-iohk's open thread, not repeated here. Same 9 file names on synonymdev/bitkit-ios#1441; 7 byte-identical,
jade-connect-sign.xmldiffers only in identifiers,jade-device-locked.xmladapted and documented in the suite README. - CI green at this head.
perf: not relevant for shipped builds (scanDevices returns immediately when disabled).
Device gate (partial): 9f5af34 — not run yet; J1–J9 need the Jade emulator from bitkit-docker. Device result to follow.
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating; Fable 5.2 (claude-fable-5-2) primary review
Reasoning effort: Not exposed
|
Device gate (partial): 9f5af34 — J1 (
Still running: J2–J9. |
jvsena42
left a comment
There was a problem hiding this comment.
Approving at 9f5af34. Open LOWs: the XML one from my earlier review and one new journey step, inline. Fix them here or in a follow-up issue, and reply on each thread with which. J5 fails on device exactly as piotr-iohk's open MEDIUM says; I've added the device output on that thread rather than raising it again.
Device gate: 9f5af34 — journeys: 8 passed, 1 failed (jade-uninitialized.xml step 4, piotr-iohk's thread). Run on the Android emulator (API 37) against the bitkit-docker Jade emulator (firmware 1.0.41-dirty), staging regtest; J7 on the local regtest.
- J1 connect-sign: paired in 7 s, signed and broadcast 50 000 sats about 13 s after the tap (success screen 17 s).
- J2 sign-on-device: decline leaves the sign screen with no payment; approve sends once (balance −50 141, one Sent row), success 9 s after the press.
- J3 wrong PIN: "Wrong PIN. Try again on your Jade." stays on Found from 0 to 36 s. Back and reopen, or Cancel and reopen, show no stale error. Retrying with the right PIN clears it and pairs. No re-scan ran in that window, so persistence under repeated scans isn't shown.
- J4 network mismatch, J6 wallet mismatch, J8 device locked (info toast, no hang), J9 passphrase (second wallet listed at 0): pass.
- J7 PSBT too large: 200 UTXOs funded;
signPsbt failed [AppError='size=92036, max=16384'], the documented toast, no broadcast.
perf: not relevant (debug-only transport); l10n: no UI text changed.
⚠️ Not verified: real USB replug, BLE re-discovery and the Trezor path through the changedonFoundRoute; the emulator only covers the TCP transport.
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating; Fable 5.2 (claude-fable-5-2, reasoning medium) primary review and device runbook; Sonnet 5.5 (claude-sonnet-5-5, reasoning low) device driver
Reasoning effort: Not exposed (coordinator)
|
Merging: approved by @jvsena42 with CI green. The four review points (J5 text, J1 Show details, psbt journey mining and XML) go in a follow-up PR, linked in their threads. |
Refs #2049
Twin: synonymdev/bitkit-ios#1441
Dependency: synonymdev/bitkit-docker#45
This PR lets debug builds drive every Jade flow against the Blockstream Jade emulator from bitkit-docker, and adds a journey for each.
Description
JADE_EMULATORin debug builds, so the Jade flows run on an emulator without a device. The emulator shows up in scans as one more Jade.hardware__jade_*error the app can reach, logging out on the device and a passphrase wallet.Out of Scope
JadeRepo: a Jade logged out on the device shows "Your Jade is busy", where iOS asks for the PIN again and retries: bug: a jade logged out on the device shows busy instead of asking for its pin #2050.Design
N/A — no design available.
Preview
The Found step's wrong PIN message stays on screen, and the app reconnects after the emulator restarts:
android-wrong-pin2x.mp4
android-restart-reconnect2x.mp4
QA Notes
Setup
./start.sh, then./scripts/jade-emulator start(each journey names theJADE_*settings it needs;docs/jade-emulator.mdhas the recipes).JADE_EMULATOR=true; the app reaches the emulator at10.0.2.2:30121(JADE_EMULATOR_URLoverrides it)../scripts/jade-emulator press,pinandpassphrasein bitkit-docker.Journeys
jade-connect-sign.xml— pairs the emulated Jade, verifies a receive address on it and sends from itjade-sign-on-device.xml— declining on the device cancels the send; approving it sendsjade-wrong-pin.xml— a wrong PIN shows the Found step's message, then the right PIN pairsjade-network-mismatch.xml— a mainnet Jade shows the network mismatch messagejade-uninitialized.xml— a Jade with no seed shows the not set up messagejade-wallet-mismatch.xml— a Jade with another seed shows the different wallet messagejade-psbt-too-large.xml— a send over 200 inputs shows the transaction too large messagejade-device-locked.xml— logging out on the device shows the busy messagejade-passphrase.xml— a passphrase typed on the Jade pairs as a second wallet of the same JadeManual Tests
N/A
Automated Checks
JadeEmulatorTransportTest.kt— the emulator is listed only while its port answers, and reads and writes go over the socketJadeTransportTest.kt— emulator paths go to the TCP transport, and a closed emulator socket reports the Jade disconnectedHwConnectViewModelTest.kt— the wrong PIN message stays when the next scan finds the same JadeEvidence
Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)Claude Sonnet 5.5(reasoning:high)