From 97994b6bfb983c3b950f74673d4f94227896c619 Mon Sep 17 00:00:00 2001 From: lykimq Date: Fri, 5 May 2023 10:34:04 +0200 Subject: [PATCH 1/2] Alcotezt: port [src/lib_srs_extraction/test] --- manifest/main.ml | 6 +-- opam/octez-srs-extraction.opam | 3 +- src/lib_srs_extraction/test/dune | 40 ++++++++++++++----- .../test/{main.ml => test_main.ml} | 6 ++- tezt/tests/dune | 1 + 5 files changed, 40 insertions(+), 16 deletions(-) rename src/lib_srs_extraction/test/{main.ml => test_main.ml} (68%) diff --git a/manifest/main.ml b/manifest/main.ml index 5f6c60c36079..06d9e72637c6 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -1187,11 +1187,11 @@ let _octez_srs_extraction_main = ] let _octez_srs_extraction_tests = - tests - ["main"] + tezt + ["test_main"] ~path:"src/lib_srs_extraction/test" ~opam:"octez-srs-extraction" - ~deps:[octez_srs_extraction |> open_; alcotest] + ~deps:[octez_srs_extraction |> open_; alcotezt] ~dep_files:["phase1radix2m5"] ~dune: Dune.( diff --git a/opam/octez-srs-extraction.opam b/opam/octez-srs-extraction.opam index 87a3fb9443ef..01a81edae562 100644 --- a/opam/octez-srs-extraction.opam +++ b/opam/octez-srs-extraction.opam @@ -14,7 +14,8 @@ depends: [ "octez-bls12-381-polynomial" "cmdliner" { >= "1.1.0" } "base-unix" - "alcotest" { with-test & >= "1.5.0" } + "tezt" { with-test & >= "3.1.0" } + "octez-alcotezt" {with-test} ] build: [ ["rm" "-r" "vendors"] diff --git a/src/lib_srs_extraction/test/dune b/src/lib_srs_extraction/test/dune index 1f33f9abaa40..065f767147fa 100644 --- a/src/lib_srs_extraction/test/dune +++ b/src/lib_srs_extraction/test/dune @@ -1,20 +1,21 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executable - (name main) +(library + (name src_lib_srs_extraction_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core octez-srs-extraction - alcotest) + octez-alcotezt) + (library_flags (:standard -linkall)) (flags (:standard) - -open Octez_srs_extraction)) - -(rule - (alias runtest) - (package octez-srs-extraction) - (deps phase1radix2m5) - (action (run %{dep:./main.exe}))) + -open Tezt_core + -open Tezt_core.Base + -open Octez_srs_extraction + -open Octez_alcotezt) + (modules test_main)) (rule (alias runtest) @@ -60,3 +61,22 @@ (deps srs_filecoin_g1_6 srs_filecoin_g2_6) (action (run ../srs_extraction_main.exe check srs_filecoin_g1_6 srs_filecoin_g2_6))) + +(executable + (name main) + (instrumentation (backend bisect_ppx --bisect-sigterm)) + (libraries + src_lib_srs_extraction_test_tezt_lib + tezt) + (modules main)) + +(rule + (alias runtest) + (package octez-srs-extraction) + (deps phase1radix2m5) + (enabled_if (<> false %{env:RUNTEZTALIAS=true})) + (action (run %{dep:./main.exe}))) + +(rule + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/src/lib_srs_extraction/test/main.ml b/src/lib_srs_extraction/test/test_main.ml similarity index 68% rename from src/lib_srs_extraction/test/main.ml rename to src/lib_srs_extraction/test/test_main.ml index 12341fc7aa60..62e3ba8f0564 100644 --- a/src/lib_srs_extraction/test/main.ml +++ b/src/lib_srs_extraction/test/test_main.ml @@ -1,7 +1,9 @@ open Libsrs +let path = project_root // Filename.dirname __FILE__ + let test_lagrange () = - let input_file = "phase1radix2m5" in + let input_file = path // "phase1radix2m5" in let g1_elements = Powers_of_tau.to_g1s input_file in let g2_elements = Powers_of_tau.to_g2s input_file in Checks.equality g1_elements g2_elements @@ -10,4 +12,4 @@ let tests = [("lagrange zcash_srs", test_lagrange)] let () = let wrap = List.map (fun (name, f) -> Alcotest.test_case name `Quick f) in - Alcotest.run ~verbose:true "SRS" [("Srs", wrap tests)] + Alcotest.run ~__FILE__ "SRS" [("Srs", wrap tests)] diff --git a/tezt/tests/dune b/tezt/tests/dune index cbe04364aa61..d9c6d6f89e21 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -69,6 +69,7 @@ src_lib_stdlib_unix_test__tezt_lib src_lib_stdlib_test_unix_tezt_lib src_lib_stdlib_test_tezt_lib + src_lib_srs_extraction_test_tezt_lib src_lib_signer_backends_unix_test_tezt_lib src_lib_signer_backends_test_tezt_lib src_lib_shell_services_test_tezt_lib -- GitLab From 8993bd2e2df96974055b4138b235cff79a5a8372 Mon Sep 17 00:00:00 2001 From: lykimq Date: Fri, 5 May 2023 10:36:03 +0200 Subject: [PATCH 2/2] Alcotezt-UX: add copyright and invocation header --- src/lib_srs_extraction/libsrs.ml | 25 ++++++++++++++ src/lib_srs_extraction/srs_extraction_main.ml | 25 ++++++++++++++ src/lib_srs_extraction/test/test_main.ml | 33 +++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/src/lib_srs_extraction/libsrs.ml b/src/lib_srs_extraction/libsrs.ml index 36e1e15e7631..d2348087b98d 100644 --- a/src/lib_srs_extraction/libsrs.ml +++ b/src/lib_srs_extraction/libsrs.ml @@ -1,3 +1,28 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + open Bls12_381 module G1 = G1 module G2 = G2 diff --git a/src/lib_srs_extraction/srs_extraction_main.ml b/src/lib_srs_extraction/srs_extraction_main.ml index b4a3484b7c00..15df92d98baa 100644 --- a/src/lib_srs_extraction/srs_extraction_main.ml +++ b/src/lib_srs_extraction/srs_extraction_main.ml @@ -1,3 +1,28 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + open Libsrs type curve = G1 | G2 diff --git a/src/lib_srs_extraction/test/test_main.ml b/src/lib_srs_extraction/test/test_main.ml index 62e3ba8f0564..7250f49e6579 100644 --- a/src/lib_srs_extraction/test/test_main.ml +++ b/src/lib_srs_extraction/test/test_main.ml @@ -1,3 +1,36 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(* Testing + ------- + Component: Lib_srs_extraction + Invocation: dune exec src/lib_srs_extraction/test/main.exe \ + -- --file test_main.ml + Subject: Test srs extraction +*) + open Libsrs let path = project_root // Filename.dirname __FILE__ -- GitLab