diff --git a/rosenpass/src/bin/gen-ipc-msg-types.rs b/rosenpass/src/bin/gen-ipc-msg-types.rs index b85e059..4b3ea47 100644 --- a/rosenpass/src/bin/gen-ipc-msg-types.rs +++ b/rosenpass/src/bin/gen-ipc-msg-types.rs @@ -33,7 +33,7 @@ fn print_literal(path: &[&str], shake_or_blake: EitherShakeOrBlake) -> Result<() .map(|chunk| chunk.iter().collect::()) .collect::>(); println!("const {var_name} : RawMsgType = RawMsgType::from_le_bytes(hex!(\"{} {} {} {} {} {} {} {}\"));", - c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); + c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); Ok(()) } @@ -77,30 +77,25 @@ impl Tree { /// Helper for generating hash-based message IDs for the IPC API fn main() -> Result<()> { - - fn print_IPC_API_info(shake_or_blake: EitherShakeOrBlake, name: String) -> Result<()> { - let tree = Tree::Branch( - format!("Rosenpass IPC API {}", name).to_owned(), - vec![Tree::Branch( - "Rosenpass Protocol Server".to_owned(), - vec![ - Tree::Leaf("Ping Request".to_owned()), - Tree::Leaf("Ping Response".to_owned()), - Tree::Leaf("Supply Keypair Request".to_owned()), - Tree::Leaf("Supply Keypair Response".to_owned()), - Tree::Leaf("Add Listen Socket Request".to_owned()), - Tree::Leaf("Add Listen Socket Response".to_owned()), - Tree::Leaf("Add Psk Broker Request".to_owned()), - Tree::Leaf("Add Psk Broker Response".to_owned()), - ], - )], - ); + let tree = Tree::Branch( + "Rosenpass IPC API".to_owned(), + vec![Tree::Branch( + "Rosenpass Protocol Server".to_owned(), + vec![ + Tree::Leaf("Ping Request".to_owned()), + Tree::Leaf("Ping Response".to_owned()), + Tree::Leaf("Supply Keypair Request".to_owned()), + Tree::Leaf("Supply Keypair Response".to_owned()), + Tree::Leaf("Add Listen Socket Request".to_owned()), + Tree::Leaf("Add Listen Socket Response".to_owned()), + Tree::Leaf("Add Psk Broker Request".to_owned()), + Tree::Leaf("Add Psk Broker Response".to_owned()), + ], + )], + ); - println!("type RawMsgType = u128;"); - println!(); - tree.gen_code(shake_or_blake) - } - - print_IPC_API_info(EitherShakeOrBlake::Left(SHAKE256Core), " (SHAKE256)".to_owned())?; - print_IPC_API_info(EitherShakeOrBlake::Right(Blake2bCore), " (Blake2b)".to_owned()) + println!("type RawMsgType = u128;"); + println!(); + tree.gen_code(EitherShakeOrBlake::Left(SHAKE256Core))?; + tree.gen_code(EitherShakeOrBlake::Right(Blake2bCore)) } diff --git a/rosenpass/tests/gen-ipc-msg-types.rs b/rosenpass/tests/gen-ipc-msg-types.rs index 3d4629e..1b46144 100644 --- a/rosenpass/tests/gen-ipc-msg-types.rs +++ b/rosenpass/tests/gen-ipc-msg-types.rs @@ -1,4 +1,4 @@ -use std::{borrow::Borrow, process::Command}; +use std::{process::Command}; #[test] fn test_gen_ipc_msg_types() -> anyhow::Result<()> { @@ -11,5 +11,6 @@ fn test_gen_ipc_msg_types() -> anyhow::Result<()> { assert!(stdout.contains("type RawMsgType = u128;")); assert!(stdout.contains("const SUPPLY_KEYPAIR_RESPONSE : RawMsgType = RawMsgType::from_le_bytes(hex!(\"f2dc 49bd e261 5f10 40b7 3c16 ec61 edb9\"));")); + // TODO: Also test SHAKE256 here Ok(()) }