Skip to content

Commit eb234fe

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..e22e864d1ce2ebbf02f1e3fee1ac846ab54bcafd - 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 7fea7c4 commit eb234fe

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

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 = "e22e864d1ce2ebbf02f1e3fee1ac846ab54bcafd"

tests/electrum.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ fn test_electrum() -> Result<()> {
3737
let notify_wallet = || {
3838
electrum_server.notify();
3939
std::thread::sleep(std::time::Duration::from_millis(200));
40+
electrum_wallet.call("wait_for_sync", &json!([])).unwrap();
4041
};
4142

4243
let assert_balance = |confirmed: f64, unconfirmed: f64| {
@@ -108,18 +109,18 @@ fn test_electrum() -> Result<()> {
108109
let history = electrum_wallet.call("onchain_history", &json!([]))?;
109110
log::debug!("history = {:#?}", history);
110111
assert_eq!(
111-
history["transactions"][0]["txid"].as_str(),
112+
history[0]["txid"].as_str(),
112113
Some(txid1.to_string().as_str())
113114
);
114-
assert_eq!(history["transactions"][0]["height"].as_u64(), Some(102));
115-
assert_eq!(history["transactions"][0]["bc_value"].as_str(), Some("0.1"));
115+
assert_eq!(history[0]["height"].as_u64(), Some(102));
116+
assert_eq!(history[0]["bc_value"].as_str(), Some("0.1"));
116117

117118
assert_eq!(
118-
history["transactions"][1]["txid"].as_str(),
119+
history[1]["txid"].as_str(),
119120
Some(txid2.to_string().as_str())
120121
);
121-
assert_eq!(history["transactions"][1]["height"].as_u64(), Some(103));
122-
assert_eq!(history["transactions"][1]["bc_value"].as_str(), Some("0.2"));
122+
assert_eq!(history[1]["height"].as_u64(), Some(103));
123+
assert_eq!(history[1]["bc_value"].as_str(), Some("0.2"));
123124

124125
// Send an outgoing payment
125126
electrum_wallet.call(

0 commit comments

Comments
 (0)