From c231d9cd90e0ef961c24e677784f74278f9bc2dc Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 5 Jun 2024 23:08:15 -0700 Subject: [PATCH] assert expected openpilot undefined message behavior (#1050) assert expected openpilot behavior --- can/tests/test_packer_parser.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/can/tests/test_packer_parser.py b/can/tests/test_packer_parser.py index 79f24ec5aa..c313805c47 100755 --- a/can/tests/test_packer_parser.py +++ b/can/tests/test_packer_parser.py @@ -382,6 +382,18 @@ def test_disallow_duplicate_messages(self): with self.assertRaises(RuntimeError): CANParser("toyota_nodsu_pt_generated", [("ACC_CONTROL", 10), ("ACC_CONTROL", 10)]) + def test_allow_undefined_msgs(self): + # TODO: we should throw an exception for these, but we need good + # discovery tests in openpilot first + packer = CANPacker("toyota_nodsu_pt_generated") + + self.assertEqual(packer.make_can_msg("ACC_CONTROL", 0, {"UNKNOWN_SIGNAL": 0}), + [835, 0, b'\x00\x00\x00\x00\x00\x00\x00N', 0]) + self.assertEqual(packer.make_can_msg("UNKNOWN_MESSAGE", 0, {"UNKNOWN_SIGNAL": 0}), + [0, 0, b'', 0]) + self.assertEqual(packer.make_can_msg(0, 0, {"UNKNOWN_SIGNAL": 0}), + [0, 0, b'', 0]) + if __name__ == "__main__": unittest.main()