Repository navigation
Conversation
The Electrum wallet tests drove the Python Electrum wallet through electrumd, which only builds on Linux x86_64. Use bdk_wallet + bdk_electrum against the in-process server instead, and cover the subscription push path with a raw-socket test. Closes Blockstream#224.
|
Tested this on Linux x86_64 (
Happy to push the rebase to a branch if that's useful. |
Closes #224.
Replaces the
electrumddev-dependency (which downloads and runs the Python Electrum wallet, Linux x86_64 only) with an in-process BDK wallet, following the plan in the issue.What changed
Cargo.toml: dropelectrumdand its[patch.crates-io.electrumd]section; addbdk_wallet = "3.2"andbdk_electrum = { version = "0.24.1", default-features = false }as dev-dependencies. Both usebitcoin 0.32, same as electrs, so no type conversions are needed.tests/electrum.rs:WalletTesternow holds a regtest BDK wallet (deterministicwpkhdescriptors from a fixed seed) and aBdkElectrumClientpointed at the in-process electrs server.sync_wallet()does afull_scanthrough electrs and applies the update.test_electrum_balance: same sequence as before (send, mine, send, mine), asserting confirmed and unconfirmed balances in sats.test_electrum_history: looks transactions up by txid instead of relying on order, and checks confirmation heights (102, 103) and received amounts.test_electrum_payment: builds a PSBT for 0.16 BTC with an explicit 0.001 BTC fee, signs it, broadcasts it through electrs, checks it reached bitcoind's mempool, then checks the fee and the 0.139 BTC change before and after it confirms. As the issue anticipated, BDK reports the unconfirmed change as pending rather than confirmed, so the assertion follows BDK's categories.test_electrum_subscription_notifications: BDK polls, so this covers the push path over a raw socket. It subscribes to headers and to a scripthash, then checks thatnotify()delivers a scripthash status change for a mempool tx, and both a new header (tip + 1) and a new status once it is mined.electrumd::jsonrpc::serde_jsonreferences now useserde_jsondirectly; theElectrumDerror variant andFrom<electrumd::Error>are gone fromtests/common.rs.#[cfg(not(feature = "liquid"))]instead ofallow(dead_code)under liquid, since the BDK types are Bitcoin-only.flake.nix: removedELECTRUMD_SKIP_DOWNLOADandELECTRUMD_EXE.Testing (macOS, Apple Silicon arm64, no
electrumdpatch, Rust 1.96):cargo test --test electrum: 12 passedcargo test --lib: 170 passed (per Replace the electrumd dev-dependency in tests/electrum.rs with a pure-Rust wallet (BDK) #224 this needed theelectrumdpatch to compile on macOS)cargo test --tests --no-run: builds with no warningscargo check --tests --features liquid: builds with no new warningsrustfmt --checkon the changed test filesI haven't run it on Linux; CI should cover that.