From 7e1dc4ddefb43f8ae523e1ea2aaadd8b14bdce53 Mon Sep 17 00:00:00 2001 From: Ramana Kumar Date: Tue, 20 Sep 2022 23:43:38 +0100 Subject: [PATCH] Add test of load_trusted_setup_test not working yet: segfaults after the test runs --- src/Makefile | 2 +- src/c_kzg_4844.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 2116433..0f5899b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ TESTS = bls12_381_test das_extension_test c_kzg_alloc_test fft_common_test fft_fr_test fft_g1_test \ - fk20_proofs_test kzg_proofs_test poly_test recover_test utility_test zero_poly_test + fk20_proofs_test kzg_proofs_test poly_test recover_test utility_test zero_poly_test c_kzg_4844_test BENCH = fft_fr_bench fft_g1_bench recover_bench zero_poly_bench kzg_proofs_bench poly_bench poly_barycentric_bench compute_proof_lagrange_bench TUNE = poly_mul_tune poly_div_tune LIB_SRC = bls12_381.c c_kzg_alloc.c das_extension.c fft_common.c fft_fr.c fft_g1.c fk20_proofs.c kzg_proofs.c poly.c recover.c utility.c zero_poly.c diff --git a/src/c_kzg_4844.c b/src/c_kzg_4844.c index fba17c0..f34b951 100644 --- a/src/c_kzg_4844.c +++ b/src/c_kzg_4844.c @@ -92,3 +92,24 @@ C_KZG_RET compute_kzg_proof(KZGProof *out, const PolynomialEvalForm *polynomial, TRY(evaluate_polynomial_in_evaluation_form(&value, polynomial, z, s)); return compute_proof_single_l(out, polynomial, z, &value, s); } + +#ifdef KZGTEST + +#include "../inc/acutest.h" +#include "test_util.h" + +void load_trusted_setup_test(void) { + FILE *in = fopen("trusted_setup.txt", "r"); + KZGSettings ks; + TEST_CHECK(C_KZG_OK == load_trusted_setup(&ks, in)); + fclose(in); + free_kzg_settings(&ks); +} + +TEST_LIST = { + {"C_KZG_4844_TEST", title}, + {"load_trusted_setup_test", load_trusted_setup_test}, + {NULL, NULL} /* zero record marks the end of the list */ +}; + +#endif // KZGTEST