Skip to content

Commit

Permalink
feat(tcp): add a test for (set|get)_congestion_control()
Browse files Browse the repository at this point in the history
Signed-off-by: Yuuki Takano <[email protected]>
  • Loading branch information
ytakano committed Feb 21, 2024
1 parent b3e38ee commit 04c62d9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ impl<'a> Socket<'a> {
/// be more efficient and fair compared to `CongestionControl::Reno`.
/// It is the default choice for Linux, Windows, and macOS.
///
/// `CongestionControl::Reno` is a classic congestion control algorithm valued for its simplicity and
/// widespread support. Despite having a lower algorithmic complexity than `Cubic`,
/// `CongestionControl::Reno` is a classic congestion control algorithm valued for its simplicity.
/// Despite having a lower algorithmic complexity than `Cubic`,
/// it is less efficient in terms of bandwidth usage.
pub fn set_congestion_control(&mut self, congestion_control: CongestionControl) {
use congestion_controller::*;
Expand Down Expand Up @@ -7378,4 +7378,18 @@ mod test {
assert_eq!(r.retransmission_timeout(), Duration::from_millis(rto));
}
}

#[test]
fn test_set_get_congestion_control() {
let mut s = socket_established();

s.set_congestion_control(CongestionControl::Reno);
assert_eq!(s.get_congestion_control(), CongestionControl::Reno);

s.set_congestion_control(CongestionControl::Cubic);
assert_eq!(s.get_congestion_control(), CongestionControl::Cubic);

s.set_congestion_control(CongestionControl::None);
assert_eq!(s.get_congestion_control(), CongestionControl::None);
}
}

0 comments on commit 04c62d9

Please sign in to comment.