@@ -70,55 +70,41 @@ fn get_block_header_verbose() { // verbose = true
7070 assert ! ( json. into_model( ) . is_ok( ) ) ;
7171}
7272
73- #[ cfg( not( any( feature = "v18" , feature = " v19", feature = "v20" , feature = "v21" , feature = "v22" , feature = "v23" , feature = "v24" ) ) ) ]
73+ #[ cfg( not( any( feature = "v19" , feature = "v20" , feature = "v21" , feature = "v22" , feature = "v23" , feature = "v24" ) ) ) ]
7474// `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
7575// (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
7676// allowing to.
7777#[ test]
7878fn get_block_stats ( ) {
79- get_block_stats_by_height ( ) ;
80- get_block_stats_by_hash ( ) ;
79+ // Version 18 cannot getblockstats if -txindex is not enabled.
80+ #[ cfg( not( feature = "v18" ) ) ]
81+ getblockstats ( ) ;
82+
83+ // All non-feature gated versions including 18 can getblockstats if -txindex is enabled.
84+ getblockstats_txindex ( ) ;
8185}
8286
8387#[ cfg( not( any( feature = "v18" , feature = "v19" , feature = "v20" , feature = "v21" , feature = "v22" , feature = "v23" , feature = "v24" ) ) ) ]
84- // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
85- // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
86- // allowing to.
87- fn get_block_stats_by_height ( ) {
88- let node = Node :: new_no_wallet ( ) ;
89- let json = node. client . get_block_stats_by_height ( 0 ) . expect ( "getblockstats" ) ;
88+ fn getblockstats ( ) {
89+ let node = Node :: new_with_default_wallet ( ) ;
90+ node. mine_a_block ( ) ;
91+
92+ let json = node. client . get_block_stats_by_height ( 1 ) . expect ( "getblockstats" ) ;
9093 assert ! ( json. into_model( ) . is_ok( ) ) ;
91- }
9294
93- #[ cfg( not( any( feature = "v18" , feature = "v19" , feature = "v20" , feature = "v21" , feature = "v22" , feature = "v23" , feature = "v24" ) ) ) ]
94- // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
95- // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
96- // allowing to.
97- fn get_block_stats_by_hash ( ) { // verbose = true
98- let node = Node :: new_no_wallet ( ) ;
9995 let block_hash = best_block_hash ( ) ;
10096 let json = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
10197 assert ! ( json. into_model( ) . is_ok( ) ) ;
10298}
10399
104100#[ cfg( not( any( feature = "v19" , feature = "v20" , feature = "v21" , feature = "v22" , feature = "v23" , feature = "v24" ) ) ) ]
105- // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
106- // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
107- // allowing to.
108- #[ test]
109- fn get_block_stats_by_height_txindex ( ) {
110- let node = Node :: new_no_wallet_txindex ( ) ;
111- let json = node. client . get_block_stats_by_height ( 0 ) . expect ( "getblockstats" ) ;
101+ fn getblockstats_txindex ( ) {
102+ let node = Node :: new_with_default_wallet_txindex ( ) ;
103+ node. mine_a_block ( ) ;
104+
105+ let json = node. client . get_block_stats_by_height ( 1 ) . expect ( "getblockstats" ) ;
112106 assert ! ( json. into_model( ) . is_ok( ) ) ;
113- }
114107
115- #[ cfg( not( any( feature = "v19" , feature = "v20" , feature = "v21" , feature = "v22" , feature = "v23" , feature = "v24" ) ) ) ]
116- // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
117- // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
118- // allowing to.
119- #[ test]
120- fn get_block_stats_by_hash_txindex ( ) { // verbose = true
121- let node = Node :: new_no_wallet_txindex ( ) ;
122108 let block_hash = best_block_hash ( ) ;
123109 let json = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
124110 assert ! ( json. into_model( ) . is_ok( ) ) ;
0 commit comments