wip validate response
This commit is contained in:
parent
4784f32df5
commit
9213604385
2 changed files with 63 additions and 0 deletions
|
|
@ -7,3 +7,8 @@
|
||||||
(name test_crypto)
|
(name test_crypto)
|
||||||
(modules test_crypto)
|
(modules test_crypto)
|
||||||
(libraries mte fmt))
|
(libraries mte fmt))
|
||||||
|
|
||||||
|
(executable
|
||||||
|
(name validate_response)
|
||||||
|
(modules validate_response)
|
||||||
|
(libraries mte fmt bos))
|
||||||
|
|
|
||||||
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