Beispiel #1
0
    def test_to_wire(self):
        opcode, blockn = (ACKPacket.opcode, 12)
        raw_data = struct.pack('!HH', opcode, blockn)

        packet = ACKPacket(blockn)
        self.assertEqual(packet.to_wire(), raw_data)
Beispiel #2
0
    def test_from_wire_bad_input(self):
        raw_data = 'b'.encode()

        with self.assertRaises(PayloadParseError):
            ACKPacket.from_wire(raw_data)