Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit 07d0f1e

Browse files
committed
WIP: Add support for Bitcoin Core v28
Add support and testing for Bitcoin Core versions `28.0`
1 parent ad04577 commit 07d0f1e

File tree

14 files changed

+515
-18
lines changed

14 files changed

+515
-18
lines changed

.github/workflows/rust.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ jobs:
178178
matrix:
179179
feature:
180180
[
181+
"28_0",
181182
"27_1",
182183
"27_0",
183184
"26_2",

client/src/client_sync/v28.rs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! A JSON-RPC client for testing against Bitcoin Core `v27`.
4+
//!
5+
//! We ignore option arguments unless they effect the shape of the returned JSON data.
6+
7+
use bitcoin::address::{Address, NetworkChecked};
8+
use bitcoin::{Amount, Block, BlockHash, Txid};
9+
10+
use crate::client_sync::{handle_defaults, into_json};
11+
use crate::json::v28::*;
12+
13+
crate::define_jsonrpc_minreq_client!("v27");
14+
15+
// == Blockchain ==
16+
crate::impl_client_v17__getblockchaininfo!();
17+
crate::impl_client_v17__getbestblockhash!();
18+
crate::impl_client_v17__getblock!();
19+
crate::impl_client_v17__gettxout!();
20+
21+
// == Control ==
22+
crate::impl_client_v17__stop!();
23+
24+
// == Generating ==
25+
crate::impl_client_v17__generatetoaddress!();
26+
27+
// == Network ==
28+
crate::impl_client_v17__getnetworkinfo!();
29+
crate::impl_client_check_expected_server_version!({ [270000, 270100] });
30+
31+
// == Rawtransactions ==
32+
crate::impl_client_v17__sendrawtransaction!();
33+
34+
// == Wallet ==
35+
crate::impl_client_v17__createwallet!();
36+
crate::impl_client_v22__unloadwallet!();
37+
crate::impl_client_v22__loadwallet!();
38+
crate::impl_client_v17__getbalance!();
39+
crate::impl_client_v19__getbalances!();
40+
crate::impl_client_v17__getnewaddress!();
41+
crate::impl_client_v17__sendtoaddress!();
42+
crate::impl_client_v17__gettransaction!();
43+
44+
pub use crate::client_sync::v23::AddressType;

contrib/run_bitcoind.sh

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ COMMAND
2323
- stop Kill all bitcoind nodes using 'pkill bitcoind'.
2424
2525
KNOWN_VERSION
26+
- v28 Bitcoin Core v28.0
2627
- v27 Bitcoin Core v27.1
2728
- v26 Bitcoin Core v26.2
2829
- v25 Bitcoin Core v25.2
@@ -49,6 +50,7 @@ main() {
4950

5051
case $cmd in
5152
all)
53+
start "v28" # 28.0
5254
start "v27" # 27.1
5355
start "v26" # 26.2
5456
start "v25" # 25.2
@@ -84,6 +86,11 @@ start() {
8486
local version="$1"
8587

8688
case $version in
89+
v28)
90+
local version_number="28.0"
91+
local version_id="280"
92+
;;
93+
8794
v27)
8895
local version_number="27.1"
8996
local version_id="271"

integration_test/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ edition = "2021"
1313
[features]
1414
# Enable the same feature in `bitcoind` and the version feature here.
1515
# All minor releases (but only the latest patch release).
16+
"28_0" = ["v28", "bitcoind/28_0"]
1617
"27_1" = ["v27", "bitcoind/27_1"]
1718
"27_0" = ["v27", "bitcoind/27_0"]
1819
"26_2" = ["v26", "bitcoind/26_2"]
@@ -37,6 +38,7 @@ edition = "2021"
3738
"0_17_1" = ["v17", "bitcoind/0_17_1"]
3839

3940
# Each minor version is tested with the same client.
41+
"v28" = []
4042
"v27" = []
4143
"v26" = []
4244
"v25" = []

integration_test/tests/v28_api.rs

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//! Test the JSON-RPC API against `bitcoind v28.0`.
2+
3+
#![cfg(feature = "v28")]
4+
5+
use integration_test::*;
6+
7+
// == Blockchain ==
8+
mod blockchain {
9+
use super::*;
10+
11+
impl_test_v17__getblockchaininfo!();
12+
impl_test_v17__getbestblockhash!();
13+
impl_test_v17__getblock_verbosity_0!();
14+
impl_test_v17__getblock_verbosity_1!();
15+
}
16+
17+
// == Control ==
18+
mod control {
19+
use super::*;
20+
21+
impl_test_v17__stop!();
22+
}
23+
24+
// == Generating ==
25+
mod generating {
26+
use super::*;
27+
28+
impl_test_v17__generatetoaddress!();
29+
}
30+
31+
// == Network ==
32+
mod network {
33+
use super::*;
34+
35+
impl_test_v17__getnetworkinfo!();
36+
}
37+
38+
// == Rawtransactions ==
39+
mod raw_transactions {
40+
use super::*;
41+
42+
impl_test_v17__sendrawtransaction!();
43+
}
44+
45+
// == Wallet ==
46+
mod wallet {
47+
use super::*;
48+
49+
impl_test_v17__createwallet!();
50+
impl_test_v17__loadwallet!();
51+
52+
impl_test_v17__getnewaddress!();
53+
impl_test_v17__getbalance!();
54+
impl_test_v19__getbalances!();
55+
impl_test_v17__sendtoaddress!();
56+
impl_test_v17__gettransaction!();
57+
}

json/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub mod v24;
1919
pub mod v25;
2020
pub mod v26;
2121
pub mod v27;
22+
pub mod v28;
2223

2324
// JSON types that model _all_ `bitcoind` versions.
2425
pub mod model;

json/src/v17/blockchain.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ impl fmt::Display for GetBlockchainInfoError {
201201

202202
match *self {
203203
Chain(ref e) => write_err!(f, "conversion of the `chain` field failed"; e),
204-
BestBlockHash(ref e) =>
205-
write_err!(f, "conversion of the `best_block_hash` field failed"; e),
204+
BestBlockHash(ref e) => {
205+
write_err!(f, "conversion of the `best_block_hash` field failed"; e)
206+
}
206207
ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e),
207208
}
208209
}
@@ -369,10 +370,12 @@ impl fmt::Display for GetBlockVerbosityOneError {
369370
Tx(ref e) => write_err!(f, "conversion of the `tx` field failed"; e),
370371
Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e),
371372
ChainWork(ref e) => write_err!(f, "conversion of the `chain_ork` field failed"; e),
372-
PreviousBlockHash(ref e) =>
373-
write_err!(f, "conversion of the `previous_block_hash` field failed"; e),
374-
NextBlockHash(ref e) =>
375-
write_err!(f, "conversion of the `next_block_hash` field failed"; e),
373+
PreviousBlockHash(ref e) => {
374+
write_err!(f, "conversion of the `previous_block_hash` field failed"; e)
375+
}
376+
NextBlockHash(ref e) => {
377+
write_err!(f, "conversion of the `next_block_hash` field failed"; e)
378+
}
376379
}
377380
}
378381
}
@@ -481,8 +484,9 @@ impl fmt::Display for GetTxOutError {
481484
match *self {
482485
BestBlock(ref e) => write_err!(f, "conversion of the `best_block` field failed"; e),
483486
Value(ref e) => write_err!(f, "conversion of the `value` field failed"; e),
484-
ScriptPubkey(ref e) =>
485-
write_err!(f, "conversion of the `script_pubkey` field failed"; e),
487+
ScriptPubkey(ref e) => {
488+
write_err!(f, "conversion of the `script_pubkey` field failed"; e)
489+
}
486490
Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e),
487491
}
488492
}

json/src/v17/network.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ impl fmt::Display for GetNetworkInfoError {
155155

156156
match *self {
157157
RelayFee(ref e) => write_err!(f, "conversion of the `relay_fee` field failed"; e),
158-
IncrementalFee(ref e) =>
159-
write_err!(f, "conversion of the `incremental_fee` field failed"; e),
158+
IncrementalFee(ref e) => {
159+
write_err!(f, "conversion of the `incremental_fee` field failed"; e)
160+
}
160161
}
161162
}
162163
}

0 commit comments

Comments
 (0)