From 830a05abee061af27638b146296ac8a3af2e849d Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 9 Apr 2025 11:12:28 +1000 Subject: [PATCH] Overhaul integration testing It has been a while since I started this project and in that time the testing strategy has evolved. Overhaul the integration tests: - Use new strategy of using explicit types (vtype, mtype, and error type) so that the integration tests ensure we re-exported things correctly. - Remove a bunch of feature gating, thereby improving test coverage. - A few other little things along the way. This patch is neigh on impossible to review with any confidence - as is typical in this lib. --- client/src/client_sync/v17/blockchain.rs | 10 +- client/src/client_sync/v17/generating.rs | 7 +- client/src/client_sync/v17/wallet.rs | 28 +-- client/src/client_sync/v19/mod.rs | 5 +- client/src/client_sync/v20.rs | 4 +- client/src/client_sync/v21/mod.rs | 4 +- client/src/client_sync/v22/mod.rs | 4 +- client/src/client_sync/{v23.rs => v23/mod.rs} | 8 +- client/src/client_sync/v23/wallet.rs | 58 +++++ client/src/client_sync/v24.rs | 6 +- client/src/client_sync/v25.rs | 6 +- client/src/client_sync/v26/mod.rs | 6 +- client/src/client_sync/v27.rs | 6 +- client/src/client_sync/v28/mod.rs | 6 +- integration_test/Cargo.toml | 1 - integration_test/tests/blockchain.rs | 225 ++++++++++-------- integration_test/tests/control.rs | 29 +-- integration_test/tests/generating.rs | 39 ++- integration_test/tests/mining.rs | 32 +-- integration_test/tests/network.rs | 23 +- integration_test/tests/raw_transactions.rs | 16 +- integration_test/tests/wallet.rs | 223 ++++++++++------- node/src/client_versions.rs | 34 +-- node/src/lib.rs | 16 +- types/src/model/blockchain.rs | 4 +- types/src/model/mod.rs | 2 +- types/src/v17/blockchain/error.rs | 14 +- types/src/v17/blockchain/into.rs | 14 +- types/src/v17/blockchain/mod.rs | 5 +- types/src/v17/mod.rs | 2 +- types/src/v18/mod.rs | 33 +-- types/src/v19/mod.rs | 20 +- types/src/v20/mod.rs | 40 ++-- types/src/v21/mod.rs | 40 ++-- types/src/v22/mod.rs | 29 ++- types/src/v23/mod.rs | 29 ++- types/src/v24/mod.rs | 29 ++- types/src/v25/mod.rs | 29 ++- types/src/v26/mod.rs | 23 +- types/src/v27/mod.rs | 23 +- types/src/v28/mod.rs | 33 +-- verify/src/main.rs | 15 +- verify/src/method/v17.rs | 13 +- verify/src/method/v18.rs | 2 +- verify/src/method/v19.rs | 4 +- verify/src/method/v20.rs | 2 +- verify/src/method/v21.rs | 2 +- verify/src/method/v22.rs | 2 +- verify/src/method/v23.rs | 2 +- verify/src/method/v24.rs | 2 +- verify/src/method/v25.rs | 2 +- verify/src/method/v26.rs | 2 +- verify/src/method/v27.rs | 2 +- verify/src/method/v28.rs | 2 +- 54 files changed, 726 insertions(+), 491 deletions(-) rename client/src/client_sync/{v23.rs => v23/mod.rs} (95%) create mode 100644 client/src/client_sync/v23/wallet.rs diff --git a/client/src/client_sync/v17/blockchain.rs b/client/src/client_sync/v17/blockchain.rs index 1a273cdf..45393c43 100644 --- a/client/src/client_sync/v17/blockchain.rs +++ b/client/src/client_sync/v17/blockchain.rs @@ -51,12 +51,12 @@ macro_rules! impl_client_v17__getblock { } /// Gets a block by blockhash with verbose set to 0. - pub fn get_block_verbose_zero(&self, hash: BlockHash) -> Result { + pub fn get_block_verbose_zero(&self, hash: BlockHash) -> Result { self.call("getblock", &[into_json(hash)?, 0.into()]) } /// Gets a block by blockhash with verbose set to 1. - pub fn get_block_verbose_one(&self, hash: BlockHash) -> Result { + pub fn get_block_verbose_one(&self, hash: BlockHash) -> Result { self.call("getblock", &[into_json(hash)?, 1.into()]) } } @@ -279,7 +279,11 @@ macro_rules! impl_client_v17__preciousblock { () => { impl Client { pub fn precious_block(&self, hash: BlockHash) -> Result<()> { - self.call("preciousblock", &[into_json(hash)?]) + match self.call("preciousblock", &[into_json(hash)?]) { + Ok(serde_json::Value::Null) => Ok(()), + Ok(res) => Err(Error::Returned(res.to_string())), + Err(err) => Err(err.into()), + } } } }; diff --git a/client/src/client_sync/v17/generating.rs b/client/src/client_sync/v17/generating.rs index c33b9360..0b0399c6 100644 --- a/client/src/client_sync/v17/generating.rs +++ b/client/src/client_sync/v17/generating.rs @@ -38,12 +38,17 @@ macro_rules! impl_client_v17__generate { } /// Implements Bitcoin Core JSON-RPC API method `invalidateblock` +// This method does not appear in the output of `bitcoin-cli help`. #[macro_export] macro_rules! impl_client_v17__invalidateblock { () => { impl Client { pub fn invalidate_block(&self, hash: BlockHash) -> Result<()> { - self.call("invalidateblock", &[into_json(hash)?]) + match self.call("invalidateblock", &[into_json(hash)?]) { + Ok(serde_json::Value::Null) => Ok(()), + Ok(res) => Err(Error::Returned(res.to_string())), + Err(err) => Err(err.into()), + } } } }; diff --git a/client/src/client_sync/v17/wallet.rs b/client/src/client_sync/v17/wallet.rs index a633cbd6..ce8f6093 100644 --- a/client/src/client_sync/v17/wallet.rs +++ b/client/src/client_sync/v17/wallet.rs @@ -9,7 +9,7 @@ //! //! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. -/// Implements Bitcoin Core JSON-RPC API method `createwallet`. +/// Implements Bitcoin Core JSON-RPC API method `addmultisigaddress`. #[macro_export] macro_rules! impl_client_v17__addmultisigaddress { () => { @@ -123,24 +123,16 @@ macro_rules! impl_client_v17__getnewaddress { impl Client { /// Gets a new address from `bitcoind` and parses it assuming its correct. pub fn new_address(&self) -> Result { - use core::str::FromStr; - let json = self.get_new_address(None, None)?; - let address = bitcoin::Address::from_str(&json.0) - .expect("assume the address is valid") - .assume_checked(); // Assume bitcoind will return an valid address for the network its on. - Ok(address) + let model = json.into_model().unwrap(); + Ok(model.0.assume_checked()) } /// Gets a new address from `bitcoind` and parses it assuming its correct. pub fn new_address_with_type(&self, ty: AddressType) -> Result { - use core::str::FromStr; - let json = self.get_new_address(None, Some(ty))?; - let address = bitcoin::Address::from_str(&json.0) - .expect("assume the address is valid") - .assume_checked(); // Assume bitcoind will return an valid address for the network its on. - Ok(address) + let model = json.into_model().unwrap(); + Ok(model.0.assume_checked()) } /// Gets a new address with label from `bitcoind` and parses it assuming its correct. @@ -149,15 +141,13 @@ macro_rules! impl_client_v17__getnewaddress { &self, label: &str, ) -> Result> { - use core::str::FromStr; - let json = self.get_new_address(Some(label), None)?; - let address = - bitcoin::Address::from_str(&json.0).expect("assume the address is valid"); - Ok(address) + let model = json.into_model().unwrap(); + Ok(model.0) } - fn get_new_address( + /// Gets a new address - low level RPC call. + pub fn get_new_address( &self, label: Option<&str>, ty: Option, diff --git a/client/src/client_sync/v19/mod.rs b/client/src/client_sync/v19/mod.rs index 1824e3e3..5c2ed9d9 100644 --- a/client/src/client_sync/v19/mod.rs +++ b/client/src/client_sync/v19/mod.rs @@ -20,6 +20,7 @@ use crate::types::v19::*; pub use crate::client_sync::{v17::AddressType, WalletCreateFundedPsbtInput}; crate::define_jsonrpc_minreq_client!("v19"); +crate::impl_client_check_expected_server_version!({ [190100] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -64,8 +65,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [190100] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == @@ -82,6 +84,7 @@ crate::impl_client_v17__dumpwallet!(); crate::impl_client_v17__getaddressesbylabel!(); crate::impl_client_v17__getaddressinfo!(); crate::impl_client_v17__getbalance!(); +crate::impl_client_v19__getbalances!(); crate::impl_client_v17__getnewaddress!(); crate::impl_client_v17__getrawchangeaddress!(); crate::impl_client_v17__getreceivedbyaddress!(); diff --git a/client/src/client_sync/v20.rs b/client/src/client_sync/v20.rs index c793a498..488ea744 100644 --- a/client/src/client_sync/v20.rs +++ b/client/src/client_sync/v20.rs @@ -17,6 +17,7 @@ use crate::types::v20::*; pub use crate::client_sync::{v17::AddressType, WalletCreateFundedPsbtInput}; crate::define_jsonrpc_minreq_client!("v20"); +crate::impl_client_check_expected_server_version!({ [200200] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -61,8 +62,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [200200] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == diff --git a/client/src/client_sync/v21/mod.rs b/client/src/client_sync/v21/mod.rs index c64b3375..6c1bd42a 100644 --- a/client/src/client_sync/v21/mod.rs +++ b/client/src/client_sync/v21/mod.rs @@ -19,6 +19,7 @@ use crate::types::v21::*; pub use crate::client_sync::{v17::AddressType, WalletCreateFundedPsbtInput}; crate::define_jsonrpc_minreq_client!("v21"); +crate::impl_client_check_expected_server_version!({ [210200] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -63,8 +64,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [210200] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == diff --git a/client/src/client_sync/v22/mod.rs b/client/src/client_sync/v22/mod.rs index e46003c5..3ad79a4b 100644 --- a/client/src/client_sync/v22/mod.rs +++ b/client/src/client_sync/v22/mod.rs @@ -20,6 +20,7 @@ use crate::types::v22::*; pub use crate::client_sync::{v17::AddressType, WalletCreateFundedPsbtInput}; crate::define_jsonrpc_minreq_client!("v22"); +crate::impl_client_check_expected_server_version!({ [220100] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -64,8 +65,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [220000, 220100] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == diff --git a/client/src/client_sync/v23.rs b/client/src/client_sync/v23/mod.rs similarity index 95% rename from client/src/client_sync/v23.rs rename to client/src/client_sync/v23/mod.rs index 1731c8ca..f500d8c0 100644 --- a/client/src/client_sync/v23.rs +++ b/client/src/client_sync/v23/mod.rs @@ -4,6 +4,8 @@ //! //! We ignore option arguments unless they effect the shape of the returned JSON data. +pub mod wallet; + use std::collections::BTreeMap; use std::path::Path; @@ -18,6 +20,7 @@ use crate::types::v23::*; pub use crate::client_sync::WalletCreateFundedPsbtInput; crate::define_jsonrpc_minreq_client!("v23"); +crate::impl_client_check_expected_server_version!({ [230200] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -62,8 +65,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [230000, 230100, 230200] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == @@ -74,7 +78,7 @@ crate::impl_client_v17__sendrawtransaction!(); // == Wallet == crate::impl_client_v17__addmultisigaddress!(); crate::impl_client_v17__bumpfee!(); -crate::impl_client_v17__createwallet!(); +crate::impl_client_v23__createwallet!(); crate::impl_client_v17__dumpprivkey!(); crate::impl_client_v17__dumpwallet!(); crate::impl_client_v17__getaddressesbylabel!(); diff --git a/client/src/client_sync/v23/wallet.rs b/client/src/client_sync/v23/wallet.rs new file mode 100644 index 00000000..b9a59075 --- /dev/null +++ b/client/src/client_sync/v23/wallet.rs @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods on a client. +//! +//! Specifically this is methods found under the `== Wallet ==` section of the +//! API docs of Bitcoin Core `v23`. +//! +//! All macros require `Client` to be in scope. +//! +//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. + +/// Implements Bitcoin Core JSON-RPC API method `createwallet`. +#[macro_export] +macro_rules! impl_client_v23__createwallet { + () => { + impl Client { + /// Calls `createwallet` with `wallet` as the only argument. + pub fn create_wallet(&self, wallet: &str) -> Result { + self.call("createwallet", &[wallet.into()]) + } + + /// Creates a legacy wallet (i.e not a native descriptor wallet). + /// + /// > createwallet "wallet_name" ( disable_private_keys blank "passphrase" avoid_reuse descriptors load_on_startup external_signer ) + /// > + /// > Creates and loads a new wallet. + /// > + /// > Arguments: + /// > 1. wallet_name (string, required) The name for the new wallet. If this is a path, the wallet will be created at the path location. + /// > 2. disable_private_keys (boolean, optional, default=false) Disable the possibility of private keys (only watchonlys are possible in this mode). + /// > 3. blank (boolean, optional, default=false) Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed. + /// > 4. passphrase (string, optional) Encrypt the wallet with this passphrase. + /// > 5. avoid_reuse (boolean, optional, default=false) Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind. + /// > 6. descriptors (boolean, optional, default=true) Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation + /// > 7. load_on_startup (boolean, optional) Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged. + /// > 8. external_signer (boolean, optional, default=false) Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true. + pub fn create_legacy_wallet(&self, wallet: &str) -> Result { + let disable_private_keys = false; + let blank = false; + let passphrase = String::new(); + let avoid_reuse = false; + let descriptors = false; + + self.call( + "createwallet", + &[ + wallet.into(), + disable_private_keys.into(), + blank.into(), + passphrase.into(), + avoid_reuse.into(), + descriptors.into(), + ], + ) + } + } + }; +} diff --git a/client/src/client_sync/v24.rs b/client/src/client_sync/v24.rs index e52bd120..026583a0 100644 --- a/client/src/client_sync/v24.rs +++ b/client/src/client_sync/v24.rs @@ -17,6 +17,7 @@ use crate::types::v24::*; pub use crate::client_sync::{v23::AddressType, WalletCreateFundedPsbtInput}; crate::define_jsonrpc_minreq_client!("v24"); +crate::impl_client_check_expected_server_version!({ [240200] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -61,8 +62,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [240001, 240100, 240200] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == @@ -73,7 +75,7 @@ crate::impl_client_v17__sendrawtransaction!(); // == Wallet == crate::impl_client_v17__addmultisigaddress!(); crate::impl_client_v17__bumpfee!(); -crate::impl_client_v17__createwallet!(); +crate::impl_client_v23__createwallet!(); crate::impl_client_v17__dumpprivkey!(); crate::impl_client_v17__dumpwallet!(); crate::impl_client_v17__getaddressesbylabel!(); diff --git a/client/src/client_sync/v25.rs b/client/src/client_sync/v25.rs index 2b2a37e5..f9e3cd6d 100644 --- a/client/src/client_sync/v25.rs +++ b/client/src/client_sync/v25.rs @@ -17,6 +17,7 @@ use crate::types::v25::*; pub use crate::client_sync::{v23::AddressType, WalletCreateFundedPsbtInput}; crate::define_jsonrpc_minreq_client!("v25"); +crate::impl_client_check_expected_server_version!({ [250200] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -61,8 +62,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [250000, 250100, 250200] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == @@ -73,7 +75,7 @@ crate::impl_client_v17__sendrawtransaction!(); // == Wallet == crate::impl_client_v17__addmultisigaddress!(); crate::impl_client_v17__bumpfee!(); -crate::impl_client_v17__createwallet!(); +crate::impl_client_v23__createwallet!(); crate::impl_client_v17__dumpprivkey!(); crate::impl_client_v17__dumpwallet!(); crate::impl_client_v17__getaddressesbylabel!(); diff --git a/client/src/client_sync/v26/mod.rs b/client/src/client_sync/v26/mod.rs index 8cb8ebcc..b0c5e2c0 100644 --- a/client/src/client_sync/v26/mod.rs +++ b/client/src/client_sync/v26/mod.rs @@ -20,6 +20,7 @@ use crate::types::v26::*; pub use crate::client_sync::{v23::AddressType, WalletCreateFundedPsbtInput}; crate::define_jsonrpc_minreq_client!("v26"); +crate::impl_client_check_expected_server_version!({ [260000, 260100, 260200] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -65,8 +66,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [260000, 260100, 260200] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == @@ -77,7 +79,7 @@ crate::impl_client_v17__sendrawtransaction!(); // == Wallet == crate::impl_client_v17__addmultisigaddress!(); crate::impl_client_v17__bumpfee!(); -crate::impl_client_v17__createwallet!(); +crate::impl_client_v23__createwallet!(); crate::impl_client_v17__dumpprivkey!(); crate::impl_client_v17__dumpwallet!(); crate::impl_client_v17__getaddressesbylabel!(); diff --git a/client/src/client_sync/v27.rs b/client/src/client_sync/v27.rs index 05e2cb6c..d9901e72 100644 --- a/client/src/client_sync/v27.rs +++ b/client/src/client_sync/v27.rs @@ -17,6 +17,7 @@ use crate::types::v27::*; pub use crate::client_sync::{v23::AddressType, WalletCreateFundedPsbtInput}; crate::define_jsonrpc_minreq_client!("v27"); +crate::impl_client_check_expected_server_version!({ [270000, 270100] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -62,8 +63,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [270000, 270100] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == @@ -74,7 +76,7 @@ crate::impl_client_v17__sendrawtransaction!(); // == Wallet == crate::impl_client_v17__addmultisigaddress!(); crate::impl_client_v17__bumpfee!(); -crate::impl_client_v17__createwallet!(); +crate::impl_client_v23__createwallet!(); crate::impl_client_v17__dumpprivkey!(); crate::impl_client_v17__dumpwallet!(); crate::impl_client_v17__getaddressesbylabel!(); diff --git a/client/src/client_sync/v28/mod.rs b/client/src/client_sync/v28/mod.rs index 97ec10b3..ce8ce37f 100644 --- a/client/src/client_sync/v28/mod.rs +++ b/client/src/client_sync/v28/mod.rs @@ -19,6 +19,7 @@ use crate::types::v28::*; pub use crate::client_sync::{v23::AddressType, WalletCreateFundedPsbtInput}; crate::define_jsonrpc_minreq_client!("v28"); +crate::impl_client_check_expected_server_version!({ [280000] }); // == Blockchain == crate::impl_client_v17__getbestblockhash!(); @@ -64,8 +65,9 @@ crate::impl_client_v17__prioritisetransaction!(); crate::impl_client_v17__submitblock!(); // == Network == +crate::impl_client_v17__getaddednodeinfo!(); +crate::impl_client_v17__getnettotals!(); crate::impl_client_v17__getnetworkinfo!(); -crate::impl_client_check_expected_server_version!({ [280000] }); crate::impl_client_v17__getpeerinfo!(); // == Rawtransactions == @@ -77,7 +79,7 @@ crate::impl_client_v28__submitpackage!(); // == Wallet == crate::impl_client_v17__addmultisigaddress!(); crate::impl_client_v17__bumpfee!(); -crate::impl_client_v17__createwallet!(); +crate::impl_client_v23__createwallet!(); crate::impl_client_v17__dumpprivkey!(); crate::impl_client_v17__dumpwallet!(); crate::impl_client_v17__getaddressesbylabel!(); diff --git a/integration_test/Cargo.toml b/integration_test/Cargo.toml index 65bbbd9a..84513892 100644 --- a/integration_test/Cargo.toml +++ b/integration_test/Cargo.toml @@ -50,7 +50,6 @@ TODO = [] # This is a dirty hack while writing the tests. [dependencies] bitcoin = { version = "0.32.0", default-features = false, features = ["std", "serde"] } -client = { package = "corepc-client", version = "0.7.0", default-features = false, features = ["client-sync"] } node = { package = "corepc-node", version = "0.7.0", default-features = false, features = ["download"] } rand = "0.8.5" env_logger = "0.9.0" diff --git a/integration_test/tests/blockchain.rs b/integration_test/tests/blockchain.rs index b640e78d..28c90bbf 100644 --- a/integration_test/tests/blockchain.rs +++ b/integration_test/tests/blockchain.rs @@ -2,32 +2,34 @@ //! Tests for methods found under the `== Blockchain ==` section of the API docs. +#![allow(non_snake_case)] // Test names intentionally use double underscore. + use integration_test::{Node, NodeExt as _, Wallet}; +use node::client::client_sync; +use node::vtype::*; // All the version specific types. +use node::mtype; #[test] -fn get_blockchain_info() { +fn blockchain__get_best_block_hash__modelled() { let node = Node::with_wallet(Wallet::None, &[]); - let json = node.client.get_blockchain_info().expect("getblockchaininfo"); - assert!(json.into_model().is_ok()); -} -#[test] -fn get_best_block_hash() { - let node = Node::with_wallet(Wallet::None, &[]); - let json = node.client.get_best_block_hash().expect("getbestblockhash"); - assert!(json.into_model().is_ok()); + let json = node.client.get_best_block_hash().expect("rpc"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn get_block() { +fn blockchain__get_block__modelled() { let node = Node::with_wallet(Wallet::None, &[]); let block_hash = node.client.best_block_hash().expect("best_block_hash failed"); - let json = node.client.get_block_verbose_zero(block_hash).expect("getblock verbose=0"); - assert!(json.into_model().is_ok()); + let json: GetBlockVerboseZero = node.client.get_block_verbose_zero(block_hash).expect("getblock verbose=0"); + let model: Result = json.into_model(); + model.expect("GetBlock into model"); - let json = node.client.get_block_verbose_one(block_hash).expect("getblock verbose=1"); - assert!(json.into_model().is_ok()); + let json: GetBlockVerboseOne = node.client.get_block_verbose_one(block_hash).expect("getblock verbose=1"); + let model: Result = json.into_model(); + model.expect("GetBlockVerbose into model"); // TODO: Test getblock 2 // let json = node.client.get_block_with_verbosity(block_hash, 2).expect("getblock verbosity 2"); @@ -35,56 +37,67 @@ fn get_block() { } #[test] -fn get_block_count() { +fn blockchain__get_blockchain_info__modelled() { + let node = Node::with_wallet(Wallet::None, &[]); + + let json: GetBlockchainInfo = node.client.get_blockchain_info().expect("rpc"); + let model: Result = json.into_model(); + model.unwrap(); +} + +#[test] +fn blockchain__get_block_count__modelled() { let node = Node::with_wallet(Wallet::None, &[]); - let json = node.client.get_block_count().expect("getblockcount"); - let _ = json.into_model(); + + let json: GetBlockCount = node.client.get_block_count().unwrap(); + let _: mtype::GetBlockCount = json.into_model(); } #[test] #[cfg(not(feature = "v17"))] #[cfg(not(feature = "v18"))] -fn get_block_filter() { +fn blockchain__get_block_filter__modelled() { let node = Node::with_wallet(Wallet::Default, &["-blockfilterindex"]); node.mine_a_block(); let hash = node.client.best_block_hash().expect("best_block_hash failed"); - let json = node.client.get_block_filter(hash).expect("getblockfilter"); - let _ = json.into_model(); + let json: GetBlockFilter = node.client.get_block_filter(hash).expect("getblockfilter"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn get_block_hash() { +fn blockchain__get_block_hash__modelled() { let node = Node::with_wallet(Wallet::None, &[]); - let json = node.client.get_block_hash(0).expect("getblockhash"); - assert!(json.into_model().is_ok()); + + let json: GetBlockHash = node.client.get_block_hash(0).expect("getblockhash"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn get_block_header() { - // verbose = false +fn blockchain__get_block_header__modelled() { let node = Node::with_wallet(Wallet::None, &[]); let block_hash = node.client.best_block_hash().expect("best_block_hash failed"); - let json = node.client.get_block_header(&block_hash).expect("getblockheader"); - assert!(json.into_model().is_ok()); -} -#[test] -fn get_block_header_verbose() { + // verbose = false + let json: GetBlockHeader = node.client.get_block_header(&block_hash).expect("getblockheader"); + let model: Result = json.into_model(); + model.unwrap(); + // verbose = true - let node = Node::with_wallet(Wallet::None, &[]); - let block_hash = node.client.best_block_hash().expect("best_block_hash failed"); - let json = node.client.get_block_header_verbose(&block_hash).expect("getblockheader"); - assert!(json.into_model().is_ok()); + let json:GetBlockHeaderVerbose = node.client.get_block_header_verbose(&block_hash).expect("getblockheader"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn get_block_stats() { - // Version 18 cannot getblockstats if -txindex is not enabled. +fn blockchain__get_block_stats__modelled() { + // Version 18 cannot call `getblockstats` if `-txindex` is not enabled. #[cfg(not(feature = "v18"))] getblockstats(); - // All non-feature gated versions including 18 can getblockstats if -txindex is enabled. + // All versions including 18 can `getblockstats` if `-txindex` is enabled. getblockstats_txindex(); } @@ -94,125 +107,131 @@ fn getblockstats() { node.fund_wallet(); let json = node.client.get_block_stats_by_height(1).expect("getblockstats"); - assert!(json.into_model().is_ok()); + json.into_model().unwrap(); + // No need for explicit types, used explicitly in test below. let block_hash = node.client.best_block_hash().expect("best_block_hash failed"); let json = node.client.get_block_stats_by_block_hash(&block_hash).expect("getblockstats"); - assert!(json.into_model().is_ok()); + json.into_model().unwrap(); } fn getblockstats_txindex() { let node = Node::with_wallet(Wallet::Default, &["-txindex"]); node.fund_wallet(); - let json = node.client.get_block_stats_by_height(101).expect("getblockstats"); - assert!(json.into_model().is_ok()); + // Get block stats by height. + let json: GetBlockStats = node.client.get_block_stats_by_height(101).expect("getblockstats"); + let model: Result = json.into_model(); + model.expect("GetBlockStats into model"); + // Get block stats by block hash. let block_hash = node.client.best_block_hash().expect("best_block_hash failed"); let json = node.client.get_block_stats_by_block_hash(&block_hash).expect("getblockstats"); - assert!(json.into_model().is_ok()); + json.into_model().unwrap(); } #[test] -fn get_chain_tips() { +fn blockchain__get_chain_tips__modelled() { let node = Node::with_wallet(Wallet::None, &[]); - let json = node.client.get_chain_tips().expect("getchaintips"); - assert!(json.into_model().is_ok()); + + let json: GetChainTips = node.client.get_chain_tips().expect("getchaintips"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn get_chain_tx_stats() { +fn blockchain__get_chain_tx_stats__modelled() { let node = Node::with_wallet(Wallet::None, &[]); - let json = node.client.get_chain_tx_stats().expect("getchaintxstats"); - assert!(json.into_model().is_ok()); + + let json: GetChainTxStats = node.client.get_chain_tx_stats().expect("getchaintxstats"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn get_difficulty() { +fn blockchain__get_difficulty__modelled() { let node = Node::with_wallet(Wallet::None, &[]); - let json = node.client.get_difficulty().expect("getdifficulty"); - let _ = json.into_model(); + + let json: GetDifficulty = node.client.get_difficulty().expect("getdifficulty"); + let _: mtype::GetDifficulty = json.into_model(); } #[test] #[cfg(feature = "TODO")] -fn get_mempool_ancestors() { - // We can probably get away with not testing this because it returns the - // same type as `getmempoolentry` which is tested below. +fn blockchain__get_mempool_ancestors__modelled() { + // We can probably get away with not testing this because it returns the same type as + // `getmempoolentry` which is tested below (for verbose=true). For verbose=false it + // just returns a txid. } #[test] #[cfg(feature = "TODO")] -fn get_mempool_descendants() { - // We can probably get away with not testing this because it returns the - // same type as `getmempoolentry` which is tested below. +fn blockchain__get_mempool_descendants__modelled() { + // Same justification as for `blockchain__get_mempool_ancestors__modelled` } #[test] -fn get_mempool_entry() { +fn blockchain__get_mempool_entry__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); let (_address, txid) = node.create_mempool_transaction(); - let json = node.client.get_mempool_entry(txid).expect("getmempoolentry"); - assert!(json.into_model().is_ok()); + let json: GetMempoolEntry = node.client.get_mempool_entry(txid).expect("getmempoolentry"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn get_mempool_info() { +fn blockchain__get_mempool_info__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); let (_address, _txid) = node.create_mempool_transaction(); - // Test the type and into model conversion code. - let json = node.client.get_mempool_info().expect("getmempoolinfo"); - let info = json.into_model().expect("into_model"); + let json: GetMempoolInfo = node.client.get_mempool_info().expect("getmempoolinfo"); + let model: Result = json.clone().into_model(); + let info = model.unwrap(); + // Sanity check. assert_eq!(info.size, 1); } #[test] -fn get_raw_mempool() { +fn blockchain__get_raw_mempool__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); let (_address, _txid) = node.create_mempool_transaction(); - // Test the type and into model conversion code. - let json = node.client.get_raw_mempool().expect("getrawmempool"); - let mempool = json.into_model().expect("into_model"); + // verbose = false + let json: GetRawMempool = node.client.get_raw_mempool().expect("getrawmempool"); + let model: Result = json.clone().into_model(); + let mempool = model.unwrap(); // Sanity check. assert_eq!(mempool.0.len(), 1); -} - -#[test] -// FIXME: Fails with getrawmempool verbose: JsonRpc(Json(Error("invalid type: map, expected a sequence", line: 1, column: 0))) -#[cfg(feature = "TODO")] -fn get_raw_mempool_verbose() { - let node = Node::with_wallet(Wallet::Default, &[]); - node.fund_wallet(); - let (_address, _txid) = node.create_mempool_transaction(); - // Test the type and into model conversion code. - let json = node.client.get_raw_mempool_verbose().expect("getrawmempool verbose"); - let mempool = json.into_model().expect("into_model"); - // Sanity check. - assert_eq!(mempool.0.len(), 1); + // FIXME: Fails: JsonRpc(Json(Error("invalid type: map, expected a sequence", line: 1, column: 0))) + // verbose = true + // let json: GetRawMempoolVerbose = node.client.get_raw_mempool_verbose().expect("getrawmempool verbose"); + // let model: Result = json.into_model(); + // let mempool = model.unwrap(); + // // Sanity check. + // assert_eq!(mempool.0.len(), 1); } #[test] -fn get_tx_out() { +fn blockchain__get_tx_out__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); let (_address, tx) = node.create_mined_transaction(); let txid = tx.compute_txid(); // Test the type and into model conversion code. - let json = node.client.get_tx_out(txid, 1).expect("gettxout"); - let _ = json.into_model().expect("into_model"); + let json: GetTxOut = node.client.get_tx_out(txid, 1).expect("gettxout"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn get_tx_out_proof() { +fn blockchain__get_tx_out_proof() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); let (_address, tx) = node.create_mined_transaction(); @@ -222,18 +241,18 @@ fn get_tx_out_proof() { } #[test] -fn get_tx_out_set_info() { +fn blockchain__get_tx_out_set_info__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); let (_address, _tx) = node.create_mined_transaction(); - // Test the type and into model conversion code. - let json = node.client.get_tx_out_set_info().expect("gettxoutsetinfo"); - let _ = json.into_model().expect("into_model"); + let json: GetTxOutSetInfo = node.client.get_tx_out_set_info().expect("gettxoutsetinfo"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn precious_block() { +fn blockchain__precious_block() { let node = Node::with_wallet(Wallet::Default, &[]); node.mine_a_block(); let hash = node.client.best_block_hash().expect("best_block_hash failed"); @@ -242,16 +261,32 @@ fn precious_block() { let _ = node.client.precious_block(hash).expect("preciousblock"); } -// Implicitly tests the omitted method `gettxoutproof` as well. #[test] -fn verify_tx_out_proof() { +fn blockchain__verify_tx_out_proof__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); + verify_tx_out_proof(&node).unwrap(); +} + +#[test] +fn blockchain__get_tx_out_proof__modelled() { + let node = Node::with_wallet(Wallet::Default, &[]); + node.fund_wallet(); + verify_tx_out_proof(&node).unwrap(); +} + +fn verify_tx_out_proof(node: &Node) -> Result<(), client_sync::Error> { let (_address, tx) = node.create_mined_transaction(); let txid = tx.compute_txid(); - let proof = node.client.get_tx_out_proof(&[txid]).expect("gettxoutproof"); + let proof = node.client.get_tx_out_proof(&[txid])?; - let txids = node.client.verify_tx_out_proof(&proof).expect("verifytxoutproof"); + let json: VerifyTxOutProof = node.client.verify_tx_out_proof(&proof)?; + let model: Result = json.into_model(); + let txids = model.unwrap(); + + // sanity check assert_eq!(txids.0.len(), 1); + + Ok(()) } diff --git a/integration_test/tests/control.rs b/integration_test/tests/control.rs index 0534b6a6..d324ef09 100644 --- a/integration_test/tests/control.rs +++ b/integration_test/tests/control.rs @@ -2,43 +2,44 @@ //! Tests for methods found under the `== Control ==` section of the API docs. +#![allow(non_snake_case)] // Test names intentionally use double underscore. + use integration_test::{Node, NodeExt as _, Wallet}; +use node::vtype::*; // All the version specific types. #[test] -fn get_memory_info() { +fn control__get_memory_info() { let node = Node::with_wallet(Wallet::None, &[]); - let _ = node.client.get_memory_info().expect("getmemoryinfo"); + let _: GetMemoryInfoStats = node.client.get_memory_info().unwrap(); } #[cfg(not(feature = "v17"))] #[test] -fn get_rpc_info() { +fn control__get_rpc_info() { let node = Node::with_wallet(Wallet::None, &[]); - let _ = node.client.get_rpc_info().expect("getrpcinfo"); + let _ = node.client.get_rpc_info().unwrap(); } #[test] -fn help() { +fn control__help() { let node = Node::with_wallet(Wallet::None, &[]); - // There is no json object for `stop`, we just return a string. - let _ = node.client.help().expect("help"); + let _ = node.client.help().unwrap(); } #[test] -fn logging() { +fn control__logging() { let node = Node::with_wallet(Wallet::None, &[]); - let _ = node.client.logging().expect("logging"); + let _: Logging = node.client.logging().unwrap(); } #[test] -fn stop() { +fn control__stop() { let node = Node::with_wallet(Wallet::None, &[]); - // There is no json object for `stop`, we just return a string. - let _ = node.client.stop().expect("stop"); + let _ = node.client.stop().unwrap(); } #[test] -fn uptime() { +fn control__uptime() { let node = Node::with_wallet(Wallet::None, &[]); - let _ = node.client.uptime().expect("uptime"); + let _ = node.client.uptime().unwrap(); } diff --git a/integration_test/tests/generating.rs b/integration_test/tests/generating.rs index ab575f89..5e8d7ce6 100644 --- a/integration_test/tests/generating.rs +++ b/integration_test/tests/generating.rs @@ -2,31 +2,41 @@ //! Tests for methods found under the `== Generating ==` section of the API docs. +#![allow(non_snake_case)] // Test names intentionally use double underscore. + use integration_test::{Node, NodeExt as _, Wallet}; +use node::vtype::*; // All the version specific types. +use node::mtype; #[test] -// The `generate` method deprecated in Core v18 and was removed in v19. +// The `generate` method was deprecated in Core v18 and was removed in v19. #[cfg(feature = "v17")] -fn generate() { +fn generating__generate__modelled() { const NBLOCKS: usize = 10; - let node = Node::with_wallet(Wallet::Default, &[]); - let _ = node.client.generate(NBLOCKS).expect("generate"); + + let json: Generate = node.client.generate(NBLOCKS).expect("generate"); + + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn generate_to_address() { +fn generating__generate_to_address__modelled() { const NBLOCKS: usize = 1; let node = Node::with_wallet(Wallet::Default, &[]); - let address = node.client.new_address().expect("failed to get new address"); - let json = node.client.generate_to_address(NBLOCKS, &address).expect("generatetoaddress"); - json.into_model().unwrap(); + + let json: GenerateToAddress = node.client.generate_to_address(NBLOCKS, &address).expect("generatetoaddress"); + + let model: Result = json.into_model(); + let _ = model.unwrap(); } +// This method does not appear in the output of `bitcoin-cli help`. #[test] -fn invalidate_block() { +fn generating__invalidate_block() { const NBLOCKS: usize = 1; let node = Node::with_wallet(Wallet::Default, &[]); @@ -49,14 +59,3 @@ fn invalidate_block() { node.client.get_best_block_hash().expect("getbestblockhash").into_model().unwrap().0; assert_eq!(old_best_block, best_block); } - -// #[test] -// #[cfg(not(feature = "v19"))] -// fn generate() { -// const NBLOCKS: usize = 100; - -// let node = Node::with_wallet_with_default_wallet(); -// let json = node.client.generate(NBLOCKS).expect("generate"); -// let model = json.into_model().unwrap(); -// assert_eq!(model.len(), NBLOCKS); -// } diff --git a/integration_test/tests/mining.rs b/integration_test/tests/mining.rs index 4be75d04..a5b83abb 100644 --- a/integration_test/tests/mining.rs +++ b/integration_test/tests/mining.rs @@ -2,13 +2,16 @@ //! Tests for methods found under the `== Mining ==` section of the API docs. +#![allow(non_snake_case)] // Test names intentionally use double underscore. + use bitcoin::SignedAmount; -use client::types::model::GetBlockTemplate; -use client::client_sync::{TemplateRequest, TemplateRules}; use integration_test::{Node, NodeExt as _, Wallet}; +use node::client::client_sync::{TemplateRequest, TemplateRules}; +use node::vtype::*; // All the version specific types. +use node::mtype; #[test] -fn get_block_template() { +fn mining__get_block_template__modelled() { // Requires connected nodes otherwise the RPC call errors. let (node1, node2, node3) = integration_test::three_node_network(); @@ -19,21 +22,22 @@ fn get_block_template() { let options = TemplateRequest { rules: vec![TemplateRules::Segwit] }; - let json = node1.client.get_block_template(&options).expect("getblocktemplate"); - assert!(json.into_model().is_ok()); + let json: GetBlockTemplate = node1.client.get_block_template(&options).expect("rpc"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn get_mining_info() { +fn mining__get_mining_info() { let node = Node::with_wallet(Wallet::Default, &[]); - let _ = node.client.get_mining_info().expect("getmininginfo"); + let _: GetMiningInfo = node.client.get_mining_info().expect("rpc"); } #[test] -fn get_network_hash_ps() { +fn mining__get_network_hash_ps() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); - let _ = node.client.get_network_hash_ps().expect("getnetworkhashps"); + let _ = node.client.get_network_hash_ps().expect("rpc"); } #[test] @@ -49,7 +53,7 @@ fn get_network_hash_ps() { not(feature = "v24"), not(feature = "v25"), ))] -fn get_prioritised_transactions() { +fn mining__get_prioritised_transactions() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); @@ -57,7 +61,7 @@ fn get_prioritised_transactions() { } #[test] -fn prioritise_transaction() { +fn mining__prioritise_transaction() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); @@ -69,7 +73,7 @@ fn prioritise_transaction() { #[test] #[cfg(feature = "TODO")] // This test is flaky - no clue why. -fn submit_block() { +fn mining__submit_block() { // Requires connected nodes otherwise the RPC call errors. let (node1, node2, node3) = integration_test::three_node_network(); @@ -89,7 +93,7 @@ fn submit_block() { // Code copied from BDK - thanks! // FIXME: Submitting this block sometimes works and sometimes returns 'inconclusive'. #[allow(dead_code)] -fn submit_empty_block(node: &Node, bt: &GetBlockTemplate) { +fn submit_empty_block(node: &Node, bt: &mtype::GetBlockTemplate) { use bitcoin::hashes::Hash as _; use bitcoin::{ absolute, block, transaction, Amount, Block, OutPoint, ScriptBuf, Sequence, @@ -141,7 +145,7 @@ fn submit_empty_block(node: &Node, bt: &GetBlockTemplate) { // FIXME: Submitting this block returns 'inconclusive'. #[allow(dead_code)] -fn submit_block_with_dummy_coinbase(node: &Node, bt: &GetBlockTemplate) { +fn mining__submit_block_with_dummy_coinbase(node: &Node, bt: &mtype::GetBlockTemplate) { use bitcoin::hashes::Hash as _; use bitcoin::{ absolute, block, transaction, Amount, Block, OutPoint, ScriptBuf, Sequence, diff --git a/integration_test/tests/network.rs b/integration_test/tests/network.rs index 1a26931c..c0ba298b 100644 --- a/integration_test/tests/network.rs +++ b/integration_test/tests/network.rs @@ -2,41 +2,44 @@ //! Tests for methods found under the `== Network ==` section of the API docs. -#![cfg(any(feature = "0_17_1", feature = "0_18_1"))] +#![allow(non_snake_case)] // Test names intentionally use double underscore. use integration_test::{Node, NodeExt as _, Wallet}; +use node::vtype::*; // All the version specific types. +use node::mtype; #[test] -fn get_added_node_info() { +fn network__get_added_node_info() { let node = Node::with_wallet(Wallet::None, &[]); - let _ = node.client.get_added_node_info().expect("getaddednodeinfo"); + let _: GetAddedNodeInfo = node.client.get_added_node_info().expect("getaddednodeinfo"); } #[test] -fn get_net_totals() { +fn network__get_net_totals() { let node = Node::with_wallet(Wallet::None, &[]); - let _ = node.client.get_net_totals().expect("getnettotals"); + let _: GetNetTotals = node.client.get_net_totals().expect("getnettotals"); } #[test] -fn get_network_info() { +fn network__get_network_info() { let node = Node::with_wallet(Wallet::None, &[]); - let json = node.client.get_network_info().expect("getnetworkinfo"); - assert!(json.into_model().is_ok()); + let json: GetNetworkInfo = node.client.get_network_info().expect("getnetworkinfo"); + let model: Result = json.into_model(); + model.unwrap(); // Server version is returned as part of the getnetworkinfo method. node.client.check_expected_server_version().expect("unexpected version"); } #[test] -fn get_peer_info() { +fn network__get_peer_info() { get_peer_info_one_node_network(); get_peer_info_three_node_network(); } fn get_peer_info_one_node_network() { let node = Node::with_wallet(Wallet::None, &[]); - let json = node.client.get_peer_info().expect("getpeerinfo"); + let json: GetPeerInfo = node.client.get_peer_info().expect("getpeerinfo"); assert_eq!(json.0.len(), 0); } diff --git a/integration_test/tests/raw_transactions.rs b/integration_test/tests/raw_transactions.rs index bb99e405..52a89876 100644 --- a/integration_test/tests/raw_transactions.rs +++ b/integration_test/tests/raw_transactions.rs @@ -2,14 +2,18 @@ //! Tests for methods found under the `== Rawtransactions ==` section of the API docs. +#![allow(non_snake_case)] // Test names intentionally use double underscore. + use std::collections::BTreeMap; use bitcoin::{Amount, Sequence}; -use client::client_sync::Input; +#[cfg(feature = "TODO")] +use bitcoin::{absolute, transaction, consensus, TxOut, Transaction}; use integration_test::{Node, NodeExt as _, Wallet}; +use node::client::client_sync::Input; #[test] -fn create_raw_transaction() { +fn raw_transacitons__create_raw_transaction() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); // Calls `createrawtransaction`. @@ -18,14 +22,14 @@ fn create_raw_transaction() { #[test] #[cfg(feature = "TODO")] -fn fund_raw_transaction() { +fn raw_transactions__fund_raw_transaction() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); _create_fund_and_send(&node); } #[test] -fn send_raw_transaction() { +fn raw_transactions__send_raw_transaction() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); // Calls `sendrawtransaction`. @@ -111,7 +115,7 @@ fn _create_fund_and_send(node: &Node) { input: vec![], output: vec![spend, change], }; - let tx = consensus::encode::serialize_hex(&tx); + let _ = consensus::encode::serialize_hex(&tx); // TODO: This errors with: RpcError { code: -22, message: "TX decode failed", data: None } // let json = node.client.fund_raw_transaction(&tx).expect("fundrawtransaction"); @@ -128,7 +132,7 @@ fn _create_fund_and_send(node: &Node) { #[test] #[cfg(feature = "v28")] -fn submitpackage() { +fn raw_transactions__submitpackage() { let node = Node::with_wallet(Wallet::Default, &[]); // Submitting the empty package should simply fail. diff --git a/integration_test/tests/wallet.rs b/integration_test/tests/wallet.rs index c76c189e..59182219 100644 --- a/integration_test/tests/wallet.rs +++ b/integration_test/tests/wallet.rs @@ -2,17 +2,19 @@ //! Tests for methods found under the `== Wallet ==` section of the API docs. +#![allow(non_snake_case)] // Test names intentionally use double underscore. + #[cfg(feature = "TODO")] use bitcoin::address::{Address, NetworkChecked}; -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] use bitcoin::Amount; use integration_test::{Node, NodeExt as _, Wallet}; -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] use node::AddressType; +use node::vtype::*; // All the version specific types. +use node::mtype; #[test] #[cfg(feature = "TODO")] -pub fn add_multisig_address() { +fn wallet__add_multisig_address__modelled() { let nrequired = 1; // 1-of-2 multisig. let add1: Address = @@ -21,16 +23,16 @@ pub fn add_multisig_address() { "132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM".parse::>().unwrap().assume_checked(); let node = Node::with_wallet(Wallet::Default, &[]); - let json = node + let json: AddMultisigAddress = node .client .add_multisig_address_with_addresses(nrequired, vec![add1, add2]) .expect("addmultisigaddress"); - assert!(json.into_model().is_ok()); + let model: Result = json.into_model(); + model.unwrap(); } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] -pub fn bump_fee() { +fn wallet__bump_fee__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); let address = node.client.new_address().expect("failed to create new address"); let _ = node.client.generate_to_address(101, &address).expect("generatetoaddress"); @@ -42,89 +44,150 @@ pub fn bump_fee() { .txid() .unwrap(); - let json = node.client.bump_fee(txid).expect("bumpfee"); - assert!(json.into_model().is_ok()); + let json: BumpFee = node.client.bump_fee(txid).expect("bumpfee"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -pub fn create_wallet() { +fn wallet__create_wallet__modelled() { // Implicitly tests `createwallet` because we create the default wallet. let _ = Node::with_wallet(Wallet::Default, &[]); } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] -pub fn dump_priv_key() { - let node = Node::with_wallet(Wallet::Default, &[]); - let address = node.client.new_address().expect("failed to create new address"); - let json = node.client.dump_priv_key(&address).expect("dumpprivkey"); - assert!(json.into_model().is_ok()); +fn wallet__dump_priv_key__modelled() { + // As of Core v23 the default wallet is an native descriptor wallet which does not + // support dumping private keys. Legacy wallets are supported upto v25 it seems. + #[cfg(any( + feature = "v23", + feature = "v24", + feature = "v25", + ))] + { + let node = Node::with_wallet(Wallet::None, &[]); + + node.client.create_legacy_wallet("legacy_wallet").expect("legacy create_wallet"); + let address = node.client.get_new_address(Some("label"), Some(AddressType::Legacy)).expect("legacy get_new_address"); + let address = address.into_model().unwrap().0.assume_checked(); + + let json: DumpPrivKey = node.client.dump_priv_key(&address).expect("dumpprivkey"); + let model: Result = json.into_model(); + model.unwrap(); + } + + #[cfg(any( + feature = "v17", + feature = "v18", + feature = "v19", + feature = "v20", + feature = "v21", + feature = "v22", + ))] + { + let node = Node::with_wallet(Wallet::Default, &[]); + let address = node.client.new_address().expect("failed to get new address"); + + let json: DumpPrivKey = node.client.dump_priv_key(&address).expect("dumpprivkey"); + let model: Result = json.into_model(); + model.unwrap(); + } } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] -pub fn dump_wallet() { - let node = Node::with_wallet(Wallet::Default, &[]); - let out = integration_test::random_tmp_file(); - let json = node.client.dump_wallet(&out).expect("dumpwallet"); - let _ = json.into_model(); +fn wallet__dump_wallet__modelled() { + // As of Core v23 the default wallet is an native descriptor wallet which does not + // support dumping private keys. Legacy wallets are supported upto v25 it seems. + #[cfg(any( + feature = "v23", + feature = "v24", + feature = "v25", + ))] + { + let node = Node::with_wallet(Wallet::None, &[]); + + node.client.create_legacy_wallet("legacy_wallet").expect("legacy create_wallet"); + let out = integration_test::random_tmp_file(); + + let json: DumpWallet = node.client.dump_wallet(&out).expect("dumpwallet"); + let _: mtype::DumpWallet = json.into_model(); + } + + #[cfg(any( + feature = "v17", + feature = "v18", + feature = "v19", + feature = "v20", + feature = "v21", + feature = "v22", + ))] + { + let node = Node::with_wallet(Wallet::Default, &[]); + let out = integration_test::random_tmp_file(); + + let json: DumpWallet = node.client.dump_wallet(&out).expect("dumpwallet"); + let _: mtype::DumpWallet = json.into_model(); + } } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] -pub fn get_addresses_by_label() { +fn wallet__get_addresses_by_label__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); let label = "some-label"; let addr = node.client.new_address_with_label(label).expect("failed to get new address"); - let json = node.client.get_addresses_by_label(label).expect("getaddressesbylabel"); - let map = json.into_model().expect("failed to convert to model").0; - assert!(!map.is_empty()); - assert!(map.get(&addr).is_some()); + + let json: GetAddressesByLabel = node.client.get_addresses_by_label(label).expect("getaddressesbylabel"); + let model: Result = json.into_model(); + let map = model.unwrap(); + + // sanity checks. + assert!(!map.0.is_empty()); + assert!(map.0.get(&addr).is_some()); } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] +#[cfg(feature = "TODO")] // FIXME: The types are broken. // TODO: Consider testing a few different address types. -#[cfg(feature = "TODO")] -pub fn get_address_info() { +fn wallet__get_address_info__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); let address = node.client.new_address().expect("failed to create new address"); - let json = node.client.get_address_info(&address).expect("getaddressinfo"); - assert!(json.into_model().is_ok()); + + let json: GetAddressInfo = node.client.get_address_info(&address).expect("getaddressinfo"); + let model: Result = json.into_model(); + model.unwrap(); } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] -fn get_balance() { +fn wallet__get_balance__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); - let json = node.client.get_balance().expect("getbalance"); - assert!(json.into_model().is_ok()); + let json: GetBalance = node.client.get_balance().expect("getbalance"); + let model: Result = json.into_model(); + model.unwrap(); + + // Check non-zero balance just for giggles. node.fund_wallet(); let json = node.client.get_balance().expect("getbalance"); - assert!(json.into_model().is_ok()); + json.into_model().unwrap(); } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] + #[test] -#[cfg(feature = "v19")] -fn get_balances() { +#[cfg(all(not(feature = "v17"), not(feature = "v18")))] +fn wallet__get_balances() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); - let json = node.client.get_balances().expect("getbalances"); - let model = json.into_model().expect("into_model"); - // TODO: Do more fine grained testing. - assert!(model.mine.trusted > Amount::ZERO); + + let json: GetBalances = node.client.get_balances().expect("getbalances"); + let model: Result = json.into_model(); + model.unwrap(); } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] -fn get_new_address() { +fn wallet__get_new_address__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); - let _ = node.client.new_address().expect("getnewaddress"); - - // Test the helper as well just for good measure. + // Implicitly tests `getnewaddress`. let _ = node.client.new_address().unwrap(); // Exhaustively test address types with helper. @@ -133,17 +196,16 @@ fn get_new_address() { let _ = node.client.new_address_with_type(AddressType::Bech32).unwrap(); } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] -fn get_raw_change_address() { +fn wallet__get_raw_change_address__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); - let json = node.client.get_raw_change_address().expect("getrawchangeaddress"); - assert!(json.into_model().is_ok()); + let json: GetRawChangeAddress = node.client.get_raw_change_address().expect("getrawchangeaddress"); + let model: Result = json.into_model(); + model.unwrap(); } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] -fn get_received_by_address() { +fn wallet__get_received_by_address__modelled() { let amount = Amount::from_sat(10_000); let node = Node::with_wallet(Wallet::Default, &[]); @@ -154,14 +216,15 @@ fn get_received_by_address() { node.client.send_to_address(&address, amount).expect("sendtoaddress").txid().unwrap(); node.mine_a_block(); - let json = node.client.get_received_by_address(&address).expect("getreceivedbyaddress"); - let model = json.into_model().expect("into_model failed"); + let json: GetReceivedByAddress = node.client.get_received_by_address(&address).expect("getreceivedbyaddress"); + let model: Result = json.into_model(); + let model = model.unwrap(); + assert_eq!(model.0, amount); } -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] #[test] -fn get_transaction() { +fn wallet__get_transaction__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); let address = node.client.new_address().expect("failed to create new address"); @@ -173,20 +236,33 @@ fn get_transaction() { .txid() .unwrap(); - let json = node.client.get_transaction(txid).expect("gettransaction"); - assert!(json.into_model().is_ok()); + let json: GetTransaction = node.client.get_transaction(txid).expect("gettransaction"); + let model: Result = json.into_model(); + model.unwrap(); } #[test] -fn load_wallet() { +fn wallet__load_wallet__modelled() { create_load_unload_wallet(); } #[test] -fn unload_wallet() { +fn wallet__unload_wallet() { create_load_unload_wallet(); } +#[test] +fn wallet__send_to_address__modelled() { + let node = Node::with_wallet(Wallet::Default, &[]); + node.fund_wallet(); + let address = node.client.new_address().expect("failed to create new address"); + + let json: SendToAddress = + node.client.send_to_address(&address, Amount::from_sat(10_000)).expect("sendtddress"); + let model: Result = json.into_model(); + model.unwrap(); +} + fn create_load_unload_wallet() { let node = Node::with_wallet(Wallet::None, &[]); @@ -200,22 +276,9 @@ fn create_load_unload_wallet() { // From version 21 Core returns warnings for `unloadwallet`. #[cfg(all(not(feature = "v17"), not(feature = "v18"), not(feature = "v19"), not(feature = "v20")))] { - let json = node.client.unload_wallet(&wallet).expect("unloadwallet"); - let _ = json.into_model(); + let json: UnloadWallet = node.client.unload_wallet(&wallet).expect("unloadwallet"); + let _: mtype::UnloadWallet = json.into_model(); } - let json = node.client.load_wallet(&wallet).expect("loadwallet"); - let _ = json.into_model(); -} - -#[cfg(any(feature = "0_17_1", feature = "0_18_1"))] -#[test] -fn send_to_address() { - let node = Node::with_wallet(Wallet::Default, &[]); - node.fund_wallet(); - let address = node.client.new_address().expect("failed to create new address"); - - let json = - node.client.send_to_address(&address, Amount::from_sat(10_000)).expect("sendtddress"); - assert!(json.into_model().is_ok()); + let _: LoadWallet = node.client.load_wallet(&wallet).expect("loadwallet"); } diff --git a/node/src/client_versions.rs b/node/src/client_versions.rs index 5fdb025a..b6db43cc 100644 --- a/node/src/client_versions.rs +++ b/node/src/client_versions.rs @@ -7,52 +7,52 @@ #![allow(unused_imports)] // Not all users need the json types. #[cfg(feature = "28_0")] -pub use corepc_client::{client_sync::v28::{Client, AddressType}, types::v28 as types}; +pub use corepc_client::{client_sync::v28::{Client, AddressType}, types::v28 as vtype}; #[cfg(all(feature = "27_2", not(feature = "28_0")))] -pub use corepc_client::{client_sync::v27::{Client, AddressType}, types::v27 as types}; +pub use corepc_client::{client_sync::v27::{Client, AddressType}, types::v27 as vtype}; #[cfg(all(feature = "27_1", not(feature = "27_2")))] -pub use corepc_client::{client_sync::v27::{Client, AddressType}, types::v27 as types}; +pub use corepc_client::{client_sync::v27::{Client, AddressType}, types::v27 as vtype}; #[cfg(all(feature = "27_0", not(feature = "27_1")))] -pub use corepc_client::{client_sync::v27::{Client, AddressType}, types::v27 as types}; +pub use corepc_client::{client_sync::v27::{Client, AddressType}, types::v27 as vtype}; #[cfg(all(feature = "26_2", not(feature = "27_0")))] -pub use corepc_client::{client_sync::v26::{Client, AddressType}, types::v26 as types}; +pub use corepc_client::{client_sync::v26::{Client, AddressType}, types::v26 as vtype}; #[cfg(all(feature = "26_1", not(feature = "26_2")))] -pub use corepc_client::{client_sync::v26::{Client, AddressType}, types::v26 as types}; +pub use corepc_client::{client_sync::v26::{Client, AddressType}, types::v26 as vtype}; #[cfg(all(feature = "26_0", not(feature = "26_1")))] -pub use corepc_client::{client_sync::v26::{Client, AddressType}, types::v26 as types}; +pub use corepc_client::{client_sync::v26::{Client, AddressType}, types::v26 as vtype}; #[cfg(all(feature = "25_2", not(feature = "26_0")))] -pub use corepc_client::{client_sync::v25::{Client, AddressType}, types::v25 as types}; +pub use corepc_client::{client_sync::v25::{Client, AddressType}, types::v25 as vtype}; #[cfg(all(feature = "24_2", not(feature = "25_2")))] -pub use corepc_client::{client_sync::v24::{Client, AddressType}, types::v24 as types}; +pub use corepc_client::{client_sync::v24::{Client, AddressType}, types::v24 as vtype}; #[cfg(all(feature = "23_2", not(feature = "24_2")))] -pub use corepc_client::{client_sync::v23::{Client, AddressType}, types::v23 as types}; +pub use corepc_client::{client_sync::v23::{Client, AddressType}, types::v23 as vtype}; #[cfg(all(feature = "22_1", not(feature = "23_2")))] -pub use corepc_client::{client_sync::v22::{Client, AddressType}, types::v22 as types}; +pub use corepc_client::{client_sync::v22::{Client, AddressType}, types::v22 as vtype}; #[cfg(all(feature = "0_21_2", not(feature = "22_1")))] -pub use corepc_client::{client_sync::v21::{Client, AddressType}, types::v21 as types}; +pub use corepc_client::{client_sync::v21::{Client, AddressType}, types::v21 as vtype}; #[cfg(all(feature = "0_20_2", not(feature = "0_21_2")))] -pub use corepc_client::{client_sync::v20::{Client, AddressType}, types::v20 as types}; +pub use corepc_client::{client_sync::v20::{Client, AddressType}, types::v20 as vtype}; #[cfg(all(feature = "0_19_1", not(feature = "0_20_2")))] -pub use corepc_client::{client_sync::v19::{Client, AddressType}, types::v19 as types}; +pub use corepc_client::{client_sync::v19::{Client, AddressType}, types::v19 as vtype}; #[cfg(all(feature = "0_18_1", not(feature = "0_19_1")))] -pub use corepc_client::{client_sync::v18::{Client, AddressType}, types::v18 as types}; +pub use corepc_client::{client_sync::v18::{Client, AddressType}, types::v18 as vtype}; #[cfg(all(feature = "0_17_1", not(feature = "0_18_1")))] -pub use corepc_client::{client_sync::v17::{Client, AddressType}, types::v17 as types}; +pub use corepc_client::{client_sync::v17::{Client, AddressType}, types::v17 as vtype}; /// This is meaningless but we need it otherwise we can't get far enough into /// the build process to trigger the `compile_error!` in `./versions.rs`. @@ -74,4 +74,4 @@ pub use corepc_client::{client_sync::v17::{Client, AddressType}, types::v17 as t not(feature = "0_18_1"), not(feature = "0_17_1") ))] -pub use corepc_client::{client_sync::v28::{Client, AddressType}, types::v28 as types}; +pub use corepc_client::{client_sync::v28::{Client, AddressType}, types::v28 as vtype}; diff --git a/node/src/lib.rs b/node/src/lib.rs index e996ee08..6e3c2eb5 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -23,8 +23,12 @@ pub use {anyhow, serde_json, tempfile, which}; #[rustfmt::skip] // Keep pubic re-exports separate. #[doc(inline)] pub use self::{ - client_versions::{types, Client, AddressType}, + // Re-export `vtype` - the version specific types. + client_versions::{vtype, Client, AddressType}, + // Re-export the version string e.g., "28.0". versions::VERSION, + // Re-export the model types as `mtype` to differentiate it from `vtype`. + client::types::model as mtype, // `types` is the `corepc-types` crate. }; #[derive(Debug)] @@ -731,10 +735,10 @@ mod test { node.client.generate_to_address(101, &bob_address).unwrap(); let balances = alice.get_balances().unwrap(); - let alice_balances: types::GetBalances = balances; + let alice_balances: vtype::GetBalances = balances; let balances = bob.get_balances().unwrap(); - let bob_balances: types::GetBalances = balances; + let bob_balances: vtype::GetBalances = balances; assert_eq!( Amount::from_btc(50.0).unwrap(), @@ -751,7 +755,7 @@ mod test { let _txid = alice.send_to_address(&bob_address, Amount::from_btc(1.0).unwrap()).unwrap(); let balances = alice.get_balances().unwrap(); - let alice_balances: types::GetBalances = balances; + let alice_balances: vtype::GetBalances = balances; assert!( Amount::from_btc(alice_balances.mine.trusted).unwrap() @@ -763,7 +767,7 @@ mod test { // bob wallet may not be immediately updated for _ in 0..30 { let balances = bob.get_balances().unwrap(); - let bob_balances: types::GetBalances = balances; + let bob_balances: vtype::GetBalances = balances; if Amount::from_btc(bob_balances.mine.untrusted_pending).unwrap().to_sat() > 0 { break; @@ -771,7 +775,7 @@ mod test { std::thread::sleep(std::time::Duration::from_millis(100)); } let balances = bob.get_balances().unwrap(); - let bob_balances: types::GetBalances = balances; + let bob_balances: vtype::GetBalances = balances; assert_eq!( Amount::from_btc(1.0).unwrap(), diff --git a/types/src/model/blockchain.rs b/types/src/model/blockchain.rs index f26b012f..f035c1b4 100644 --- a/types/src/model/blockchain.rs +++ b/types/src/model/blockchain.rs @@ -20,11 +20,11 @@ pub struct GetBestBlockHash(pub BlockHash); /// Models the result of JSON-RPC method `getblock` with verbosity set to 0. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct GetBlockVerbosityZero(pub Block); +pub struct GetBlockVerboseZero(pub Block); /// Models the result of JSON-RPC method `getblock` with verbosity set to 1. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct GetBlockVerbosityOne { +pub struct GetBlockVerboseOne { /// The block hash (same as provided) in RPC call. pub hash: BlockHash, /// The number of confirmations, or -1 if the block is not on the main chain. diff --git a/types/src/model/mod.rs b/types/src/model/mod.rs index 64fa8c84..0a00202f 100644 --- a/types/src/model/mod.rs +++ b/types/src/model/mod.rs @@ -23,7 +23,7 @@ pub use self::{ blockchain::{ Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, ChainTips, ChainTipsStatus, GetBestBlockHash, GetBlockCount, GetBlockFilter, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockVerbosityOne, GetBlockVerbosityZero, + GetBlockHeaderVerbose, GetBlockStats, GetBlockVerboseOne, GetBlockVerboseZero, GetBlockchainInfo, GetChainTips, GetChainTxStats, GetDifficulty, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetRawMempool, GetRawMempoolVerbose, GetTxOut, diff --git a/types/src/v17/blockchain/error.rs b/types/src/v17/blockchain/error.rs index 582d81cf..d7bfdc62 100644 --- a/types/src/v17/blockchain/error.rs +++ b/types/src/v17/blockchain/error.rs @@ -10,9 +10,9 @@ use bitcoin::{address, hex, network}; use crate::error::write_err; use crate::NumericError; -/// Error when converting a `GetBlockVerbosityOne` type into the model type. +/// Error when converting a `GetBlockVerboseOne` type into the model type. #[derive(Debug)] -pub enum GetBlockVerbosityOneError { +pub enum GetBlockVerboseOneError { /// Conversion of numeric type to expected type failed. Numeric(NumericError), /// Conversion of the transaction `hash` field failed. @@ -29,9 +29,9 @@ pub enum GetBlockVerbosityOneError { NextBlockHash(hex::HexToArrayError), } -impl fmt::Display for GetBlockVerbosityOneError { +impl fmt::Display for GetBlockVerboseOneError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockVerbosityOneError::*; + use GetBlockVerboseOneError::*; match *self { Numeric(ref e) => write_err!(f, "numeric"; e), @@ -48,9 +48,9 @@ impl fmt::Display for GetBlockVerbosityOneError { } #[cfg(feature = "std")] -impl std::error::Error for GetBlockVerbosityOneError { +impl std::error::Error for GetBlockVerboseOneError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockVerbosityOneError::*; + use GetBlockVerboseOneError::*; match *self { Numeric(ref e) => Some(e), @@ -64,7 +64,7 @@ impl std::error::Error for GetBlockVerbosityOneError { } } -impl From for GetBlockVerbosityOneError { +impl From for GetBlockVerboseOneError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } diff --git a/types/src/v17/blockchain/into.rs b/types/src/v17/blockchain/into.rs index 98a9189d..aa8a9c90 100644 --- a/types/src/v17/blockchain/into.rs +++ b/types/src/v17/blockchain/into.rs @@ -17,21 +17,21 @@ impl GetBestBlockHash { pub fn block_hash(self) -> Result { Ok(self.into_model()?.0) } } -impl GetBlockVerbosityZero { +impl GetBlockVerboseZero { /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model(self) -> Result { + pub fn into_model(self) -> Result { let block = encode::deserialize_hex(&self.0)?; - Ok(model::GetBlockVerbosityZero(block)) + Ok(model::GetBlockVerboseZero(block)) } /// Converts json straight to a `bitcoin::Block`. pub fn block(self) -> Result { Ok(self.into_model()?.0) } } -impl GetBlockVerbosityOne { +impl GetBlockVerboseOne { /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model(self) -> Result { - use GetBlockVerbosityOneError as E; + pub fn into_model(self) -> Result { + use GetBlockVerboseOneError as E; let hash = self.hash.parse::().map_err(E::Hash)?; let stripped_size = @@ -57,7 +57,7 @@ impl GetBlockVerbosityOne { .transpose() .map_err(E::NextBlockHash)?; - Ok(model::GetBlockVerbosityOne { + Ok(model::GetBlockVerboseOne { hash, confirmations: self.confirmations, size: crate::to_u32(self.size, "size")?, diff --git a/types/src/v17/blockchain/mod.rs b/types/src/v17/blockchain/mod.rs index ba728b3d..81056d10 100644 --- a/types/src/v17/blockchain/mod.rs +++ b/types/src/v17/blockchain/mod.rs @@ -37,15 +37,14 @@ pub struct GetBestBlockHash(pub String); /// > 1. "blockhash" (string, required) The block hash /// > 2. verbosity (numeric, optional, default=1) 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data #[derive(Clone, PartialEq, Debug, Deserialize, Serialize)] -// TODO: Consider renaming this to `GetBlcokVerboseZero`. -pub struct GetBlockVerbosityZero( +pub struct GetBlockVerboseZero( /// A string that is serialized, hex-encoded data for block 'hash'. pub String, ); /// Result of JSON-RPC method `getblock` with verbosity set to 1. #[derive(Clone, PartialEq, Debug, Deserialize, Serialize)] -pub struct GetBlockVerbosityOne { +pub struct GetBlockVerboseOne { /// The block hash (same as provided) in RPC call. pub hash: String, /// The number of confirmations, or -1 if the block is not on the main chain. diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index c42e5686..02c7ceef 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -228,7 +228,7 @@ pub use self::{ Bip9Softfork, Bip9SoftforkStatus, ChainTips, ChainTipsError, ChainTipsStatus, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, - GetBlockVerbosityOne, GetBlockVerbosityOneError, GetBlockVerbosityZero, GetBlockchainInfo, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetBlockchainInfo, GetBlockchainInfoError, GetChainTips, GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index aeeb0455..b3f2b31c 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -240,24 +240,25 @@ pub use crate::v17::{ GetAddressInfoLabel, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, GetBlockTemplate, - GetBlockTemplateError, GetBlockVerbosityOne, GetBlockVerbosityOneError, GetBlockVerbosityZero, + GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetBlockchainInfo, GetBlockchainInfoError, GetChainTips, GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, - GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, - GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, GetTransactionDetail, - GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, - GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, - ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, - ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, - ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspent, - ListUnspentItem, ListUnspentItemError, ListWallets, LoadWallet, Locked, Logging, - MapMempoolEntryError, MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, - PeerInfo, RescanBlockchain, ScriptPubkey, SendMany, SendRawTransaction, SendToAddress, - SignErrorData, SignErrorDataError, SignMessage, SignRawTransactionWithWallet, - SignRawTransactionWithWalletError, Softfork, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, + GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, + GetTransactionDetail, GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, + GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, + GetWalletInfoError, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, + ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, + ListLockUnspentItemError, ListReceivedByAddress, ListReceivedByAddressError, + ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, + ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, + ListTransactionsItemError, ListUnspent, ListUnspentItem, ListUnspentItemError, ListWallets, + LoadWallet, Locked, Logging, MapMempoolEntryError, MempoolEntry, MempoolEntryError, + MempoolEntryFees, MempoolEntryFeesError, PeerInfo, RescanBlockchain, ScriptPubkey, SendMany, + SendRawTransaction, SendToAddress, SignErrorData, SignErrorDataError, SignMessage, + SignRawTransactionWithWallet, SignRawTransactionWithWalletError, Softfork, SoftforkReject, + TransactionCategory, UploadTarget, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, }; diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index 1b7d0963..f462a836 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -246,16 +246,16 @@ pub use crate::v17::{ GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, - GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerbosityOne, - GetBlockVerbosityOneError, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, - GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, - GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionDetailError, - GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, - GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, GetZmqNotifications, - ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, - ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, + GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, + GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, + GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, + GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, + GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, + GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, GetTransactionDetail, + GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError, + GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, + ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspent, diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index c4993670..293399b6 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -231,25 +231,29 @@ pub use self::control::Logging; #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddedNode, AddedNodeAddress, AddressInformation, Banned, BumpFee, - ChainTips, ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, + AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, + AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerbosityOne, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetMiningInfo, GetNetTotals, GetNetworkInfo, - GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, - GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTxOut, GetTxOutSetInfo, - GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, ListAddressGroupings, - ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, - ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, - ListUnspentItem, ListWallets, LoadWallet, Locked, PeerInfo, RescanBlockchain, ScriptPubkey, - SendMany, SendRawTransaction, SendToAddress, SignErrorData, SignMessage, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, + GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, + GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, + GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, + GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, + GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, + GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOut, GetTxOutError, + GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, + GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, + ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, + ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, + ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, Locked, + PeerInfo, RescanBlockchain, ScriptPubkey, SendMany, SendRawTransaction, SendToAddress, + SignErrorData, SignMessage, SignRawTransactionWithWallet, SoftforkReject, + TransactionCategory, UploadTarget, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index eb456fe6..8f6adb01 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -237,25 +237,29 @@ pub use self::wallet::UnloadWallet; #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddedNode, AddedNodeAddress, AddressInformation, Banned, BumpFee, - ChainTips, ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, + AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, + AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerbosityOne, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetMiningInfo, GetNetTotals, GetNetworkInfo, - GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, - GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTxOut, GetTxOutSetInfo, - GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, ListAddressGroupings, - ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, - ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, - ListUnspentItem, ListWallets, LoadWallet, Locked, PeerInfo, RescanBlockchain, ScriptPubkey, - SendMany, SendRawTransaction, SendToAddress, SignErrorData, SignMessage, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, + GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, + GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, + GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, + GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, + GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, + GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOut, GetTxOutError, + GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, + GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, + ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, + ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, + ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, Locked, + PeerInfo, RescanBlockchain, ScriptPubkey, SendMany, SendRawTransaction, SendToAddress, + SignErrorData, SignMessage, SignRawTransactionWithWallet, SoftforkReject, + TransactionCategory, UploadTarget, VerifyTxOutProof, WalletCreateFundedPsbt, + WalletProcessPsbt, }, v18::{ActiveCommand, GetRpcInfo}, v19::{ diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 4f78af2f..28f572af 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -252,20 +252,23 @@ pub use self::{ #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddedNode, AddedNodeAddress, AddressInformation, Banned, BumpFee, - ChainTips, ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, + AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, + AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerbosityOne, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetMiningInfo, GetNetTotals, GetNetworkInfo, - GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, - GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTxOutSetInfo, - GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, ListAddressGroupings, - ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, + GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, + GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, + GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, + GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, + GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, + GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOutSetInfo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, + ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, Locked, PeerInfo, RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, SignErrorData, SignMessage, diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index 765612d6..b0bc177c 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -236,20 +236,23 @@ #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddedNode, AddedNodeAddress, AddressInformation, Banned, BumpFee, - ChainTips, ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, + AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, + AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerbosityOne, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetMiningInfo, GetNetTotals, GetNetworkInfo, - GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, - GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTxOutSetInfo, - GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, ListAddressGroupings, - ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, + GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, + GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, + GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, + GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, + GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, + GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOutSetInfo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, + ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, Locked, PeerInfo, RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, SignErrorData, SignMessage, diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index aede4eca..63488831 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -240,20 +240,23 @@ #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddedNode, AddedNodeAddress, AddressInformation, Banned, BumpFee, - ChainTips, ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, + AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, + AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CreateRawTransaction, CreateWallet, DumpPrivKey, DumpWallet, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerbosityOne, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetMiningInfo, GetNetTotals, GetNetworkInfo, - GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, - GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTxOutSetInfo, - GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, ListAddressGroupings, - ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, + GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, + GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, + GetBlockStats, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, + GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, + GetChainTxStats, GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, + GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, + GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOutSetInfo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, + ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, LoadWallet, Locked, PeerInfo, RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, SignErrorData, SignMessage, diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index 68593747..9d029430 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -245,20 +245,23 @@ pub use self::wallet::{CreateWallet, LoadWallet, UnloadWallet}; #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddedNode, AddedNodeAddress, AddressInformation, Banned, BumpFee, - ChainTips, ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoLabel, GetAddressesByLabel, + AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, + AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, FundRawTransaction, + FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, + GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerbosityOne, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetMiningInfo, GetNetTotals, GetNetworkInfo, - GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, - GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTxOutSetInfo, - GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, ListAddressGroupings, - ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, + GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, + GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, + GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, + GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, + GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, + GetTransaction, GetTransactionDetail, GetTransactionError, GetTxOutSetInfo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, + ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, Locked, PeerInfo, RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, SignErrorData, SignMessage, diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index 3246b1c6..ad5b9f51 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -259,17 +259,20 @@ pub use self::{ #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddedNode, AddedNodeAddress, AddressInformation, Banned, BumpFee, - ChainTips, ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoLabel, GetAddressesByLabel, + AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, + AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, FundRawTransaction, + FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, + GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerbosityOne, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetMiningInfo, GetNetTotals, GetNetworkInfo, - GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, - GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetUnconfirmedBalance, + GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, + GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, + GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, + GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, + GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, + GetTransaction, GetTransactionDetail, GetTransactionError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 4bc42a64..0a5d56cd 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -249,17 +249,20 @@ #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddedNode, AddedNodeAddress, AddressInformation, Banned, BumpFee, - ChainTips, ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoLabel, GetAddressesByLabel, + AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, + AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, FundRawTransaction, + FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, + GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerbosityOne, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetMiningInfo, GetNetTotals, GetNetworkInfo, - GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, - GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetUnconfirmedBalance, + GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, + GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, + GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, + GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, + GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, + GetTransaction, GetTransactionDetail, GetTransactionError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 3a7569a8..b49ff179 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -263,22 +263,25 @@ pub use self::{blockchain::GetBlockchainInfo, mining::GetMiningInfo, network::Ge #[doc(inline)] pub use crate::{ v17::{ - AddMultisigAddress, AddedNode, AddedNodeAddress, AddressInformation, Banned, BumpFee, - ChainTips, ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, - FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoLabel, GetAddressesByLabel, + AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, + AddressInformation, Banned, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CreateRawTransaction, DumpPrivKey, DumpWallet, FundRawTransaction, + FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfo, + GetAddressInfoEmbedded, GetAddressInfoError, GetAddressInfoLabel, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderVerbose, GetBlockStats, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerbosityOne, GetBlockVerbosityZero, GetChainTips, GetChainTxStats, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfo, GetNetTotals, GetNetworkInfoAddress, - GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, - GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetReceivedByAddress, - GetTransaction, GetTransactionDetail, GetUnconfirmedBalance, GetWalletInfo, - GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsItem, ListBanned, - ListLabels, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, - ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockTransaction, ListTransactions, - ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, Locked, PeerInfo, - RescanBlockchain, SendMany, SendRawTransaction, SendToAddress, SignErrorData, SignMessage, + GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, + GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, + GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStats, + GetChainTxStatsError, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, + GetMempoolInfoError, GetNetTotals, GetNetworkInfoAddress, GetNetworkInfoError, + GetNetworkInfoNetwork, GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, + GetRawMempoolVerbose, GetReceivedByAddress, GetTransaction, GetTransactionDetail, + GetTransactionError, GetUnconfirmedBalance, GetWalletInfo, GetZmqNotifications, + ListAddressGroupings, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, ListSinceBlock, + ListSinceBlockTransaction, ListTransactions, ListTransactionsItem, ListUnspent, + ListUnspentItem, ListWallets, Locked, PeerInfo, RescanBlockchain, SendMany, + SendRawTransaction, SendToAddress, SignErrorData, SignMessage, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, VerifyTxOutProof, WalletCreateFundedPsbt, WalletProcessPsbt, }, diff --git a/verify/src/main.rs b/verify/src/main.rs index 2826808c..5ab4de83 100644 --- a/verify/src/main.rs +++ b/verify/src/main.rs @@ -212,7 +212,7 @@ mod check_integration_test_crate { Ok(functions) } - /// Checks that a type exists in `model` module. + /// Checks that a test exists in the given test output. pub fn test_exists(version: Version, method_name: &str, test_output: &str) -> Result { let method = match method::Method::from_name(version, method_name) { Some(m) => m, @@ -223,11 +223,16 @@ mod check_integration_test_crate { ))), }; - let tests = all_test_functions(test_output)?; - if !tests.contains(&method.function.to_string()) { - Ok(false) + let test_name = if method.requires_model { + format!("__{}__modelled", method.function) } else { - Ok(true) + format!("__{}", method.function) + }; + for t in all_test_functions(test_output)? { + if t.contains(&test_name) { + return Ok(true) + } } + Ok(false) } } diff --git a/verify/src/method/v17.rs b/verify/src/method/v17.rs index a5a2d93f..303ae2f2 100644 --- a/verify/src/method/v17.rs +++ b/verify/src/method/v17.rs @@ -6,8 +6,9 @@ use super::Method; /// Data for the JSON RPC methods provided by Bitcoin Core v17. pub const METHODS: &[Method] = &[ + // blockchain Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockhash", "GetBlockHash", "get_block_hash"), @@ -34,18 +35,22 @@ pub const METHODS: &[Method] = &[ Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), Method::new_bool("verifychain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), + // control Method::new_no_model("getmemoryinfo", "GetMemoryInfoStats", "get_memory_info"), Method::new_string("help", "help"), Method::new_no_model("logging", "Logging", "logging"), Method::new_string("stop", "stop"), Method::new_numeric("uptime", "uptime"), + // generating Method::new_modelled("generate", "Generate", "generate"), Method::new_modelled("generatetoaddress", "GenerateToAddress", "generate_to_address"), + // mining Method::new_modelled("getblocktemplate", "GetBlockTemplate", "get_block_template"), Method::new_no_model("getmininginfo", "GetMiningInfo", "get_mining_info"), - Method::new_nothing("getnetworkhashps", "get_network_hashes_per_second"), + Method::new_numeric("getnetworkhashps", "get_network_hashes_per_second"), Method::new_bool("prioritisetransaction", "prioritise_transaction"), Method::new_nothing("submitblock", "submit_block"), + // network Method::new_nothing("addnode", "add_node"), Method::new_nothing("clearbanned", "clear_banned"), Method::new_nothing("disconnectnode", "disconnect_node"), @@ -58,6 +63,7 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("ping", "ping"), Method::new_nothing("setban", "set_ban"), Method::new_nothing("setnetworkactive", "set_network_active"), + // raw transactions Method::new_nothing("combinepsbt", "combine_psbt"), Method::new_nothing("combinerawtransaction", "combine_raw_transaction"), Method::new_nothing("converttopsbt", "convert_to_psbt"), @@ -73,11 +79,13 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("signrawtransaction", "sign_raw_transaction"), Method::new_nothing("signrawtransactionwithkey", "sign_raw_transaction_with_key"), Method::new_nothing("testmempoolaccept", "test_mempool_accept"), + // util Method::new_modelled("createmultisig", "CreateMultisig", "create_multisig"), Method::new_nothing("estimatesmartfee", "estimate_smart_fee"), Method::new_string("signmessagewithprivkey", "sign_message_with_priv_key"), Method::new_modelled("validateaddress", "ValidateAddress", "validate_address"), Method::new_bool("verifymessage", "verify_message"), + // wallet Method::new_nothing("abandontransaction", "abandon_transaction"), Method::new_nothing("abortrescan", "abort_rescan"), Method::new_modelled("addmultisigaddress", "AddMultisigAddress", "add_multisig_address"), @@ -152,5 +160,6 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("walletpassphrase", "wallet_passphrase"), Method::new_nothing("walletpassphrasechange", "wallet_passphrase_change"), Method::new_modelled("walletprocesspsbt", "WalletProcessPsbt", "wallet_process_psbt"), + // zmq Method::new_no_model("getzmqnotifications", "GetZmqNotifications", "get_zmq_notifications"), ]; diff --git a/verify/src/method/v18.rs b/verify/src/method/v18.rs index af0f0b83..0aa49696 100644 --- a/verify/src/method/v18.rs +++ b/verify/src/method/v18.rs @@ -7,7 +7,7 @@ use super::Method; /// Data for the JSON RPC methods provided by Bitcoin Core v18. pub const METHODS: &[Method] = &[ Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockhash", "GetBlockHash", "get_block_hash"), diff --git a/verify/src/method/v19.rs b/verify/src/method/v19.rs index cd12304c..6cb27897 100644 --- a/verify/src/method/v19.rs +++ b/verify/src/method/v19.rs @@ -7,10 +7,10 @@ use super::Method; /// Data for the JSON RPC methods provided by Bitcoin Core v19. pub const METHODS: &[Method] = &[ Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), - Method::new_no_model("getblockfilter", "GetBlockFilter", "get_block_filter"), // TODO: Use modeled. + Method::new_no_model("getblockfilter", "GetBlockFilter", "get_block_filter"), // TODO: Use modelled. Method::new_modelled("getblockhash", "GetBlockHash", "get_block_hash"), Method::new_modelled("getblockheader", "GetBlockHeader", "get_block_header"), Method::new_modelled("getblockstats", "GetBlockStats", "get_block_stats"), diff --git a/verify/src/method/v20.rs b/verify/src/method/v20.rs index 56da545b..0783ead3 100644 --- a/verify/src/method/v20.rs +++ b/verify/src/method/v20.rs @@ -7,7 +7,7 @@ use super::Method; /// Data for the JSON RPC methods provided by Bitcoin Core v20. pub const METHODS: &[Method] = &[ Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockfilter", "GetBlockFilter", "get_block_filter"), diff --git a/verify/src/method/v21.rs b/verify/src/method/v21.rs index 8bb6d5d3..e0fd0601 100644 --- a/verify/src/method/v21.rs +++ b/verify/src/method/v21.rs @@ -7,7 +7,7 @@ use super::Method; /// Data for the JSON RPC methods provided by Bitcoin Core v21. pub const METHODS: &[Method] = &[ Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockfilter", "GetBlockFilter", "get_block_filter"), diff --git a/verify/src/method/v22.rs b/verify/src/method/v22.rs index 01f2debd..207599a4 100644 --- a/verify/src/method/v22.rs +++ b/verify/src/method/v22.rs @@ -7,7 +7,7 @@ use super::Method; /// Data for the JSON RPC methods provided by Bitcoin Core v22. pub const METHODS: &[Method] = &[ Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockfilter", "GetBlockFilter", "get_block_filter"), diff --git a/verify/src/method/v23.rs b/verify/src/method/v23.rs index c6688b81..0b2d06b4 100644 --- a/verify/src/method/v23.rs +++ b/verify/src/method/v23.rs @@ -7,7 +7,7 @@ use super::Method; /// Data for the JSON RPC methods provided by Bitcoin Core v23. pub const METHODS: &[Method] = &[ Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockfilter", "GetBlockFilter", "get_block_filter"), diff --git a/verify/src/method/v24.rs b/verify/src/method/v24.rs index c41c7e9c..bb16af93 100644 --- a/verify/src/method/v24.rs +++ b/verify/src/method/v24.rs @@ -7,7 +7,7 @@ use super::Method; /// Data for the JSON RPC methods provided by Bitcoin Core v24. pub const METHODS: &[Method] = &[ Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockfilter", "GetBlockFilter", "get_block_filter"), diff --git a/verify/src/method/v25.rs b/verify/src/method/v25.rs index 32020e6b..2c5ea011 100644 --- a/verify/src/method/v25.rs +++ b/verify/src/method/v25.rs @@ -7,7 +7,7 @@ use super::Method; /// Data for the JSON RPC methods provided by Bitcoin Core v25. pub const METHODS: &[Method] = &[ Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockfilter", "GetBlockFilter", "get_block_filter"), diff --git a/verify/src/method/v26.rs b/verify/src/method/v26.rs index eda33e6e..db26e8c8 100644 --- a/verify/src/method/v26.rs +++ b/verify/src/method/v26.rs @@ -8,7 +8,7 @@ use super::Method; pub const METHODS: &[Method] = &[ Method::new_no_model("dumptxoutset", "DumpTxOutSet", "dump_tx_out_set"), Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockfilter", "GetBlockFilter", "get_block_filter"), diff --git a/verify/src/method/v27.rs b/verify/src/method/v27.rs index 6d67c428..2dfb3cb3 100644 --- a/verify/src/method/v27.rs +++ b/verify/src/method/v27.rs @@ -8,7 +8,7 @@ use super::Method; pub const METHODS: &[Method] = &[ Method::new_no_model("dumptxoutset", "DumpTxOutSet", "dump_tx_out_set"), Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockfilter", "GetBlockFilter", "get_block_filter"), diff --git a/verify/src/method/v28.rs b/verify/src/method/v28.rs index c954655d..e757f65a 100644 --- a/verify/src/method/v28.rs +++ b/verify/src/method/v28.rs @@ -8,7 +8,7 @@ use super::Method; pub const METHODS: &[Method] = &[ Method::new_no_model("dumptxoutset", "DumpTxOutSet", "dump_tx_out_set"), Method::new_modelled("getbestblockhash", "GetBestBlockHash", "get_best_block_hash"), - Method::new_modelled("getblock", "GetBlockVerbosityZero", "get_block"), // We only check one of the types. + Method::new_modelled("getblock", "GetBlockVerboseZero", "get_block"), // We only check one of the types. Method::new_modelled("getblockchaininfo", "GetBlockchainInfo", "get_blockchain_info"), Method::new_modelled("getblockcount", "GetBlockCount", "get_block_count"), Method::new_modelled("getblockfilter", "GetBlockFilter", "get_block_filter"),