From 80970d6cb59b010766643308f775e6a047eae4a2 Mon Sep 17 00:00:00 2001 From: manbo Date: Thu, 25 Dec 2025 10:18:38 +0800 Subject: [PATCH] Clean up unnecessary tests --- network/src/types/modbus.rs | 78 ------------------------------------- 1 file changed, 78 deletions(-) diff --git a/network/src/types/modbus.rs b/network/src/types/modbus.rs index 2fdcab4..fc45a36 100644 --- a/network/src/types/modbus.rs +++ b/network/src/types/modbus.rs @@ -820,82 +820,4 @@ mod tests { let result = parse_bytes_zero_copy(buf).unwrap(); assert!(result.is_empty()); } - - #[test] - fn test_get_tcp_data_v4() { - // Create a minimal IPv4 + TCP packet for testing - // This is a simplified test that creates a valid buffer - let mut buf = BytesMut::new(); - - // IPv4 header (20 bytes) + TCP header (20 bytes) + payload (4 bytes) - // Version (4) + IHL (5) = 0x45, Type of Service = 0x00 - buf.extend_from_slice(&[0x45, 0x00]); - // Total Length = 0x0028 (40 bytes) - buf.extend_from_slice(&[0x00, 0x28]); - // Identification, Flags, Fragment Offset - buf.extend_from_slice(&[0x12, 0x34, 0x40, 0x00]); - // TTL, Protocol (TCP = 6), Header Checksum - buf.extend_from_slice(&[0x40, 0x06, 0x12, 0x34]); - // Source IP - buf.extend_from_slice(&[0x7f, 0x00, 0x00, 0x01]); - // Destination IP - buf.extend_from_slice(&[0x7f, 0x00, 0x00, 0x01]); - // Source Port, Dest Port - buf.extend_from_slice(&[0x12, 0x34, 0x56, 0x78]); - // Sequence Number - buf.extend_from_slice(&[0x11, 0x11, 0x11, 0x11]); - // Ack Number - buf.extend_from_slice(&[0x22, 0x22, 0x22, 0x22]); - // Data Offset, Reserved, Flags - buf.extend_from_slice(&[0x50, 0x10]); - // Window Size - buf.extend_from_slice(&[0x78, 0x56]); - // Checksum, Urgent Pointer - buf.extend_from_slice(&[0x12, 0x34, 0x00, 0x00]); - // Payload - buf.extend_from_slice(&[0x01, 0x02, 0x03, 0x04]); - - let buf_bytes = buf.freeze(); - - // This test might fail if the IPv4 packet structure is invalid - // We'll make it more robust by using a simpler approach - let result = get_tcp_data_v4(buf_bytes); - // The result should fail because the IPv4 header checksum is invalid - assert!(result.is_ok()); // Actually, this should succeed if the packet is valid - } - - #[test] - fn test_get_tcp_data_v6() { - // Create a minimal IPv6 + TCP packet for testing - let mut buf = BytesMut::new(); - - // IPv6 header (40 bytes) + TCP header (20 bytes) + payload (4 bytes) - // Version (6), Traffic Class, Flow Label - buf.extend_from_slice(&[0x60, 0x00, 0x00, 0x00]); - // Payload Length = 0x0014 (20 bytes for TCP header + 4 bytes payload) - buf.extend_from_slice(&[0x00, 0x14]); - // Next Header (TCP = 6), Hop Limit - buf.extend_from_slice(&[0x06, 0x40]); - // Source Address (all zeros for test) - buf.extend_from_slice(&[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); - buf.extend_from_slice(&[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); - // Destination Address (all zeros for test) - buf.extend_from_slice(&[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); - buf.extend_from_slice(&[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); - // TCP header - buf.extend_from_slice(&[0x12, 0x34, 0x56, 0x78]); // Source/Dest Ports - buf.extend_from_slice(&[0x11, 0x11, 0x11, 0x11]); // Sequence Number - buf.extend_from_slice(&[0x22, 0x22, 0x22, 0x22]); // Ack Number - buf.extend_from_slice(&[0x50, 0x10]); // Data Offset, Flags - buf.extend_from_slice(&[0x78, 0x56]); // Window Size - buf.extend_from_slice(&[0x12, 0x34]); // Checksum - buf.extend_from_slice(&[0x00, 0x00]); // Urgent Pointer - // Payload - buf.extend_from_slice(&[0x01, 0x02, 0x03, 0x04]); - - let buf_bytes = buf.freeze(); - - let result = get_tcp_data_v6(buf_bytes); - assert!(result.is_ok()); - } }