File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -681,7 +681,7 @@ fn ln_transfers() {
681
681
println ! ( "\n 7. broadcast old PSBT" ) ;
682
682
let tx = wlt_1. sign_finalize ( & mut old_psbt) ;
683
683
wlt_1. broadcast_tx ( & tx) ;
684
- mine ( false ) ;
684
+ wlt_1 . mine_tx ( & tx . txid ( ) , false ) ;
685
685
wlt_1. sync ( ) ;
686
686
wlt_1. update_witnesses ( pre_funding_height) ;
687
687
let mut wlt_3 = get_wallet ( & DescriptorType :: Wpkh ) ;
@@ -714,8 +714,8 @@ fn mainnet_wlt_receiving_test_asset() {
714
714
wlt_2. close_method ( ) ,
715
715
InvoiceType :: Blinded ( Some ( utxo) ) ,
716
716
) ;
717
- let ( consignment, _ ) = wlt_1. transfer ( invoice. clone ( ) , None , Some ( 500 ) ) ;
718
- mine ( false ) ;
717
+ let ( consignment, tx ) = wlt_1. transfer ( invoice. clone ( ) , None , Some ( 500 ) ) ;
718
+ wlt_1 . mine_tx ( & tx . txid ( ) , false ) ;
719
719
match consignment. validate ( & wlt_2. get_resolver ( ) , wlt_2. testnet ( ) ) {
720
720
Err ( ( status, _invalid_consignment) ) => {
721
721
assert_eq ! (
Original file line number Diff line number Diff line change @@ -578,6 +578,17 @@ impl TestWallet {
578
578
}
579
579
}
580
580
581
+ pub fn get_tx_height ( & self , txid : & Txid ) -> Option < u32 > {
582
+ match self
583
+ . get_resolver ( )
584
+ . resolve_pub_witness_ord ( XWitnessId :: Bitcoin ( * txid) )
585
+ . unwrap ( )
586
+ {
587
+ WitnessOrd :: Mined ( witness_pos) => Some ( witness_pos. height ( ) . get ( ) ) ,
588
+ _ => None ,
589
+ }
590
+ }
591
+
581
592
pub fn sync ( & mut self ) {
582
593
let indexer = self . get_indexer ( ) ;
583
594
self . wallet
@@ -591,6 +602,20 @@ impl TestWallet {
591
602
self . wallet . wallet ( ) . seal_close_method ( )
592
603
}
593
604
605
+ pub fn mine_tx ( & self , txid : & Txid , resume : bool ) {
606
+ let mut attempts = 10 ;
607
+ loop {
608
+ mine ( resume) ;
609
+ if self . get_tx_height ( txid) . is_some ( ) {
610
+ break ;
611
+ }
612
+ attempts -= 1 ;
613
+ if attempts == 0 {
614
+ panic ! ( "TX is not getting mined" ) ;
615
+ }
616
+ }
617
+ }
618
+
594
619
pub fn issue_with_info (
595
620
& mut self ,
596
621
asset_info : AssetInfo ,
@@ -926,7 +951,7 @@ impl TestWallet {
926
951
fee : Option < u64 > ,
927
952
) -> ( Transfer , Tx ) {
928
953
let ( consignment, tx) = self . transfer ( invoice, sats, fee) ;
929
- mine ( false ) ;
954
+ self . mine_tx ( & tx . txid ( ) , false ) ;
930
955
recv_wlt. accept_transfer ( consignment. clone ( ) ) ;
931
956
self . sync ( ) ;
932
957
( consignment, tx)
You can’t perform that action at this time.
0 commit comments