File: test_packets.py

package info (click to toggle)
2ping 4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 464 kB
  • sloc: python: 2,827; sh: 80; makefile: 38
file content (377 lines) | stat: -rw-r--r-- 19,015 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#!/usr/bin/env python3

import unittest
from twoping import packets

try:
    from Crypto.Cipher import AES
    has_aes = True
except ImportError:
    has_aes = False


class TestPacketsOpcodes(unittest.TestCase):
    def test_opcode_unknown(self):
        data = b'Unknown data'
        opcode = packets.Opcode()
        opcode.load(data)
        self.assertEqual(opcode.id, None)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_reply_requested(self):
        data = b''
        opcode = packets.OpcodeReplyRequested()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0001)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_in_reply_to(self):
        data = b'\x01\x02\x03\x04\x05\x06'
        opcode = packets.OpcodeInReplyTo()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0002)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_rtt_enclosed(self):
        data = b'\x12\x34\x56\x78'
        opcode = packets.OpcodeRTTEnclosed()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0004)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_investigation_seen(self):
        data = b'\x01\x02\x03\x04\x05\x06\x11\x12\x13\x14\x15\x16'
        opcode = packets.OpcodeInvestigationSeen()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0008)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_investigation_unseen(self):
        data = b'\x01\x02\x03\x04\x05\x06\x11\x12\x13\x14\x15\x16'
        opcode = packets.OpcodeInvestigationUnseen()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0010)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_investigate(self):
        data = b'\x01\x02\x03\x04\x05\x06\x11\x12\x13\x14\x15\x16'
        opcode = packets.OpcodeInvestigate()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0020)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_courtesy_expiration(self):
        data = b'\x01\x02\x03\x04\x05\x06\x11\x12\x13\x14\x15\x16'
        opcode = packets.OpcodeCourtesyExpiration()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0040)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_hmac(self):
        data = b'\x00\x04\x01\x02\x03\x04'
        # The dump always includes a zeroed hash area
        data_out = b'\x00\x04\x00\x00\x00\x00'
        opcode = packets.OpcodeHMAC()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0080)
        self.assertEqual(opcode.dump(), data_out)

    def test_opcode_host_latency(self):
        data = b'\x12\x34\x56\x78'
        opcode = packets.OpcodeHostLatency()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0100)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_encrypted(self):
        data = b'\x00\x01\xaa\xb1\xc0\x0f\x0f\x83\xd2\xc4x\xfe\xa1\xe2\x10by\xee"Rp\xf1\x93\xee\xe98G\xea\x11\xd1\xc9\x80=\xe3'
        opcode = packets.OpcodeEncrypted()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x0200)
        self.assertEqual(opcode.dump(), data)

    def test_opcode_extended(self):
        data = b'\x32\x50\x56\x4e\x00\x12Test 2ping version'
        opcode = packets.OpcodeExtended()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x8000)
        self.assertEqual(opcode.dump(), data)

    def test_extended_unknown(self):
        data = b'Unknown extended data'
        opcode = packets.Extended()
        opcode.load(data)
        self.assertEqual(opcode.id, None)
        self.assertEqual(opcode.dump(), data)

    def test_extended_version(self):
        data = b'Test 2ping version'
        opcode = packets.ExtendedVersion()
        opcode.load(data)
        self.assertEqual(opcode.id, 0x3250564e)
        self.assertEqual(opcode.dump(), data)

    def test_extended_notice(self):
        data = b'Notice announcement'
        opcode = packets.ExtendedNotice()
        opcode.load(data)
        self.assertEqual(opcode.id, 0xa837b44e)
        self.assertEqual(opcode.dump(), data)

    def test_extended_wallclock_load(self):
        opcode = packets.ExtendedWallClock()
        opcode.load(b'\x00\x03\x63\x73\xe7\x7a\xc2\x20')
        self.assertEqual(opcode.id, 0x64f69319)
        self.assertEqual(opcode.time_us, int(953774386.102816 * 1000000))

    def test_extended_wallclock_dump(self):
        opcode = packets.ExtendedWallClock()
        opcode.time_us = int(1454187789.993266 * 1000000)
        self.assertEqual(opcode.id, 0x64f69319)
        self.assertEqual(opcode.dump(), b'\x00\x05\x2a\x93\x7a\xa8\xc5\x32')

    def test_extended_monotonicclock_load(self):
        opcode = packets.ExtendedMonotonicClock()
        opcode.load(b'\x7d\x67\x00\x03\x63\x73\xe7\x7a\xc2\x20')
        self.assertEqual(opcode.id, 0x771d8dfb)
        self.assertEqual(opcode.generation, 32103)
        self.assertEqual(opcode.time_us, int(953774386.102816 * 1000000))

    def test_extended_monotonicclock_dump(self):
        opcode = packets.ExtendedMonotonicClock()
        opcode.generation = 9311
        opcode.time_us = int(1454187789.993266 * 1000000)
        self.assertEqual(opcode.id, 0x771d8dfb)
        self.assertEqual(opcode.dump(), b'\x24\x5f\x00\x05\x2a\x93\x7a\xa8\xc5\x32')

    def test_extended_random_load(self):
        random_data = b'\xf1\xfd\xf8\x9c\xe3\x9a\x87\x14'
        opcode = packets.ExtendedRandom()
        opcode.load(b'\x00\x03' + random_data)
        self.assertEqual(opcode.id, 0x2ff6ad68)
        self.assertTrue(opcode.is_hwrng)
        self.assertTrue(opcode.is_os)
        self.assertEqual(opcode.random_data, random_data)

    def test_extended_random_dump(self):
        random_data = b'\xbc\xde\xdc\xe5\xa8\x9a\xbd\x14'
        opcode = packets.ExtendedRandom()
        opcode.is_hwrng = True
        opcode.random_data = random_data
        self.assertEqual(opcode.id, 0x2ff6ad68)
        self.assertEqual(opcode.dump(), b'\x00\x01' + random_data)

    def test_extended_batteries_load(self):
        opcode = packets.ExtendedBatteryLevels()
        opcode.load(b'\x00\x02\x00\x00\xff\xff\x00\x01\xce\xa3')
        self.assertEqual(opcode.id, 0x88a1f7c7)
        self.assertEqual(opcode.batteries[0], 65535)
        self.assertEqual(opcode.batteries[1], 52899)

    def test_extended_batteries_dump(self):
        opcode = packets.ExtendedBatteryLevels()
        opcode.batteries = {
            0: 65535,
            1: 52899,
        }
        self.assertEqual(opcode.id, 0x88a1f7c7)
        self.assertEqual(opcode.dump(), b'\x00\x02\x00\x00\xff\xff\x00\x01\xce\xa3')

    @unittest.skipUnless(has_aes, 'PyCrypto required')
    def test_encrypted_encrypt_decrypt(self):
        key = b'Secret key'
        iv = b'2\xf0J/\xb3x\xe3\xf3s+J\x8c\x02t\xca\x0e'
        minimal_packet_data = b'2P\xda\x0a\x0e\xa5[\xe2\x89\x1d\x00\x00\x00\x00\x00\x00'
        opcode = packets.OpcodeEncrypted()
        opcode.session = b'z\xe3\xcb\xdfeK\x86\x96'
        opcode.iv = iv
        opcode.method_index = 1
        opcode.encrypt(minimal_packet_data, key)
        self.assertEqual(opcode.decrypt(key), minimal_packet_data)


class TestPacketsReference(unittest.TestCase):
    ''' Test protocol reference packets

    These tests replicate the reference packets included as examples in
    the 2ping protocol specification.
    '''
    def test_reference_1a(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x01'
        self.assertEqual(packet.dump(), b'\x32\x50\x2d\xae\x00\x00\x00\x00\xa0\x01\x00\x00')

    def test_reference_2a(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x01'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        self.assertEqual(packet.dump(), b'\x32\x50\x2d\xad\x00\x00\x00\x00\xa0\x01\x00\x01\x00\x00')

    def test_reference_2b(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xb0\x01'
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xa0\x01'
        self.assertEqual(packet.dump(), b'\x32\x50\x7d\xa4\x00\x00\x00\x00\xb0\x01\x00\x02\x00\x06\x00\x00\x00\x00\xa0\x01')

    def test_reference_3a(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x01'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        self.assertEqual(packet.dump(), b'\x32\x50\x2d\xad\x00\x00\x00\x00\xa0\x01\x00\x01\x00\x00')

    def test_reference_3b(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xb0\x01'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xa0\x01'
        self.assertEqual(packet.dump(), b'\x32\x50\x7d\xa3\x00\x00\x00\x00\xb0\x01\x00\x03\x00\x00\x00\x06\x00\x00\x00\x00\xa0\x01')

    def test_reference_3c(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x02'
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xb0\x01'
        packet.opcodes[packets.OpcodeRTTEnclosed.id] = packets.OpcodeRTTEnclosed()
        packet.opcodes[packets.OpcodeRTTEnclosed.id].rtt_us = 12345
        self.assertEqual(packet.dump(), b'\x32\x50\x4d\x62\x00\x00\x00\x00\xa0\x02\x00\x06\x00\x06\x00\x00\x00\x00\xb0\x01\x00\x04\x00\x00\x30\x39')

    def test_reference_4a(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x01'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        self.assertEqual(packet.dump(), b'\x32\x50\x2d\xad\x00\x00\x00\x00\xa0\x01\x00\x01\x00\x00')

    def test_reference_4b(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x02'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        packet.opcodes[packets.OpcodeInvestigate.id] = packets.OpcodeInvestigate()
        packet.opcodes[packets.OpcodeInvestigate.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x01')
        self.assertEqual(packet.dump(), b'\x32\x50\x8d\x81\x00\x00\x00\x00\xa0\x02\x00\x21\x00\x00\x00\x08\x00\x01\x00\x00\x00\x00\xa0\x01')

    def test_reference_4c(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xb0\x02'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xa0\x02'
        packet.opcodes[packets.OpcodeInvestigationSeen.id] = packets.OpcodeInvestigationSeen()
        packet.opcodes[packets.OpcodeInvestigationSeen.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x01')
        self.assertEqual(packet.dump(), b'\x32\x50\xdd\x8e\x00\x00\x00\x00\xb0\x02\x00\x0b\x00\x00\x00\x06\x00\x00\x00\x00\xa0\x02\x00\x08\x00\x01\x00\x00\x00\x00\xa0\x01')

    def test_reference_4d(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x03'
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xb0\x02'
        packet.opcodes[packets.OpcodeRTTEnclosed.id] = packets.OpcodeRTTEnclosed()
        packet.opcodes[packets.OpcodeRTTEnclosed.id].rtt_us = 12345
        self.assertEqual(packet.dump(), b'\x32\x50\x4d\x60\x00\x00\x00\x00\xa0\x03\x00\x06\x00\x06\x00\x00\x00\x00\xb0\x02\x00\x04\x00\x00\x30\x39')

    def test_reference_5a(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x01'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        self.assertEqual(packet.dump(), b'\x32\x50\x2d\xad\x00\x00\x00\x00\xa0\x01\x00\x01\x00\x00')

    def test_reference_5b(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x02'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        packet.opcodes[packets.OpcodeInvestigate.id] = packets.OpcodeInvestigate()
        packet.opcodes[packets.OpcodeInvestigate.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x01')
        self.assertEqual(packet.dump(), b'\x32\x50\x8d\x81\x00\x00\x00\x00\xa0\x02\x00\x21\x00\x00\x00\x08\x00\x01\x00\x00\x00\x00\xa0\x01')

    def test_reference_5c(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xb0\x01'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xa0\x02'
        packet.opcodes[packets.OpcodeInvestigationUnseen.id] = packets.OpcodeInvestigationUnseen()
        packet.opcodes[packets.OpcodeInvestigationUnseen.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x01')
        self.assertEqual(packet.dump(), b'\x32\x50\xdd\x87\x00\x00\x00\x00\xb0\x01\x00\x13\x00\x00\x00\x06\x00\x00\x00\x00\xa0\x02\x00\x08\x00\x01\x00\x00\x00\x00\xa0\x01')

    def test_reference_5d(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x03'
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xb0\x01'
        packet.opcodes[packets.OpcodeRTTEnclosed.id] = packets.OpcodeRTTEnclosed()
        packet.opcodes[packets.OpcodeRTTEnclosed.id].rtt_us = 12345
        self.assertEqual(packet.dump(), b'\x32\x50\x4d\x61\x00\x00\x00\x00\xa0\x03\x00\x06\x00\x06\x00\x00\x00\x00\xb0\x01\x00\x04\x00\x00\x30\x39')

    def test_reference_6a(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x01'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        self.assertEqual(packet.dump(), b'\x32\x50\x2d\xad\x00\x00\x00\x00\xa0\x01\x00\x01\x00\x00')

    def test_reference_6b(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x02'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        self.assertEqual(packet.dump(), b'\x32\x50\x2d\xac\x00\x00\x00\x00\xa0\x02\x00\x01\x00\x00')

    def test_reference_6c(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x03'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        self.assertEqual(packet.dump(), b'\x32\x50\x2d\xab\x00\x00\x00\x00\xa0\x03\x00\x01\x00\x00')

    def test_reference_6d(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xb0\x02'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xa0\x03'
        self.assertEqual(packet.dump(), b'\x32\x50\x7d\xa0\x00\x00\x00\x00\xb0\x02\x00\x03\x00\x00\x00\x06\x00\x00\x00\x00\xa0\x03')

    def test_reference_6e(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x04'
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xb0\x02'
        packet.opcodes[packets.OpcodeRTTEnclosed.id] = packets.OpcodeRTTEnclosed()
        packet.opcodes[packets.OpcodeRTTEnclosed.id].rtt_us = 12823
        self.assertEqual(packet.dump(), b'\x32\x50\x4b\x81\x00\x00\x00\x00\xa0\x04\x00\x06\x00\x06\x00\x00\x00\x00\xb0\x02\x00\x04\x00\x00\x32\x17')

    def test_reference_6f(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x0a'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        packet.opcodes[packets.OpcodeInvestigate.id] = packets.OpcodeInvestigate()
        packet.opcodes[packets.OpcodeInvestigate.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x01')
        packet.opcodes[packets.OpcodeInvestigate.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x02')
        self.assertEqual(packet.dump(), b'\x32\x50\xed\x6f\x00\x00\x00\x00\xa0\x0a\x00\x21\x00\x00\x00\x0e\x00\x02\x00\x00\x00\x00\xa0\x01\x00\x00\x00\x00\xa0\x02')

    def test_reference_6g(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xb0\x06'
        packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested()
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xa0\x0a'
        packet.opcodes[packets.OpcodeInvestigationSeen.id] = packets.OpcodeInvestigationSeen()
        packet.opcodes[packets.OpcodeInvestigationSeen.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x01')
        packet.opcodes[packets.OpcodeInvestigationUnseen.id] = packets.OpcodeInvestigationUnseen()
        packet.opcodes[packets.OpcodeInvestigationUnseen.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x02')
        packet.opcodes[packets.OpcodeInvestigate.id] = packets.OpcodeInvestigate()
        packet.opcodes[packets.OpcodeInvestigate.id].message_ids.append(b'\x00\x00\x00\x00\xb0\x02')
        self.assertEqual(packet.dump(), b'\x32\x50\x8d\x3b\x00\x00\x00\x00\xb0\x06\x00\x3b\x00\x00\x00\x06\x00\x00\x00\x00\xa0\x0a\x00\x08\x00\x01\x00\x00\x00\x00\xa0\x01\x00\x08\x00\x01\x00\x00\x00\x00\xa0\x02\x00\x08\x00\x01\x00\x00\x00\x00\xb0\x02')

    def test_reference_6h(self):
        packet = packets.Packet()
        packet.message_id = b'\x00\x00\x00\x00\xa0\x0b'
        packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo()
        packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xb0\x06'
        packet.opcodes[packets.OpcodeRTTEnclosed.id] = packets.OpcodeRTTEnclosed()
        packet.opcodes[packets.OpcodeRTTEnclosed.id].rtt_us = 13112
        packet.opcodes[packets.OpcodeInvestigationSeen.id] = packets.OpcodeInvestigationSeen()
        packet.opcodes[packets.OpcodeInvestigationSeen.id].message_ids.append(b'\x00\x00\x00\x00\xb0\x02')
        self.assertEqual(packet.dump(), b'\x32\x50\x9a\x41\x00\x00\x00\x00\xa0\x0b\x00\x0e\x00\x06\x00\x00\x00\x00\xb0\x06\x00\x04\x00\x00\x33\x38\x00\x08\x00\x01\x00\x00\x00\x00\xb0\x02')


if __name__ == '__main__':
    unittest.main()