Skip to content

Commit a7d86ce

Browse files
committed
f Drop unnecessary preminig
.. and `s/BitcoinRpc/BitcoindRpc/`
1 parent eb470d2 commit a7d86ce

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

tests/common/mod.rs

Lines changed: 2 additions & 37 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

@@ -245,7 +244,7 @@ type TestNode = Node;
245244
#[derive(Clone)]
246245
pub(crate) enum TestChainSource<'a> {
247246
Esplora(&'a ElectrsD),
248-
BitcoinRpc(&'a BitcoinD),
247+
BitcoindRpc(&'a BitcoinD),
249248
}
250249

251250
macro_rules! setup_builder {
@@ -294,7 +293,7 @@ pub(crate) fn setup_node(chain_source: &TestChainSource, config: Config) -> Test
294293
sync_config.lightning_wallet_sync_interval_secs = 100000;
295294
builder.set_chain_source_esplora(esplora_url.clone(), Some(sync_config));
296295
},
297-
TestChainSource::BitcoinRpc(bitcoind) => {
296+
TestChainSource::BitcoindRpc(bitcoind) => {
298297
let rpc_host = bitcoind.params.rpc_socket.ip().to_string();
299298
let rpc_port = bitcoind.params.rpc_socket.port();
300299
let values = bitcoind.params.get_cookie_values().unwrap().unwrap();
@@ -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: 4 additions & 5 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;
@@ -21,7 +21,7 @@ use ldk_node::{Builder, Event, NodeError};
2121
use lightning::ln::channelmanager::PaymentId;
2222
use lightning::util::persist::KVStore;
2323

24-
use bitcoin::{Amount, Network};
24+
use bitcoin::Amount;
2525

2626
use std::sync::Arc;
2727

@@ -36,8 +36,7 @@ fn channel_full_cycle() {
3636
#[test]
3737
fn channel_full_cycle_bitcoind() {
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::BitcoindRpc(&bitcoind);
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
}

0 commit comments

Comments
 (0)