@pytest.mark.parametrize('testcase', [[1, 2, 3, 4, 5, 6, 7, 8], [i for i in range(200)]])
@pytest.mark.parametrize('scheme,ctx', [(sealapi.SCHEME_TYPE.BFV, helper_context_bfv()), (sealapi.SCHEME_TYPE.CKKS, helper_context_ckks())])
def test_ciphertext(testcase, scheme, ctx):
    poly_modulus_degree = helper_poly_modulus_degree(ctx)
    ctx_data = ctx.key_context_data()
    parms = ctx_data.parms()
    coeff_mod_count = len(parms.coeff_modulus())
    keygen = sealapi.KeyGenerator(ctx)
    ciphertext = sealapi.Ciphertext(ctx)
    plaintext = helper_encode(scheme, ctx, testcase)
    pk = sealapi.PublicKey()
    keygen.create_public_key(pk)
    encryptor = sealapi.Encryptor(ctx, pk)
    decryptor = sealapi.Decryptor(ctx, keygen.secret_key())
    encryptor.encrypt(plaintext, ciphertext)
    assert (len(ciphertext.parms_id()) > 0)
    assert (ciphertext.scale > 0)
    assert (ciphertext.coeff_modulus_size() == (coeff_mod_count - 1))
    assert (ciphertext.poly_modulus_degree() == poly_modulus_degree)
    assert (ciphertext.dyn_array().size() > 0)
    assert (ciphertext.size() == 2)
    assert (ciphertext.size_capacity() == 2)
    assert (ciphertext.is_transparent() is False)
    assert (ciphertext.is_ntt_form() is (scheme == sealapi.SCHEME_TYPE.CKKS))

    def save_load(path):
        ciphertext.save(path)
        save_test = sealapi.Ciphertext(ctx)
        save_test.load(ctx, path)
        decryptor.decrypt(save_test, plaintext)
        decoded = helper_decode(scheme, ctx, plaintext)
        is_close_enough(decoded[:len(testcase)], testcase)
    tmp_file(save_load)
    ciphertext.resize(ctx, 10)
    assert (ciphertext.size() == 10)
    assert (ciphertext.size_capacity() == 10)
    ciphertext.reserve(15)
    assert (ciphertext.size() == 10)
    assert (ciphertext.size_capacity() == 15)
@pytest.mark.parametrize('testcase', [[1, 2, 3, 4, 5, 6, 7, 8], [i for i in range(200)]])
@pytest.mark.parametrize('scheme,ctx', [(sealapi.SCHEME_TYPE.BFV, helper_context_bfv()), (sealapi.SCHEME_TYPE.CKKS, helper_context_ckks())])
def test_ciphertext(testcase, scheme, ctx):
    poly_modulus_degree = helper_poly_modulus_degree(ctx)
    ctx_data = ctx.key_context_data()
    parms = ctx_data.parms()
    coeff_mod_count = len(parms.coeff_modulus())
    keygen = sealapi.KeyGenerator(ctx)
    ciphertext = sealapi.Ciphertext(ctx)
    plaintext = helper_encode(scheme, ctx, testcase)
    pk = sealapi.PublicKey()
    keygen.create_public_key(pk)
    encryptor = sealapi.Encryptor(ctx, pk)
    decryptor = sealapi.Decryptor(ctx, keygen.secret_key())
    encryptor.encrypt(plaintext, ciphertext)
    assert (len(ciphertext.parms_id()) > 0)
    assert (ciphertext.scale > 0)
    assert (ciphertext.coeff_modulus_size() == (coeff_mod_count - 1))
    assert (ciphertext.poly_modulus_degree() == poly_modulus_degree)
    assert (ciphertext.dyn_array().size() > 0)
    assert (ciphertext.size() == 2)
    assert (ciphertext.size_capacity() == 2)
    assert (ciphertext.is_transparent() is False)
    assert (ciphertext.is_ntt_form() is (scheme == sealapi.SCHEME_TYPE.CKKS))

    def save_load(path):
        ciphertext.save(path)
        save_test = sealapi.Ciphertext(ctx)
        save_test.load(ctx, path)
        decryptor.decrypt(save_test, plaintext)
        decoded = helper_decode(scheme, ctx, plaintext)
        is_close_enough(decoded[:len(testcase)], testcase)
    tmp_file(save_load)
    ciphertext.resize(ctx, 10)
    assert (ciphertext.size() == 10)
    assert (ciphertext.size_capacity() == 10)
    ciphertext.reserve(15)
    assert (ciphertext.size() == 10)
    assert (ciphertext.size_capacity() == 15)