From 55662a3543b71108bd0128ec87bf4be5b83ca7de Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Tue, 17 Jan 2023 11:41:27 +0400 Subject: [PATCH] add test --- comms/dht/src/inbound/decryption.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/comms/dht/src/inbound/decryption.rs b/comms/dht/src/inbound/decryption.rs index 5177ad63079..e414044f2b6 100644 --- a/comms/dht/src/inbound/decryption.rs +++ b/comms/dht/src/inbound/decryption.rs @@ -578,6 +578,29 @@ mod test { assert_eq!(decrypted.decryption_result.unwrap_err(), inbound_msg.body); } + #[test] + fn decrypt_inbound_fail_empty_contents() { + let service = service_fn(move |_msg: DecryptedDhtMessage| future::ready(Result::<(), PipelineError>::Ok(()))); + let node_identity = make_node_identity(); + let (connectivity, _) = create_connectivity_mock(); + let mut service = DecryptionService::new(Default::default(), node_identity, connectivity, service); + + let some_other_node_identity = make_node_identity(); + let mut inbound_msg = make_dht_inbound_message( + &some_other_node_identity, + &Vec::new(), + DhtMessageFlags::ENCRYPTED, + true, + true, + ) + .unwrap(); + inbound_msg.body = Vec::new(); + + let err = block_on(service.call(inbound_msg.clone())).unwrap_err(); + let err = err.downcast::().unwrap(); + unpack_enum!(DecryptionError::EncryptedMessageEmptyBody = err); + } + #[runtime::test] async fn decrypt_inbound_fail_destination() { let (connectivity, mock) = create_connectivity_mock();