@@ -35,6 +35,7 @@ use ldk_node::config::{
3535use ldk_node:: entropy:: { generate_entropy_mnemonic, NodeEntropy } ;
3636use ldk_node:: io:: sqlite_store:: SqliteStore ;
3737use ldk_node:: payment:: { PaymentDirection , PaymentKind , PaymentStatus } ;
38+ use ldk_node:: probing:: ProbingConfig ;
3839use ldk_node:: {
3940 Builder , ChannelShutdownState , CustomTlvRecord , Event , LightningBalance , Node , NodeError ,
4041 PendingSweepBalance , UserChannelId ,
@@ -318,9 +319,9 @@ pub(crate) fn random_config(anchor_channels: bool) -> TestConfig {
318319}
319320
320321#[ cfg( feature = "uniffi" ) ]
321- type TestNode = Arc < Node > ;
322+ pub ( crate ) type TestNode = Arc < Node > ;
322323#[ cfg( not( feature = "uniffi" ) ) ]
323- type TestNode = Node ;
324+ pub ( crate ) type TestNode = Node ;
324325
325326#[ derive( Clone ) ]
326327pub ( crate ) enum TestChainSource < ' a > {
@@ -350,6 +351,7 @@ pub(crate) struct TestConfig {
350351 pub node_entropy : NodeEntropy ,
351352 pub async_payments_role : Option < AsyncPaymentsRole > ,
352353 pub recovery_mode : bool ,
354+ pub probing : Option < ProbingConfig > ,
353355}
354356
355357impl Default for TestConfig {
@@ -369,6 +371,7 @@ impl Default for TestConfig {
369371 node_entropy,
370372 async_payments_role,
371373 recovery_mode,
374+ probing : None ,
372375 }
373376 }
374377}
@@ -501,6 +504,10 @@ pub(crate) fn setup_node(chain_source: &TestChainSource, config: TestConfig) ->
501504 builder. set_wallet_recovery_mode ( ) ;
502505 }
503506
507+ if let Some ( probing) = config. probing {
508+ builder. set_probing_config ( probing. into ( ) ) ;
509+ }
510+
504511 let node = match config. store_type {
505512 TestStoreType :: TestSyncStore => {
506513 let kv_store = TestSyncStore :: new ( config. node_config . storage_dir_path . into ( ) ) ;
@@ -728,12 +735,18 @@ pub async fn open_channel(
728735 node_a : & TestNode , node_b : & TestNode , funding_amount_sat : u64 , should_announce : bool ,
729736 electrsd : & ElectrsD ,
730737) -> OutPoint {
731- open_channel_push_amt ( node_a, node_b, funding_amount_sat, None , should_announce, electrsd) . await
738+ let funding_txo =
739+ open_channel_no_wait ( node_a, node_b, funding_amount_sat, None , should_announce) . await ;
740+ wait_for_tx ( & electrsd. client , funding_txo. txid ) . await ;
741+ funding_txo
732742}
733743
734- pub async fn open_channel_push_amt (
744+ /// Like [`open_channel`] but skips the `wait_for_tx` electrum check so that
745+ /// multiple channels can be opened back-to-back before any blocks are mined.
746+ /// The caller is responsible for mining blocks and confirming the funding txs.
747+ pub async fn open_channel_no_wait (
735748 node_a : & TestNode , node_b : & TestNode , funding_amount_sat : u64 , push_amount_msat : Option < u64 > ,
736- should_announce : bool , electrsd : & ElectrsD ,
749+ should_announce : bool ,
737750) -> OutPoint {
738751 if should_announce {
739752 node_a
@@ -761,11 +774,20 @@ pub async fn open_channel_push_amt(
761774 let funding_txo_a = expect_channel_pending_event ! ( node_a, node_b. node_id( ) ) ;
762775 let funding_txo_b = expect_channel_pending_event ! ( node_b, node_a. node_id( ) ) ;
763776 assert_eq ! ( funding_txo_a, funding_txo_b) ;
764- wait_for_tx ( & electrsd. client , funding_txo_a. txid ) . await ;
765-
766777 funding_txo_a
767778}
768779
780+ pub async fn open_channel_push_amt (
781+ node_a : & TestNode , node_b : & TestNode , funding_amount_sat : u64 , push_amount_msat : Option < u64 > ,
782+ should_announce : bool , electrsd : & ElectrsD ,
783+ ) -> OutPoint {
784+ let funding_txo =
785+ open_channel_no_wait ( node_a, node_b, funding_amount_sat, push_amount_msat, should_announce)
786+ . await ;
787+ wait_for_tx ( & electrsd. client , funding_txo. txid ) . await ;
788+ funding_txo
789+ }
790+
769791pub async fn open_channel_with_all (
770792 node_a : & TestNode , node_b : & TestNode , should_announce : bool , electrsd : & ElectrsD ,
771793) -> OutPoint {
0 commit comments