From 50c5198a5792edde7651d5eddf90898da89b7220 Mon Sep 17 00:00:00 2001 From: swrup Date: Tue, 7 Oct 2025 16:26:05 +0200 Subject: [PATCH] --- test/dune | 7 ++++++ test/signatures.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/signatures.output | Bin 0 -> 76 bytes test/test.ml | 7 +++++- test/test.output | Bin 0 -> 76 bytes 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 test/signatures.c create mode 100644 test/signatures.output create mode 100644 test/test.output diff --git a/test/dune b/test/dune index 57d2e7e5..1eefa8ef 100644 --- a/test/dune +++ b/test/dune @@ -2,3 +2,10 @@ (name test) (modules test) (libraries mte fmt)) + +; TODO +; cram test? +; gcc -o a.out ./test/signatures.c && ./a.out > a.output +; rm ./a.out +; dune exec ./test/test.exe > b.output +; cmp -l a.output b.output diff --git a/test/signatures.c b/test/signatures.c new file mode 100644 index 00000000..bcebe993 --- /dev/null +++ b/test/signatures.c @@ -0,0 +1,55 @@ +#include +#include + +struct H64 { + uint8_t hash[64]; +}; +struct Hhh { + struct H64 hash; +}; +struct Purpose { + uint32_t size; + uint32_t purpose; +}; + +struct PS { + struct Purpose purpose; + struct Hhh h; + uint32_t noreveal_index; +}; + +int main(void) { + struct Purpose purpose; + struct PS ps; + + purpose.size = 3 * 4 + 64; + purpose.purpose = 1050; + + struct Hhh h = { + .hash = { + .hash = { + 1 , 2 , 3 , 4 , 5, 6, 7, 8, + 9 , 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64 + } + } + }; + + uint32_t noreveal_index = 0; + + ps.purpose = purpose; + ps.h = h; + ps.noreveal_index = noreveal_index; + + + fwrite(&ps, sizeof(ps), 1, stdout); + + // printf("\n"); + + return 0; +} diff --git a/test/signatures.output b/test/signatures.output new file mode 100644 index 0000000000000000000000000000000000000000..53eb1eba6bd76a2ede16edea6546a89a6798d61b GIT binary patch literal 76 zcmeZaU|^79VPIfnVrF4wW9Q)H;^yJy;};MV5*85^6PJ*bl9rK`lUGnwQdUt_Q`gYc f($>+{(>E|QGBz Char.unsafe_chr (i + 1)) in let dummy_t = { h_planchets= { v= { v= str64 } }; noreveal_index= 0_l } in let size' = Bin.size_of_value bin dummy_t |> Option.get in assert (size = size'); assert (size = 76); + + (* for cmp test with signatures.c output + let raw_str = Bin.to_string bin dummy_t in + Printf.printf "%s" raw_str; + *) () diff --git a/test/test.output b/test/test.output new file mode 100644 index 0000000000000000000000000000000000000000..53eb1eba6bd76a2ede16edea6546a89a6798d61b GIT binary patch literal 76 zcmeZaU|^79VPIfnVrF4wW9Q)H;^yJy;};MV5*85^6PJ*bl9rK`lUGnwQdUt_Q`gYc f($>+{(>E|QGBz