diff --git a/manifest/main.ml b/manifest/main.ml index 5f6c60c36079ef6d928846eeb383d20190391aad..06d9e72637c67afd879f55812900973cd8f0485e 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 87a3fb9443efdb1b5f4617dad8279dd03bcbcb76..01a81edae5621d4e5cea9a812ee592ba6f431a9f 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/libsrs.ml b/src/lib_srs_extraction/libsrs.ml index 36e1e15e763169f8ff38a63d894e7dbf92cf8041..d2348087b98d05d3ec20a83cf8d325ad85f169e8 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 b4a3484b7c000ca9a97337de1fa5dd664ecd16f1..15df92d98baa43db224b64413f5a5838407236a2 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/dune b/src/lib_srs_extraction/test/dune index 1f33f9abaa4008148e84b56f5ef6a15dcdee9e32..065f767147fada71dd8ad26aaf3499538163c740 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/main.ml deleted file mode 100644 index 12341fc7aa60cb4b4729b4f70cd275120429d739..0000000000000000000000000000000000000000 --- a/src/lib_srs_extraction/test/main.ml +++ /dev/null @@ -1,13 +0,0 @@ -open Libsrs - -let test_lagrange () = - let input_file = "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 - -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)] diff --git a/src/lib_srs_extraction/test/test_main.ml b/src/lib_srs_extraction/test/test_main.ml new file mode 100644 index 0000000000000000000000000000000000000000..7250f49e657955df13c1f6c8ac386241de79a1ce --- /dev/null +++ b/src/lib_srs_extraction/test/test_main.ml @@ -0,0 +1,48 @@ +(*****************************************************************************) +(* *) +(* 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__ + +let test_lagrange () = + 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 + +let tests = [("lagrange zcash_srs", test_lagrange)] + +let () = + let wrap = List.map (fun (name, f) -> Alcotest.test_case name `Quick f) in + Alcotest.run ~__FILE__ "SRS" [("Srs", wrap tests)] diff --git a/tezt/tests/dune b/tezt/tests/dune index cbe04364aa61c4ad523c3c62e9824c870577625c..d9c6d6f89e210a0e06e1954391184f637b190de3 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