Skip to content

Commit 719383b

Browse files
committed
Disable background sync in manual Esplora tests
Store-backed integration tests drive wallet syncs explicitly. Leaving Esplora background sync enabled let the first background scan start before the funded address was tracked, so a later sync_wallets call could observe a zero premine balance. Reuse the manual Esplora sync config from shared test setup for Postgres, VSS, migration, and current-version compatibility builders. Co-Authored-By: HAL 9000
1 parent d8a5839 commit 719383b

6 files changed

Lines changed: 37 additions & 19 deletions

tests/common/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,18 @@ pub(crate) fn setup_two_nodes_with_store(
643643
(node_a, node_b)
644644
}
645645

646+
pub(crate) fn manual_esplora_sync_config() -> EsploraSyncConfig {
647+
let mut sync_config = EsploraSyncConfig::default();
648+
sync_config.background_sync_config = None;
649+
sync_config
650+
}
651+
646652
pub(crate) fn setup_node(chain_source: &TestChainSource, config: TestConfig) -> TestNode {
647653
setup_builder!(builder, config.node_config);
648654
match chain_source {
649655
TestChainSource::Esplora(electrsd) => {
650656
let esplora_url = format!("http://{}", electrsd.esplora_url.as_ref().unwrap());
651-
let mut sync_config = EsploraSyncConfig::default();
652-
sync_config.background_sync_config = None;
657+
let mut sync_config = manual_esplora_sync_config();
653658
sync_config.force_wallet_full_scan = config.force_wallet_full_scan;
654659
if let Some(full_scan_stop_gap) = config.full_scan_stop_gap {
655660
sync_config.full_scan_stop_gap = full_scan_stop_gap;

tests/integration_tests_migration.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ async fn build_migration_node(
9090
esplora_url: &str,
9191
) -> ldk_node::Node {
9292
let mut builder = Builder::from_config(node_config);
93-
builder.set_chain_source_esplora(esplora_url.to_string(), None);
93+
builder.set_chain_source_esplora(
94+
esplora_url.to_string(),
95+
Some(common::manual_esplora_sync_config()),
96+
);
9497
with_opened_store!(instance, |store| builder.build_with_store(node_entropy, store).unwrap())
9598
}
9699

tests/integration_tests_postgres.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ async fn channel_full_cycle_with_postgres_store() {
2424
let esplora_url = format!("http://{}", electrsd.esplora_url.as_ref().unwrap());
2525
let config_a = common::random_config();
2626
let mut builder_a = Builder::from_config(config_a.node_config);
27-
builder_a.set_chain_source_esplora(esplora_url.clone(), None);
27+
builder_a
28+
.set_chain_source_esplora(esplora_url.clone(), Some(common::manual_esplora_sync_config()));
2829
let node_a = builder_a
2930
.build_with_postgres_store(
3031
config_a.node_entropy,
@@ -39,7 +40,8 @@ async fn channel_full_cycle_with_postgres_store() {
3940
println!("\n== Node B ==");
4041
let config_b = common::random_config();
4142
let mut builder_b = Builder::from_config(config_b.node_config);
42-
builder_b.set_chain_source_esplora(esplora_url.clone(), None);
43+
builder_b
44+
.set_chain_source_esplora(esplora_url.clone(), Some(common::manual_esplora_sync_config()));
4345
let node_b = builder_b
4446
.build_with_postgres_store(
4547
config_b.node_entropy,
@@ -85,7 +87,10 @@ async fn postgres_node_restart() {
8587
let mut builder = Builder::new();
8688
builder.set_network(bitcoin::Network::Regtest);
8789
builder.set_storage_dir_path(storage_path.clone());
88-
builder.set_chain_source_esplora(esplora_url.clone(), None);
90+
builder.set_chain_source_esplora(
91+
esplora_url.clone(),
92+
Some(common::manual_esplora_sync_config()),
93+
);
8994
let node = builder
9095
.build_with_postgres_store(
9196
node_entropy,
@@ -119,7 +124,7 @@ async fn postgres_node_restart() {
119124
let mut builder = Builder::new();
120125
builder.set_network(bitcoin::Network::Regtest);
121126
builder.set_storage_dir_path(storage_path);
122-
builder.set_chain_source_esplora(esplora_url, None);
127+
builder.set_chain_source_esplora(esplora_url, Some(common::manual_esplora_sync_config()));
123128

124129
let node = builder
125130
.build_with_postgres_store(

tests/integration_tests_rust.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ use common::{
2121
expect_channel_pending_event, expect_channel_ready_event, expect_channel_ready_events,
2222
expect_event, expect_payment_claimable_event, expect_payment_received_event,
2323
expect_payment_successful_event, expect_splice_negotiated_event, generate_blocks_and_wait,
24-
generate_listening_addresses, invalidate_blocks, open_channel, open_channel_push_amt,
25-
open_channel_with_all, premine_and_distribute_funds, premine_blocks, prepare_rbf,
26-
random_chain_source, random_config, setup_bitcoind_and_electrsd, setup_builder, setup_node,
27-
setup_two_nodes, splice_in_with_all, wait_for_block, wait_for_tx, TestChainSource, TestConfig,
28-
TestStoreType, TestSyncStore,
24+
generate_listening_addresses, invalidate_blocks, manual_esplora_sync_config, open_channel,
25+
open_channel_push_amt, open_channel_with_all, premine_and_distribute_funds, premine_blocks,
26+
prepare_rbf, random_chain_source, random_config, setup_bitcoind_and_electrsd, setup_builder,
27+
setup_node, setup_two_nodes, splice_in_with_all, wait_for_block, wait_for_tx, TestChainSource,
28+
TestConfig, TestStoreType, TestSyncStore,
2929
};
3030
use electrsd::corepc_node::{self, Node as BitcoinD};
3131
use electrsd::ElectrsD;
@@ -3606,7 +3606,7 @@ async fn do_persistence_backwards_compatibility(version: OldLdkVersion) {
36063606
let mut builder_new = Builder::new();
36073607
builder_new.set_network(bitcoin::Network::Regtest);
36083608
builder_new.set_storage_dir_path(storage_path);
3609-
builder_new.set_chain_source_esplora(esplora_url, None);
3609+
builder_new.set_chain_source_esplora(esplora_url, Some(manual_esplora_sync_config()));
36103610

36113611
#[cfg(feature = "uniffi")]
36123612
let node_entropy = NodeEntropy::from_seed_bytes(seed_bytes.to_vec()).unwrap();
@@ -3655,7 +3655,7 @@ async fn fs_store_persistence_backwards_compatibility() {
36553655
let mut builder_new = Builder::new();
36563656
builder_new.set_network(bitcoin::Network::Regtest);
36573657
builder_new.set_storage_dir_path(storage_path);
3658-
builder_new.set_chain_source_esplora(esplora_url, None);
3658+
builder_new.set_chain_source_esplora(esplora_url, Some(manual_esplora_sync_config()));
36593659

36603660
#[cfg(feature = "uniffi")]
36613661
let node_entropy = NodeEntropy::from_seed_bytes(seed_bytes.to_vec()).unwrap();

tests/integration_tests_vss.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ async fn channel_full_cycle_with_vss_store() {
2222
let esplora_url = format!("http://{}", electrsd.esplora_url.as_ref().unwrap());
2323
let config_a = common::random_config();
2424
let mut builder_a = Builder::from_config(config_a.node_config);
25-
builder_a.set_chain_source_esplora(esplora_url.clone(), None);
25+
builder_a
26+
.set_chain_source_esplora(esplora_url.clone(), Some(common::manual_esplora_sync_config()));
2627
let vss_base_url = std::env::var("TEST_VSS_BASE_URL").unwrap();
2728
let node_a = builder_a
2829
.build_with_vss_store(
@@ -37,7 +38,8 @@ async fn channel_full_cycle_with_vss_store() {
3738
println!("\n== Node B ==");
3839
let config_b = common::random_config();
3940
let mut builder_b = Builder::from_config(config_b.node_config);
40-
builder_b.set_chain_source_esplora(esplora_url.clone(), None);
41+
builder_b
42+
.set_chain_source_esplora(esplora_url.clone(), Some(common::manual_esplora_sync_config()));
4143
let node_b = builder_b
4244
.build_with_vss_store(
4345
config_b.node_entropy,
@@ -77,7 +79,10 @@ async fn vss_node_restart() {
7779
let mut builder = Builder::new();
7880
builder.set_network(bitcoin::Network::Regtest);
7981
builder.set_storage_dir_path(storage_path.clone());
80-
builder.set_chain_source_esplora(esplora_url.clone(), None);
82+
builder.set_chain_source_esplora(
83+
esplora_url.clone(),
84+
Some(common::manual_esplora_sync_config()),
85+
);
8186
let node = builder
8287
.build_with_vss_store(
8388
node_entropy,
@@ -110,7 +115,7 @@ async fn vss_node_restart() {
110115
let mut builder = Builder::new();
111116
builder.set_network(bitcoin::Network::Regtest);
112117
builder.set_storage_dir_path(storage_path);
113-
builder.set_chain_source_esplora(esplora_url, None);
118+
builder.set_chain_source_esplora(esplora_url, Some(common::manual_esplora_sync_config()));
114119

115120
let node = builder
116121
.build_with_vss_store(node_entropy, vss_base_url, "store_id".to_owned(), HashMap::new())

tests/integration_tests_vss_no_auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async fn vss_v0_schema_backwards_compatibility() {
7272
let mut builder_new = Builder::new();
7373
builder_new.set_network(bitcoin::Network::Regtest);
7474
builder_new.set_storage_dir_path(storage_path);
75-
builder_new.set_chain_source_esplora(esplora_url, None);
75+
builder_new.set_chain_source_esplora(esplora_url, Some(common::manual_esplora_sync_config()));
7676

7777
let node_new = builder_new
7878
.build_with_vss_store_and_fixed_headers(

0 commit comments

Comments
 (0)