mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: use DEFAULT_DISCOVERY_PORT constant (#4356)
This commit is contained in:
@ -2178,7 +2178,7 @@ mod tests {
|
||||
|
||||
let v4: Ipv4Addr = "0.0.0.0".parse().unwrap();
|
||||
let v6 = v4.to_ipv6_mapped();
|
||||
let addr: SocketAddr = (v6, 30303).into();
|
||||
let addr: SocketAddr = (v6, DEFAULT_DISCOVERY_PORT).into();
|
||||
|
||||
let ping = Ping {
|
||||
from: rng_endpoint(&mut rng),
|
||||
@ -2210,7 +2210,7 @@ mod tests {
|
||||
|
||||
let v4: Ipv4Addr = "0.0.0.0".parse().unwrap();
|
||||
let v6 = v4.to_ipv6_mapped();
|
||||
let addr: SocketAddr = (v6, 30303).into();
|
||||
let addr: SocketAddr = (v6, DEFAULT_DISCOVERY_PORT).into();
|
||||
|
||||
let ping = Ping {
|
||||
from: rng_endpoint(&mut rng),
|
||||
|
||||
@ -496,7 +496,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
test_utils::{rng_endpoint, rng_ipv4_record, rng_ipv6_record, rng_message},
|
||||
SAFE_MAX_DATAGRAM_NEIGHBOUR_RECORDS,
|
||||
DEFAULT_DISCOVERY_PORT, SAFE_MAX_DATAGRAM_NEIGHBOUR_RECORDS,
|
||||
};
|
||||
use enr::{EnrBuilder, EnrPublicKey};
|
||||
use rand::{thread_rng, Rng, RngCore};
|
||||
@ -773,7 +773,7 @@ mod tests {
|
||||
|
||||
assert_eq!(enr.0.ip4(), Some(Ipv4Addr::new(127, 0, 0, 1)));
|
||||
assert_eq!(enr.0.id(), Some(String::from("v4")));
|
||||
assert_eq!(enr.0.udp4(), Some(30303));
|
||||
assert_eq!(enr.0.udp4(), Some(DEFAULT_DISCOVERY_PORT));
|
||||
assert_eq!(enr.0.tcp4(), None);
|
||||
assert_eq!(enr.0.signature(), &signature[..]);
|
||||
assert_eq!(pubkey.to_vec(), expected_pubkey);
|
||||
@ -808,7 +808,7 @@ mod tests {
|
||||
|
||||
assert_eq!(enr.0.ip4(), Some(Ipv4Addr::new(127, 0, 0, 1)));
|
||||
assert_eq!(enr.0.id(), Some(String::from("v4")));
|
||||
assert_eq!(enr.0.udp4(), Some(30303));
|
||||
assert_eq!(enr.0.udp4(), Some(DEFAULT_DISCOVERY_PORT));
|
||||
assert_eq!(enr.0.tcp4(), None);
|
||||
assert_eq!(enr.0.signature(), &signature[..]);
|
||||
assert_eq!(pubkey.to_vec(), expected_pubkey);
|
||||
|
||||
@ -24,6 +24,7 @@ reth-rlp = { workspace = true, features = [
|
||||
"ethereum-types",
|
||||
"smol_str",
|
||||
] }
|
||||
reth-discv4 = {path = "../discv4" }
|
||||
|
||||
# metrics
|
||||
reth-metrics.workspace = true
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
use crate::{
|
||||
capability::Capability, hello::HelloMessage, p2pstream::ProtocolVersion, EthVersion, Status,
|
||||
};
|
||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
||||
use reth_primitives::{Chain, ForkId, PeerId, H256, U256};
|
||||
|
||||
/// Builder for [`Status`](crate::types::Status) messages.
|
||||
@ -100,7 +101,7 @@ impl HelloBuilder {
|
||||
client_version: "Ethereum/1.0.0".to_string(),
|
||||
capabilities: vec![EthVersion::Eth68.into()],
|
||||
// TODO: default port config
|
||||
port: 30303,
|
||||
port: DEFAULT_DISCOVERY_PORT,
|
||||
id: pubkey,
|
||||
},
|
||||
}
|
||||
|
||||
@ -323,6 +323,7 @@ mod tests {
|
||||
};
|
||||
use ethers_core::types::Chain;
|
||||
use futures::{SinkExt, StreamExt};
|
||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
||||
use reth_ecies::{stream::ECIESStream, util::pk2id};
|
||||
use reth_primitives::{ForkFilter, Head, H256, U256};
|
||||
use secp256k1::{SecretKey, SECP256K1};
|
||||
@ -591,7 +592,7 @@ mod tests {
|
||||
protocol_version: ProtocolVersion::V5,
|
||||
client_version: "bitcoind/1.0.0".to_string(),
|
||||
capabilities: vec![Capability::new("eth".into(), EthVersion::Eth67 as usize)],
|
||||
port: 30303,
|
||||
port: DEFAULT_DISCOVERY_PORT,
|
||||
id: pk2id(&server_key.public_key(SECP256K1)),
|
||||
};
|
||||
|
||||
@ -619,7 +620,7 @@ mod tests {
|
||||
protocol_version: ProtocolVersion::V5,
|
||||
client_version: "bitcoind/1.0.0".to_string(),
|
||||
capabilities: vec![Capability::new("eth".into(), EthVersion::Eth67 as usize)],
|
||||
port: 30303,
|
||||
port: DEFAULT_DISCOVERY_PORT,
|
||||
id: pk2id(&client_key.public_key(SECP256K1)),
|
||||
};
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use crate::{capability::Capability, EthVersion, ProtocolVersion};
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
||||
use reth_primitives::{constants::RETH_CLIENT_VERSION, PeerId};
|
||||
use reth_rlp::{RlpDecodable, RlpEncodable};
|
||||
|
||||
@ -99,7 +100,7 @@ impl HelloMessageBuilder {
|
||||
capabilities: capabilities.unwrap_or_else(|| {
|
||||
vec![EthVersion::Eth68.into(), EthVersion::Eth67.into(), EthVersion::Eth66.into()]
|
||||
}),
|
||||
port: port.unwrap_or(30303),
|
||||
port: port.unwrap_or(DEFAULT_DISCOVERY_PORT),
|
||||
id,
|
||||
}
|
||||
}
|
||||
@ -107,6 +108,7 @@ impl HelloMessageBuilder {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
||||
use reth_ecies::util::pk2id;
|
||||
use reth_rlp::{Decodable, Encodable, EMPTY_STRING_CODE};
|
||||
use secp256k1::{SecretKey, SECP256K1};
|
||||
@ -123,7 +125,7 @@ mod tests {
|
||||
protocol_version: ProtocolVersion::V5,
|
||||
client_version: "reth/0.1.0".to_string(),
|
||||
capabilities: vec![Capability::new("eth".into(), EthVersion::Eth67 as usize)],
|
||||
port: 30303,
|
||||
port: DEFAULT_DISCOVERY_PORT,
|
||||
id,
|
||||
});
|
||||
|
||||
@ -143,7 +145,7 @@ mod tests {
|
||||
protocol_version: ProtocolVersion::V5,
|
||||
client_version: "reth/0.1.0".to_string(),
|
||||
capabilities: vec![Capability::new("eth".into(), EthVersion::Eth67 as usize)],
|
||||
port: 30303,
|
||||
port: DEFAULT_DISCOVERY_PORT,
|
||||
id,
|
||||
});
|
||||
|
||||
@ -162,7 +164,7 @@ mod tests {
|
||||
protocol_version: ProtocolVersion::V5,
|
||||
client_version: "reth/0.1.0".to_string(),
|
||||
capabilities: vec![Capability::new("eth".into(), EthVersion::Eth67 as usize)],
|
||||
port: 30303,
|
||||
port: DEFAULT_DISCOVERY_PORT,
|
||||
id,
|
||||
});
|
||||
|
||||
|
||||
@ -827,6 +827,7 @@ impl Decodable for ProtocolVersion {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{DisconnectReason, EthVersion};
|
||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
||||
use reth_ecies::util::pk2id;
|
||||
use secp256k1::{SecretKey, SECP256K1};
|
||||
use tokio::net::{TcpListener, TcpStream};
|
||||
@ -839,7 +840,7 @@ mod tests {
|
||||
protocol_version: ProtocolVersion::V5,
|
||||
client_version: "bitcoind/1.0.0".to_string(),
|
||||
capabilities: vec![EthVersion::Eth67.into()],
|
||||
port: 30303,
|
||||
port: DEFAULT_DISCOVERY_PORT,
|
||||
id: pk2id(&server_key.public_key(SECP256K1)),
|
||||
};
|
||||
(hello, server_key)
|
||||
|
||||
@ -13,6 +13,7 @@ description = "Network interfaces"
|
||||
reth-primitives.workspace = true
|
||||
reth-eth-wire = { path = "../eth-wire" }
|
||||
reth-rpc-types.workspace = true
|
||||
reth-discv4 = { path = "../discv4" }
|
||||
|
||||
# io
|
||||
serde = { workspace = true, features = ["derive"], optional = true }
|
||||
|
||||
@ -7,6 +7,7 @@ use crate::{
|
||||
NetworkError, NetworkInfo, PeerKind, Peers, PeersInfo, Reputation, ReputationChangeKind,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use reth_discv4::DEFAULT_DISCOVERY_PORT;
|
||||
use reth_eth_wire::{DisconnectReason, ProtocolVersion};
|
||||
use reth_primitives::{Chain, NodeRecord, PeerId};
|
||||
use reth_rpc_types::{EthProtocolInfo, NetworkStatus};
|
||||
@ -22,7 +23,7 @@ pub struct NoopNetwork;
|
||||
#[async_trait]
|
||||
impl NetworkInfo for NoopNetwork {
|
||||
fn local_addr(&self) -> SocketAddr {
|
||||
(IpAddr::from(std::net::Ipv4Addr::UNSPECIFIED), 30303).into()
|
||||
(IpAddr::from(std::net::Ipv4Addr::UNSPECIFIED), DEFAULT_DISCOVERY_PORT).into()
|
||||
}
|
||||
|
||||
async fn network_status(&self) -> Result<NetworkStatus, NetworkError> {
|
||||
|
||||
Reference in New Issue
Block a user