def test_reconstruct_with_same_seed(self):
        redundancy_factor = 3
        block_size = 1024

        data = b'A' * 1024 * 512 + b'A' * 100  # test for padding
        blocks1 = luby.encode(redundancy_factor, block_size, data)
        seeds = luby.get_seeds(blocks1)
        blocks2 = luby.encode(redundancy_factor, block_size, data, seeds)
        self.assertEqual(blocks1[0], blocks2[0])
    def test_luby_encode_2_times_compare_result(self):
        redundancy_factor = 3
        block_size = 1024

        data = b'A' * 1024 * 512 + b'A' * 100  # test for padding
        blocks1 = luby.encode(redundancy_factor, block_size, data)
        blocks2 = luby.encode(redundancy_factor, block_size, data)
        self.assertNotEqual(blocks1[0], blocks2[0])
        decoded1 = luby.decode(blocks1)
        decoded2 = luby.decode(blocks2)

        self.assertEqual(decoded1, decoded2)
    def generate_luby_chunks(imagedata):
        chunks = luby.encode(NetWorkSettings.LUBY_REDUNDANCY_FACTOR, NetWorkSettings.CHUNKSIZE, imagedata)

        # test that the chunks are correct
        luby.verify_blocks(chunks)

        return chunks
    def test_luby_decode_encoded(self):
        redundancy_factor = 2
        block_size = 1024

        data = b'A' * 1024 * 512 + b'A' * 100  # test for padding
        blocks = luby.encode(redundancy_factor, block_size, data)
        decoded = luby.decode(blocks)
        self.assertEqual(data, decoded)