def test(self, super_pack): inst = SCIONExtPacket() inst._l4_proto = 0x42 super_pack.return_value = b"super" inst.ext_hdrs = [] for idx, class_, len_, type_ in ((0, 0x1, 0x0, 0x0), (1, 0x2, 0x1, 0x11), (2, 0x3, 0x2, 0x1)): hdr = create_mock(["hdr_len", "EXT_CLASS", "EXT_TYPE", "pack"]) hdr.EXT_CLASS = class_ hdr.hdr_len.return_value = len_ hdr.EXT_TYPE = type_ hdr.pack.return_value = bytes( range(5 + len_ * ExtensionHeader.LINE_LEN)) inst.ext_hdrs.append(hdr) expected = b"".join([ b"super", bytes([0x2, 0x0, 0x0]), bytes(range(5)), bytes([0x3, 0x1, 0x11]), bytes(range(13)), bytes([0x42, 0x2, 0x1]), bytes(range(21)), ]) # Call ntools.eq_(inst._inner_pack(), expected)
def test_no_exts(self): inst = SCIONExtPacket() inst.ext_hdrs = [] inst._l4_proto = 42 # Call ntools.eq_(inst._get_next_hdr(), 42)