From a78bde9037a520ccfdcfa97420f7b0339d7cf72e Mon Sep 17 00:00:00 2001 From: mnovak Date: Fri, 4 Dec 2026 15:47:21 +0100 Subject: [PATCH] [domistream] Control host: test first, a refused INPUT_DATA names its input type --- crates/domistream/tests/control_host.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/domistream/tests/control_host.rs b/crates/domistream/tests/control_host.rs index a069a9d..06b1f96 100644 --- a/crates/domistream/tests/control_host.rs +++ b/crates/domistream/tests/control_host.rs @@ -784,3 +784,27 @@ proptest! { prop_assert!(messages <= plains.len()); } } + +/// Diagnostics (decision D2 on the host): an INPUT_DATA the host cannot read still says which input type it was, so +/// the black-box log can name what a real client sends (L2 demo: one 10-byte body of an unknown layout, U21). +#[test] +fn refused_input_names_its_type() { + // INPUT_DATA (0x0206): length 10, size (BE) 6 = type + 2 data bytes, type TOUCH 0x55000002 (LE), 2 data bytes. + let mut m = vec![0x06, 0x02, 10, 0]; + m.extend_from_slice(&6u32.to_be_bytes()); + m.extend_from_slice(&0x5500_0002u32.to_le_bytes()); + m.extend_from_slice(&[0xAA, 0xBB]); + match parse_client_message(&m) { + Ok(ClientControlMessage::InputRejected { body_len, input_type, .. }) => { + assert_eq!(body_len, 10); + assert_eq!(input_type, Some(0x5500_0002)); + } + other => panic!("{other:?}"), + } + // Too short to carry a type: none. + let short = vec![0x06, 0x02, 2, 0, 0, 0]; + match parse_client_message(&short) { + Ok(ClientControlMessage::InputRejected { input_type, .. }) => assert_eq!(input_type, None), + other => panic!("{other:?}"), + } +}