This commit is contained in:
parent
f56ef6b544
commit
dd668028ce
6 changed files with 127 additions and 11 deletions
58
test/validate_response.ml
Normal file
58
test/validate_response.ml
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
open Syntax
|
||||
(*open Crypto*)
|
||||
|
||||
let keys content =
|
||||
let open Api.ExchangeKeysResponse in
|
||||
let* v = Api.decode jsont content in
|
||||
(* validate version compatibility *)
|
||||
let* () =
|
||||
if
|
||||
Libtool_version.is_compatible
|
||||
~implementation:Libtool_version.mte_protocol_version v.version
|
||||
then Ok ()
|
||||
else Fmt.error "version incompatible"
|
||||
in
|
||||
|
||||
(* TODO *)
|
||||
(* validate currency specification *)
|
||||
(* validate all amounts *)
|
||||
(* validate all timestamp/duration *)
|
||||
(* validate master_public_key *)
|
||||
(* validate accounts *)
|
||||
(* validate wire-fees *)
|
||||
(* validate signkeys *)
|
||||
(* validate exchange_pub *)
|
||||
(* validate denominations *)
|
||||
(* validate exchange_sig *)
|
||||
(* validate global-fees *)
|
||||
(* validate list_issue_date *)
|
||||
(* validate auditors *)
|
||||
Ok ()
|
||||
|
||||
(* --- *)
|
||||
open Cmdliner
|
||||
open Cmdliner.Term.Syntax
|
||||
|
||||
let keys_cmd =
|
||||
let input =
|
||||
let doc = "input file" in
|
||||
Arg.(required & opt (some filepath) None & info [ "i"; "input" ] ~doc)
|
||||
in
|
||||
let doc = "validate a /keys JSON response" in
|
||||
Cmd.make (Cmd.info "keys" ~doc)
|
||||
@@
|
||||
let+ input = input in
|
||||
let* content =
|
||||
Result.bind (Fpath.of_string input) Bos.OS.File.read |> unwrap_err_msg
|
||||
in
|
||||
keys content
|
||||
|
||||
let cli =
|
||||
let info =
|
||||
let doc = "Testing tool to validate exchange responses" in
|
||||
Cmd.info "validate" ~doc
|
||||
in
|
||||
Cmd.group info [ keys_cmd ]
|
||||
|
||||
let main () = Cmd.eval_result cli
|
||||
let () = if !Sys.interactive then () else exit (main ())
|
||||
Loading…
Add table
Add a link
Reference in a new issue