package octez-protocol-alpha-libs

  1. Overview
  2. Docs
Octez protocol alpha libraries

Install

Dune Dependency

Authors

Maintainers

Sources

octez-19.0.tar.gz
sha256=c6df840ebbf115e454db949028c595bec558a59a66cade73b52a6d099d6fa4d4
sha512=d8aee903b9fe130d73176bc8ec38b78c9ff65317da3cb4f3415f09af0c625b4384e7498201fdb61aa39086a7d5d409d0ab3423f9bc3ab989a680cf444a79bc13

doc/src/octez-protocol-alpha-libs.client/client_proto_tzt.ml.html

Source file client_proto_tzt.ml

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
(*****************************************************************************)
(*                                                                           *)
(* SPDX-License-Identifier: MIT                                              *)
(* Copyright (c) 2023 Nomadic Labs <contact@nomadic-labs.com>                *)
(*                                                                           *)
(*****************************************************************************)

open Protocol
open Alpha_context

type unit_test_with_source = {
  source : string;
  parsed : string Michelson_v1_parser.parser_result;
}

let print_stack out l = Michelson_v1_printer.print_typed_stack out l

let run_unit_test (cctxt : #Protocol_client_context.rpc_context)
    ~(chain : Chain_services.chain) ~block ~(test : unit_test_with_source) () =
  let open Lwt_result_syntax in
  let*? ut = Michelson_v1_stack.parse_unit_test test.parsed in
  let* chain_id = Chain_services.chain_id cctxt ~chain () in
  let amount = Tez.zero in
  let* expected_output =
    Plugin.RPC.Scripts.normalize_stack
      cctxt
      (chain, block)
      ~stack:ut.output
      ~unparsing_mode:Readable
      ~legacy:true
      ~other_contracts:None
      ~extra_big_maps:None
  in
  let* output, _gas =
    Plugin.RPC.Scripts.run_instr
      ~legacy:true
      ~gas:None
      ~input:ut.input
      ~code:ut.code
      ~now:None
      ~level:None
      ~sender:None
      ~source:None
      ~chain_id
      ~self:None
      ~parameter:None
      ~amount
      ~balance:None
      ~other_contracts:None
      ~extra_big_maps:None
      ~unparsing_mode:None
      cctxt
      (chain, block)
  in
  if output = expected_output then return_unit
  else
    failwith
      "Output: %a@.Expected: %a@."
      print_stack
      output
      print_stack
      expected_output
OCaml

Innovation. Community. Security.