Skip to content

Commit 0aeb84b

Browse files
committed
Update tests to use Electrum v4.6.2
- Update `electrumd` to support newer Electrum releases The changes in `electrumd` can be reviewed here: https://github.com/shesek/electrumd/compare/b35d9db285d932cb3c2296beab65e571a2506349..9897271b3538ef1e20166ec870746af8167a8d4b - Update to new JSON response format for `onchain_history` - Electrum v4.6 appears to process new blocks/transactions significantly slower compared to v4.5. This initially required increasing the sleep() in `notify_wallet` up to several seconds for the tests to pass, however I found that there's a new `wait_for_rpc` command that can be used instead: spesmilo/electrum@f3551f3
1 parent 49fcaa4 commit 0aeb84b

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ electrs_macros = { path = "electrs_macros", default-features = false }
7979
[dev-dependencies]
8080
corepc-node = { version = "0.10", features = ["download", "29_0"] }
8181
elementsd = { version = "0.11", features = ["22_1_1"] }
82-
electrumd = { version = "0.1.0", features = ["4_5_4"] }
82+
electrumd = { version = "0.1.0", features = ["4_6_2"] }
8383
ureq = { version = "3.1", default-features = false, features = ["json"] }
8484
tempfile = "3.10"
8585
criterion = { version = "0.8", features = ["html_reports"] }
@@ -103,4 +103,4 @@ rev = "d3792352992a539afffbe11501d1aff9fd5b919d" # add-peer branch
103103
# not yet published on crates.io
104104
[patch.crates-io.electrumd]
105105
git = "https://github.com/shesek/electrumd"
106-
rev = "b35d9db285d932cb3c2296beab65e571a2506349"
106+
rev = "9897271b3538ef1e20166ec870746af8167a8d4b"

tests/electrum.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl WalletTester {
5151
fn notify_wallet(&self) {
5252
self.electrum_server.notify();
5353
std::thread::sleep(std::time::Duration::from_millis(200));
54+
self.electrum_wallet.call("wait_for_sync", &json!([])).unwrap();
5455
}
5556

5657
fn assert_balance(&self, confirmed: f64, unconfirmed: f64) {
@@ -141,18 +142,18 @@ fn test_electrum_history() -> Result<()> {
141142
let history = wt.electrum_wallet.call("onchain_history", &json!([]))?;
142143
log::debug!("history = {:#?}", history);
143144
assert_eq!(
144-
history["transactions"][0]["txid"].as_str(),
145+
history[0]["txid"].as_str(),
145146
Some(txid1.to_string().as_str())
146147
);
147-
assert_eq!(history["transactions"][0]["height"].as_u64(), Some(102));
148-
assert_eq!(history["transactions"][0]["bc_value"].as_str(), Some("0.1"));
148+
assert_eq!(history[0]["height"].as_u64(), Some(102));
149+
assert_eq!(history[0]["bc_value"].as_str(), Some("0.1"));
149150

150151
assert_eq!(
151-
history["transactions"][1]["txid"].as_str(),
152+
history[1]["txid"].as_str(),
152153
Some(txid2.to_string().as_str())
153154
);
154-
assert_eq!(history["transactions"][1]["height"].as_u64(), Some(103));
155-
assert_eq!(history["transactions"][1]["bc_value"].as_str(), Some("0.2"));
155+
assert_eq!(history[1]["height"].as_u64(), Some(103));
156+
assert_eq!(history[1]["bc_value"].as_str(), Some("0.2"));
156157

157158
Ok(())
158159
}

0 commit comments

Comments
 (0)