aboutsummaryrefslogtreecommitdiff
path: root/p2p
diff options
context:
space:
mode:
authorhozan23 <hozan23@proton.me>2023-11-29 12:48:28 +0300
committerhozan23 <hozan23@proton.me>2023-11-29 12:48:28 +0300
commit58b249773ba4d63a8cdde92ff1cb22719e9b3334 (patch)
treee54fb041c1213280a23e67c04b75c8ff8856be7a /p2p
parent63e8b2fa6b5d4d9bf1ba9234bff0be8a255e612e (diff)
p2p/tls_config: add a small test
Diffstat (limited to 'p2p')
-rw-r--r--p2p/src/tls_config.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/p2p/src/tls_config.rs b/p2p/src/tls_config.rs
index 2994bcf..5d5e90e 100644
--- a/p2p/src/tls_config.rs
+++ b/p2p/src/tls_config.rs
@@ -212,3 +212,20 @@ impl ClientCertVerifier for CliCertVerifier {
&[]
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn verify_generated_certificate() {
+ let key_pair = KeyPair::generate(&KeyPairType::Ed25519);
+ let (cert, _) = generate_cert(&key_pair).unwrap();
+
+ let result = verify_cert(&cert);
+ assert!(result.is_ok());
+ let peer_id = result.unwrap();
+ assert_eq!(peer_id, PeerID::try_from(key_pair.public()).unwrap());
+ assert_eq!(peer_id.0, key_pair.public().as_bytes());
+ }
+}