unittest for bind two consecutive ports (#23008)
* minor fix of comments in fork-selection tests * fix doc link * add unittest for bind_two_consecutive_in_range
This commit is contained in:
parent
8de88d0a55
commit
4f0070a5c6
|
@ -1,13 +1,13 @@
|
||||||
//! Fork Selection Simulation
|
//! Fork Selection Simulation
|
||||||
//!
|
//!
|
||||||
//! Description of the algorithm can be found in [docs/src/fork-selection.md](docs/src/fork-selection.md).
|
//! Description of the algorithm can be found in [docs/src/cluster/managing-forks.md](docs/src/cluster/managing-forks.md).
|
||||||
//!
|
//!
|
||||||
//! A test library function exists for configuring networks.
|
//! A test library function exists for configuring networks.
|
||||||
//! ```
|
//! ```
|
||||||
//! /// * num_partitions - 1 to 100 partitions
|
//! /// * num_partitions - 1 to 100 partitions
|
||||||
//! /// * fail_rate - 0 to 1.0 rate of packet receive failure
|
//! /// * fail_rate - 0 to 1.0 rate of packet receive failure
|
||||||
//! /// * delay_count - number of forks to observe before voting
|
//! /// * delay_count - number of forks to observe before voting
|
||||||
//! /// * parasite_rate - number of parasite nodes that vote opposite the greedy choice
|
//! /// * parasite_rate - percentage of parasite nodes that vote opposite the greedy choice
|
||||||
//! fn test_with_partitions(num_partitions: usize, fail_rate: f64, delay_count: usize, parasite_rate: f64);
|
//! fn test_with_partitions(num_partitions: usize, fail_rate: f64, delay_count: usize, parasite_rate: f64);
|
||||||
//! ```
|
//! ```
|
||||||
//! Modify the test function
|
//! Modify the test function
|
||||||
|
@ -497,7 +497,7 @@ fn test_no_partitions() {
|
||||||
/// * num_partitions - 1 to 100 partitions
|
/// * num_partitions - 1 to 100 partitions
|
||||||
/// * fail_rate - 0 to 1.0 rate of packet receive failure
|
/// * fail_rate - 0 to 1.0 rate of packet receive failure
|
||||||
/// * delay_count - number of forks to observe before voting
|
/// * delay_count - number of forks to observe before voting
|
||||||
/// * parasite_rate - number of parasite nodes that vote opposite the greedy choice
|
/// * parasite_rate - percentage of parasite nodes that vote opposite the greedy choice
|
||||||
fn test_with_partitions(
|
fn test_with_partitions(
|
||||||
num_partitions: usize,
|
num_partitions: usize,
|
||||||
fail_rate: f64,
|
fail_rate: f64,
|
||||||
|
|
|
@ -790,4 +790,14 @@ mod tests {
|
||||||
3,
|
3,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_bind_two_consecutive_in_range() {
|
||||||
|
solana_logger::setup();
|
||||||
|
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||||
|
if let Ok(((port1, _), (port2, _))) = bind_two_consecutive_in_range(ip_addr, (1024, 65535))
|
||||||
|
{
|
||||||
|
assert!(port2 == port1 + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue