Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove test feature from cfg #3435

Merged
merged 1 commit into from
Nov 13, 2024
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
10 changes: 5 additions & 5 deletions node/bft/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use futures::SinkExt;
use indexmap::{IndexMap, IndexSet};
use parking_lot::{Mutex, RwLock};
use rand::seq::{IteratorRandom, SliceRandom};
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
use std::net::IpAddr;
use std::{collections::HashSet, future::Future, io, net::SocketAddr, sync::Arc, time::Duration};
use tokio::{
Expand All @@ -92,7 +92,7 @@ const MIN_CONNECTED_VALIDATORS: usize = 175;
const MAX_VALIDATORS_TO_SEND: usize = 200;

/// The minimum permitted interval between connection attempts for an IP; anything shorter is considered malicious.
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
const CONNECTION_ATTEMPTS_SINCE_SECS: i64 = 10;
/// The amount of time an IP address is prohibited from connecting.
const IP_BAN_TIME_IN_SECS: u64 = 300;
Expand Down Expand Up @@ -469,13 +469,13 @@ impl<N: Network> Gateway<N> {
}

/// Check whether the given IP address is currently banned.
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
fn is_ip_banned(&self, ip: IpAddr) -> bool {
self.tcp.banned_peers().is_ip_banned(&ip)
}

/// Insert or update a banned IP.
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
fn update_ip_ban(&self, ip: IpAddr) {
self.tcp.banned_peers().update_ip_ban(ip);
}
Expand Down Expand Up @@ -1154,7 +1154,7 @@ impl<N: Network> Handshake for Gateway<N> {
let peer_side = connection.side();

// Check (or impose) IP-level bans.
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
if self.dev().is_none() && peer_side == ConnectionSide::Initiator {
// If the IP is already banned reject the connection.
if self.is_ip_banned(peer_addr.ip()) {
Expand Down
2 changes: 1 addition & 1 deletion node/router/src/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<N: Network> Router<N> {
};

// Check (or impose) IP-level bans.
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
if !self.is_dev() && peer_side == ConnectionSide::Initiator {
// If the IP is already banned reject the connection.
if self.is_ip_banned(peer_addr.ip()) {
Expand Down
10 changes: 5 additions & 5 deletions node/router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use snarkvm::prelude::{Address, Network, PrivateKey, ViewKey};

use anyhow::{Result, bail};
use parking_lot::{Mutex, RwLock};
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
use std::net::IpAddr;
use std::{
collections::{HashMap, HashSet, hash_map::Entry},
Expand Down Expand Up @@ -107,14 +107,14 @@ pub struct InnerRouter<N: Network> {

impl<N: Network> Router<N> {
/// The minimum permitted interval between connection attempts for an IP; anything shorter is considered malicious.
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
const CONNECTION_ATTEMPTS_SINCE_SECS: i64 = 10;
/// The maximum number of candidate peers permitted to be stored in the node.
const MAXIMUM_CANDIDATE_PEERS: usize = 10_000;
/// The maximum number of connection failures permitted by an inbound connecting peer.
const MAXIMUM_CONNECTION_FAILURES: usize = 5;
/// The maximum amount of connection attempts withing a 10 second threshold
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
const MAX_CONNECTION_ATTEMPTS: usize = 10;
/// The duration in seconds after which a connected peer is considered inactive or
/// disconnected if no message has been received in the meantime.
Expand Down Expand Up @@ -450,13 +450,13 @@ impl<N: Network> Router<N> {
}

/// Check whether the given IP address is currently banned.
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
fn is_ip_banned(&self, ip: IpAddr) -> bool {
self.tcp.banned_peers().is_ip_banned(&ip)
}

/// Insert or update a banned IP.
#[cfg(not(any(test, feature = "test")))]
#[cfg(not(any(test)))]
fn update_ip_ban(&self, ip: IpAddr) {
self.tcp.banned_peers().update_ip_ban(ip);
}
Expand Down