🚧 wip: setting up testing for PTTH_QUIC

main
(on company time) 2022-12-19 13:17:22 -06:00
parent 93be903b86
commit 415c8954c1
5 changed files with 52 additions and 0 deletions

1
Cargo.lock generated
View File

@ -1363,6 +1363,7 @@ dependencies = [
"rand", "rand",
"rcgen", "rcgen",
"reqwest", "reqwest",
"ring",
"rmp-serde 1.1.1", "rmp-serde 1.1.1",
"rustls", "rustls",
"rusty_ulid 1.0.0", "rusty_ulid 1.0.0",

View File

@ -17,6 +17,7 @@ hyper = { version = "0.14.23", features = ["http1", "server", "stream", "tcp"] }
quinn = "0.9.3" quinn = "0.9.3"
rand = "0.8.5" rand = "0.8.5"
rcgen = "0.10.0" rcgen = "0.10.0"
ring = "0.16.20"
rmp-serde = "1.1.1" rmp-serde = "1.1.1"
rustls = "0.20.7" rustls = "0.20.7"
rusty_ulid = "1.0.0" rusty_ulid = "1.0.0"

View File

@ -0,0 +1,32 @@
#[cfg (test)]
mod test {
#[test]
fn signing () -> anyhow::Result <()> {
use std::fs;
use ring::{
signature::{
self,
Ed25519KeyPair,
KeyPair,
},
};
fs::create_dir_all ("untracked")?;
let rng = ring::rand::SystemRandom::new ();
let pkcs8_bytes = Ed25519KeyPair::generate_pkcs8 (&rng).map_err (|_| anyhow::anyhow! ("generate_pkcs8"))?;
let key_pair = Ed25519KeyPair::from_pkcs8 (pkcs8_bytes.as_ref ()).map_err (|_| anyhow::anyhow! ("from_pkcs8"))?;
const MESSAGE: &[u8] = b":V";
let sig = key_pair.sign (MESSAGE);
let peer_public_key_bytes = key_pair.public_key ().as_ref ();
let peer_public_key = signature::UnparsedPublicKey::new (&signature::ED25519, peer_public_key_bytes);
peer_public_key.verify (MESSAGE, sig.as_ref ()).map_err (|_| anyhow::anyhow! ("verify"))?;
Ok (())
}
}

View File

@ -1,7 +1,11 @@
pub mod client_proxy; pub mod client_proxy;
pub mod connection; pub mod connection;
pub mod crypto;
pub mod executable_end_server; pub mod executable_end_server;
pub mod executable_relay_server; pub mod executable_relay_server;
pub mod prelude; pub mod prelude;
pub mod protocol; pub mod protocol;
pub mod quinn_utils; pub mod quinn_utils;
#[cfg (test)]
mod tests;

View File

@ -0,0 +1,14 @@
#[test]
fn end_to_end () -> anyhow::Result <()> {
let rt = tokio::runtime::Runtime::new ()?;
rt.block_on (end_to_end_async ())?;
Ok (())
}
async fn end_to_end_async () -> anyhow::Result <()> {
// let task_relay = crate::executable_relay_server::main ();
Ok (())
}