@@ -267,7 +267,7 @@ mod test {
267
267
use tokio:: sync:: Mutex ;
268
268
#[ cfg( all( feature = "blocking" , feature = "async" ) ) ]
269
269
use {
270
- bitcoin:: { consensus , hashes:: Hash , Amount } ,
270
+ bitcoin:: { hashes:: Hash , Amount } ,
271
271
corepc_node:: AddressType ,
272
272
electrsd:: electrum_client:: ElectrumApi ,
273
273
std:: time:: Duration ,
@@ -535,9 +535,20 @@ mod test {
535
535
let _miner = MINER . lock ( ) . await ;
536
536
generate_blocks_and_wait ( 1 ) ;
537
537
538
- let height: Option < u32 > = BITCOIND . client . get_block_count ( ) . unwrap ( ) . 0 . try_into ( ) . ok ( ) ;
539
- let tx_res = BITCOIND . client . get_transaction ( txid) . unwrap ( ) ;
540
- let tx_exp: Transaction = consensus:: encode:: deserialize_hex ( & tx_res. hex ) . unwrap ( ) ;
538
+ let tx_res = BITCOIND
539
+ . client
540
+ . get_transaction ( txid)
541
+ . unwrap ( )
542
+ . into_model ( )
543
+ . unwrap ( ) ;
544
+ let tx_exp: Transaction = tx_res. tx ;
545
+ let tx_block_height = BITCOIND
546
+ . client
547
+ . get_block_header_verbose ( & tx_res. block_hash . unwrap ( ) )
548
+ . unwrap ( )
549
+ . into_model ( )
550
+ . unwrap ( )
551
+ . height ;
541
552
542
553
let tx_info = blocking_client
543
554
. get_tx_info ( & txid)
@@ -553,21 +564,15 @@ mod test {
553
564
assert_eq ! ( tx_info. to_tx( ) , tx_exp) ;
554
565
assert_eq ! ( tx_info. size, tx_exp. total_size( ) ) ;
555
566
assert_eq ! ( tx_info. weight( ) , tx_exp. weight( ) ) ;
556
- assert_eq ! (
557
- tx_info. fee( ) ,
558
- tx_res
559
- . fee
560
- . map( |fee| Amount :: from_btc( fee. abs( ) ) . unwrap( ) )
561
- . unwrap( )
562
- ) ;
567
+ assert_eq ! ( tx_info. fee( ) , tx_res. fee. unwrap( ) . unsigned_abs( ) ) ;
563
568
assert ! ( tx_info. status. confirmed) ;
564
569
// TODO(corepc): No .block_height field on GetTransaction ?
565
- assert_eq ! ( tx_info. status. block_height, height) ;
570
+ assert_eq ! ( tx_info. status. block_height, Some ( tx_block_height) ) ;
571
+ assert_eq ! ( tx_info. status. block_hash, tx_res. block_hash) ;
566
572
assert_eq ! (
567
- tx_info. status. block_hash . map ( |hash| hash . to_string ( ) ) ,
568
- tx_res. block_hash
573
+ tx_info. status. block_time ,
574
+ tx_res. block_time . map ( |bt| bt as u64 )
569
575
) ;
570
- assert ! ( tx_info. status. block_time >= Some ( tx_res. time as u64 ) ) ;
571
576
572
577
let txid = Txid :: hash ( b"not exist" ) ;
573
578
assert_eq ! ( blocking_client. get_tx_info( & txid) . unwrap( ) , None ) ;
@@ -583,8 +588,7 @@ mod test {
583
588
. client
584
589
. get_block_hash ( 23 )
585
590
. unwrap ( )
586
- . 0
587
- . parse ( )
591
+ . block_hash ( )
588
592
. unwrap ( ) ;
589
593
590
594
let block_header = blocking_client. get_header_by_hash ( & block_hash) . unwrap ( ) ;
@@ -601,15 +605,13 @@ mod test {
601
605
. client
602
606
. get_block_hash ( 21 )
603
607
. unwrap ( )
604
- . 0
605
- . parse ( )
608
+ . block_hash ( )
606
609
. unwrap ( ) ;
607
610
let next_block_hash = BITCOIND
608
611
. client
609
612
. get_block_hash ( 22 )
610
613
. unwrap ( )
611
- . 0
612
- . parse ( )
614
+ . block_hash ( )
613
615
. unwrap ( ) ;
614
616
615
617
let expected = BlockStatus {
@@ -658,8 +660,7 @@ mod test {
658
660
. client
659
661
. get_block_hash ( 21 )
660
662
. unwrap ( )
661
- . 0
662
- . parse ( )
663
+ . block_hash ( )
663
664
. unwrap ( ) ;
664
665
665
666
let expected = Some ( BITCOIND . client . get_block ( block_hash) . unwrap ( ) ) ;
@@ -835,8 +836,7 @@ mod test {
835
836
. client
836
837
. get_block_hash ( 21 )
837
838
. unwrap ( )
838
- . 0
839
- . parse :: < BlockHash > ( )
839
+ . block_hash ( )
840
840
. unwrap ( ) ;
841
841
842
842
let block_hash_blocking = blocking_client. get_block_hash ( 21 ) . unwrap ( ) ;
@@ -854,8 +854,7 @@ mod test {
854
854
. client
855
855
. get_block_hash ( 23 )
856
856
. unwrap ( )
857
- . 0
858
- . parse ( )
857
+ . block_hash ( )
859
858
. unwrap ( ) ;
860
859
861
860
let txid_at_block_index = blocking_client
@@ -897,8 +896,13 @@ mod test {
897
896
let _miner = MINER . lock ( ) . await ;
898
897
generate_blocks_and_wait ( 1 ) ;
899
898
900
- let get_tx = BITCOIND . client . get_transaction ( txid) . unwrap ( ) ;
901
- let expected_tx: Transaction = consensus:: encode:: deserialize_hex ( & get_tx. hex ) . unwrap ( ) ;
899
+ let expected_tx = BITCOIND
900
+ . client
901
+ . get_transaction ( txid)
902
+ . unwrap ( )
903
+ . into_model ( )
904
+ . unwrap ( )
905
+ . tx ;
902
906
let script = & expected_tx. output [ 0 ] . script_pubkey ;
903
907
let scripthash_txs_txids: Vec < Txid > = blocking_client
904
908
. scripthash_txs ( script, None )
0 commit comments