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 <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2024-01-10 14:30:36 +00:00 committed by cloudhead
parent b6d8bc9489
commit f7b53139f4
No known key found for this signature in database
1 changed files with 26 additions and 0 deletions

View File

@ -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,