@@ -503,6 +503,60 @@ mod test {
503503 assert ! ( tx_status. block_time. is_none( ) ) ;
504504 }
505505
506+ #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
507+ #[ tokio:: test]
508+ async fn test_get_tx_info ( ) {
509+ let ( blocking_client, async_client) = setup_clients ( ) . await ;
510+
511+ let address = BITCOIND
512+ . client
513+ . get_new_address ( Some ( "test" ) , Some ( AddressType :: Legacy ) )
514+ . unwrap ( )
515+ . assume_checked ( ) ;
516+ let txid = BITCOIND
517+ . client
518+ . send_to_address (
519+ & address,
520+ Amount :: from_sat ( 1000 ) ,
521+ None ,
522+ None ,
523+ None ,
524+ None ,
525+ None ,
526+ None ,
527+ )
528+ . unwrap ( ) ;
529+ let _miner = MINER . lock ( ) . await ;
530+ generate_blocks_and_wait ( 1 ) ;
531+
532+ let tx_res = BITCOIND . client . get_transaction ( & txid, None ) . unwrap ( ) ;
533+ let tx_exp = tx_res. transaction ( ) . expect ( "must decode" ) ;
534+
535+ let tx_info = blocking_client
536+ . get_tx_info ( & txid)
537+ . unwrap ( )
538+ . expect ( "must get tx" ) ;
539+ let tx_info_async = async_client
540+ . get_tx_info ( & txid)
541+ . await
542+ . unwrap ( )
543+ . expect ( "must get tx" ) ;
544+ assert_eq ! ( tx_info, tx_info_async) ;
545+ assert_eq ! ( tx_info. txid, txid) ;
546+ assert_eq ! ( tx_info. to_tx( ) , tx_exp) ;
547+ assert_eq ! ( tx_info. size, tx_exp. total_size( ) ) ;
548+ assert_eq ! ( tx_info. weight( ) , tx_exp. weight( ) ) ;
549+ assert_eq ! ( tx_info. fee( ) , tx_res. fee. unwrap( ) . unsigned_abs( ) ) ;
550+ assert ! ( tx_info. status. confirmed) ;
551+ assert_eq ! ( tx_info. status. block_height, tx_res. info. blockheight) ;
552+ assert_eq ! ( tx_info. status. block_hash, tx_res. info. blockhash) ;
553+ assert_eq ! ( tx_info. status. block_time, tx_res. info. blocktime) ;
554+
555+ let txid = Txid :: hash ( b"not exist" ) ;
556+ assert_eq ! ( blocking_client. get_tx_info( & txid) . unwrap( ) , None ) ;
557+ assert_eq ! ( async_client. get_tx_info( & txid) . await . unwrap( ) , None ) ;
558+ }
559+
506560 #[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
507561 #[ tokio:: test]
508562 async fn test_get_header_by_hash ( ) {
0 commit comments