From 960403a2d238f596f80c4551955875a7db0403ce Mon Sep 17 00:00:00 2001 From: Hai Nguyen Van Date: Thu, 8 Oct 2020 11:14:41 +0200 Subject: [PATCH 1/3] Testing: Better comments in testing files of src/lib_signer_backends --- .../test/test_encrypted.ml | 19 +++++++++++++++++++ .../unix/test/test_crouching.ml | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/lib_signer_backends/test/test_encrypted.ml b/src/lib_signer_backends/test/test_encrypted.ml index 4c4add99931c..24d61a323fbe 100644 --- a/src/lib_signer_backends/test/test_encrypted.ml +++ b/src/lib_signer_backends/test/test_encrypted.ml @@ -7,6 +7,13 @@ (* *) (**************************************************************************) +(* Testing + ------- + Component: Remote-signature Backends + Invocation: dune build @src/lib_signer_backends/runtest + Subject: On secret keys and URIs. +*) + open Error_monad let loops = 10 @@ -143,11 +150,23 @@ let test_random algo = in inner 0 +(* Test. + For each of the algorithms [Ed25519; Secp256k1; P256], creates a + dummy context. It randomly generates a secret key, then encrypts it + into a URI and decrypts it. It it asserted that the secret key is + preserved. This process is repeated 10 times. +*) let test_random _switch () = iter_s test_random Signature.[Ed25519; Secp256k1; P256] >>= function | Ok _ -> Lwt.return_unit | Error _ -> Lwt.fail_with "test_random" +(* Test. + For each of the algorithms [Ed25519; Secp256k1; P256], creates a + dummy context, uses it to decrypt a list of secret key URIs + [...__sks_encrypted]. It is asserted that the decrypted keys shall + match the list [..._sks]. +*) let test_vectors _switch () = test_vectors () >>= function diff --git a/src/lib_signer_backends/unix/test/test_crouching.ml b/src/lib_signer_backends/unix/test/test_crouching.ml index 9bbae3a0bea4..ad5e6fd2d5a0 100644 --- a/src/lib_signer_backends/unix/test/test_crouching.ml +++ b/src/lib_signer_backends/unix/test/test_crouching.ml @@ -1,3 +1,15 @@ +(* Testing + ------- + Component: Remote-signature Backends + Invocation: dune build @src/lib_signer_backends/runtest + Subject: On pseudo-unique names for Ledger Nano S devices. +*) + +(* Test. + Deterministically-derive a sentence with the form + adjective-animal-adjective-animal from "12345". It is asserted that + the tuple is "calculating-meerkat-straight-beetle". +*) let test_example () = let name = Ledger_names.crouching_tiger "12345" in assert ( -- GitLab From fd3700f040574a1d3d3d55334b4bcaa285af8390 Mon Sep 17 00:00:00 2001 From: Hai Nguyen Van Date: Tue, 27 Oct 2020 14:10:50 +0100 Subject: [PATCH 2/3] Testing: Compliance with ocamldoc --- .../test/test_encrypted.ml | 28 +++++++++---------- .../unix/test/test_crouching.ml | 17 ++++++----- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/lib_signer_backends/test/test_encrypted.ml b/src/lib_signer_backends/test/test_encrypted.ml index 24d61a323fbe..aea7a878094e 100644 --- a/src/lib_signer_backends/test/test_encrypted.ml +++ b/src/lib_signer_backends/test/test_encrypted.ml @@ -7,11 +7,11 @@ (* *) (**************************************************************************) -(* Testing - ------- - Component: Remote-signature Backends - Invocation: dune build @src/lib_signer_backends/runtest - Subject: On secret keys and URIs. +(** Testing + ------- + Component: Remote-signature Backends + Invocation: dune build @src/lib_signer_backends/runtest + Subject: On secret keys and URIs. *) open Error_monad @@ -150,22 +150,20 @@ let test_random algo = in inner 0 -(* Test. - For each of the algorithms [Ed25519; Secp256k1; P256], creates a - dummy context. It randomly generates a secret key, then encrypts it - into a URI and decrypts it. It it asserted that the secret key is - preserved. This process is repeated 10 times. +(** For each of the algorithms [Ed25519; Secp256k1; P256], creates a + dummy context. It randomly generates a secret key, then encrypts it + into a URI and decrypts it. It it asserted that the secret key is + preserved. This process is repeated 10 times. *) let test_random _switch () = iter_s test_random Signature.[Ed25519; Secp256k1; P256] >>= function | Ok _ -> Lwt.return_unit | Error _ -> Lwt.fail_with "test_random" -(* Test. - For each of the algorithms [Ed25519; Secp256k1; P256], creates a - dummy context, uses it to decrypt a list of secret key URIs - [...__sks_encrypted]. It is asserted that the decrypted keys shall - match the list [..._sks]. +(** For each of the algorithms [Ed25519; Secp256k1; P256], creates a + dummy context, uses it to decrypt a list of secret key URIs + [...__sks_encrypted]. It is asserted that the decrypted keys shall + match the list [..._sks]. *) let test_vectors _switch () = test_vectors () diff --git a/src/lib_signer_backends/unix/test/test_crouching.ml b/src/lib_signer_backends/unix/test/test_crouching.ml index ad5e6fd2d5a0..455c488110ff 100644 --- a/src/lib_signer_backends/unix/test/test_crouching.ml +++ b/src/lib_signer_backends/unix/test/test_crouching.ml @@ -1,14 +1,13 @@ -(* Testing - ------- - Component: Remote-signature Backends - Invocation: dune build @src/lib_signer_backends/runtest - Subject: On pseudo-unique names for Ledger Nano S devices. +(** Testing + ------- + Component: Remote-signature Backends + Invocation: dune build @src/lib_signer_backends/runtest + Subject: On pseudo-unique names for Ledger Nano S devices. *) -(* Test. - Deterministically-derive a sentence with the form - adjective-animal-adjective-animal from "12345". It is asserted that - the tuple is "calculating-meerkat-straight-beetle". +(** Deterministically-derive a sentence with the form + adjective-animal-adjective-animal from "12345". It is asserted that + the tuple is "calculating-meerkat-straight-beetle". *) let test_example () = let name = Ledger_names.crouching_tiger "12345" in -- GitLab From bb0f130be8f77700598d463aa4b02da7efa870e2 Mon Sep 17 00:00:00 2001 From: Hai Nguyen Van Date: Sun, 1 Nov 2020 20:40:48 +0100 Subject: [PATCH 3/3] Testing: Amended according to @victor-dumitrescu's review. --- src/lib_signer_backends/test/test_encrypted.ml | 7 ++++--- src/lib_signer_backends/unix/test/test_crouching.ml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib_signer_backends/test/test_encrypted.ml b/src/lib_signer_backends/test/test_encrypted.ml index aea7a878094e..81200e812d48 100644 --- a/src/lib_signer_backends/test/test_encrypted.ml +++ b/src/lib_signer_backends/test/test_encrypted.ml @@ -151,9 +151,10 @@ let test_random algo = inner 0 (** For each of the algorithms [Ed25519; Secp256k1; P256], creates a - dummy context. It randomly generates a secret key, then encrypts it - into a URI and decrypts it. It it asserted that the secret key is - preserved. This process is repeated 10 times. + dummy context. It randomly generates a Base58-encoded secret key, + then encrypts it into a URI and decrypts it. It it asserted that + the secret key is preserved after Base58-decoding comparison. This + process is repeated 10 times. *) let test_random _switch () = iter_s test_random Signature.[Ed25519; Secp256k1; P256] diff --git a/src/lib_signer_backends/unix/test/test_crouching.ml b/src/lib_signer_backends/unix/test/test_crouching.ml index 455c488110ff..df2e867c4276 100644 --- a/src/lib_signer_backends/unix/test/test_crouching.ml +++ b/src/lib_signer_backends/unix/test/test_crouching.ml @@ -5,7 +5,7 @@ Subject: On pseudo-unique names for Ledger Nano S devices. *) -(** Deterministically-derive a sentence with the form +(** Deterministically derive a sentence with the form adjective-animal-adjective-animal from "12345". It is asserted that the tuple is "calculating-meerkat-straight-beetle". *) -- GitLab