Skip to content

Commit

Permalink
fix(dht/test): ban peers who send empty encrypted messages (#5130)
Browse files Browse the repository at this point in the history
Description
---
Bans peers who send empty encrypted messages. Significantly updates tests to check for more failure modes and assert ban status for each.

Closes [issue 5132](#5132).

Motivation and Context
---
An [earlier PR](#5123) introduces an error when a peer sends an empty encrypted message, which is not allowed. However, the peer was not banned.

Further, [another PR](#5129) updates the handling of unsigned encrypted messages to ensure that bans are done correctly, but does not update tests to check for the bug that led to it.

This PR updates the banning logic to ban a peer who forwards an empty encrypted message, which is always detectable.

It also significantly refactors and updates tests. For each relevant high-level message failure mode, we test for proper error detection. We also check for the proper ban status of the forwarding peer.

How Has This Been Tested?
---
[Who tests the testers?](https://en.wikipedia.org/wiki/Quis_custodiet_ipsos_custodes%3F)
  • Loading branch information
AaronFeickert committed Jan 31, 2023
1 parent 4c4a056 commit 86a9eaf
Show file tree
Hide file tree
Showing 3 changed files with 254 additions and 147 deletions.
2 changes: 1 addition & 1 deletion comms/dht/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use thiserror::Error;

#[derive(Debug, Error)]
#[derive(Debug, Error, PartialEq)]
pub enum DhtEncryptError {
#[error("Message body invalid")]
InvalidMessageBody,
Expand Down
Loading

0 comments on commit 86a9eaf

Please sign in to comment.