mina_tree/dummy/for_tests.rs
1use mina_p2p_messages::{binprot::BinProtRead, v2::MinaBaseUserCommandStableV2};
2
3use crate::scan_state::transaction_logic::valid;
4
5/// 882 signed commands (non-zkapps) generated this way in `src/staged_ledger/staged_ledger.ml`:
6///
7/// let cmds_per_iter = [
8/// 126;
9/// 126;
10/// 126;
11/// 126;
12/// 126;
13/// 126;
14/// 126;
15/// ] in
16/// let total_cmds = List.fold cmds_per_iter ~init:0 ~f:( + ) in
17/// let%bind cmds =
18/// User_command.Valid.Gen.sequence ~length:total_cmds ~sign_type:`Real
19/// ledger_init_state
20/// in
21/// assert (List.length cmds = total_cmds) ;
22///
23/// (* let buf = Bigstring.create (List.bin_size_t User_command.Valid.Stable.V2.bin_size_t cmds) in *)
24/// (* ignore (List.bin_write_t User_command.Valid.Stable.V2.bin_write_t buf ~pos:0 cmds : int) ; *)
25/// (* let bytes = Bigstring.to_bytes buf in *)
26/// (* let explode s = List.init (String.length s) ~f:(fun i -> String.get s i) in *)
27/// (* let s = (String.concat ~sep:"," (List.map (explode (Bytes.to_string bytes)) ~f:(fun b -> string_of_int (Char.to_int b)))) in *)
28/// (* Core.Printf.eprintf !"cmds_binprot=[%s]\n%!" s; *)
29///
30/// (* return (ledger_init_state, cmds, a) *)
31///
32/// let cmds_per_iter = [126; 126; 126; 1] in
33/// (* let cmds_per_iter = [126; 126; 126; 126] in *)
34/// let total_cmds = List.fold cmds_per_iter ~init:0 ~f:( + ) in
35/// let cmds = List.take cmds total_cmds in
36/// Core.Printf.eprintf !"cmds=%{sexp: User_command.Valid.t list}\n%!" cmds;
37pub fn list_of_cmds() -> Vec<valid::UserCommand> {
38 let mut cursor = std::io::Cursor::new(include_bytes!("cmds.bin"));
39 let cmds: Vec<MinaBaseUserCommandStableV2> =
40 Vec::<MinaBaseUserCommandStableV2>::binprot_read(&mut cursor).unwrap();
41
42 cmds.iter().map(|cmd| cmd.try_into().unwrap()).collect()
43}
44
45/// Core.Printf.eprintf
46/// !"PROTOCOL_STATE=%{sexp: Mina_state.Protocol_state.value}\n%!" state ;
47///
48/// let buf = Bigstring.create (Mina_state.Protocol_state.Value.Stable.V2.bin_size_t state) in
49/// ignore (Mina_state.Protocol_state.Value.Stable.V2.bin_write_t buf ~pos:0 state : int) ;
50/// let bytes = Bigstring.to_bytes buf in
51/// let explode s = List.init (String.length s) ~f:(fun i -> String.get s i) in
52/// let s = (String.concat ~sep:"," (List.map (explode (Bytes.to_string bytes)) ~f:(fun b -> string_of_int (Char.to_int b)))) in
53///
54/// Core.Printf.eprintf !"state_binprot=[%s]\n%!" s;
55///
56pub fn dummy_protocol_state() -> mina_p2p_messages::v2::MinaStateProtocolStateValueStableV2 {
57 let mut cursor = std::io::Cursor::new(include_bytes!("protocol_state.bin"));
58 mina_p2p_messages::v2::MinaStateProtocolStateValueStableV2::binprot_read(&mut cursor).unwrap()
59}