Skip to content

Commit 6365c55

Browse files
committed
f Default to use BitcoindRpc in tests
1 parent eb470d2 commit 6365c55

File tree

2 files changed

+20
-56
lines changed

2 files changed

+20
-56
lines changed

tests/common/mod.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use rand::{thread_rng, Rng};
3636

3737
use std::env;
3838
use std::path::PathBuf;
39-
use std::str::FromStr;
4039
use std::sync::{Arc, RwLock};
4140
use std::time::Duration;
4241

@@ -402,40 +401,6 @@ where
402401
}
403402
}
404403

405-
// Premine dummy blocks to populate estimatesmartfee
406-
pub(crate) fn premine_dummy_blocks<E: ElectrumApi>(bitcoind: &BitcoindClient, electrs: &E) {
407-
let _ = bitcoind.create_wallet("ldk_node_test", None, None, None, None);
408-
let _ = bitcoind.load_wallet("ldk_node_test");
409-
let mut rng = thread_rng();
410-
411-
generate_blocks_and_wait(bitcoind, electrs, 101);
412-
413-
let amount = Amount::from_sat(100000);
414-
for i in 0..5 {
415-
println!("Pre-mining block {}", i);
416-
let num_txs = rng.gen_range(10..42);
417-
let mut last_txid = None;
418-
for _ in 10..num_txs {
419-
let dummy_address: Address =
420-
Address::from_str("bcrt1qh3mvjaldwxynmmwsmx4az4vdg5yj7sjzjpdga5")
421-
.unwrap()
422-
.require_network(Network::Regtest)
423-
.unwrap();
424-
let txid = bitcoind
425-
.send_to_address(&dummy_address, amount, None, None, None, None, Some(1), None)
426-
.unwrap();
427-
println!("Created dummy transaction {}", txid);
428-
last_txid = Some(txid);
429-
}
430-
if let Some(last_txid) = last_txid {
431-
wait_for_tx(electrs, last_txid);
432-
}
433-
generate_blocks_and_wait(bitcoind, electrs, 1);
434-
}
435-
436-
generate_blocks_and_wait(bitcoind, electrs, 1);
437-
}
438-
439404
pub(crate) fn premine_and_distribute_funds<E: ElectrumApi>(
440405
bitcoind: &BitcoindClient, electrs: &E, addrs: Vec<Address>, amount: Amount,
441406
) {

tests/integration_tests_rust.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ mod common;
1010
use common::{
1111
do_channel_full_cycle, expect_channel_ready_event, expect_event, expect_payment_received_event,
1212
expect_payment_successful_event, generate_blocks_and_wait, open_channel,
13-
premine_and_distribute_funds, premine_dummy_blocks, random_config, setup_bitcoind_and_electrsd,
14-
setup_builder, setup_node, setup_two_nodes, wait_for_tx, TestChainSource, TestSyncStore,
13+
premine_and_distribute_funds, random_config, setup_bitcoind_and_electrsd, setup_builder,
14+
setup_node, setup_two_nodes, wait_for_tx, TestChainSource, TestSyncStore,
1515
};
1616

1717
use ldk_node::config::EsploraSyncConfig;
@@ -28,56 +28,55 @@ use std::sync::Arc;
2828
#[test]
2929
fn channel_full_cycle() {
3030
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
31-
let chain_source = TestChainSource::Esplora(&electrsd);
31+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
3232
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false);
3333
do_channel_full_cycle(node_a, node_b, &bitcoind.client, &electrsd.client, false, true, false);
3434
}
3535

3636
#[test]
37-
fn channel_full_cycle_bitcoind() {
37+
fn channel_full_cycle_esplora() {
3838
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
39-
premine_dummy_blocks(&bitcoind.client, &electrsd.client);
40-
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
39+
let chain_source = TestChainSource::Esplora(&electrsd);
4140
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false);
4241
do_channel_full_cycle(node_a, node_b, &bitcoind.client, &electrsd.client, false, true, false);
4342
}
4443

4544
#[test]
4645
fn channel_full_cycle_force_close() {
4746
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
48-
let chain_source = TestChainSource::Esplora(&electrsd);
47+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
4948
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false);
5049
do_channel_full_cycle(node_a, node_b, &bitcoind.client, &electrsd.client, false, true, true);
5150
}
5251

5352
#[test]
5453
fn channel_full_cycle_force_close_trusted_no_reserve() {
5554
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
56-
let chain_source = TestChainSource::Esplora(&electrsd);
55+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
5756
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, true);
5857
do_channel_full_cycle(node_a, node_b, &bitcoind.client, &electrsd.client, false, true, true);
5958
}
6059

6160
#[test]
6261
fn channel_full_cycle_0conf() {
6362
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
64-
let chain_source = TestChainSource::Esplora(&electrsd);
63+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
6564
let (node_a, node_b) = setup_two_nodes(&chain_source, true, true, false);
6665
do_channel_full_cycle(node_a, node_b, &bitcoind.client, &electrsd.client, true, true, false)
6766
}
6867

6968
#[test]
7069
fn channel_full_cycle_legacy_staticremotekey() {
7170
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
72-
let chain_source = TestChainSource::Esplora(&electrsd);
71+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
7372
let (node_a, node_b) = setup_two_nodes(&chain_source, false, false, false);
7473
do_channel_full_cycle(node_a, node_b, &bitcoind.client, &electrsd.client, false, false, false);
7574
}
7675

7776
#[test]
7877
fn channel_open_fails_when_funds_insufficient() {
7978
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
80-
let chain_source = TestChainSource::Esplora(&electrsd);
79+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
8180
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false);
8281

8382
let addr_a = node_a.onchain_payment().new_address().unwrap();
@@ -281,7 +280,7 @@ fn start_stop_reinit() {
281280
#[test]
282281
fn onchain_spend_receive() {
283282
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
284-
let chain_source = TestChainSource::Esplora(&electrsd);
283+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
285284
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false);
286285

287286
let addr_a = node_a.onchain_payment().new_address().unwrap();
@@ -329,9 +328,9 @@ fn onchain_spend_receive() {
329328

330329
#[test]
331330
fn sign_verify_msg() {
332-
let (_bitcoind, electrsd) = setup_bitcoind_and_electrsd();
331+
let (bitcoind, _electrsd) = setup_bitcoind_and_electrsd();
333332
let config = random_config(true);
334-
let chain_source = TestChainSource::Esplora(&electrsd);
333+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
335334
let node = setup_node(&chain_source, config);
336335

337336
// Tests arbitrary message signing and later verification
@@ -348,8 +347,8 @@ fn connection_restart_behavior() {
348347
}
349348

350349
fn do_connection_restart_behavior(persist: bool) {
351-
let (_bitcoind, electrsd) = setup_bitcoind_and_electrsd();
352-
let chain_source = TestChainSource::Esplora(&electrsd);
350+
let (bitcoind, _electrsd) = setup_bitcoind_and_electrsd();
351+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
353352
let (node_a, node_b) = setup_two_nodes(&chain_source, false, false, false);
354353

355354
let node_id_a = node_a.node_id();
@@ -400,8 +399,8 @@ fn do_connection_restart_behavior(persist: bool) {
400399

401400
#[test]
402401
fn concurrent_connections_succeed() {
403-
let (_bitcoind, electrsd) = setup_bitcoind_and_electrsd();
404-
let chain_source = TestChainSource::Esplora(&electrsd);
402+
let (bitcoind, _electrsd) = setup_bitcoind_and_electrsd();
403+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
405404
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false);
406405

407406
let node_a = Arc::new(node_a);
@@ -432,7 +431,7 @@ fn concurrent_connections_succeed() {
432431
#[test]
433432
fn simple_bolt12_send_receive() {
434433
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
435-
let chain_source = TestChainSource::Esplora(&electrsd);
434+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
436435
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false);
437436

438437
let address_a = node_a.onchain_payment().new_address().unwrap();
@@ -640,7 +639,7 @@ fn simple_bolt12_send_receive() {
640639
#[test]
641640
fn generate_bip21_uri() {
642641
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
643-
let chain_source = TestChainSource::Esplora(&electrsd);
642+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
644643
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false);
645644

646645
let address_a = node_a.onchain_payment().new_address().unwrap();
@@ -682,7 +681,7 @@ fn generate_bip21_uri() {
682681
#[test]
683682
fn unified_qr_send_receive() {
684683
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
685-
let chain_source = TestChainSource::Esplora(&electrsd);
684+
let chain_source = TestChainSource::BitcoinRpc(&bitcoind);
686685
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false);
687686

688687
let address_a = node_a.onchain_payment().new_address().unwrap();

0 commit comments

Comments
 (0)