コード例 #1
0
 def setUp(self):
     self.location_data = proto.LocationMsg.data_struct.pack(1.1, 2.2, 3.3, 100, 5, 2)
     self.data = proto.Msg.marker_struct.pack(proto.Msg.begin) + \
            proto.Msg.header_struct.pack(0, proto.LocationMsg.TYPE,
                                         proto.LocationMsg.data_struct.size,
                                         hab_utils.crc32(self.location_data)) + \
            self.location_data + \
            proto.Msg.marker_struct.pack(proto.Msg.end)
コード例 #2
0
 def setUp(self):
     self.ping_data = proto.PingMsg.data_struct.pack(0x1234)
     self.data = proto.Msg.marker_struct.pack(proto.Msg.begin) + \
                 proto.Msg.header_struct.pack(0, proto.PingMsg.TYPE,
                                              proto.PingMsg.data_struct.size,
                                              hab_utils.crc32(self.ping_data)) + \
                 self.ping_data + \
                 proto.Msg.marker_struct.pack(proto.Msg.end)
コード例 #3
0
    def test_bad_end_marker(self):
        reader = proto.MsgReader()
        data_bytes = '\xff' * proto.LocationMsg.data_struct.size
        data_crc = hab_utils.crc32(data_bytes)
        data = StringIO('\xa3\x9a' + \
                        struct.pack('!LBBL', 0,
                                             proto.LocationMsg.TYPE,
                                             proto.LocationMsg.data_struct.size,
                                             data_crc) + \
                        data_bytes + \
                        '\xff\xff')

        self.assertRaises(proto.BadMarker, lambda: reader.read(data))