diff --git a/src/hash.ml b/src/hash.ml index ca32519f..0a4d9002 100644 --- a/src/hash.ml +++ b/src/hash.ml @@ -49,7 +49,9 @@ module H64 = struct let of_octets s = match String.length s = 64 with - | false -> Fmt.failwith "Hash.of_octets failure: data is not 64 bytes" + | false -> + Fmt.epr "s length: %d@." (String.length s); + Fmt.failwith "Hash.of_octets failure: data is not 64 bytes" | true -> SHA512.of_raw_string s let to_octets v = diff --git a/test/b32.ml b/test/b32.ml index c6986084..1858461f 100644 --- a/test/b32.ml +++ b/test/b32.ml @@ -1,6 +1,6 @@ let () = let id s = s |> B32.encode |> B32.decode |> Result.get_ok in - let f s = + let round_trip s = let s' = id s in match s' = s with | false -> @@ -8,8 +8,25 @@ let () = | true -> () in let s = String.init 0xff Char.chr in + round_trip s; let s_l = List.init 0x0f (fun i -> String.init i Char.chr) in - f s; - List.iter f s_l; + List.iter round_trip s_l; () + +let () = + let input = "91JPRV3F5GG4EKJNDSJQ8" in + Fmt.epr "input length: %d@." (String.length input); + let output = + input + |> Hash.H64.of_b32 + |> Result.get_ok + |> Hash.H64.to_octets + |> B32.encode + in + let expected = + "D0R24RZ1TPASVQ2NY56CT8AJDYZE9ZGDB0GVZ05E9D4YGZQW2RC5YFPQ0Q86EPW836DY7VYQTNFFJT3ZR2K508F4JVS5JNJKYN2MMFR" + in + Fmt.pr "input : %s@." input; + Fmt.pr "output : %s@." output; + Fmt.pr "expected: %s@." expected; () diff --git a/test/dune b/test/dune index bec41ef4..3c54d887 100644 --- a/test/dune +++ b/test/dune @@ -6,7 +6,7 @@ (test (name b32) (modules b32) - (libraries b32 fmt)) + (libraries mte b32 fmt)) ; TODO ; cram test?