Skip to content

Commit 86b07a3

Browse files
committed
Test getblockstats for all versions
I was confused by `getblockstats` not working and thought it did not work for version 19-24 however there was a bug in a helper function that meant we always tried to get block stats for the genesis block and this does not work for these versions. That bug has been fixed, now we can test and set the status of `getblockstats` for all versions.
1 parent 0a06f68 commit 86b07a3

File tree

11 files changed

+13
-19
lines changed

11 files changed

+13
-19
lines changed

integration_test/tests/blockchain.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ fn get_block_header_verbose() { // verbose = true
6464
assert!(json.into_model().is_ok());
6565
}
6666

67-
#[cfg(not(any(feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
68-
// `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
69-
// (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
70-
// allowing to.
7167
#[test]
7268
fn get_block_stats() {
7369
// Version 18 cannot getblockstats if -txindex is not enabled.
@@ -78,10 +74,9 @@ fn get_block_stats() {
7874
getblockstats_txindex();
7975
}
8076

81-
#[cfg(not(any(feature = "v18", feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
8277
fn getblockstats() {
8378
let node = Node::new_with_default_wallet();
84-
node.mine_a_block();
79+
node.fund_wallet();
8580

8681
let json = node.client.get_block_stats_by_height(1).expect("getblockstats");
8782
assert!(json.into_model().is_ok());
@@ -91,12 +86,11 @@ fn getblockstats() {
9186
assert!(json.into_model().is_ok());
9287
}
9388

94-
#[cfg(not(any(feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
9589
fn getblockstats_txindex() {
9690
let node = Node::new_with_default_wallet_txindex();
97-
node.mine_a_block();
91+
node.fund_wallet();
9892

99-
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");
10094
assert!(json.into_model().is_ok());
10195

10296
let block_hash = node.client.best_block_hash().expect("best_block_hash failed");

types/src/v19/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! | getblockfilter | todo |
2525
//! | getblockhash | done |
2626
//! | getblockheader | done |
27-
//! | getblockstats | done (untested) |
27+
//! | getblockstats | done |
2828
//! | getchaintips | done |
2929
//! | getchaintxstats | done |
3030
//! | getdifficulty | done |

types/src/v20/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! | getblockfilter | todo |
2525
//! | getblockhash | done |
2626
//! | getblockheader | done |
27-
//! | getblockstats | done (untested) |
27+
//! | getblockstats | done |
2828
//! | getchaintips | done |
2929
//! | getchaintxstats | done |
3030
//! | getdifficulty | done |

types/src/v21/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! | getblockfilter | todo |
2525
//! | getblockhash | done |
2626
//! | getblockheader | done |
27-
//! | getblockstats | done (untested) |
27+
//! | getblockstats | done |
2828
//! | getchaintips | done |
2929
//! | getchaintxstats | done |
3030
//! | getdifficulty | done |

types/src/v22/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! | getblockfilter | todo |
2525
//! | getblockhash | done |
2626
//! | getblockheader | done |
27-
//! | getblockstats | done (untested) |
27+
//! | getblockstats | done |
2828
//! | getchaintips | done |
2929
//! | getchaintxstats | done |
3030
//! | getdifficulty | done |

types/src/v23/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//! | getblockfrompeer | todo |
2626
//! | getblockhash | done |
2727
//! | getblockheader | done |
28-
//! | getblockstats | done (untested) |
28+
//! | getblockstats | done |
2929
//! | getchaintips | done |
3030
//! | getchaintxstats | done |
3131
//! | getdeploymentinfo | todo |

types/src/v24/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//! | getblockfrompeer | todo |
2626
//! | getblockhash | done |
2727
//! | getblockheader | done |
28-
//! | getblockstats | done (untested) |
28+
//! | getblockstats | done |
2929
//! | getchaintips | done |
3030
//! | getchaintxstats | done |
3131
//! | getdeploymentinfo | todo |

types/src/v25/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//! | getblockfrompeer | todo |
2626
//! | getblockhash | done |
2727
//! | getblockheader | done |
28-
//! | getblockstats | done (untested) |
28+
//! | getblockstats | done |
2929
//! | getchaintips | done |
3030
//! | getchaintxstats | done |
3131
//! | getdeploymentinfo | todo |

types/src/v26/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
//! | getblockfrompeer | todo |
2727
//! | getblockhash | done |
2828
//! | getblockheader | done |
29-
//! | getblockstats | done (untested) |
29+
//! | getblockstats | done |
3030
//! | getchainstates | todo |
3131
//! | getchaintips | done |
3232
//! | getchaintxstats | done |

types/src/v27/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
//! | getblockfrompeer | todo |
2727
//! | getblockhash | done |
2828
//! | getblockheader | done |
29-
//! | getblockstats | done (untested) |
29+
//! | getblockstats | done |
3030
//! | getchainstates | todo |
3131
//! | getchaintips | done |
3232
//! | getchaintxstats | done |

0 commit comments

Comments
 (0)