mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
Remove generic Id param from RequestId (#6032)
* rename RequestId's for better context, and move them to lighthouse_network crate. * remove unrequired generic AppReqId from RequestID
This commit is contained in:
@@ -212,7 +212,7 @@ mod tests {
|
||||
use crate::rpc::rate_limiter::Quota;
|
||||
use crate::rpc::self_limiter::SelfRateLimiter;
|
||||
use crate::rpc::{OutboundRequest, Ping, Protocol};
|
||||
use crate::service::api_types::RequestId;
|
||||
use crate::service::api_types::{AppRequestId, RequestId, SyncRequestId};
|
||||
use libp2p::PeerId;
|
||||
use std::time::Duration;
|
||||
use types::MainnetEthSpec;
|
||||
@@ -225,15 +225,17 @@ mod tests {
|
||||
ping_quota: Quota::n_every(1, 2),
|
||||
..Default::default()
|
||||
});
|
||||
let mut limiter: SelfRateLimiter<RequestId<u64>, MainnetEthSpec> =
|
||||
let mut limiter: SelfRateLimiter<RequestId, MainnetEthSpec> =
|
||||
SelfRateLimiter::new(config, log).unwrap();
|
||||
let peer_id = PeerId::random();
|
||||
|
||||
for i in 1..=5 {
|
||||
for i in 1..=5u32 {
|
||||
let _ = limiter.allows(
|
||||
peer_id,
|
||||
RequestId::Application(i),
|
||||
OutboundRequest::Ping(Ping { data: i }),
|
||||
RequestId::Application(AppRequestId::Sync(SyncRequestId::RangeBlockAndBlobs {
|
||||
id: i,
|
||||
})),
|
||||
OutboundRequest::Ping(Ping { data: i as u64 }),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -246,8 +248,13 @@ mod tests {
|
||||
|
||||
// Check that requests in the queue are ordered in the sequence 2, 3, 4, 5.
|
||||
let mut iter = queue.iter();
|
||||
for i in 2..=5 {
|
||||
assert_eq!(iter.next().unwrap().request_id, RequestId::Application(i));
|
||||
for i in 2..=5u32 {
|
||||
assert!(matches!(
|
||||
iter.next().unwrap().request_id,
|
||||
RequestId::Application(AppRequestId::Sync(SyncRequestId::RangeBlockAndBlobs {
|
||||
id,
|
||||
})) if id == i
|
||||
));
|
||||
}
|
||||
|
||||
assert_eq!(limiter.ready_requests.len(), 0);
|
||||
@@ -267,7 +274,12 @@ mod tests {
|
||||
// Check that requests in the queue are ordered in the sequence 3, 4, 5.
|
||||
let mut iter = queue.iter();
|
||||
for i in 3..=5 {
|
||||
assert_eq!(iter.next().unwrap().request_id, RequestId::Application(i));
|
||||
assert!(matches!(
|
||||
iter.next().unwrap().request_id,
|
||||
RequestId::Application(AppRequestId::Sync(SyncRequestId::RangeBlockAndBlobs {
|
||||
id
|
||||
})) if id == i
|
||||
));
|
||||
}
|
||||
|
||||
assert_eq!(limiter.ready_requests.len(), 1);
|
||||
|
||||
Reference in New Issue
Block a user