From f7b53139f48cbee3a0799b82043b1aec675fbb58 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 10 Jan 2024 14:30:36 +0000 Subject: [PATCH] radicle: add Config::seed constructor Add a `Config` constructor for testing seed nodes that uses `usize::MAX` for capacity. This allows test scenarios to not drop messages due to rate limiting -- all nodes are on the same IP address and rate limiting is performed per IP address. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle/src/node/config.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/radicle/src/node/config.rs b/radicle/src/node/config.rs index 9281eab7..29a04afa 100644 --- a/radicle/src/node/config.rs +++ b/radicle/src/node/config.rs @@ -227,6 +227,32 @@ impl Config { } } + /// Configuration for a test seed node. + /// + /// It sets the `RateLimit::capacity` to `usize::MAX` ensuring + /// that there are no rate limits for test nodes, since they all + /// operate on the same IP address. This prevents any announcement + /// messages from being dropped. + pub fn seed(alias: Alias) -> Self { + Self { + network: Network::Test, + limits: Limits { + rate: RateLimits { + inbound: RateLimit { + fill_rate: 1.0, + capacity: usize::MAX, + }, + outbound: RateLimit { + fill_rate: 1.0, + capacity: usize::MAX, + }, + }, + ..Limits::default() + }, + ..Self::new(alias) + } + } + pub fn new(alias: Alias) -> Self { Self { alias,