Skip to content

Commit

Permalink
Fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ackintosh committed Nov 29, 2024
1 parent 2d7a679 commit b73a336
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion beacon_node/lighthouse_network/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ impl<Id: ReqId, E: EthSpec> RPC<Id, E> {
Ok(event) => self.events.push(event),
Err(_e) => {
// Request is logged and queued internally in the self rate limiter.
return;
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions beacon_node/lighthouse_network/src/rpc/self_limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,13 @@ mod tests {
})),
RequestType::Ping(Ping { data: i as u64 }),
);

// Check that the limiter allows the first two requests.
if i <= 2 {
assert!(result.is_ok());
} else {
assert!(result.is_err());
}
}
}

Expand All @@ -455,6 +462,7 @@ mod tests {
.get(&(peer2, Protocol::Ping))
.is_some());

// Check that the limiter returns the IDs of pending requests and that the IDs are ordered correctly.
let mut failed_requests = limiter.peer_disconnected(peer1);
for i in 3..=5u32 {
let (request_id, _) = failed_requests.remove(0);
Expand All @@ -472,6 +480,7 @@ mod tests {
.delayed_requests
.get(&(peer1, Protocol::Ping))
.is_none());

assert!(limiter.active_requests.get(&peer2).is_some());
assert!(limiter
.delayed_requests
Expand Down

0 comments on commit b73a336

Please sign in to comment.