version: answer 1.7 to head units offering 4.x and 6.x too, as they accept it

This commit is contained in:
Seb3thehacker committed 2026-10-21 12:30:38 -07:00
1 parent 6efdad5e53
commit c7077f2a57
3 files changed
+15 -6

No files matched your search

@@ -104,7 +104,7 @@ class ConnectionLifecycleTest {
}
@Test fun `unsupported version sends rejection and ends without waiting for peer EOF`() {
val input = CountingInput(message(1, byteArrayOf(0, 2, 0, 0)))
val input = CountingInput(message(1, byteArrayOf(0, 0, 0, 9)))
val output = ByteArrayOutputStream()
val runner = GearslipRunner(input, output, ::identity)
runner.run()
@@ -112,7 +112,7 @@ class ConnectionLifecycleTest {
val parser = Frames.Parser()
parser.append(output.toByteArray(), output.size())
val response = requireNotNull(parser.next())
assertArrayEquals(byteArrayOf(0, 2) + ProtocolVersion.respond(2, 0).bytes, response.payload)
assertArrayEquals(byteArrayOf(0, 2) + ProtocolVersion.respond(0, 9).bytes, response.payload)
assertEquals("Unsupported protocol", SessionStatus.state.value.headline)
}
@@ -10,8 +10,13 @@ class ProtocolVersionTest {
assertArrayEquals(byteArrayOf(0, 1, 0, 7, 0, 0), ProtocolVersion.respond(1, 9).bytes)
}
@Test fun `unsupported major is never reported as a successful downgrade`() {
val response = ProtocolVersion.respond(4, 3)
@Test fun `newer head units get the 1x answer they accept`() {
assertArrayEquals(byteArrayOf(0, 1, 0, 7, 0, 0), ProtocolVersion.respond(4, 2).bytes)
assertArrayEquals(byteArrayOf(0, 1, 0, 7, 0, 0), ProtocolVersion.respond(6, 1).bytes)
}
@Test fun `major version 0 is refused`() {
val response = ProtocolVersion.respond(0, 9)
assertFalse(response.supported)
assertArrayEquals(byteArrayOf(0, 1, 0, 7, -1, -1), response.bytes)
}