Skip to content

Commit 145b682

Browse files
Merge rust-bitcoin/corepc#197: Update integration test feature gating
e9196806c87897bab2847911b21546f69323cd8f Update integration test feature gating (Jamil Lambert, PhD) Pull request description: Change the version feature gates to be that version and below to make feature gating the tests easier. Closes #195 ACKs for top commit: tcharding: ACK e9196806c87897bab2847911b21546f69323cd8f Tree-SHA512: af757de1adbc638c35e920057b5fd099488d3264f1a716beadabd6c16b1db8104f83a2f7bed74a646b67d3919b9b827170cdd7488c676ca4a24e4d37c45a0851
2 parents 2b2b6c8 + 81abf04 commit 145b682

7 files changed

Lines changed: 61 additions & 160 deletions

File tree

integration_test/Cargo.toml

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,41 @@ download = ["node/download"]
1515

1616
# Enable the same feature in `node` and the version feature here.
1717
# All minor releases of the latest three versions.
18-
29_0 = ["v29", "node/29_0"]
19-
28_1 = ["v28", "node/28_1"]
20-
28_0 = ["v28", "node/28_0"]
21-
27_2 = ["v27", "node/27_2"]
22-
27_1 = ["v27", "node/27_1"]
23-
27_0 = ["v27", "node/27_0"]
18+
29_0 = ["v29_and_below", "node/29_0"]
19+
28_1 = ["v28_and_below", "node/28_1"]
20+
28_0 = ["v28_and_below", "node/28_0"]
21+
27_2 = ["v27_and_below", "node/27_2"]
22+
27_1 = ["v27_and_below", "node/27_1"]
23+
27_0 = ["v27_and_below", "node/27_0"]
2424
# Only the latest minor version for older versions.
25-
26_2 = ["v26", "node/26_2"]
26-
25_2 = ["v25", "node/25_2"]
27-
24_2 = ["v24", "node/24_2"]
28-
23_2 = ["v23", "node/23_2"]
29-
22_1 = ["v22", "node/22_1"]
30-
0_21_2 = ["v21", "node/0_21_2"]
31-
0_20_2 = ["v20", "node/0_20_2"]
32-
0_19_1 = ["v19", "node/0_19_1"]
33-
0_18_1 = ["v18", "node/0_18_1"]
25+
26_2 = ["v26_and_below", "node/26_2"]
26+
25_2 = ["v25_and_below", "node/25_2"]
27+
24_2 = ["v24_and_below", "node/24_2"]
28+
23_2 = ["v23_and_below", "node/23_2"]
29+
22_1 = ["v22_and_below", "node/22_1"]
30+
0_21_2 = ["v21_and_below", "node/0_21_2"]
31+
0_20_2 = ["v20_and_below", "node/0_20_2"]
32+
0_19_1 = ["v19_and_below", "node/0_19_1"]
33+
0_18_1 = ["v18_and_below", "node/0_18_1"]
3434
0_17_2 = ["v17", "node/0_17_2"]
3535

3636
# These features are just for internal use (feature gating).
3737
# Each major version is tested with the same client.
38-
v29 = []
39-
v28 = []
40-
v27 = []
41-
v26 = []
42-
v25 = []
43-
v24 = []
44-
v23 = []
45-
v22 = []
46-
v21 = []
47-
v20 = []
48-
v19 = []
49-
v18 = []
50-
v17 = []
38+
# A specific range of versions can be specified e.g. for 24-26:
39+
# #[cfg(all(feature = "v26_and_below", not(feature = "v23_and_below")))]
40+
v29_and_below = []
41+
v28_and_below = ["v29_and_below"]
42+
v27_and_below = ["v28_and_below"]
43+
v26_and_below = ["v27_and_below"]
44+
v25_and_below = ["v26_and_below"]
45+
v24_and_below = ["v25_and_below"]
46+
v23_and_below = ["v24_and_below"]
47+
v22_and_below = ["v23_and_below"]
48+
v21_and_below = ["v22_and_below"]
49+
v20_and_below = ["v21_and_below"]
50+
v19_and_below = ["v20_and_below"]
51+
v18_and_below = ["v19_and_below"]
52+
v17 = ["v18_and_below"]
5153

5254
TODO = [] # This is a dirty hack while writing the tests.
5355

integration_test/tests/blockchain.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ fn blockchain__get_block_count__modelled() {
5454
}
5555

5656
#[test]
57-
#[cfg(not(feature = "v17"))]
58-
#[cfg(not(feature = "v18"))]
57+
#[cfg(not(feature = "v18_and_below"))]
5958
fn blockchain__get_block_filter__modelled() {
6059
let node = Node::with_wallet(Wallet::Default, &["-blockfilterindex"]);
6160
node.mine_a_block();
@@ -93,15 +92,15 @@ fn blockchain__get_block_header__modelled() {
9392

9493
#[test]
9594
fn blockchain__get_block_stats__modelled() {
96-
// Version 18 cannot call `getblockstats` if `-txindex` is not enabled.
97-
#[cfg(not(feature = "v18"))]
95+
// Version 17 and 18 cannot call `getblockstats` if `-txindex` is not enabled.
96+
#[cfg(not(feature = "v18_and_below"))]
9897
getblockstats();
9998

100-
// All versions including 18 can `getblockstats` if `-txindex` is enabled.
99+
// All versions including 17 and 18 can `getblockstats` if `-txindex` is enabled.
101100
getblockstats_txindex();
102101
}
103102

104-
#[cfg(not(feature = "v18"))]
103+
#[cfg(not(feature = "v18_and_below"))]
105104
fn getblockstats() {
106105
let node = Node::with_wallet(Wallet::Default, &[]);
107106
node.fund_wallet();
@@ -149,7 +148,7 @@ fn blockchain__get_chain_tx_stats__modelled() {
149148
}
150149

151150
#[test]
152-
#[cfg(feature = "v29")]
151+
#[cfg(not(feature = "v28_and_below"))]
153152
fn blockchain__get_descriptor_activity__modelled() {
154153
let node = Node::with_wallet(Wallet::None, &["-coinstatsindex=1", "-txindex=1"]);
155154

@@ -292,26 +291,12 @@ fn blockchain__savemempool() {
292291
node.fund_wallet();
293292
let (_addr, _txid) = node.create_mempool_transaction();
294293

295-
#[cfg(any(
296-
feature = "v17",
297-
feature = "v18",
298-
feature = "v19",
299-
feature = "v20",
300-
feature = "v21",
301-
feature = "v22",
302-
))]
294+
#[cfg(feature = "v22_and_below")]
303295
{
304296
node.client.save_mempool().expect("savemempool");
305297
}
306298

307-
#[cfg(not(any(
308-
feature = "v17",
309-
feature = "v18",
310-
feature = "v19",
311-
feature = "v20",
312-
feature = "v21",
313-
feature = "v22",
314-
)))]
299+
#[cfg(not(feature = "v22_and_below"))]
315300
{
316301
let _: Result<SaveMempool, _> = node.client.save_mempool();
317302
}

integration_test/tests/generating.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ use node::mtype;
1010

1111
#[test]
1212
// The `generate` method was deprecated in Core v18 and was removed in v19.
13-
#[cfg(all(
14-
feature = "v17",
15-
not(feature = "v18") // We just need one `not` so that --all-features builds.
16-
))]
13+
#[cfg(feature = "v17")]
1714
fn generating__generate__modelled() {
1815
const NBLOCKS: usize = 10;
1916
let node = Node::with_wallet(Wallet::Default, &[]);

integration_test/tests/mining.rs

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ fn mining__get_block_template__modelled() {
2020
node3.mine_a_block();
2121

2222
let options = match () {
23-
#[cfg(not(feature = "v29"))]
23+
#[cfg(feature = "v28_and_below")]
2424
() => TemplateRequest { rules: vec![TemplateRules::Segwit] },
25-
#[cfg(feature = "v29")]
25+
#[cfg(not(feature = "v28_and_below"))]
2626
() => TemplateRequest {
2727
rules: vec![TemplateRules::Segwit],
2828
mode: Some("template".to_string()),
@@ -41,38 +41,12 @@ fn mining__get_mining_info() {
4141

4242
let json: GetMiningInfo = node.client.get_mining_info().expect("rpc");
4343

44-
// Upto v9 there is no error converting into model.
45-
#[cfg(any(
46-
feature = "v17",
47-
feature = "v18",
48-
feature = "v19",
49-
feature = "v20",
50-
feature = "v21",
51-
feature = "v22",
52-
feature = "v23",
53-
feature = "v24",
54-
feature = "v25",
55-
feature = "v26",
56-
feature = "v27",
57-
feature = "v28",
58-
))]
44+
// Up to v28 (i.e., not 29_0) there is no error converting into model.
45+
#[cfg(feature = "v28_and_below")]
5946
let _: mtype::GetMiningInfo = json.into_model();
6047

61-
// v29 onwards - these feature gates are shit, we need a better way to do this.
62-
#[cfg(not(any(
63-
feature = "v17",
64-
feature = "v18",
65-
feature = "v19",
66-
feature = "v20",
67-
feature = "v21",
68-
feature = "v22",
69-
feature = "v23",
70-
feature = "v24",
71-
feature = "v25",
72-
feature = "v26",
73-
feature = "v27",
74-
feature = "v28",
75-
)))]
48+
// v29 onwards
49+
#[cfg(not(feature = "v28_and_below"))]
7650
{
7751
let model: Result<mtype::GetMiningInfo, GetMiningInfoError> = json.into_model();
7852
model.unwrap();
@@ -88,17 +62,7 @@ fn mining__get_network_hash_ps() {
8862

8963
#[test]
9064
// Core version 26 onwards.
91-
#[cfg(all(
92-
not(feature = "v17"),
93-
not(feature = "v18"),
94-
not(feature = "v19"),
95-
not(feature = "v20"),
96-
not(feature = "v21"),
97-
not(feature = "v22"),
98-
not(feature = "v23"),
99-
not(feature = "v24"),
100-
not(feature = "v25"),
101-
))]
65+
#[cfg(not(feature = "v25_and_below"))]
10266
fn mining__get_prioritised_transactions() {
10367
let node = Node::with_wallet(Wallet::Default, &[]);
10468
node.fund_wallet();

integration_test/tests/network.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,15 @@ use node::{AddNodeCommand, mtype};
1212
fn network__add_node() {
1313
let dummy_peer = "192.0.2.1:8333";
1414

15-
#[cfg(not(any(
16-
feature = "v26",
17-
feature = "v27",
18-
feature = "v28",
19-
feature = "v29",
20-
)))]
15+
#[cfg(feature = "v25_and_below")]
2116
{
2217
let node = Node::with_wallet(Wallet::None, &[]);
2318
node.client.add_node(dummy_peer, AddNodeCommand::OneTry).expect("addnode onetry");
2419
node.client.add_node(dummy_peer, AddNodeCommand::Add).expect("addnode add");
2520
node.client.add_node(dummy_peer, AddNodeCommand::Remove).expect("addnode remove");
2621
}
2722

28-
#[cfg(any(
29-
feature = "v26",
30-
feature = "v27",
31-
feature = "v28",
32-
feature = "v29",
33-
))]
23+
#[cfg(not(feature = "v25_and_below"))]
3424
{
3525
let node = Node::with_wallet(Wallet::None, &["-v2transport"]);
3626
node.client.add_node(dummy_peer, AddNodeCommand::OneTry).expect("addnode onetry");

integration_test/tests/raw_transactions.rs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,10 @@ fn raw_transactions__decode_psbt__modelled() {
169169
let decoded = res.expect("DecodePsbt into model");
170170

171171
// Before Core v23 global xpubs was not a known keypair.
172-
#[cfg(feature = "v17")]
173-
#[cfg(feature = "v22")]
172+
#[cfg(feature = "v22_and_below")]
174173
assert_eq!(decoded.psbt.unknown.len(), 1);
175174

176-
#[cfg(feature = "v23")]
175+
#[cfg(not(feature = "v22_and_below"))]
177176
assert_eq!(decoded.psbt.xpub.len(), 1);
178177

179178
// TODO: Add a taproot field and test it with v24
@@ -360,14 +359,7 @@ fn raw_transactions__sign_raw_transaction__modelled() {
360359

361360
// TODO: Work out how to test things without using dumpprivkey.
362361
#[test]
363-
#[cfg(any(
364-
feature = "v17",
365-
feature = "v18",
366-
feature = "v19",
367-
feature = "v20",
368-
feature = "v21",
369-
feature = "v22",
370-
))] // In v23 dumpprivkey no longer works.
362+
#[cfg(feature = "v22_and_below")] // In v23 dumpprivkey no longer works.
371363
fn raw_transactions__sign_raw_transaction_with_key__modelled() {
372364
let node = Node::with_wallet(Wallet::Default, &["-txindex"]);
373365
node.fund_wallet();
@@ -376,7 +368,7 @@ fn raw_transactions__sign_raw_transaction_with_key__modelled() {
376368

377369
// FIXME: Doesn't work for v26 for some reason.
378370
#[test]
379-
#[cfg(all(feature = "v27", not(feature = "v28")))]
371+
#[cfg(all(feature = "v27_and_below", not(feature = "v26_and_below")))]
380372
fn raw_transactions__submit_package__modelled() {
381373
let node = Node::with_wallet(Wallet::Default, &["-txindex"]);
382374

@@ -404,7 +396,7 @@ fn raw_transactions__submit_package__modelled() {
404396

405397
// In Core v28 submitpackage has additional optional features.
406398
#[test]
407-
#[cfg(all(not(feature = "v27"), feature = "v28"))]
399+
#[cfg(not(feature = "v27_and_below"))]
408400
fn raw_transactions__submit_package__modelled() {
409401
let node = Node::with_wallet(Wallet::Default, &["-txindex"]);
410402

@@ -499,14 +491,7 @@ fn create_sign_send(node: &Node) {
499491
// - send_raw_transaction
500492
//
501493
// TODO: Work out how to get a private key without using `dumpprivkey`.
502-
#[cfg(any(
503-
feature = "v17",
504-
feature = "v18",
505-
feature = "v19",
506-
feature = "v20",
507-
feature = "v21",
508-
feature = "v22",
509-
))] // In v23 dumpprivkey no longer works.
494+
#[cfg(feature = "v22_and_below")] // In v23 dumpprivkey no longer works.
510495
fn create_sign_with_key_send(node: &Node) {
511496
let (addr, _tx, txid, tx_out, vout) = create_utxo(node);
512497

integration_test/tests/wallet.rs

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ fn wallet__create_wallet__modelled() {
5858
fn wallet__dump_priv_key__modelled() {
5959
// As of Core v23 the default wallet is an native descriptor wallet which does not
6060
// support dumping private keys. Legacy wallets are supported upto v25 it seems.
61-
#[cfg(any(
62-
feature = "v23",
63-
feature = "v24",
64-
feature = "v25",
65-
))]
61+
#[cfg(all(feature = "v25_and_below", not(feature = "v22_and_below")))]
6662
{
6763
let node = Node::with_wallet(Wallet::None, &[]);
6864

@@ -75,14 +71,7 @@ fn wallet__dump_priv_key__modelled() {
7571
model.unwrap();
7672
}
7773

78-
#[cfg(any(
79-
feature = "v17",
80-
feature = "v18",
81-
feature = "v19",
82-
feature = "v20",
83-
feature = "v21",
84-
feature = "v22",
85-
))]
74+
#[cfg(feature = "v22_and_below")]
8675
{
8776
let node = Node::with_wallet(Wallet::Default, &[]);
8877
let address = node.client.new_address().expect("failed to get new address");
@@ -97,11 +86,7 @@ fn wallet__dump_priv_key__modelled() {
9786
fn wallet__dump_wallet() {
9887
// As of Core v23 the default wallet is an native descriptor wallet which does not
9988
// support dumping private keys. Legacy wallets are supported upto v25 it seems.
100-
#[cfg(any(
101-
feature = "v23",
102-
feature = "v24",
103-
feature = "v25",
104-
))]
89+
#[cfg(all(feature = "v25_and_below", not(feature = "v22_and_below")))]
10590
{
10691
let node = Node::with_wallet(Wallet::None, &[]);
10792

@@ -111,14 +96,7 @@ fn wallet__dump_wallet() {
11196
let _: DumpWallet = node.client.dump_wallet(&out).expect("dumpwallet");
11297
}
11398

114-
#[cfg(any(
115-
feature = "v17",
116-
feature = "v18",
117-
feature = "v19",
118-
feature = "v20",
119-
feature = "v21",
120-
feature = "v22",
121-
))]
99+
#[cfg(feature = "v22_and_below")]
122100
{
123101
let node = Node::with_wallet(Wallet::Default, &[]);
124102
let out = integration_test::random_tmp_file();
@@ -169,7 +147,7 @@ fn wallet__get_balance__modelled() {
169147
}
170148

171149
#[test]
172-
#[cfg(all(not(feature = "v17"), not(feature = "v18")))]
150+
#[cfg(not(feature = "v18_and_below"))]
173151
fn wallet__get_balances() {
174152
let node = Node::with_wallet(Wallet::Default, &[]);
175153
node.fund_wallet();
@@ -287,11 +265,11 @@ fn create_load_unload_wallet() {
287265
node.client.create_wallet(&wallet).expect("failed to create wallet");
288266

289267
// Upto version 20 Core returns null for `unloadwallet`.
290-
#[cfg(any(feature = "v17", feature = "v18", feature = "v19", feature = "v20"))]
268+
#[cfg(feature = "v20_and_below")]
291269
let _ = node.client.unload_wallet(&wallet).expect("unloadwallet");
292270

293271
// From version 21 Core returns warnings for `unloadwallet`.
294-
#[cfg(all(not(feature = "v17"), not(feature = "v18"), not(feature = "v19"), not(feature = "v20")))]
272+
#[cfg(not(feature = "v20_and_below"))]
295273
{
296274
let json: UnloadWallet = node.client.unload_wallet(&wallet).expect("unloadwallet");
297275
let _: mtype::UnloadWallet = json.into_model();

0 commit comments

Comments
 (0)