Download codex-rs/exec-server/src/noise_relay/ordered_ciphertext_tests.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/exec-server/src/noise_relay/ordered_ciphertext_tests.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/exec-server/src/noise_relay/ordered_ciphertext_tests.rs
-
curl -L -o ordered_ciphertext_tests.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/exec-server/src/noise_relay/ordered_ciphertext_tests.rs
1.38 kB
| use pretty_assertions::assert_eq; | |
| use super::MAX_PENDING_BYTES; | |
| use super::OrderedCiphertextFrames; | |
| fn releases_ciphertexts_only_in_nonce_order() { | |
| let mut frames = OrderedCiphertextFrames::default(); | |
| assert_eq!( | |
| frames.push(/*seq*/ 1, b"second".to_vec()).unwrap(), | |
| Vec::<Vec<u8>>::new() | |
| ); | |
| assert_eq!( | |
| frames.push(/*seq*/ 0, b"first".to_vec()).unwrap(), | |
| vec![b"first".to_vec(), b"second".to_vec()] | |
| ); | |
| } | |
| fn ignores_duplicate_ciphertexts_without_replacing_buffered_record() { | |
| let mut frames = OrderedCiphertextFrames::default(); | |
| assert_eq!( | |
| frames.push(/*seq*/ 1, b"first copy".to_vec()).unwrap(), | |
| Vec::<Vec<u8>>::new() | |
| ); | |
| assert_eq!( | |
| frames.push(/*seq*/ 1, b"replacement".to_vec()).unwrap(), | |
| Vec::<Vec<u8>>::new() | |
| ); | |
| assert_eq!( | |
| frames.push(/*seq*/ 0, b"zero".to_vec()).unwrap(), | |
| vec![b"zero".to_vec(), b"first copy".to_vec()] | |
| ); | |
| assert_eq!( | |
| frames.push(/*seq*/ 0, b"duplicate".to_vec()).unwrap(), | |
| Vec::<Vec<u8>>::new() | |
| ); | |
| } | |
| fn rejects_unbounded_reordering() { | |
| let mut frames = OrderedCiphertextFrames::default(); | |
| assert!(frames.push(/*seq*/ 65, Vec::new()).is_err()); | |
| assert!( | |
| frames | |
| .push(/*seq*/ 1, vec![0; MAX_PENDING_BYTES + 1]) | |
| .is_err() | |
| ); | |
| } | |