JJ: Description from the destination commit:
more module renaming JJ: Description from source commit: test binary_formats
This commit is contained in:
parent
e4b9fb473a
commit
1112106eb2
7 changed files with 114 additions and 39 deletions
|
|
@ -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
|
||||
|
|
|
|||
55
test/signatures.c
Normal file
55
test/signatures.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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;
|
||||
}
|
||||
13
test/test.ml
13
test/test.ml
|
|
@ -18,9 +18,9 @@ let () =
|
|||
check_bad Timestamp.jsont {|{"t_s": "123456780"}|};
|
||||
check_bad Timestamp.jsont {|{"t_s": "agagou"}|};
|
||||
|
||||
check Denomination_key.jsont
|
||||
check DenominationKey.jsont
|
||||
{|{"cipher": "RSA", "age_mask": 18, "rsa_pub": "agagouh"}|};
|
||||
check Denomination_key.jsont
|
||||
check DenominationKey.jsont
|
||||
{|{"cipher": "CS", "age_mask": 18, "cs_pub": "ouhagag"}|};
|
||||
()
|
||||
|
||||
|
|
@ -73,10 +73,15 @@ let () =
|
|||
()
|
||||
|
||||
let () =
|
||||
let open Binary_formats.WithdrawConfirmationPs in
|
||||
let str64 = String.make 64 '0' in
|
||||
let open Binary_formats.WithdrawConfirmationPS in
|
||||
let str64 = String.init 64 (fun i -> 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;
|
||||
|
||||
()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue