Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/src/client_sync/v17/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::client_sync::{handle_defaults, into_json};
use crate::json::v17::*;

crate::define_jsonrpc_minreq_client!("v17");
crate::impl_client_check_expected_server_version!({ [170100] });

// == Blockchain ==
crate::impl_client_v17__getblockchaininfo!();
Expand All @@ -45,8 +46,9 @@ crate::impl_client_v17__generatetoaddress!();
crate::impl_client_v17__generate!();

// == Network ==
crate::impl_client_v17__getnettotals!();
crate::impl_client_v17__getnetworkinfo!();
crate::impl_client_check_expected_server_version!({ [170100] });
crate::impl_client_v17__getpeerinfo!();

// == Rawtransactions ==
crate::impl_client_v17__sendrawtransaction!();
Expand Down
20 changes: 20 additions & 0 deletions client/src/client_sync/v17/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
//!
//! See, or use the `define_jsonrpc_minreq_client!` macro to define a `Client`.

/// Implements bitcoind JSON-RPC API method `getnettotals`
#[macro_export]
macro_rules! impl_client_v17__getnettotals {
() => {
impl Client {
pub fn get_net_totals(&self) -> Result<GetNetTotals> { self.call("getnettotals", &[]) }
}
};
}

/// Implements bitcoind JSON-RPC API method `getnetworkinfo`
#[macro_export]
macro_rules! impl_client_v17__getnetworkinfo {
Expand All @@ -26,3 +36,13 @@ macro_rules! impl_client_v17__getnetworkinfo {
}
};
}

/// Implements bitcoind JSON-RPC API method `getpeerinfo`
#[macro_export]
macro_rules! impl_client_v17__getpeerinfo {
() => {
impl Client {
pub fn get_peer_info(&self) -> Result<GetPeerInfo> { self.call("getpeerinfo", &[]) }
}
};
}
27 changes: 25 additions & 2 deletions integration_test/src/v17/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,40 @@
//! Specifically this is methods found under the `== Network ==` section of the
//! API docs of `bitcoind v0.17.1`.

/// Requires `Client` to be in scope and to implement `get_network_info`.
#[macro_export]
macro_rules! impl_test_v17__getnettotals {
() => {
#[test]
fn get_net_totals() {
let bitcoind = $crate::bitcoind_no_wallet();
let _ = bitcoind.client.get_net_totals().expect("getnettotals");
}
};
}

/// Requires `Client` to be in scope and to implement `get_network_info`.
#[macro_export]
macro_rules! impl_test_v17__getnetworkinfo {
() => {
#[test]
fn get_network_info() {
let bitcoind = $crate::bitcoind_no_wallet();
let json = bitcoind.client.get_network_info().expect("getnetworkinfo");
json.into_model().unwrap();
let _ = bitcoind.client.get_network_info().expect("getnetworkinfo");

bitcoind.client.check_expected_server_version().expect("unexpected version");
}
};
}

/// Requires `Client` to be in scope and to implement `get_peer_info`.
#[macro_export]
macro_rules! impl_test_v17__getpeerinfo {
() => {
#[test]
fn get_peer_info() {
let bitcoind = $crate::bitcoind_no_wallet();
let _ = bitcoind.client.get_peer_info().expect("getpeerinfo");
}
};
}
2 changes: 2 additions & 0 deletions integration_test/tests/v17_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ mod generating {
mod network {
use super::*;

impl_test_v17__getnettotals!();
impl_test_v17__getnetworkinfo!();
impl_test_v17__getpeerinfo!();
}

// == Rawtransactions ==
Expand Down
2 changes: 0 additions & 2 deletions json/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mod blockchain;
mod control;
mod generating;
mod mining;
mod network;
mod raw_transactions;
mod util;
mod wallet;
Expand All @@ -33,7 +32,6 @@ pub use self::{
GetMempoolAncestorsVerbose, GetTxOut, Softfork, SoftforkType,
},
generating::{Generate, GenerateToAddress},
network::{GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoNetwork},
raw_transactions::SendRawTransaction,
wallet::{
CreateWallet, GetBalance, GetBalances, GetBalancesMine, GetBalancesWatchOnly,
Expand Down
68 changes: 0 additions & 68 deletions json/src/model/network.rs

This file was deleted.

25 changes: 14 additions & 11 deletions json/src/v17/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@
//! - [ ] `submitblock "hexdata" ( "dummy" )`
//!
//! **== Network ==**
//! - [ ] `addnode "node" "add|remove|onetry"`
//! - [ ] `clearbanned`
//! - [ ] `disconnectnode "[address]" [nodeid]`
//! - [-] `addnode "node" "add|remove|onetry"`
//! - [-] `clearbanned`
//! - [-] `disconnectnode "[address]" [nodeid]`
//! - [ ] `getaddednodeinfo ( "node" )`
//! - [ ] `getconnectioncount`
//! - [ ] `getnettotals`
//! - [-] `getconnectioncount`
//! - [x] `getnettotals`
//! - [x] `getnetworkinfo`
//! - [ ] `getpeerinfo`
//! - [ ] `listbanned`
//! - [ ] `ping`
//! - [ ] `setban "subnet" "add|remove" (bantime) (absolute)`
//! - [ ] `setnetworkactive true|false`
//! - [x] `getpeerinfo`
//! - [-] `listbanned`
//! - [-] `ping`
//! - [-] `setban "subnet" "add|remove" (bantime) (absolute)`
//! - [-] `setnetworkactive true|false`
//!
//! **== Rawtransactions ==**
//! - [ ] `combinepsbt ["psbt",...]`
Expand Down Expand Up @@ -179,7 +179,10 @@ pub use self::{
},
control::{GetMemoryInfoStats, Locked, Logging, Uptime},
generating::{Generate, GenerateToAddress},
network::{GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoNetwork},
network::{
AddedNodeAddress, BytesPerMessage, GetAddedNodeInfo, GetNetTotals, GetNetworkInfo,
GetNetworkInfoAddress, GetNetworkInfoNetwork, GetPeerInfo, PeerInfo, UploadTarget,
},
raw_transactions::SendRawTransaction,
wallet::{
CreateWallet, GetBalance, GetNewAddress, GetTransaction, GetTransactionDetail,
Expand Down
Loading
Loading