Skip to content

Commit 40a773c

Browse files
randomloginfebyeji
authored andcommitted
Make LDK_TEST_CHAIN_SOURCE configurable during integration testing
1 parent 9692ff4 commit 40a773c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

tests/common/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,16 @@ pub(crate) fn setup_bitcoind_and_electrsd() -> (BitcoinD, ElectrsD) {
245245
pub(crate) fn random_chain_source<'a>(
246246
bitcoind: &'a BitcoinD, electrsd: &'a ElectrsD,
247247
) -> TestChainSource<'a> {
248-
let r = rand::random_range(0..3);
248+
// Allow forcing a specific backend via LDK_TEST_CHAIN_SOURCE env var.
249+
// Valid values: "esplora", "electrum", "bitcoind-rpc", "bitcoind-rest", "cbf"
250+
let r = match std::env::var("LDK_TEST_CHAIN_SOURCE").ok().as_deref() {
251+
Some("esplora") => 0,
252+
Some("electrum") => 1,
253+
Some("bitcoind-rpc") => 2,
254+
Some("bitcoind-rest") => 3,
255+
Some("cbf") => 4,
256+
_ => rand::random_range(0..5),
257+
};
249258
match r {
250259
0 => {
251260
println!("Randomly setting up Esplora chain syncing...");
@@ -263,6 +272,10 @@ pub(crate) fn random_chain_source<'a>(
263272
println!("Randomly setting up Bitcoind REST chain syncing...");
264273
TestChainSource::BitcoindRestSync(bitcoind)
265274
},
275+
4 => {
276+
println!("Randomly setting up CBF compact block filter syncing...");
277+
TestChainSource::Cbf(bitcoind)
278+
},
266279
_ => unreachable!(),
267280
}
268281
}

0 commit comments

Comments
 (0)