diff --git a/src/binary_formats.ml b/src/binary_formats.ml index f51dc198..a750e089 100644 --- a/src/binary_formats.ml +++ b/src/binary_formats.ml @@ -451,15 +451,23 @@ module WithdrawConfirmationPS = struct noreveal_index: int32; } - let size = Purpose.size + HashPlanchetsP.size + int32_size - let purpose = Purpose.make ~size Taler_signatures.exchange_confirm_withdraw + (*let size = Purpose.size + HashPlanchetsP.size + int32_size*) + + open Bin let bin = - let open Bin in - record (fun _urpose h_planchets noreveal_index -> - { h_planchets; noreveal_index }) - |+ field Purpose.bin (Fun.const purpose) - |+ field HashPlanchetsP.bin (fun t -> t.h_planchets) - |+ field beint32 (fun t -> t.noreveal_index) + record (fun purpose h_planchets noreveal_index -> + (purpose, { h_planchets; noreveal_index })) + |+ field Purpose.bin (fun (purpose, _t) -> purpose) + |+ field HashPlanchetsP.bin (fun (_p, t) -> t.h_planchets) + |+ field beint32 (fun (_p, t) -> t.noreveal_index) |> sealr + + let size = + match Size.of_value (Size.size_of bin) with + | Dynamic _ | Unknown -> Fmt.failwith "size_of failure: size is not Static" + | Static n -> n + + let purpose = Purpose.make ~size Taler_signatures.exchange_confirm_withdraw + let bin = map bin (fun (_p, t) -> t) (fun t -> (purpose, t)) end diff --git a/test/test.ml b/test/test.ml index 5629d120..8f233513 100644 --- a/test/test.ml +++ b/test/test.ml @@ -80,8 +80,8 @@ let () = assert (size = size'); assert (size = 76); - (* for cmp test with signatures.c output + (* for cmp test with signatures.c output *) let raw_str = Bin.to_string bin dummy_t in Printf.printf "%s" raw_str; - *) + ()