44
55use integration_test:: { Node , NodeExt as _} ;
66
7- // FIXME: Do we need this?
8- fn best_block_hash ( ) -> bitcoin:: BlockHash {
9- let node = Node :: new_no_wallet ( ) ;
10- node. client . best_block_hash ( ) . expect ( "best_block_hash failed" )
11- }
12-
137#[ test]
148fn get_blockchain_info ( ) {
159 let node = Node :: new_no_wallet ( ) ;
@@ -27,7 +21,7 @@ fn get_best_block_hash() {
2721#[ test]
2822fn get_block ( ) {
2923 let node = Node :: new_no_wallet ( ) ;
30- let block_hash = best_block_hash ( ) ;
24+ let block_hash = node . client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
3125
3226 let json = node. client . get_block_verbose_zero ( block_hash) . expect ( "getblock verbose=0" ) ;
3327 assert ! ( json. into_model( ) . is_ok( ) ) ;
@@ -57,23 +51,19 @@ fn get_block_hash() {
5751#[ test]
5852fn get_block_header ( ) { // verbose = false
5953 let node = Node :: new_no_wallet ( ) ;
60- let block_hash = best_block_hash ( ) ;
54+ let block_hash = node . client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
6155 let json = node. client . get_block_header ( & block_hash) . expect ( "getblockheader" ) ;
6256 assert ! ( json. into_model( ) . is_ok( ) ) ;
6357}
6458
6559#[ test]
6660fn get_block_header_verbose ( ) { // verbose = true
6761 let node = Node :: new_no_wallet ( ) ;
68- let block_hash = best_block_hash ( ) ;
62+ let block_hash = node . client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
6963 let json = node. client . get_block_header_verbose ( & block_hash) . expect ( "getblockheader" ) ;
7064 assert ! ( json. into_model( ) . is_ok( ) ) ;
7165}
7266
73- #[ cfg( not( any( feature = "v19" , feature = "v20" , feature = "v21" , feature = "v22" , feature = "v23" , feature = "v24" ) ) ) ]
74- // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
75- // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
76- // allowing to.
7767#[ test]
7868fn get_block_stats ( ) {
7969 // Version 18 cannot getblockstats if -txindex is not enabled.
@@ -84,28 +74,26 @@ fn get_block_stats() {
8474 getblockstats_txindex ( ) ;
8575}
8676
87- #[ cfg( not( any( feature = "v18" , feature = "v19" , feature = "v20" , feature = "v21" , feature = "v22" , feature = "v23" , feature = "v24" ) ) ) ]
8877fn getblockstats ( ) {
8978 let node = Node :: new_with_default_wallet ( ) ;
90- node. mine_a_block ( ) ;
79+ node. fund_wallet ( ) ;
9180
9281 let json = node. client . get_block_stats_by_height ( 1 ) . expect ( "getblockstats" ) ;
9382 assert ! ( json. into_model( ) . is_ok( ) ) ;
9483
95- let block_hash = best_block_hash ( ) ;
84+ let block_hash = node . client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
9685 let json = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
9786 assert ! ( json. into_model( ) . is_ok( ) ) ;
9887}
9988
100- #[ cfg( not( any( feature = "v19" , feature = "v20" , feature = "v21" , feature = "v22" , feature = "v23" , feature = "v24" ) ) ) ]
10189fn getblockstats_txindex ( ) {
10290 let node = Node :: new_with_default_wallet_txindex ( ) ;
103- node. mine_a_block ( ) ;
91+ node. fund_wallet ( ) ;
10492
105- let json = node. client . get_block_stats_by_height ( 1 ) . expect ( "getblockstats" ) ;
93+ let json = node. client . get_block_stats_by_height ( 101 ) . expect ( "getblockstats" ) ;
10694 assert ! ( json. into_model( ) . is_ok( ) ) ;
10795
108- let block_hash = best_block_hash ( ) ;
96+ let block_hash = node . client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
10997 let json = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
11098 assert ! ( json. into_model( ) . is_ok( ) ) ;
11199}
@@ -234,7 +222,7 @@ fn get_tx_out_set_info() {
234222fn precious_block ( ) {
235223 let node = Node :: new_with_default_wallet ( ) ;
236224 node. mine_a_block ( ) ;
237- let hash = node. client . best_block_hash ( ) . expect ( "bestblockhash " ) ;
225+ let hash = node. client . best_block_hash ( ) . expect ( "best_block_hash failed " ) ;
238226 node. mine_a_block ( ) ;
239227
240228 let _ = node. client . precious_block ( hash) . expect ( "preciousblock" ) ;
0 commit comments