1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-27 08:57:45 +00:00

Add more segment types to the size test

This commit is contained in:
Joshua Goins 2025-03-11 21:56:29 -04:00
parent 7116389afe
commit 37ae4a63d8

View file

@ -65,6 +65,7 @@ pub enum SegmentType {
#[brw(magic = 0xAu32)] #[brw(magic = 0xAu32)]
InitializationEncryptionResponse { InitializationEncryptionResponse {
#[br(count = 0x280)] #[br(count = 0x280)]
#[brw(pad_size_to = 640)]
data: Vec<u8>, data: Vec<u8>,
}, },
#[brw(magic = 0x8u32)] #[brw(magic = 0x8u32)]
@ -262,12 +263,24 @@ pub async fn send_keep_alive(
mod tests { mod tests {
use super::*; use super::*;
/// Ensure that the packet size as reported matches up with what we write
#[test] #[test]
fn test_packet_sizes() { fn test_packet_sizes() {
let packet_types = [SegmentType::InitializeEncryption { let packet_types = [
phrase: String::new(), SegmentType::InitializeEncryption {
key: [0; 4], phrase: String::new(),
}]; key: [0; 4],
},
SegmentType::InitializationEncryptionResponse { data: Vec::new() },
SegmentType::KeepAlive {
id: 0,
timestamp: 0,
},
SegmentType::KeepAliveResponse {
id: 0,
timestamp: 0,
},
];
for packet in &packet_types { for packet in &packet_types {
let mut cursor = Cursor::new(Vec::new()); let mut cursor = Cursor::new(Vec::new());