From 397849da2389766d3c6387ec8e3016aeb41f0256 Mon Sep 17 00:00:00 2001 From: lykimq Date: Mon, 27 Mar 2023 11:36:29 +0200 Subject: [PATCH] Alcotezt: port [src/lib_bls12_381_polynomial/test] --- manifest/main.ml | 15 +++++-- opam/tezos-bls12-381-polynomial-internal.opam | 4 +- src/lib_bls12_381_polynomial/test/dune | 39 ++++++++++++++++--- .../test/{main.ml => test_main.ml} | 8 +++- src/lib_bls12_381_polynomial/test/test_srs.ml | 6 ++- tezt/tests/dune | 1 + 6 files changed, 61 insertions(+), 12 deletions(-) rename src/lib_bls12_381_polynomial/test/{main.ml => test_main.ml} (94%) diff --git a/manifest/main.ml b/manifest/main.ml index 9918396a9af7..cb8877795195 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -941,13 +941,22 @@ let octez_bls12_381_polynomial_internal = } let _octez_bls12_381_polynomial_tests = - tests - ["main"] + tezt + [ + "test_main"; + "helpers"; + "test_coefficients"; + "test_domains"; + "test_evaluations"; + "test_pbt"; + "test_polynomial"; + "test_srs"; + ] ~path:"src/lib_bls12_381_polynomial/test" ~opam:"tezos-bls12-381-polynomial-internal" ~deps: [ - alcotest; + alcotezt; qcheck_alcotest; polynomial; bisect_ppx; diff --git a/opam/tezos-bls12-381-polynomial-internal.opam b/opam/tezos-bls12-381-polynomial-internal.opam index 2a5e92765871..f0f91de7f031 100644 --- a/opam/tezos-bls12-381-polynomial-internal.opam +++ b/opam/tezos-bls12-381-polynomial-internal.opam @@ -13,7 +13,8 @@ depends: [ "ppx_repr" { >= "0.6.0" } "bls12-381" { >= "6.0.1" & < "6.1.0" } "bigstringaf" { >= "0.5.0" } - "alcotest" { with-test & >= "1.5.0" } + "tezt" { with-test & >= "3.0.0" } + "octez-alcotezt" {with-test} "qcheck-alcotest" { with-test & >= "0.20" } "polynomial" { with-test & >= "0.4.0" & < "0.5.0" } "bisect_ppx" { with-test & >= "2.7.0" } @@ -22,5 +23,6 @@ build: [ ["rm" "-r" "vendors"] ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "@runtezt" "-p" name "-j" jobs] {with-test} ] synopsis: "Polynomials over BLS12-381 finite field - Temporary vendored version of Octez" diff --git a/src/lib_bls12_381_polynomial/test/dune b/src/lib_bls12_381_polynomial/test/dune index 9e557fcb010f..495ef546db4c 100644 --- a/src/lib_bls12_381_polynomial/test/dune +++ b/src/lib_bls12_381_polynomial/test/dune @@ -1,17 +1,46 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executable - (name main) +(library + (name src_lib_bls12_381_polynomial_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries - alcotest + tezt.core + octez-alcotezt qcheck-alcotest polynomial bls12-381 - tezos-bls12-381-polynomial-internal)) + tezos-bls12-381-polynomial-internal) + (library_flags (:standard -linkall)) + (flags + (:standard) + -open Tezt_core + -open Tezt_core.Base + -open Octez_alcotezt) + (modules + test_main + helpers + test_coefficients + test_domains + test_evaluations + test_pbt + test_polynomial + test_srs)) + +(executable + (name main) + (instrumentation (backend bisect_ppx --bisect-sigterm)) + (libraries + src_lib_bls12_381_polynomial_test_tezt_lib + tezt) + (modules main)) (rule - (alias runtest) + (alias runtezt) (package tezos-bls12-381-polynomial-internal) (deps srs_zcash_g1_5) (action (run %{dep:./main.exe}))) + +(rule + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/src/lib_bls12_381_polynomial/test/main.ml b/src/lib_bls12_381_polynomial/test/test_main.ml similarity index 94% rename from src/lib_bls12_381_polynomial/test/main.ml rename to src/lib_bls12_381_polynomial/test/test_main.ml index ec9853b47ccd..c5408f34e9fc 100644 --- a/src/lib_bls12_381_polynomial/test/main.ml +++ b/src/lib_bls12_381_polynomial/test/test_main.ml @@ -23,6 +23,13 @@ (* *) (*****************************************************************************) +(** Testing + ------- + Component: Lib_bls12_381_polynomial + Invocation: dune exec src/lib_bls12_381_polynomial/test/main.exe + Subject: Test for bls12_381 polynomial +*) + let () = (* Seed for deterministic pseudo-randomness: If the environment variable RANDOM_SEED is set, then its value is used as @@ -46,7 +53,6 @@ let () = Printf.printf "Random seed: %d\n" seed ; Random.init seed ; Alcotest.run - ~verbose:false "PlonK" [ ("Domains", Test_domains.tests); diff --git a/src/lib_bls12_381_polynomial/test/test_srs.ml b/src/lib_bls12_381_polynomial/test/test_srs.ml index 3f9d53f8561a..3ae1b0e3430a 100644 --- a/src/lib_bls12_381_polynomial/test/test_srs.ml +++ b/src/lib_bls12_381_polynomial/test/test_srs.ml @@ -163,8 +163,10 @@ let bigstring_of_file filename = false [|(* [-1] means read the whole file *) -1|] +let path = project_root // Filename.dirname __FILE__ + let test_load_from_file () = - let bs = bigstring_of_file "srs_zcash_g1_5" in + let bs = bigstring_of_file (path // "srs_zcash_g1_5") in let max_size = 1 lsl 5 in let srs = Srs.of_bigstring bs ~len:max_size |> Result.get_ok in assert (Srs.size srs = max_size) ; @@ -173,7 +175,7 @@ let test_load_from_file () = | _ -> assert false let test_load_from_file_vector () = - let bs = bigstring_of_file "srs_zcash_g1_5" in + let bs = bigstring_of_file (path // "srs_zcash_g1_5") in let srs = Srs.of_bigstring bs ~len:(1 lsl 5) |> Result.get_ok in let v = [ diff --git a/tezt/tests/dune b/tezt/tests/dune index b95109ecf5f7..a9312e3f511d 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -86,6 +86,7 @@ src_lib_client_base_unix_test_tezt_lib src_lib_client_base_test_tezt_lib src_lib_clic_test_tezt_lib + src_lib_bls12_381_polynomial_test_tezt_lib src_lib_benchmark_test_tezt_lib src_lib_base_test_tezt_lib) (link_flags -- GitLab