|
| 1 | +# Handoff: authoritative python-keepkey tests must be fully offline |
| 2 | + |
| 3 | +## Non-negotiable release rule |
| 4 | + |
| 5 | +The authoritative Python suite must never depend on an explorer, RPC service, |
| 6 | +DNS, TLS, remote retention, or the caller's working directory. A missing input |
| 7 | +is a named fixture failure, not permission to fetch mutable data. Optional live |
| 8 | +compatibility probes may exist only in a separate, non-authoritative workflow; |
| 9 | +they must never contribute release JUnit, report totals, artifacts, or a |
| 10 | +GO/NO-GO decision. |
| 11 | + |
| 12 | +This work must be ported to the upstream keepkey/python-keepkey repository by |
| 13 | +reviewed PR. The fork implementation is the reference; no upstream branch was |
| 14 | +modified while preparing it. |
| 15 | + |
| 16 | +## Fork reference implementation |
| 17 | + |
| 18 | +Branch: BitHighlander/python-keepkey:fix/hermetic-release-tests |
| 19 | + |
| 20 | +Release port: BitHighlander/python-keepkey:fix/7142-hermetic-tests, based |
| 21 | +exactly on b93f95c5698328a391487ecb97a3d3f6ea74159a. Its fixture-manifest |
| 22 | +SHA-256 is ae9f78b4cf934d501edcddc38ca671c0e095f9c7761845dade49fa07ac92837b. |
| 23 | +Use this branch, rather than merging alpha/develop, for the isolated 7.14.2 PR. |
| 24 | + |
| 25 | +The implementation is intentionally isolated from the 7.14.2 Solana/TON |
| 26 | +disclosure and PDF-report branches. Reconcile those branches only after this |
| 27 | +one is reviewed, then repin firmware to the durable Python merge commit. |
| 28 | + |
| 29 | +Affected surfaces: |
| 30 | + |
| 31 | +- keepkeylib/tx_api.py adds configure_offline_fixtures(path), resolves a fixed |
| 32 | + absolute fixture root, and raises OfflineFixtureError naming the complete key |
| 33 | + instead of falling through to HTTP. |
| 34 | +- tests/common.py makes tests/txcache module-relative and enables offline-only |
| 35 | + mode for every KeepKeyTest. |
| 36 | +- tests/conftest.py rejects external DNS, socket, and HTTP access per test while |
| 37 | + permitting only loopback emulator traffic and Unix-domain sockets. |
| 38 | +- .github/workflows/ci.yml checks fixture integrity, adds a kernel outbound-new- |
| 39 | + connection deny rule during authoritative pytest, and records the manifest |
| 40 | + SHA-256 in every summary. |
| 41 | +- tests/tx_fixture_manifest.py and tests/test_tx_fixture_integrity.py account |
| 42 | + for every fixture, reconstruct canonical transactions, recompute every txid, |
| 43 | + test cwd independence and fail-closed misses, and statically reject new |
| 44 | + network-capable helpers even when pytest would not collect them. |
| 45 | +- tests/test_sign_typed_data.py and tests/test_verify_typed_data.py resolve JSON |
| 46 | + fixtures from their module directory. |
| 47 | +- The unused tests/zcash_rpc.py live-node helper was removed. It was not |
| 48 | + collected by pytest, contained a fixed private-node endpoint and embedded |
| 49 | + RPC credentials, and had no place in authoritative test infrastructure. |
| 50 | + |
| 51 | +## Fixture rules |
| 52 | + |
| 53 | +Each manifest entry records: |
| 54 | + |
| 55 | +- source network and transaction ID; |
| 56 | +- response filename and SHA-256; |
| 57 | +- raw-response filename and SHA-256 where Zcash JoinSplit reconstruction needs |
| 58 | + it; |
| 59 | +- canonical serialized bytes and their SHA-256; |
| 60 | +- transaction-ID algorithm; |
| 61 | +- every authoritative test file that references it. |
| 62 | + |
| 63 | +Bitcoin, Testnet, Bitcoin Gold, Dash, and pre-Overwinter Zcash transaction IDs |
| 64 | +use double SHA-256. Groestlcoin transaction IDs use one SHA-256 round, matching |
| 65 | +the current Groestlcoin Core HashWriter::GetHash() implementation: |
| 66 | +https://github.com/Groestlcoin/groestlcoin/blob/master/src/hash.h |
| 67 | + |
| 68 | +Do not accept a fixture merely because its JSON txid field agrees with its |
| 69 | +filename. The canonical serialization must independently hash to the same ID. |
| 70 | + |
| 71 | +The fork audit found and corrected one latent synthetic-fixture defect: |
| 72 | +6e320339...a6ee37 advertised a txid computed with the null outpoint index |
| 73 | +0xffffffff, while its decoded fixture said index 0. The corrected decoded |
| 74 | +fixture now agrees with its canonical bytes and txid. Two cache files with no |
| 75 | +authoritative references were removed. The 7.14.2 release branch does not |
| 76 | +contain that later Taproot fixture, so its port keeps it absent and regenerates |
| 77 | +the manifest from the 26 transaction fixtures that release tests actually use. |
| 78 | + |
| 79 | +## Required upstream migration |
| 80 | + |
| 81 | +1. Port the fork commits without weakening the fail-closed behavior. |
| 82 | + For 7.14.2, start from b93f95c and use fix/7142-hermetic-tests; do not merge |
| 83 | + the alpha/develop report catalog into the active PDF remediation branch. |
| 84 | +2. Preserve public live TxApi clients for non-test callers, but ensure |
| 85 | + authoritative tests enable offline-only mode before constructing clients. |
| 86 | +3. Run python tests/tx_fixture_manifest.py --check as an early CI gate. |
| 87 | +4. Run all authoritative emulator suites with both the pytest network-denial |
| 88 | + control and OS-level outbound-new-connection denial. |
| 89 | +5. Treat a new transaction input as a fixture change requiring canonical-byte, |
| 90 | + response-hash, txid, reference, and manifest review. |
| 91 | +6. Feed the exact manifest SHA-256 into the release evidence/report pipeline. |
| 92 | + The report job must fail if the manifest is missing, stale, mutated, or not |
| 93 | + listed in provenance. |
| 94 | +7. Keep optional explorer/RPC probes in a separately named workflow that |
| 95 | + cannot satisfy or influence a required release check. Store them outside |
| 96 | + tests/ and obtain endpoints and credentials from the workflow environment; |
| 97 | + never commit either value. |
| 98 | + |
| 99 | +## Acceptance criteria |
| 100 | + |
| 101 | +- A clean checkout with an empty user cache runs the authoritative suite while |
| 102 | + outbound networking is denied. |
| 103 | +- Zero DNS, external socket, HTTP, explorer, or RPC attempt occurs. |
| 104 | +- A missing network/txid fixture fails immediately and names the requesting |
| 105 | + key; no HTTP fallback is possible. |
| 106 | +- Running from the repository root and from tests/ produces identical test |
| 107 | + counts, statuses, signed outputs, and manifest digest. |
| 108 | +- Every fixture source is content-hashed, every canonical transaction is |
| 109 | + retained, every txid is independently recomputed, and every fixture has at |
| 110 | + least one authoritative test reference. |
| 111 | +- No test is skipped or xfailed because a live service or fixture is |
| 112 | + unavailable. |
| 113 | +- Full Python JUnit is green before the Python commit is eligible for a |
| 114 | + firmware submodule repin. |
| 115 | +- The release report and provenance manifest contain the exact transaction |
| 116 | + fixture-manifest SHA-256. |
| 117 | + |
| 118 | +## Upstream handback |
| 119 | + |
| 120 | +Return the upstream PR URL, exact head and merge commits, full offline JUnit |
| 121 | +totals, fixture-manifest SHA-256, the network-denial result, CI run URL, and |
| 122 | +git diff --check. Call out any historical response that cannot be reconstructed |
| 123 | +exactly; do not silently replace, weaken, delete, or skip it. |
0 commit comments