From aa7c0a354407bdbb75068175d36f217145e43d8d Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 16 Oct 2019 10:04:58 -0400 Subject: [PATCH] test unused fields are backwards compatible --- lbry/tests/unit/dht/serialization/test_datagram.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lbry/tests/unit/dht/serialization/test_datagram.py b/lbry/tests/unit/dht/serialization/test_datagram.py index 5544f13cd..ff502cbf0 100644 --- a/lbry/tests/unit/dht/serialization/test_datagram.py +++ b/lbry/tests/unit/dht/serialization/test_datagram.py @@ -127,6 +127,18 @@ class TestDatagram(unittest.TestCase): self.assertRaises(ValueError, decode_datagram, serialized) self.assertRaises(DecodeError, decode_datagram, _bencode([1, 2, 3, 4])) + def test_optional_field_backwards_compatible(self): + datagram = decode_datagram(_bencode({ + 0: 0, + 1: b'\n\xbc\xb5&\x9dl\xfc\x1e\x87\xa0\x8e\x92\x0b\xf3\x9f\xe9\xdf\x8e\x92\xfc', + 2: b'111111111111111111111111111111111111111111111111', + 3: b'ping', + 4: [{b'protocolVersion': 1}], + 5: b'should not error' + })) + self.assertEqual(datagram.packet_type, REQUEST_TYPE) + self.assertEqual(b'ping', datagram.method) + class TestCompactAddress(unittest.TestCase): def test_encode_decode(self, address='1.2.3.4', port=4444, node_id=b'1' * 48):