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 @@ -579,6 +579,17 @@ impl TestWallet {
579
579
}
580
580
}
581
581
582
+ pub fn get_tx_height ( & self , txid : & Txid ) -> Option < u32 > {
583
+ match self
584
+ . get_resolver ( )
585
+ . resolve_pub_witness_ord ( XWitnessId :: Bitcoin ( * txid) )
586
+ . unwrap ( )
587
+ {
588
+ WitnessOrd :: Mined ( witness_pos) => Some ( witness_pos. height ( ) . get ( ) ) ,
589
+ _ => None ,
590
+ }
591
+ }
592
+
582
593
pub fn sync ( & mut self ) {
583
594
let indexer = self . get_indexer ( ) ;
584
595
self . wallet
@@ -592,6 +603,20 @@ impl TestWallet {
592
603
self . wallet . wallet ( ) . seal_close_method ( )
593
604
}
594
605
606
+ pub fn mine_tx ( & self , txid : & Txid , resume : bool ) {
607
+ let mut attempts = 10 ;
608
+ loop {
609
+ mine ( resume) ;
610
+ if self . get_tx_height ( txid) . is_some ( ) {
611
+ break ;
612
+ }
613
+ attempts -= 1 ;
614
+ if attempts == 0 {
615
+ panic ! ( "TX is not getting mined" ) ;
616
+ }
617
+ }
618
+ }
619
+
595
620
pub fn issue_with_info (
596
621
& mut self ,
597
622
asset_info : AssetInfo ,
@@ -927,7 +952,7 @@ impl TestWallet {
927
952
fee : Option < u64 > ,
928
953
) -> ( Transfer , Tx ) {
929
954
let ( consignment, tx) = self . transfer ( invoice, sats, fee) ;
930
- mine ( false ) ;
955
+ self . mine_tx ( & tx . txid ( ) , false ) ;
931
956
recv_wlt. accept_transfer ( consignment. clone ( ) ) ;
932
957
self . sync ( ) ;
933
958
( consignment, tx)
You can’t perform that action at this time.
0 commit comments