Esempio n. 1
0
 def test(self):
     inst = TracerouteExt()
     inst.hops = [1]
     inst._hdr_len = 3
     # Call
     inst.append_hop("3-4", 5, 6)
     # Tests
     ntools.eq_(inst.hops, [1, ("3-4", 5, 6)])
Esempio n. 2
0
 def test(self):
     inst = TracerouteExt()
     inst._check_len = create_mock()
     inst._hdr_len = 3
     isd_as_1_2 = create_mock(["pack"])
     isd_as_1_2.pack.return_value = b"1-2"
     isd_as_5_6 = create_mock(["pack"])
     isd_as_5_6.pack.return_value = b"5-6"
     inst.hops = [(isd_as_1_2, 3, 4), (isd_as_5_6, 7, 8)]
     expected = b"".join(
         (b'\x02', bytes(inst.PADDING_LEN), b'1-2',
          bytes.fromhex('0003 0004'), b'5-6', bytes.fromhex('0007 0008')))
     # Call
     ntools.eq_(inst.pack(), expected)
     # Tests
     inst._check_len.assert_called_once_with(expected)