Skip to content

Commit 8483376

Browse files
committed
Merge #321: Remove getnodeaddresses model
da947f1 Remove getnodeaddresses model (Jamil Lambert, PhD) Pull request description: `getnodeaddresses` returns a node address not a bitcoin address. Remove the model. Update the test to create 3 nodes and remove the model. The RPC still returns an empty list with 3 nodes see Issue #320. ACKs for top commit: tcharding: ACK da947f1 Tree-SHA512: 5d960d19726745d8136557dae271ae8810c4bcc89ec72eeef16e80811bdbbf45f51497670367ab00166403a9f8a5f9561a210944d1c76b84ab69f21e97265389
2 parents 9423aa8 + da947f1 commit 8483376

File tree

29 files changed

+33
-92
lines changed

29 files changed

+33
-92
lines changed

integration_test/tests/network.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,15 @@ fn network__get_network_info__modelled() {
8686
}
8787

8888
#[test]
89-
// Core version 18 onwards.
9089
#[cfg(not(feature = "v17"))]
9190
fn network__get_node_addresses() {
92-
let node = Node::with_wallet(Wallet::None, &[]);
93-
let json: GetNodeAddresses = node.client.get_node_addresses().expect("getnodeaddresses");
94-
let res: Result<mtype::GetNodeAddresses, _> = json.into_model();
95-
let model = res.expect("GetNodeAddresses into model");
96-
assert!(model.0.len() <= 2500);
97-
if let Some(addr) = model.0.first() {
98-
assert!(addr.port > 0);
99-
assert!(addr.time > 1231006505);
100-
}
91+
let (node1, node2, node3) = integration_test::three_node_network();
92+
93+
node1.mine_a_block();
94+
node2.mine_a_block();
95+
node3.mine_a_block();
96+
97+
let _: GetNodeAddresses = node1.client.get_node_addresses().expect("getnodeaddresses");
10198
}
10299

103100
#[test]

types/src/model/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ pub use self::{
3737
BlockTemplateTransaction, GetBlockTemplate, GetMiningInfo, GetPrioritisedTransactions,
3838
NextBlockInfo, PrioritisedTransaction,
3939
},
40-
network::{
41-
GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoNetwork, GetNodeAddresses, NodeAddress,
42-
},
40+
network::{GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoNetwork},
4341
raw_transactions::{
4442
AnalyzePsbt, AnalyzePsbtInput, AnalyzePsbtInputMissing, CombinePsbt, CombineRawTransaction,
4543
ConvertToPsbt, CreatePsbt, CreateRawTransaction, DecodePsbt, DecodeRawTransaction,

types/src/model/network.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
//! These structs model the types returned by the JSON-RPC API but have concrete types
66
//! and are not specific to a specific version of Bitcoin Core.
77
8-
use bitcoin::address::NetworkUnchecked;
9-
use bitcoin::{Address, FeeRate};
8+
use bitcoin::FeeRate;
109
use serde::{Deserialize, Serialize};
1110

1211
/// Models the result of JSON-RPC method `getnetworkinfo`.
@@ -74,26 +73,3 @@ pub struct GetNetworkInfoAddress {
7473
/// Relative score.
7574
pub score: u32,
7675
}
77-
78-
/// Result of JSON-RPC method `getnodeaddresses`.
79-
///
80-
/// > getnodeaddresses ( count )
81-
/// >
82-
/// > Return known addresses which can potentially be used to find new nodes in the network.
83-
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
84-
#[serde(deny_unknown_fields)]
85-
pub struct GetNodeAddresses(pub Vec<NodeAddress>);
86-
87-
/// An item from the list returned by the JSON-RPC method `getnodeaddresses`.
88-
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
89-
#[serde(deny_unknown_fields)]
90-
pub struct NodeAddress {
91-
/// Timestamp in seconds since epoch (Jan 1 1970 GMT) when the node was last seen.
92-
pub time: u64,
93-
/// The services offered.
94-
pub services: u64,
95-
/// The address of the node.
96-
pub address: Address<NetworkUnchecked>,
97-
/// The port of the node.
98-
pub port: u16,
99-
}

types/src/v18/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
//! | getconnectioncount | version | |
104104
//! | getnettotals | version | |
105105
//! | getnetworkinfo | version + model | |
106-
//! | getnodeaddresses | version + model | |
106+
//! | getnodeaddresses | version | |
107107
//! | getpeerinfo | version | |
108108
//! | listbanned | version | |
109109
//! | ping | returns nothing | |

types/src/v18/network/into.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

types/src/v18/network/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
//!
55
//! Types for methods found under the `== Network ==` section of the API docs.
66
7-
mod into;
8-
97
use alloc::collections::BTreeMap;
108

119
use serde::{Deserialize, Serialize};

types/src/v19/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
//! | getconnectioncount | version | |
104104
//! | getnettotals | version | |
105105
//! | getnetworkinfo | version + model | |
106-
//! | getnodeaddresses | version + model | |
106+
//! | getnodeaddresses | version | |
107107
//! | getpeerinfo | version | |
108108
//! | listbanned | version | |
109109
//! | ping | returns nothing | |

types/src/v20/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
//! | getconnectioncount | version | |
105105
//! | getnettotals | version | |
106106
//! | getnetworkinfo | version + model | |
107-
//! | getnodeaddresses | version + model | |
107+
//! | getnodeaddresses | version | |
108108
//! | getpeerinfo | version | |
109109
//! | listbanned | version | |
110110
//! | ping | returns nothing | |

types/src/v21/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
//! | getconnectioncount | version | |
106106
//! | getnettotals | version | |
107107
//! | getnetworkinfo | version + model | |
108-
//! | getnodeaddresses | version + model | |
108+
//! | getnodeaddresses | version | |
109109
//! | getpeerinfo | version | |
110110
//! | listbanned | version | |
111111
//! | ping | returns nothing | |

types/src/v22/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
//! | getconnectioncount | version | |
106106
//! | getnettotals | version | |
107107
//! | getnetworkinfo | version + model | |
108-
//! | getnodeaddresses | version + model | |
108+
//! | getnodeaddresses | version | |
109109
//! | getpeerinfo | version | |
110110
//! | listbanned | version | |
111111
//! | ping | returns nothing | |

0 commit comments

Comments
 (0)