potentially related to #2371
this is not explicitly forbidden by the spec, but the parser is accepting min_version > max_version; which is weird;
Maybe is also the case to state the obvious in the spec, but unsure;
test case showing:
diff --git a/sv2/subprotocols/common-messages/src/setup_connection.rs b/sv2/subprotocols/common-messages/src/setup_connection.rs
index 74b46e7f..b4e90fbe 100644
--- a/sv2/subprotocols/common-messages/src/setup_connection.rs
+++ b/sv2/subprotocols/common-messages/src/setup_connection.rs
@@ -522,4 +522,32 @@ mod test {
setup_conn.set_requires_standard_job();
assert!(setup_conn.requires_standard_job());
}
+
+ // Spec 3.6.1: min_version must be <= max_version.
+ // The parser currently accepts min_version > max_version, which is a spec violation.
+ #[test]
+ fn test_setup_connection_accepts_min_version_greater_than_max_version() {
+ // Build raw bytes: protocol=0, min_version=10, max_version=1, flags=0,
+ // empty strings for remaining fields.
+ let mut data = vec![
+ 0x00, // protocol: MiningProtocol (0)
+ 0x0A, 0x00, // min_version: 10 (LE)
+ 0x01, 0x00, // max_version: 1 (LE) — violates spec: min > max
+ 0x00, 0x00, 0x00, 0x00, // flags: 0
+ 0x00, // endpoint_host: empty
+ 0x00, 0x00, // endpoint_port: 0
+ 0x00, // vendor: empty
+ 0x00, // hardware_version: empty
+ 0x00, // firmware: empty
+ 0x00, // device_id: empty
+ ];
+ let parsed = SetupConnection::from_bytes(&mut data)
+ .expect("parser should accept min_version > max_version (spec 3.6.1 violation)");
+ assert_eq!(parsed.min_version, 10);
+ assert_eq!(parsed.max_version, 1);
+ assert!(
+ parsed.min_version > parsed.max_version,
+ "min_version should be greater than max_version to demonstrate the bug"
+ );
+ }
}
potentially related to #2371
this is not explicitly forbidden by the spec, but the parser is accepting min_version > max_version; which is weird;
Maybe is also the case to state the obvious in the spec, but unsure;
test case showing: