From 3334216fcf5e50ef4fb8d8279bdd2073a4250e09 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Mon, 7 Oct 2019 13:09:11 -0400 Subject: [PATCH 01/23] Sandbox: add manager.tz tests --- src/bin_sandbox/command_ledger_wallet.ml | 147 +++++++++++++++++++++-- 1 file changed, 139 insertions(+), 8 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 44b1cded95b2..89c92d01acfb 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -626,14 +626,16 @@ let delegation_tests state ~client ~src ~with_rejections ~protocol_kind tz_account_delegation () >>= fun () -> self_delegation () let transaction_tests state ~client ~src ~with_rejections ~protocol_kind - ~pair_string_nat_kt1_account ~ledger_account ~unit_kt1_account ~bake () = + ~pair_string_nat_kt1_account ~ledger_account ~unit_kt1_account ~manager_tz_kt1_account + ~bake () = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in let only_success = not with_rejections in - let test_transaction ?(storage = 0) ?arguments ~name ~dst_name ~dst_pkh () = - let amount = "15" in + let test_transaction ?(storage = 0) ?arguments ~name ~dst_name ~dst_pkh ?entrypoint ?(amount = 15) () = let command = - ["--wait"; "none"; "transfer"; amount; "from"; src; "to"; dst_name] + let opt = Option.value_map ~default:[] in + ["--wait"; "none"; "transfer"; (sprintf "%i" amount); "from"; src; "to"; dst_name] @ Option.value_map ~default:[] arguments ~f:(fun a -> ["--arg"; a]) + @ opt entrypoint ~f:(fun e -> ["--entrypoint"; e]) @ ["--burn-cap"; "100"; "--verbose-signing"] in with_ledger_test_reject_and_accept @@ -653,7 +655,7 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind | None -> ledger_should_display ppf - [ ("Amount", const string amount); + [ ("Amount", const int amount); ("Fee", const string "0.00XXX"); ("Source", const string ledger_pkh); ("Destination", const string dst_pkh); @@ -691,6 +693,14 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind >>= fun () -> let module Acc = Tezos_protocol.Account in let random_account = Acc.of_name "random-account-for-transaction-test" in + test_transaction + ~name:"Self-transaction" + ~dst_pkh:ledger_pkh + ~dst_name:src + () + >>= fun () -> + let module Acc = Tezos_protocol.Account in + let random_account = Acc.of_name "random-account-for-transaction-test" in test_transaction ~name:"transaction-to-random-tz1" ~dst_pkh:(Acc.pubkey_hash random_account) @@ -712,12 +722,121 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind () >>= fun () -> test_transaction - ~name:"parameterfull-transaction-to-kt1" + ~name:"manager.tz-remove-delegate" + ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + ~arguments:"{ DROP ; NIL operation ; NONE key_hash ; SET_DELEGATE ; CONS }" + ~dst_name:manager_tz_kt1_account + ~entrypoint:"do" + ~amount:0 + () + >>= fun () -> + test_transaction + ~name:"manager.tz-set-delegate" + ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; SOME ; SET_DELEGATE ; CONS }" ledger_pkh) + ~dst_name:manager_tz_kt1_account + ~entrypoint:"do" + ~amount:0 + () + >>= fun () -> + test_transaction + ~name:"manager.tz-transfer-originated-to-implicit" ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~arguments:"Pair \"hello from the ledger\" 51" - ~dst_name:pair_string_nat_kt1_account + ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash %s ; IMPLICIT_ACCOUNT ; PUSH mutez %s ; UNIT ; TRANSFER_TOKENS ; CONS }") + ~dst_name:manager_tz_kt1_account + ~entrypoint:"do" + () + >>= fun () -> + test_transaction + ~name:"manager.tz-transfer-originated-to-originated" + ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH address %s ; CONTRACT %%s %s ; ASSERT_SOME ; PUSH mutez %s ; %s ; TRANSFER_TOKENS ; CONS }" ledger_pkh ) + ~dst_name:manager_tz_kt1_account + ~entrypoint:"do" () +let prepare_origination_of_manager_tz_script ?(spendable = false) + ?(delegatable = false) ?delegate state + ~client ~name ~from ~protocol_kind ~ledger_account = + let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in + let manager_tz_script = + " +parameter +\ (or +\ (lambda %do unit (list operation)) +\ (unit %default)); +storage key_hash; +code +\ { UNPAIR ; +\ IF_LEFT +\ { # 'do' entrypoint +\ # Assert no token was sent: +\ # to send tokens, the default entry point should be used +\ PUSH mutez 0 ; +\ AMOUNT ; +\ ASSERT_CMPEQ ; +\ # Assert that the sender is the manager +\ DUUP ; +\ IMPLICIT_ACCOUNT ; +\ ADDRESS ; +\ SENDER ; +\ ASSERT_CMPEQ ; +\ # Execute the lambda argument +\ UNIT ; +\ EXEC ; +\ PAIR ; +\ } +\ { # 'default' entrypoint +\ DROP ; +\ NIL operation ; +\ PAIR ; +\ } +\ };" + in + let tmp = Filename.temp_file "manager" ".tz" in + System.write_file state tmp ~content:manager_tz_script + >>= fun () -> + let origination = + let opt = Option.value_map ~default:[] in + ["--wait"; "none"; "originate"; "contract"; name] + @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon -> []) + @ [ "transferring"; + "0"; + "from"; + from; + "running"; + tmp; + "--init"; + (sprintf "\"%s\"" ledger_pkh); + "--force"; + "--burn-cap"; + "300000000000"; + (* ; "--fee-cap" ; "20000000000000" *) + "--gas-limit"; + "1000000000000000"; + "--storage-limit"; + "20000000000000"; + "--verbose-signing" ] + @ opt delegate ~f:(fun s -> (* Baby & Aths *) ["--delegate"; s]) + @ (if delegatable then [(* Aths *) "--delegatable"] else []) + @ if spendable then [(* Aths *) "--spendable"] else [] + in + return origination + +let originate_manager_tz_script state ~delegate ~client ~name ~from ~bake + ~protocol_kind ~ledger_account = + prepare_origination_of_manager_tz_script + state + ~delegate + ~client + ~name + ~from + ~protocol_kind + ~ledger_account + >>= fun origination -> + Tezos_client.successful_client_cmd state ~client origination + >>= fun _ -> Fmt.kstrf bake "baking `%s` in" name + let prepare_origination_of_id_script ?(spendable = false) ?(delegatable = false) ?delegate ?(push_drops = 0) ?(amount = "2") state ~client:_ ~name ~from ~protocol_kind ~parameter ~init_storage = @@ -1240,6 +1359,17 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec ~parameter:"(pair string nat)" ~init_storage:"Pair \"the answer is: \" 42" >>= fun () -> + let manager_tz_kt1_account = "manager-tz-kt1-of-the-baker" in + originate_manager_tz_script + state + ~delegate:baker_0.Tezos_client.Keyed.key_name + ~client:client_0 + ~name:manager_tz_kt1_account + ~from:baker_0.Tezos_client.Keyed.key_name + ~bake + ~protocol_kind + ~ledger_account + >>= fun () -> let transactions_test ~with_rejections = transaction_tests state @@ -1247,6 +1377,7 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec ~ledger_account ~unit_kt1_account ~pair_string_nat_kt1_account + ~manager_tz_kt1_account ~src:signer.key_name () ~bake -- GitLab From c2a808b0851b38e668371852412350f00eb6167b Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 10 Oct 2019 11:08:37 -0400 Subject: [PATCH 02/23] Sanbox: make sure transactions tests are set up correctly --- src/bin_sandbox/command_ledger_wallet.ml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 89c92d01acfb..356021407561 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -730,29 +730,41 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ~amount:0 () >>= fun () -> + Tezos_client.client_cmd + state + ~client + [ "--wait"; + "none"; + "set"; + "delegate"; + "for"; + src; + "to"; + src; + "--verbose-signing" ] + >>= fun (_, _) -> test_transaction ~name:"manager.tz-set-delegate" ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; SOME ; SET_DELEGATE ; CONS }" ledger_pkh) + ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash %s ; SOME ; SET_DELEGATE ; CONS }" "0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00") ~dst_name:manager_tz_kt1_account ~entrypoint:"do" ~amount:0 () >>= fun () -> test_transaction - ~name:"manager.tz-transfer-originated-to-implicit" + ~name:"manager.tz-add-funds" ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash %s ; IMPLICIT_ACCOUNT ; PUSH mutez %s ; UNIT ; TRANSFER_TOKENS ; CONS }") ~dst_name:manager_tz_kt1_account - ~entrypoint:"do" () >>= fun () -> test_transaction - ~name:"manager.tz-transfer-originated-to-originated" + ~name:"manager.tz-transfer-originated-to-implicit" ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH address %s ; CONTRACT %%s %s ; ASSERT_SOME ; PUSH mutez %s ; %s ; TRANSFER_TOKENS ; CONS }" ledger_pkh ) + ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash %s ; IMPLICIT_ACCOUNT ; PUSH mutez %i ; UNIT ; TRANSFER_TOKENS ; CONS }" "0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00" 15) ~dst_name:manager_tz_kt1_account ~entrypoint:"do" + ~amount:0 () let prepare_origination_of_manager_tz_script ?(spendable = false) -- GitLab From 40a6f707e615b9aec0cf32cc5c1bc59c80bcfa55 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 10 Oct 2019 12:58:07 -0400 Subject: [PATCH 03/23] Sandbox: pack key_hash for set delegate Needs to be packed for initial ledger wallet implementation. --- src/bin_sandbox/command_ledger_wallet.ml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 356021407561..7f801856332a 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -743,10 +743,22 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind src; "--verbose-signing" ] >>= fun (_, _) -> + Tezos_client.client_cmd + state + ~client + [ "hash"; + "data"; + (sprintf "\"%s\"" ledger_pkh); + "of"; + "type"; + "key_hash"; ] + >>= fun (_, res) -> + let src_hex = List.hd_exn res#out |> String.split ~on:' ' |> (fun (s) -> List.nth_exn s 3) + in test_transaction ~name:"manager.tz-set-delegate" ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash %s ; SOME ; SET_DELEGATE ; CONS }" "0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00") + ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash %s ; SOME ; SET_DELEGATE ; CONS }" src_hex) ~dst_name:manager_tz_kt1_account ~entrypoint:"do" ~amount:0 -- GitLab From 3a8c453ce2dc22c15646a0eb05c1c4a05cf5ab48 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Tue, 15 Oct 2019 11:48:34 -0400 Subject: [PATCH 04/23] Sandbox: add wallet tests --- src/bin_sandbox/command_ledger_wallet.ml | 167 +++++++++++++++++++---- 1 file changed, 144 insertions(+), 23 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 7f801856332a..287b3470cd9e 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -361,6 +361,71 @@ let sign state ~client ~bytes = ~client:client.Tezos_client.Keyed.client ["sign"; "bytes"; "0x" ^ bytes; "for"; client.Tezos_client.Keyed.key_name] +let manager_tz_delegation_tests state ~client ~src ~contract_addr ~with_rejections ~protocol_kind + ~(delegate_pkh:string) ~ledger_account ~bake () = + (* src = signer.key, *) + let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in + let only_success = not with_rejections in + let set_delegation () = + let arg = (sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; SOME ; SET_DELEGATE ; CONS }" delegate_pkh) + in + let command = + [ "--wait"; + "none"; + "transfer"; + "0"; + "from"; + src; + "to"; + contract_addr; + "--entrypoint"; + "do"; + "--arg"; + arg; + "--verbose-signing" ] + in + with_ledger_test_reject_and_accept + state + ~only_success + ~messages: + MFmt. + [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); + show_command_message command; + (fun ppf () -> + wf + ppf + "Note that X is a placeholder for some value that will vary \ + between runs"); + (fun ppf () -> + ledger_should_display + ppf + [ ("Fee", const string "0.00XXX"); + ("Source", const string src); + ("Delegate", const string delegate_pkh); + ("Storage", const int 0) ]) ] + (fun ~user_answer -> + client_async_cmd + state + ~client + ~f:(fun _ proc -> + find_and_print_signature_hash + ~display_expectation:(protocol_kind = `Babylon) + state + proc) + command + >>= fun res -> + expect_from_output + ~message:"self-delegation" + res + ~expectation: + ( match user_answer with + | `Reject -> + `Ledger_reject_or_timeout + | `Accept -> + `Success )) + >>= fun _ -> ksprintf bake "setting self-delegate of %s" src + in set_delegation () + let delegation_tests state ~client ~src ~with_rejections ~protocol_kind ~ledger_account ~delegate ~bake () = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in @@ -626,7 +691,7 @@ let delegation_tests state ~client ~src ~with_rejections ~protocol_kind tz_account_delegation () >>= fun () -> self_delegation () let transaction_tests state ~client ~src ~with_rejections ~protocol_kind - ~pair_string_nat_kt1_account ~ledger_account ~unit_kt1_account ~manager_tz_kt1_account + ~pair_string_nat_kt1_account ~ledger_account ~unit_kt1_account ~bake () = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in let only_success = not with_rejections in @@ -693,14 +758,6 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind >>= fun () -> let module Acc = Tezos_protocol.Account in let random_account = Acc.of_name "random-account-for-transaction-test" in - test_transaction - ~name:"Self-transaction" - ~dst_pkh:ledger_pkh - ~dst_name:src - () - >>= fun () -> - let module Acc = Tezos_protocol.Account in - let random_account = Acc.of_name "random-account-for-transaction-test" in test_transaction ~name:"transaction-to-random-tz1" ~dst_pkh:(Acc.pubkey_hash random_account) @@ -720,6 +777,7 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ~dst_name:unit_kt1_account () +(* >>= fun () -> test_transaction ~name:"manager.tz-remove-delegate" @@ -753,6 +811,8 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind "type"; "key_hash"; ] >>= fun (_, res) -> + *) +(* let src_hex = List.hd_exn res#out |> String.split ~on:' ' |> (fun (s) -> List.nth_exn s 3) in test_transaction @@ -778,6 +838,7 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ~entrypoint:"do" ~amount:0 () +*) let prepare_origination_of_manager_tz_script ?(spendable = false) ?(delegatable = false) ?delegate state @@ -849,9 +910,10 @@ code let originate_manager_tz_script state ~delegate ~client ~name ~from ~bake ~protocol_kind ~ledger_account = + (* TODO: make "delegate" optional *) + let () = Pervasives.ignore delegate in prepare_origination_of_manager_tz_script state - ~delegate ~client ~name ~from @@ -1074,6 +1136,7 @@ module Wallet_scenario = struct [ `All | `Voting | `Batch_transactions + | `Manager | `Delegation | `Transactions | `Contracts @@ -1094,6 +1157,7 @@ module Wallet_scenario = struct ("delegation", `Delegation); ("transactions", `Transactions); ("contracts", `Contracts); + ("manager", `Manager); ("batch-transactions", `Batch_transactions) ] let root (ws : t) = @@ -1120,6 +1184,8 @@ module Wallet_scenario = struct let if_delegation t = run_if `Delegation t + let if_manager t = run_if `Manager t + let if_transactions t = run_if `Transactions t let if_contracts t = run_if `Contracts t @@ -1348,6 +1414,66 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec | `Reject -> `Ledger_reject_or_timeout )) in + +(**************************************************************************************) + (* + >>= fun () -> + Tezos_client.client_cmd + state + ~client + ["show"; "known"; "contract"; unit_kt1_account] + >>= fun (_, proc_result) -> + let contract_address = proc_result#out |> String.concat ~sep:"" in + test_transaction + ~name:"manager.tz-transfer-originated-to-originated" + ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH address \"%s\" ; CONTRACT unit ; ASSERT_SOME ; PUSH mutez %i ; UNIT ; TRANSFER_TOKENS ; CONS }" contract_address 5) + ~dst_name:manager_tz_kt1_account + ~entrypoint:"do" + ~amount:0 + () + *) + +(* Tezos_client.client_cmd state ~client ["show"; "address"; delegate] + >>= fun (_, proc_result) -> + let delegate_address = + List.hd_exn proc_result#out + |> String.split ~on:' ' |> List.last + |> Option.value ~default:delegate + in + * + let signer = Tezos_client.Keyed.make (client 0) ~key_name:"ledgered" ~secret_key:uri +*) + +(**************************************************************************************) + let manager_tz_kt1_account = "manager-tz-kt1-of-the-baker" in + originate_manager_tz_script + state + ~client:client_0 + ~name:manager_tz_kt1_account + ~from:signer.key_name + ~delegate:baker_0.Tezos_client.Keyed.key_name + ~bake + ~protocol_kind + ~ledger_account + (*~delegate:Tezos_protocol.Account.pubkey_hash baker_0_account *) + >>= fun () -> + let manager_tz_delegation_tests ~with_rejections = + manager_tz_delegation_tests + state + ~client:client_0 + ~src:signer.key_name + ~contract_addr:manager_tz_kt1_account + ~ledger_account + ~delegate_pkh:(Tezos_protocol.Account.pubkey_hash baker_0_account) + (* ~delegate_pkh:baker_0.Tezos_client.Keyed.key_name *) + () + ~bake + ~with_rejections + ~protocol_kind + in + +(**************************************************************************************) let delegation_tests ~with_rejections = delegation_tests state @@ -1383,25 +1509,13 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec ~parameter:"(pair string nat)" ~init_storage:"Pair \"the answer is: \" 42" >>= fun () -> - let manager_tz_kt1_account = "manager-tz-kt1-of-the-baker" in - originate_manager_tz_script - state - ~delegate:baker_0.Tezos_client.Keyed.key_name - ~client:client_0 - ~name:manager_tz_kt1_account - ~from:baker_0.Tezos_client.Keyed.key_name - ~bake - ~protocol_kind - ~ledger_account - >>= fun () -> - let transactions_test ~with_rejections = + let transactions_test ~with_rejections = transaction_tests state ~client:client_0 ~ledger_account ~unit_kt1_account ~pair_string_nat_kt1_account - ~manager_tz_kt1_account ~src:signer.key_name () ~bake @@ -1456,6 +1570,8 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec return () | Some `Delegation -> run delegation_tests + | Some `Manager -> + run manager_tz_delegation_tests | Some `All -> run delegation_tests >>= fun () -> run batch_test >>= fun () -> run voting_test @@ -1491,6 +1607,11 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec wallet_scenario ~yes:delegation_tests ~no:skipping + >>= fun () -> + Wallet_scenario.if_manager + wallet_scenario + ~yes:manager_tz_delegation_tests + ~no:skipping >>= fun () -> Interactive_test.Pauser.generic state EF.[af "Tests done."] let cmd () = -- GitLab From 9e1904742c0250a09f3693aa51c9ae2aae0e4ed0 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Wed, 16 Oct 2019 11:21:58 -0400 Subject: [PATCH 05/23] Sandbox: working set delegate test --- src/bin_sandbox/command_ledger_wallet.ml | 109 ++++++++++++----------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 287b3470cd9e..ac04f152fbed 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -1226,6 +1226,8 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec Interactive_test.Pauser.generic state EF.[af "Ready to start"; af "Root path deleted."] + +(***********************************************************************************) >>= fun () -> let ledger_client = Tezos_client.no_node_client ~exec:client_exec in Tezos_client.Ledger.show_ledger state ~client:ledger_client ~uri @@ -1336,6 +1338,7 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec `Success | `Reject -> `Ledger_reject_or_timeout )) +(***********************************************************************************) >>= fun () -> let skipping s = Console.say state EF.(haf "Skipping %s tests" s) in let voting_test ~with_rejections = @@ -1415,7 +1418,55 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec `Ledger_reject_or_timeout )) in -(**************************************************************************************) + let delegation_tests ~with_rejections = + delegation_tests + state + ~client:client_0 + ~ledger_account + ~delegate:baker_0.Tezos_client.Keyed.key_name + ~src:signer.key_name + () + ~bake + ~with_rejections + ~protocol_kind + in + let unit_kt1_account = "unit-kt1-of-the-baker" in + originate_id_script + state + ~client:client_0 + ~name:unit_kt1_account + ~from:baker_0.Tezos_client.Keyed.key_name + ~bake + ~protocol_kind + ~parameter:"unit" + ~init_storage:"Unit" + >>= fun () -> + let pair_string_nat_kt1_account = "pair-string-nat-kt1-of-the-baker" in + originate_id_script + state + ~client:client_0 + ~name:pair_string_nat_kt1_account + ~push_drops:10 + ~from:baker_0.Tezos_client.Keyed.key_name + ~bake + ~protocol_kind + ~parameter:"(pair string nat)" + ~init_storage:"Pair \"the answer is: \" 42" + >>= fun () -> + let transactions_test ~with_rejections = + transaction_tests + state + ~client:client_0 + ~ledger_account + ~unit_kt1_account + ~pair_string_nat_kt1_account + ~src:signer.key_name + () + ~bake + ~with_rejections + ~protocol_kind + in + (**************************************************************************************) (* >>= fun () -> Tezos_client.client_cmd @@ -1447,11 +1498,13 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec (**************************************************************************************) let manager_tz_kt1_account = "manager-tz-kt1-of-the-baker" in + (*let random_mgr_account = Tezos_protocol.Account.of_name "random-account-for-manager-test" in + let manager = Tezos_client.Keyed.make (client 0) ~key_name:"manager_acct" ~secret_key:(Tezos_protocol.Account.private_key random_mgr_account) in *) originate_manager_tz_script state ~client:client_0 ~name:manager_tz_kt1_account - ~from:signer.key_name + ~from:(signer.key_name) ~delegate:baker_0.Tezos_client.Keyed.key_name ~bake ~protocol_kind @@ -1462,7 +1515,7 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec manager_tz_delegation_tests state ~client:client_0 - ~src:signer.key_name + ~src:(signer.key_name) ~contract_addr:manager_tz_kt1_account ~ledger_account ~delegate_pkh:(Tezos_protocol.Account.pubkey_hash baker_0_account) @@ -1474,55 +1527,7 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec in (**************************************************************************************) - let delegation_tests ~with_rejections = - delegation_tests - state - ~client:client_0 - ~ledger_account - ~delegate:baker_0.Tezos_client.Keyed.key_name - ~src:signer.key_name - () - ~bake - ~with_rejections - ~protocol_kind - in - let unit_kt1_account = "unit-kt1-of-the-baker" in - originate_id_script - state - ~client:client_0 - ~name:unit_kt1_account - ~from:baker_0.Tezos_client.Keyed.key_name - ~bake - ~protocol_kind - ~parameter:"unit" - ~init_storage:"Unit" - >>= fun () -> - let pair_string_nat_kt1_account = "pair-string-nat-kt1-of-the-baker" in - originate_id_script - state - ~client:client_0 - ~name:pair_string_nat_kt1_account - ~push_drops:10 - ~from:baker_0.Tezos_client.Keyed.key_name - ~bake - ~protocol_kind - ~parameter:"(pair string nat)" - ~init_storage:"Pair \"the answer is: \" 42" - >>= fun () -> - let transactions_test ~with_rejections = - transaction_tests - state - ~client:client_0 - ~ledger_account - ~unit_kt1_account - ~pair_string_nat_kt1_account - ~src:signer.key_name - () - ~bake - ~with_rejections - ~protocol_kind - in - let contracts_test ~with_rejections = +let contracts_test ~with_rejections = basic_contract_operations_tests state ~client:client_0 -- GitLab From b5764ff6a7eb361d5df8c16ccff885c120c2fb83 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Wed, 16 Oct 2019 14:51:05 -0400 Subject: [PATCH 06/23] Sandbox: refactor origination of contract --- src/bin_sandbox/command_ledger_wallet.ml | 216 +++++++++++------------ 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index ac04f152fbed..4934d0a59a2e 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -361,9 +361,106 @@ let sign state ~client ~bytes = ~client:client.Tezos_client.Keyed.client ["sign"; "bytes"; "0x" ^ bytes; "for"; client.Tezos_client.Keyed.key_name] -let manager_tz_delegation_tests state ~client ~src ~contract_addr ~with_rejections ~protocol_kind - ~(delegate_pkh:string) ~ledger_account ~bake () = - (* src = signer.key, *) +let prepare_origination_of_manager_tz_script ?(spendable = false) + ?(delegatable = false) ?delegate state + ~client ~name ~from ~protocol_kind ~ledger_account = + let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in + let manager_tz_script = + " +parameter +\ (or +\ (lambda %do unit (list operation)) +\ (unit %default)); +storage key_hash; +code +\ { UNPAIR ; +\ IF_LEFT +\ { # 'do' entrypoint +\ # Assert no token was sent: +\ # to send tokens, the default entry point should be used +\ PUSH mutez 0 ; +\ AMOUNT ; +\ ASSERT_CMPEQ ; +\ # Assert that the sender is the manager +\ DUUP ; +\ IMPLICIT_ACCOUNT ; +\ ADDRESS ; +\ SENDER ; +\ ASSERT_CMPEQ ; +\ # Execute the lambda argument +\ UNIT ; +\ EXEC ; +\ PAIR ; +\ } +\ { # 'default' entrypoint +\ DROP ; +\ NIL operation ; +\ PAIR ; +\ } +\ };" + in + let tmp = Filename.temp_file "manager" ".tz" in + System.write_file state tmp ~content:manager_tz_script + >>= fun () -> + let origination = + let opt = Option.value_map ~default:[] in + ["--wait"; "none"; "originate"; "contract"; name] + @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon -> []) + @ [ "transferring"; + "0"; + "from"; + from; + "running"; + tmp; + "--init"; + (sprintf "\"%s\"" ledger_pkh); + "--force"; + "--burn-cap"; + "300000000000"; + (* ; "--fee-cap" ; "20000000000000" *) + "--gas-limit"; + "1000000000000000"; + "--storage-limit"; + "20000000000000"; + "--verbose-signing" ] + @ opt delegate ~f:(fun s -> (* Baby & Aths *) ["--delegate"; s]) + @ (if delegatable then [(* Aths *) "--delegatable"] else []) + @ if spendable then [(* Aths *) "--spendable"] else [] + in + return origination + +let originate_manager_tz_script state ~client ~name ~from ~bake + ~protocol_kind ~ledger_account = + prepare_origination_of_manager_tz_script + state + ~client + ~name + ~from + ~protocol_kind + ~ledger_account + >>= fun origination -> + Tezos_client.successful_client_cmd state ~client origination + >>= fun _ -> Fmt.kstrf bake "baking `%s` in" name + + +let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_rejections ~protocol_kind + ~delegate_key ~(delegate_pkh:string) ~bake () = + let manager_tz_kt1_account = "manager-tz" in + originate_manager_tz_script + state + ~client + ~name:manager_tz_kt1_account + ~from:ledger_key + ~bake + ~protocol_kind + ~ledger_account + >>= fun () -> + Tezos_client.client_cmd + state + ~client + ["show"; "known"; "contract"; manager_tz_kt1_account] + >>= fun (_, proc_result) -> + let contract_address = proc_result#out |> String.concat ~sep:"" in let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in let only_success = not with_rejections in let set_delegation () = @@ -375,9 +472,9 @@ let manager_tz_delegation_tests state ~client ~src ~contract_addr ~with_rejectio "transfer"; "0"; "from"; - src; + ledger_key; "to"; - contract_addr; + manager_tz_kt1_account; "--entrypoint"; "do"; "--arg"; @@ -399,8 +496,9 @@ let manager_tz_delegation_tests state ~client ~src ~contract_addr ~with_rejectio (fun ppf () -> ledger_should_display ppf - [ ("Fee", const string "0.00XXX"); - ("Source", const string src); + [ ("Delegation manager.tz", const string ""); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); ("Delegate", const string delegate_pkh); ("Storage", const int 0) ]) ] (fun ~user_answer -> @@ -423,7 +521,7 @@ let manager_tz_delegation_tests state ~client ~src ~contract_addr ~with_rejectio `Ledger_reject_or_timeout | `Accept -> `Success )) - >>= fun _ -> ksprintf bake "setting self-delegate of %s" src + >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" in set_delegation () let delegation_tests state ~client ~src ~with_rejections ~protocol_kind @@ -840,89 +938,6 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind () *) -let prepare_origination_of_manager_tz_script ?(spendable = false) - ?(delegatable = false) ?delegate state - ~client ~name ~from ~protocol_kind ~ledger_account = - let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in - let manager_tz_script = - " -parameter -\ (or -\ (lambda %do unit (list operation)) -\ (unit %default)); -storage key_hash; -code -\ { UNPAIR ; -\ IF_LEFT -\ { # 'do' entrypoint -\ # Assert no token was sent: -\ # to send tokens, the default entry point should be used -\ PUSH mutez 0 ; -\ AMOUNT ; -\ ASSERT_CMPEQ ; -\ # Assert that the sender is the manager -\ DUUP ; -\ IMPLICIT_ACCOUNT ; -\ ADDRESS ; -\ SENDER ; -\ ASSERT_CMPEQ ; -\ # Execute the lambda argument -\ UNIT ; -\ EXEC ; -\ PAIR ; -\ } -\ { # 'default' entrypoint -\ DROP ; -\ NIL operation ; -\ PAIR ; -\ } -\ };" - in - let tmp = Filename.temp_file "manager" ".tz" in - System.write_file state tmp ~content:manager_tz_script - >>= fun () -> - let origination = - let opt = Option.value_map ~default:[] in - ["--wait"; "none"; "originate"; "contract"; name] - @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon -> []) - @ [ "transferring"; - "0"; - "from"; - from; - "running"; - tmp; - "--init"; - (sprintf "\"%s\"" ledger_pkh); - "--force"; - "--burn-cap"; - "300000000000"; - (* ; "--fee-cap" ; "20000000000000" *) - "--gas-limit"; - "1000000000000000"; - "--storage-limit"; - "20000000000000"; - "--verbose-signing" ] - @ opt delegate ~f:(fun s -> (* Baby & Aths *) ["--delegate"; s]) - @ (if delegatable then [(* Aths *) "--delegatable"] else []) - @ if spendable then [(* Aths *) "--spendable"] else [] - in - return origination - -let originate_manager_tz_script state ~delegate ~client ~name ~from ~bake - ~protocol_kind ~ledger_account = - (* TODO: make "delegate" optional *) - let () = Pervasives.ignore delegate in - prepare_origination_of_manager_tz_script - state - ~client - ~name - ~from - ~protocol_kind - ~ledger_account - >>= fun origination -> - Tezos_client.successful_client_cmd state ~client origination - >>= fun _ -> Fmt.kstrf bake "baking `%s` in" name - let prepare_origination_of_id_script ?(spendable = false) ?(delegatable = false) ?delegate ?(push_drops = 0) ?(amount = "2") state ~client:_ ~name ~from ~protocol_kind ~parameter ~init_storage = @@ -1497,29 +1512,14 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec *) (**************************************************************************************) - let manager_tz_kt1_account = "manager-tz-kt1-of-the-baker" in - (*let random_mgr_account = Tezos_protocol.Account.of_name "random-account-for-manager-test" in - let manager = Tezos_client.Keyed.make (client 0) ~key_name:"manager_acct" ~secret_key:(Tezos_protocol.Account.private_key random_mgr_account) in *) - originate_manager_tz_script - state - ~client:client_0 - ~name:manager_tz_kt1_account - ~from:(signer.key_name) - ~delegate:baker_0.Tezos_client.Keyed.key_name - ~bake - ~protocol_kind - ~ledger_account - (*~delegate:Tezos_protocol.Account.pubkey_hash baker_0_account *) - >>= fun () -> let manager_tz_delegation_tests ~with_rejections = manager_tz_delegation_tests state ~client:client_0 - ~src:(signer.key_name) - ~contract_addr:manager_tz_kt1_account + ~ledger_key:(signer.key_name) ~ledger_account + ~delegate_key:(baker_0) ~delegate_pkh:(Tezos_protocol.Account.pubkey_hash baker_0_account) - (* ~delegate_pkh:baker_0.Tezos_client.Keyed.key_name *) () ~bake ~with_rejections -- GitLab From 41079ab44b11db0c50d9087160603922359af4b0 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Wed, 16 Oct 2019 16:29:36 -0400 Subject: [PATCH 07/23] Sandbox: added remove delegate test --- src/bin_sandbox/command_ledger_wallet.ml | 133 ++++++++++++++++++++++- 1 file changed, 131 insertions(+), 2 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 4934d0a59a2e..d117acb9dd62 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -442,6 +442,42 @@ let originate_manager_tz_script state ~client ~name ~from ~bake Tezos_client.successful_client_cmd state ~client origination >>= fun _ -> Fmt.kstrf bake "baking `%s` in" name + (****** +with_ledger_test_reject_and_accept + ~only_success:(Wallet_scenario.with_rejections wallet_scenario |> not) + state + ~messages: + MFmt. + [ (fun ppf () -> + wf ppf "Importing %S in client `%s`." uri client_0.Tezos_client.id); + (fun ppf () -> + wf + ppf + "The ledger should be prompting for acknowledgment to provide \ + the public key of `%s`." + (Tezos_protocol.Account.pubkey_hash ledger_account)) ] + (fun ~user_answer -> + Tezos_client.client_cmd + state + ~client:client_0 + [ "import"; + "secret"; + "key"; + signer.key_name; + signer.secret_key; + "--force" ] + >>= fun (_, proc) -> + expect_from_output + ~message:"importing key" + proc + ~expectation: + ( match user_answer with + | `Accept -> + `Success + | `Reject -> + `Ledger_reject_or_timeout )) + + ******) let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_rejections ~protocol_kind ~delegate_key ~(delegate_pkh:string) ~bake () = @@ -455,6 +491,33 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ ~protocol_kind ~ledger_account >>= fun () -> +(* + with_ledger_test_reject_and_accept + ~only_success:true + state + ~messages: MFmt.[] + (fun ~user_answer -> + client_async_cmd + state + ~client + ~f:(fun _ proc -> + find_and_print_signature_hash + ~display_expectation:(protocol_kind = `Babylon) + state + proc) + [] + >>= fun res -> + expect_from_output + ~message:"self-delegation" + res + ~expectation: + ( match user_answer with + | `Reject -> + `Ledger_reject_or_timeout + | `Accept -> + `Success )) + >>= fun _ -> +*) Tezos_client.client_cmd state ~client @@ -496,7 +559,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ (fun ppf () -> ledger_should_display ppf - [ ("Delegation manager.tz", const string ""); + [ ("Manager.tz Delegation", const string ""); ("Fee", const string "0.00XXX"); ("Source", const string contract_address); ("Delegate", const string delegate_pkh); @@ -522,7 +585,73 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ | `Accept -> `Success )) >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" - in set_delegation () + in + let remove_delegate () = + let arg = "{ DROP ; NIL operation ; NONE key_hash ; SET_DELEGATE ; CONS }" + in + let command = + [ "--wait"; + "none"; + "transfer"; + "0"; + "from"; + ledger_key; + "to"; + manager_tz_kt1_account; + "--entrypoint"; + "do"; + "--arg"; + arg; + "--verbose-signing" ] + in + with_ledger_test_reject_and_accept + state + ~only_success + ~messages: + MFmt. + [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); + show_command_message command; + (fun ppf () -> + wf + ppf + "Note that X is a placeholder for some value that will vary \ + between runs"); + (fun ppf () -> + ledger_should_display + ppf + [ ("Manager.tz Delegation", const string ""); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Delegate", const string "none"); + ("Storage", const int 0) ]) ] + (fun ~user_answer -> + client_async_cmd + state + ~client + ~f:(fun _ proc -> + find_and_print_signature_hash + ~display_expectation:(protocol_kind = `Babylon) + state + proc) + command + >>= fun res -> + expect_from_output + ~message:"self-delegation" + res + ~expectation: + ( match user_answer with + | `Reject -> + `Ledger_reject_or_timeout + | `Accept -> + `Success )) + >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" + in + let manager_tz_to_implicit () = return () + in + return () + >>= fun () -> set_delegation () + >>= fun () -> remove_delegate () + >>= fun () -> manager_tz_to_implicit () let delegation_tests state ~client ~src ~with_rejections ~protocol_kind ~ledger_account ~delegate ~bake () = -- GitLab From fa5414757940c95d1028f0a360f65ffb4a4121ad Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Thu, 17 Oct 2019 06:58:13 -0400 Subject: [PATCH 08/23] Sandbox: reorganize 4 manager-tz tests --- src/bin_sandbox/command_ledger_wallet.ml | 300 +++++++++++++++-------- 1 file changed, 198 insertions(+), 102 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index d117acb9dd62..07951f613db0 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -407,7 +407,7 @@ code ["--wait"; "none"; "originate"; "contract"; name] @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon -> []) @ [ "transferring"; - "0"; + "20"; "from"; from; "running"; @@ -431,6 +431,74 @@ code let originate_manager_tz_script state ~client ~name ~from ~bake ~protocol_kind ~ledger_account = + let prepare_origination_of_manager_tz_script ?(spendable = false) + ?(delegatable = false) ?delegate state + ~client ~name ~from ~protocol_kind ~ledger_account = + let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in + let manager_tz_script = + " + parameter + \ (or + \ (lambda %do unit (list operation)) + \ (unit %default)); + storage key_hash; + code + \ { UNPAIR ; + \ IF_LEFT + \ { # 'do' entrypoint + \ # Assert no token was sent: + \ # to send tokens, the default entry point should be used + \ PUSH mutez 0 ; + \ AMOUNT ; + \ ASSERT_CMPEQ ; + \ # Assert that the sender is the manager + \ DUUP ; + \ IMPLICIT_ACCOUNT ; + \ ADDRESS ; + \ SENDER ; + \ ASSERT_CMPEQ ; + \ # Execute the lambda argument + \ UNIT ; + \ EXEC ; + \ PAIR ; + \ } + \ { # 'default' entrypoint + \ DROP ; + \ NIL operation ; + \ PAIR ; + \ } + \ };" + in + let tmp = Filename.temp_file "manager" ".tz" in + System.write_file state tmp ~content:manager_tz_script + >>= fun () -> + let origination = + let opt = Option.value_map ~default:[] in + ["--wait"; "none"; "originate"; "contract"; name] + @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon -> []) + @ [ "transferring"; + "20"; + "from"; + from; + "running"; + tmp; + "--init"; + (sprintf "\"%s\"" ledger_pkh); + "--force"; + "--burn-cap"; + "300000000000"; + (* ; "--fee-cap" ; "20000000000000" *) + "--gas-limit"; + "1000000000000000"; + "--storage-limit"; + "20000000000000"; + "--verbose-signing" ] + @ opt delegate ~f:(fun s -> (* Baby & Aths *) ["--delegate"; s]) + @ (if delegatable then [(* Aths *) "--delegatable"] else []) + @ if spendable then [(* Aths *) "--spendable"] else [] + in + return origination + in prepare_origination_of_manager_tz_script state ~client @@ -646,12 +714,139 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ `Success )) >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" in - let manager_tz_to_implicit () = return () + let manager_tz_to_implicit () = + let random_implicit_account = Tezos_protocol.Account.of_name "random-account-for-manager-test" in + let random_acc_pkh = Tezos_protocol.Account.pubkey_hash random_implicit_account in + let arg = sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; IMPLICIT_ACCOUNT ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_acc_pkh 10000000 + in + let command = + [ "--wait"; + "none"; + "transfer"; + "0"; + "from"; + ledger_key; + "to"; + manager_tz_kt1_account; + "--burn-cap"; + "1"; + "--entrypoint"; + "do"; + "--arg"; + arg; + "--verbose-signing" ] + in + with_ledger_test_reject_and_accept + state + ~only_success + ~messages: + MFmt. + [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); + show_command_message command; + (fun ppf () -> + wf + ppf + "Note that X is a placeholder for some value that will vary \ + between runs"); + (fun ppf () -> + ledger_should_display + ppf + [ ("Manager.tz Delegation", const string ""); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Delegate", const string "none"); + ("Storage", const int 0) ]) ] + (fun ~user_answer -> + client_async_cmd + state + ~client + ~f:(fun _ proc -> + find_and_print_signature_hash + ~display_expectation:(protocol_kind = `Babylon) + state + proc) + command + >>= fun res -> + expect_from_output + ~message:"self-delegation" + res + ~expectation: + ( match user_answer with + | `Reject -> + `Ledger_reject_or_timeout + | `Accept -> + `Success )) + >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" + in + let manager_tz_to_originated () = + let random_implicit_account = Tezos_protocol.Account.of_name "random-account-for-manager-test" in + let random_acc_pkh = Tezos_protocol.Account.pubkey_hash random_implicit_account in + let arg = sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; IMPLICIT_ACCOUNT ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_acc_pkh 10000000 + in + let command = + [ "--wait"; + "none"; + "transfer"; + "0"; + "from"; + ledger_key; + "to"; + manager_tz_kt1_account; + "--burn-cap"; + "1"; + "--entrypoint"; + "do"; + "--arg"; + arg; + "--verbose-signing" ] + in + with_ledger_test_reject_and_accept + state + ~only_success + ~messages: + MFmt. + [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); + show_command_message command; + (fun ppf () -> + wf + ppf + "Note that X is a placeholder for some value that will vary \ + between runs"); + (fun ppf () -> + ledger_should_display + ppf + [ ("Manager.tz Delegation", const string ""); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Delegate", const string "none"); + ("Storage", const int 0) ]) ] + (fun ~user_answer -> + client_async_cmd + state + ~client + ~f:(fun _ proc -> + find_and_print_signature_hash + ~display_expectation:(protocol_kind = `Babylon) + state + proc) + command + >>= fun res -> + expect_from_output + ~message:"self-delegation" + res + ~expectation: + ( match user_answer with + | `Reject -> + `Ledger_reject_or_timeout + | `Accept -> + `Success )) + >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" in return () >>= fun () -> set_delegation () >>= fun () -> remove_delegate () >>= fun () -> manager_tz_to_implicit () + >>= fun () -> manager_tz_to_originated () let delegation_tests state ~client ~src ~with_rejections ~protocol_kind ~ledger_account ~delegate ~bake () = @@ -1004,68 +1199,6 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ~dst_name:unit_kt1_account () -(* - >>= fun () -> - test_transaction - ~name:"manager.tz-remove-delegate" - ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~arguments:"{ DROP ; NIL operation ; NONE key_hash ; SET_DELEGATE ; CONS }" - ~dst_name:manager_tz_kt1_account - ~entrypoint:"do" - ~amount:0 - () - >>= fun () -> - Tezos_client.client_cmd - state - ~client - [ "--wait"; - "none"; - "set"; - "delegate"; - "for"; - src; - "to"; - src; - "--verbose-signing" ] - >>= fun (_, _) -> - Tezos_client.client_cmd - state - ~client - [ "hash"; - "data"; - (sprintf "\"%s\"" ledger_pkh); - "of"; - "type"; - "key_hash"; ] - >>= fun (_, res) -> - *) -(* - let src_hex = List.hd_exn res#out |> String.split ~on:' ' |> (fun (s) -> List.nth_exn s 3) - in - test_transaction - ~name:"manager.tz-set-delegate" - ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash %s ; SOME ; SET_DELEGATE ; CONS }" src_hex) - ~dst_name:manager_tz_kt1_account - ~entrypoint:"do" - ~amount:0 - () - >>= fun () -> - test_transaction - ~name:"manager.tz-add-funds" - ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~dst_name:manager_tz_kt1_account - () - >>= fun () -> - test_transaction - ~name:"manager.tz-transfer-originated-to-implicit" - ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH key_hash %s ; IMPLICIT_ACCOUNT ; PUSH mutez %i ; UNIT ; TRANSFER_TOKENS ; CONS }" "0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00" 15) - ~dst_name:manager_tz_kt1_account - ~entrypoint:"do" - ~amount:0 - () -*) let prepare_origination_of_id_script ?(spendable = false) ?(delegatable = false) ?delegate ?(push_drops = 0) ?(amount = "2") state @@ -1370,8 +1503,6 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec Interactive_test.Pauser.generic state EF.[af "Ready to start"; af "Root path deleted."] - -(***********************************************************************************) >>= fun () -> let ledger_client = Tezos_client.no_node_client ~exec:client_exec in Tezos_client.Ledger.show_ledger state ~client:ledger_client ~uri @@ -1482,7 +1613,6 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec `Success | `Reject -> `Ledger_reject_or_timeout )) -(***********************************************************************************) >>= fun () -> let skipping s = Console.say state EF.(haf "Skipping %s tests" s) in let voting_test ~with_rejections = @@ -1561,7 +1691,6 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec | `Reject -> `Ledger_reject_or_timeout )) in - let delegation_tests ~with_rejections = delegation_tests state @@ -1610,37 +1739,6 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec ~with_rejections ~protocol_kind in - (**************************************************************************************) - (* - >>= fun () -> - Tezos_client.client_cmd - state - ~client - ["show"; "known"; "contract"; unit_kt1_account] - >>= fun (_, proc_result) -> - let contract_address = proc_result#out |> String.concat ~sep:"" in - test_transaction - ~name:"manager.tz-transfer-originated-to-originated" - ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - ~arguments:(sprintf "{ DROP ; NIL operation ; PUSH address \"%s\" ; CONTRACT unit ; ASSERT_SOME ; PUSH mutez %i ; UNIT ; TRANSFER_TOKENS ; CONS }" contract_address 5) - ~dst_name:manager_tz_kt1_account - ~entrypoint:"do" - ~amount:0 - () - *) - -(* Tezos_client.client_cmd state ~client ["show"; "address"; delegate] - >>= fun (_, proc_result) -> - let delegate_address = - List.hd_exn proc_result#out - |> String.split ~on:' ' |> List.last - |> Option.value ~default:delegate - in - * - let signer = Tezos_client.Keyed.make (client 0) ~key_name:"ledgered" ~secret_key:uri -*) - -(**************************************************************************************) let manager_tz_delegation_tests ~with_rejections = manager_tz_delegation_tests state @@ -1654,9 +1752,7 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec ~with_rejections ~protocol_kind in - -(**************************************************************************************) -let contracts_test ~with_rejections = + let contracts_test ~with_rejections = basic_contract_operations_tests state ~client:client_0 -- GitLab From f64d4de8df5fa2ff8983e19dae8f027ae142bcf2 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Thu, 17 Oct 2019 08:14:48 -0400 Subject: [PATCH 09/23] Sandbox: prompt for accepting contract origination --- src/bin_sandbox/command_ledger_wallet.ml | 82 ++++++++++-------------- 1 file changed, 35 insertions(+), 47 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 07951f613db0..4f611075e8d0 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -510,55 +510,43 @@ let originate_manager_tz_script state ~client ~name ~from ~bake Tezos_client.successful_client_cmd state ~client origination >>= fun _ -> Fmt.kstrf bake "baking `%s` in" name - (****** -with_ledger_test_reject_and_accept - ~only_success:(Wallet_scenario.with_rejections wallet_scenario |> not) - state - ~messages: - MFmt. - [ (fun ppf () -> - wf ppf "Importing %S in client `%s`." uri client_0.Tezos_client.id); - (fun ppf () -> - wf - ppf - "The ledger should be prompting for acknowledgment to provide \ - the public key of `%s`." - (Tezos_protocol.Account.pubkey_hash ledger_account)) ] - (fun ~user_answer -> - Tezos_client.client_cmd - state - ~client:client_0 - [ "import"; - "secret"; - "key"; - signer.key_name; - signer.secret_key; - "--force" ] - >>= fun (_, proc) -> - expect_from_output - ~message:"importing key" - proc - ~expectation: - ( match user_answer with - | `Accept -> - `Success - | `Reject -> - `Ledger_reject_or_timeout )) - - ******) - + let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_rejections ~protocol_kind - ~delegate_key ~(delegate_pkh:string) ~bake () = + ~delegate_key ~delegate_pkh ~bake () = let manager_tz_kt1_account = "manager-tz" in - originate_manager_tz_script - state - ~client - ~name:manager_tz_kt1_account - ~from:ledger_key - ~bake - ~protocol_kind - ~ledger_account - >>= fun () -> + with_ledger_test_reject_and_accept + ~only_success:true (* (Wallet_scenario.with_rejections wallet_scenario |> not) *) + state + ~messages: + MFmt. + [ (fun ppf () -> + wf ppf "Originating manager.tz contract "); + (fun ppf () -> + wf + ppf + "The ledger should be prompting for acknowledgment to provide \ + a signature of an unknown operation." ) ] + (fun ~user_answer -> + originate_manager_tz_script + state + ~client + ~name:manager_tz_kt1_account + ~from:ledger_key + ~bake + ~protocol_kind + ~ledger_account) + (* >>= fun (_, proc) -> + expect_from_output + ~message:"importing key" + proc + ~expectation: + ( match user_answer with + | `Accept -> + `Success + | `Reject -> + `Ledger_reject_or_timeout )) +*) + >>= fun () -> (* with_ledger_test_reject_and_accept ~only_success:true -- GitLab From cdb7d106d20c6667f501ba7a5e26d38e33f7665e Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Thu, 17 Oct 2019 10:44:21 -0400 Subject: [PATCH 10/23] Sandbox: refactored 4th manager test --- src/bin_sandbox/command_ledger_wallet.ml | 560 +++++++---------------- 1 file changed, 164 insertions(+), 396 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 4f611075e8d0..9a466e3f7708 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -361,113 +361,44 @@ let sign state ~client ~bytes = ~client:client.Tezos_client.Keyed.client ["sign"; "bytes"; "0x" ^ bytes; "for"; client.Tezos_client.Keyed.key_name] -let prepare_origination_of_manager_tz_script ?(spendable = false) - ?(delegatable = false) ?delegate state - ~client ~name ~from ~protocol_kind ~ledger_account = - let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in - let manager_tz_script = - " -parameter -\ (or -\ (lambda %do unit (list operation)) -\ (unit %default)); -storage key_hash; -code -\ { UNPAIR ; -\ IF_LEFT -\ { # 'do' entrypoint -\ # Assert no token was sent: -\ # to send tokens, the default entry point should be used -\ PUSH mutez 0 ; -\ AMOUNT ; -\ ASSERT_CMPEQ ; -\ # Assert that the sender is the manager -\ DUUP ; -\ IMPLICIT_ACCOUNT ; -\ ADDRESS ; -\ SENDER ; -\ ASSERT_CMPEQ ; -\ # Execute the lambda argument -\ UNIT ; -\ EXEC ; -\ PAIR ; -\ } -\ { # 'default' entrypoint -\ DROP ; -\ NIL operation ; -\ PAIR ; -\ } -\ };" - in - let tmp = Filename.temp_file "manager" ".tz" in - System.write_file state tmp ~content:manager_tz_script - >>= fun () -> - let origination = - let opt = Option.value_map ~default:[] in - ["--wait"; "none"; "originate"; "contract"; name] - @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon -> []) - @ [ "transferring"; - "20"; - "from"; - from; - "running"; - tmp; - "--init"; - (sprintf "\"%s\"" ledger_pkh); - "--force"; - "--burn-cap"; - "300000000000"; - (* ; "--fee-cap" ; "20000000000000" *) - "--gas-limit"; - "1000000000000000"; - "--storage-limit"; - "20000000000000"; - "--verbose-signing" ] - @ opt delegate ~f:(fun s -> (* Baby & Aths *) ["--delegate"; s]) - @ (if delegatable then [(* Aths *) "--delegatable"] else []) - @ if spendable then [(* Aths *) "--spendable"] else [] - in - return origination - let originate_manager_tz_script state ~client ~name ~from ~bake ~protocol_kind ~ledger_account = - let prepare_origination_of_manager_tz_script ?(spendable = false) - ?(delegatable = false) ?delegate state + let prepare_origination_of_manager_tz_script ?(spendable = false) ?(delegatable = false) ?delegate state ~client ~name ~from ~protocol_kind ~ledger_account = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in let manager_tz_script = " - parameter - \ (or - \ (lambda %do unit (list operation)) - \ (unit %default)); - storage key_hash; - code - \ { UNPAIR ; - \ IF_LEFT - \ { # 'do' entrypoint - \ # Assert no token was sent: - \ # to send tokens, the default entry point should be used - \ PUSH mutez 0 ; - \ AMOUNT ; - \ ASSERT_CMPEQ ; - \ # Assert that the sender is the manager - \ DUUP ; - \ IMPLICIT_ACCOUNT ; - \ ADDRESS ; - \ SENDER ; - \ ASSERT_CMPEQ ; - \ # Execute the lambda argument - \ UNIT ; - \ EXEC ; - \ PAIR ; - \ } - \ { # 'default' entrypoint - \ DROP ; - \ NIL operation ; - \ PAIR ; - \ } - \ };" + parameter + \ (or + \ (lambda %do unit (list operation)) + \ (unit %default)); + storage key_hash; + code + \ { UNPAIR ; + \ IF_LEFT + \ { # 'do' entrypoint + \ # Assert no token was sent: + \ # to send tokens, the default entry point should be used + \ PUSH mutez 0 ; + \ AMOUNT ; + \ ASSERT_CMPEQ ; + \ # Assert that the sender is the manager + \ DUUP ; + \ IMPLICIT_ACCOUNT ; + \ ADDRESS ; + \ SENDER ; + \ ASSERT_CMPEQ ; + \ # Execute the lambda argument + \ UNIT ; + \ EXEC ; + \ PAIR ; + \ } + \ { # 'default' entrypoint + \ DROP ; + \ NIL operation ; + \ PAIR ; + \ } + \ };" in let tmp = Filename.temp_file "manager" ".tz" in System.write_file state tmp ~content:manager_tz_script @@ -509,13 +440,12 @@ let originate_manager_tz_script state ~client ~name ~from ~bake >>= fun origination -> Tezos_client.successful_client_cmd state ~client origination >>= fun _ -> Fmt.kstrf bake "baking `%s` in" name - let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_rejections ~protocol_kind - ~delegate_key ~delegate_pkh ~bake () = + ~delegate_key ~delegate_pkh ~random_contract_pkh ~bake () = let manager_tz_kt1_account = "manager-tz" in with_ledger_test_reject_and_accept - ~only_success:true (* (Wallet_scenario.with_rejections wallet_scenario |> not) *) + ~only_success:true state ~messages: MFmt. @@ -535,45 +465,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ ~bake ~protocol_kind ~ledger_account) - (* >>= fun (_, proc) -> - expect_from_output - ~message:"importing key" - proc - ~expectation: - ( match user_answer with - | `Accept -> - `Success - | `Reject -> - `Ledger_reject_or_timeout )) -*) - >>= fun () -> -(* - with_ledger_test_reject_and_accept - ~only_success:true - state - ~messages: MFmt.[] - (fun ~user_answer -> - client_async_cmd - state - ~client - ~f:(fun _ proc -> - find_and_print_signature_hash - ~display_expectation:(protocol_kind = `Babylon) - state - proc) - [] - >>= fun res -> - expect_from_output - ~message:"self-delegation" - res - ~expectation: - ( match user_answer with - | `Reject -> - `Ledger_reject_or_timeout - | `Accept -> - `Success )) - >>= fun _ -> -*) + >>= fun () -> Tezos_client.client_cmd state ~client @@ -581,260 +473,122 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ >>= fun (_, proc_result) -> let contract_address = proc_result#out |> String.concat ~sep:"" in let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in + let random_implicit_account = Tezos_protocol.Account.of_name "random-account-for-manager-test" in + let random_acc_pkh = Tezos_protocol.Account.pubkey_hash random_implicit_account in let only_success = not with_rejections in - let set_delegation () = - let arg = (sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; SOME ; SET_DELEGATE ; CONS }" delegate_pkh) - in - let command = - [ "--wait"; - "none"; - "transfer"; - "0"; - "from"; - ledger_key; - "to"; - manager_tz_kt1_account; - "--entrypoint"; - "do"; - "--arg"; - arg; - "--verbose-signing" ] - in - with_ledger_test_reject_and_accept - state - ~only_success - ~messages: - MFmt. - [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); - show_command_message command; - (fun ppf () -> - wf - ppf - "Note that X is a placeholder for some value that will vary \ - between runs"); - (fun ppf () -> - ledger_should_display - ppf - [ ("Manager.tz Delegation", const string ""); - ("Fee", const string "0.00XXX"); - ("Source", const string contract_address); - ("Delegate", const string delegate_pkh); - ("Storage", const int 0) ]) ] - (fun ~user_answer -> - client_async_cmd - state - ~client - ~f:(fun _ proc -> - find_and_print_signature_hash - ~display_expectation:(protocol_kind = `Babylon) - state - proc) - command - >>= fun res -> - expect_from_output - ~message:"self-delegation" - res - ~expectation: - ( match user_answer with - | `Reject -> - `Ledger_reject_or_timeout - | `Accept -> - `Success )) - >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" - in - let remove_delegate () = - let arg = "{ DROP ; NIL operation ; NONE key_hash ; SET_DELEGATE ; CONS }" - in - let command = - [ "--wait"; - "none"; - "transfer"; - "0"; - "from"; - ledger_key; - "to"; - manager_tz_kt1_account; - "--entrypoint"; - "do"; - "--arg"; - arg; - "--verbose-signing" ] - in - with_ledger_test_reject_and_accept - state - ~only_success - ~messages: - MFmt. - [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); - show_command_message command; - (fun ppf () -> - wf - ppf - "Note that X is a placeholder for some value that will vary \ - between runs"); - (fun ppf () -> - ledger_should_display - ppf - [ ("Manager.tz Delegation", const string ""); - ("Fee", const string "0.00XXX"); - ("Source", const string contract_address); - ("Delegate", const string "none"); - ("Storage", const int 0) ]) ] - (fun ~user_answer -> - client_async_cmd - state - ~client - ~f:(fun _ proc -> - find_and_print_signature_hash - ~display_expectation:(protocol_kind = `Babylon) - state - proc) - command - >>= fun res -> - expect_from_output - ~message:"self-delegation" - res - ~expectation: - ( match user_answer with - | `Reject -> - `Ledger_reject_or_timeout - | `Accept -> - `Success )) - >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" - in - let manager_tz_to_implicit () = - let random_implicit_account = Tezos_protocol.Account.of_name "random-account-for-manager-test" in - let random_acc_pkh = Tezos_protocol.Account.pubkey_hash random_implicit_account in - let arg = sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; IMPLICIT_ACCOUNT ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_acc_pkh 10000000 - in - let command = - [ "--wait"; - "none"; - "transfer"; - "0"; - "from"; - ledger_key; - "to"; - manager_tz_kt1_account; - "--burn-cap"; - "1"; - "--entrypoint"; - "do"; - "--arg"; - arg; - "--verbose-signing" ] - in - with_ledger_test_reject_and_accept - state - ~only_success - ~messages: - MFmt. - [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); - show_command_message command; - (fun ppf () -> - wf - ppf - "Note that X is a placeholder for some value that will vary \ - between runs"); - (fun ppf () -> - ledger_should_display - ppf - [ ("Manager.tz Delegation", const string ""); - ("Fee", const string "0.00XXX"); - ("Source", const string contract_address); - ("Delegate", const string "none"); - ("Storage", const int 0) ]) ] - (fun ~user_answer -> - client_async_cmd - state - ~client - ~f:(fun _ proc -> - find_and_print_signature_hash - ~display_expectation:(protocol_kind = `Babylon) - state - proc) - command - >>= fun res -> - expect_from_output - ~message:"self-delegation" - res - ~expectation: - ( match user_answer with - | `Reject -> - `Ledger_reject_or_timeout - | `Accept -> - `Success )) - >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" + + let manager_tz_test ~contract_arg ~expected ~output_msg = + let command = + [ "--wait"; + "none"; + "transfer"; + "0"; + "from"; + ledger_key; + "to"; + manager_tz_kt1_account; + "--entrypoint"; + "do"; + "--arg"; + contract_arg; + "--burn-cap"; + "1"; + "--verbose-signing" ] + in + with_ledger_test_reject_and_accept + state + ~only_success + ~messages: + MFmt. + [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); + show_command_message command; + (fun ppf () -> + wf + ppf + "Note that X is a placeholder for some value that will vary \ + between runs"); + (fun ppf () -> ledger_should_display ppf expected) + ] + (fun ~user_answer -> + client_async_cmd + state + ~client + ~f:(fun _ proc -> + find_and_print_signature_hash + ~display_expectation:(protocol_kind = `Babylon) + state + proc) + command + >>= fun res -> + expect_from_output + ~message:output_msg + res + ~expectation: + ( match user_answer with + | `Reject -> + `Ledger_reject_or_timeout + | `Accept -> + `Success )) in - let manager_tz_to_originated () = - let random_implicit_account = Tezos_protocol.Account.of_name "random-account-for-manager-test" in - let random_acc_pkh = Tezos_protocol.Account.pubkey_hash random_implicit_account in - let arg = sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; IMPLICIT_ACCOUNT ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_acc_pkh 10000000 - in - let command = - [ "--wait"; - "none"; - "transfer"; - "0"; - "from"; - ledger_key; - "to"; - manager_tz_kt1_account; - "--burn-cap"; - "1"; - "--entrypoint"; - "do"; - "--arg"; - arg; - "--verbose-signing" ] - in - with_ledger_test_reject_and_accept - state - ~only_success - ~messages: - MFmt. - [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); - show_command_message command; - (fun ppf () -> - wf - ppf - "Note that X is a placeholder for some value that will vary \ - between runs"); - (fun ppf () -> - ledger_should_display - ppf - [ ("Manager.tz Delegation", const string ""); - ("Fee", const string "0.00XXX"); - ("Source", const string contract_address); - ("Delegate", const string "none"); - ("Storage", const int 0) ]) ] - (fun ~user_answer -> - client_async_cmd - state - ~client - ~f:(fun _ proc -> - find_and_print_signature_hash - ~display_expectation:(protocol_kind = `Babylon) - state - proc) - command - >>= fun res -> - expect_from_output - ~message:"self-delegation" - res - ~expectation: - ( match user_answer with - | `Reject -> - `Ledger_reject_or_timeout - | `Accept -> - `Success )) - >>= fun _ -> ksprintf bake "setting self-delegate of %s" "SRC" + let set_delegation () = + manager_tz_test + ~contract_arg:(sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; SOME ; SET_DELEGATE ; CONS }" delegate_pkh) + ~expected: + MFmt.[ + ("Manager.tz Delegation", const string ""); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Delegate", const string delegate_pkh); + ("Storage", const int 0) + ] + ~output_msg:"delegation" + in + let remove_delegation () = + manager_tz_test + ~contract_arg:"{ DROP ; NIL operation ; NONE key_hash ; SET_DELEGATE ; CONS }" + ~expected: + MFmt.[ + ("Withdraw Manager.tz Delegation", const string ""); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Delegate", const string "None"); + ("Storage", const int 0) + ] + ~output_msg:"delegate-removal" + in + let manager_tz_to_implicit () = + manager_tz_test + ~contract_arg:(sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; IMPLICIT_ACCOUNT ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_acc_pkh 10000000) + ~expected: + MFmt.[ + ("Confirm Manager.tz Transaction", const string ""); + ("Amount", const int 10); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Destination", const string random_acc_pkh); + ("Storage", const int 149) + ] + ~output_msg:"transfer-from-manager-tz-to-implicit" + in + let manager_tz_to_originated () = + manager_tz_test + ~contract_arg:(sprintf "{ DROP ; NIL operation ; PUSH address \"%s\" ; CONTRACT unit ; ASSERT_SOME ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_contract_pkh 10000000) + ~expected: + MFmt.[ + ("Confirm Manager.tz Transaction", const string ""); + ("Amount", const int 10); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Destination", const string random_contract_pkh); + ("Storage", const int 0) + ] + ~output_msg:"transfer-from-manager-tz-to-originated" in return () - >>= fun () -> set_delegation () - >>= fun () -> remove_delegate () - >>= fun () -> manager_tz_to_implicit () - >>= fun () -> manager_tz_to_originated () + >>= fun () -> set_delegation () >>= fun _ -> ksprintf bake "setting delegate of %s" contract_address + >>= fun () -> remove_delegation () >>= fun _ -> ksprintf bake "removing delegate of %s" contract_address + >>= fun () -> manager_tz_to_implicit () >>= fun _ -> ksprintf bake "transferring from %s to %s" contract_address random_acc_pkh + >>= fun () -> manager_tz_to_originated () >>= fun _ -> ksprintf bake "transfering from %s to %s" contract_address random_contract_pkh let delegation_tests state ~client ~src ~with_rejections ~protocol_kind ~ledger_account ~delegate ~bake () = @@ -1101,8 +855,7 @@ let delegation_tests state ~client ~src ~with_rejections ~protocol_kind tz_account_delegation () >>= fun () -> self_delegation () let transaction_tests state ~client ~src ~with_rejections ~protocol_kind - ~pair_string_nat_kt1_account ~ledger_account ~unit_kt1_account - ~bake () = + ~pair_string_nat_kt1_account ~ledger_account ~unit_kt1_account ~bake () = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in let only_success = not with_rejections in let test_transaction ?(storage = 0) ?arguments ~name ~dst_name ~dst_pkh ?entrypoint ?(amount = 15) () = @@ -1187,6 +940,14 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ~dst_name:unit_kt1_account () + >>= fun () -> + test_transaction + ~name:"parameterfull-transaction-to-kt1" + ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + ~arguments:"Pair \"hello from the ledger\" 51" + ~dst_name:pair_string_nat_kt1_account + () + let prepare_origination_of_id_script ?(spendable = false) ?(delegatable = false) ?delegate ?(push_drops = 0) ?(amount = "2") state @@ -1702,6 +1463,12 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec ~parameter:"unit" ~init_storage:"Unit" >>= fun () -> + Tezos_client.client_cmd + state + ~client:client_0 + ["show"; "known"; "contract"; unit_kt1_account] + >>= fun (_, proc_result) -> + let unit_kt1_contract_address = proc_result#out |> String.concat ~sep:"" in let pair_string_nat_kt1_account = "pair-string-nat-kt1-of-the-baker" in originate_id_script state @@ -1714,7 +1481,7 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec ~parameter:"(pair string nat)" ~init_storage:"Pair \"the answer is: \" 42" >>= fun () -> - let transactions_test ~with_rejections = + let transactions_test ~with_rejections = transaction_tests state ~client:client_0 @@ -1737,6 +1504,7 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec ~delegate_pkh:(Tezos_protocol.Account.pubkey_hash baker_0_account) () ~bake + ~random_contract_pkh:unit_kt1_contract_address ~with_rejections ~protocol_kind in -- GitLab From a0953844b7bcfe10739cfae61aabb5f8dea5b6d1 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Fri, 18 Oct 2019 16:37:11 -0400 Subject: [PATCH 11/23] Sandbox: added storage limit to manager-tz tests --- src/bin_sandbox/command_ledger_wallet.ml | 284 +++++++++++++---------- 1 file changed, 161 insertions(+), 123 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 9a466e3f7708..471d43e547d0 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -361,44 +361,45 @@ let sign state ~client ~bytes = ~client:client.Tezos_client.Keyed.client ["sign"; "bytes"; "0x" ^ bytes; "for"; client.Tezos_client.Keyed.key_name] -let originate_manager_tz_script state ~client ~name ~from ~bake - ~protocol_kind ~ledger_account = - let prepare_origination_of_manager_tz_script ?(spendable = false) ?(delegatable = false) ?delegate state - ~client ~name ~from ~protocol_kind ~ledger_account = +let originate_manager_tz_script state ~client ~name ~from ~bake ~protocol_kind + ~ledger_account = + let prepare_origination_of_manager_tz_script ?(spendable = false) + ?(delegatable = false) ?delegate state ~name ~from ~protocol_kind + ~ledger_account = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in let manager_tz_script = - " - parameter - \ (or - \ (lambda %do unit (list operation)) - \ (unit %default)); - storage key_hash; - code - \ { UNPAIR ; - \ IF_LEFT - \ { # 'do' entrypoint - \ # Assert no token was sent: - \ # to send tokens, the default entry point should be used - \ PUSH mutez 0 ; - \ AMOUNT ; - \ ASSERT_CMPEQ ; - \ # Assert that the sender is the manager - \ DUUP ; - \ IMPLICIT_ACCOUNT ; - \ ADDRESS ; - \ SENDER ; - \ ASSERT_CMPEQ ; - \ # Execute the lambda argument - \ UNIT ; - \ EXEC ; - \ PAIR ; - \ } - \ { # 'default' entrypoint - \ DROP ; - \ NIL operation ; - \ PAIR ; - \ } - \ };" + "\n\ + \ parameter\n\ + \ (or\n\ + \ (lambda %do unit (list operation))\n\ + \ (unit %default));\n\ + \ storage key_hash;\n\ + \ code\n\ + \ { UNPAIR ;\n\ + \ IF_LEFT\n\ + \ { # 'do' entrypoint\n\ + \ # Assert no token was sent:\n\ + \ # to send tokens, the default entry point should be used\n\ + \ PUSH mutez 0 ;\n\ + \ AMOUNT ;\n\ + \ ASSERT_CMPEQ ;\n\ + \ # Assert that the sender is the manager\n\ + \ DUUP ;\n\ + \ IMPLICIT_ACCOUNT ;\n\ + \ ADDRESS ;\n\ + \ SENDER ;\n\ + \ ASSERT_CMPEQ ;\n\ + \ # Execute the lambda argument\n\ + \ UNIT ;\n\ + \ EXEC ;\n\ + \ PAIR ;\n\ + \ }\n\ + \ { # 'default' entrypoint\n\ + \ DROP ;\n\ + \ NIL operation ;\n\ + \ PAIR ;\n\ + \ }\n\ + \ };" in let tmp = Filename.temp_file "manager" ".tz" in System.write_file state tmp ~content:manager_tz_script @@ -414,7 +415,7 @@ let originate_manager_tz_script state ~client ~name ~from ~bake "running"; tmp; "--init"; - (sprintf "\"%s\"" ledger_pkh); + sprintf "\"%s\"" ledger_pkh; "--force"; "--burn-cap"; "300000000000"; @@ -432,7 +433,6 @@ let originate_manager_tz_script state ~client ~name ~from ~bake in prepare_origination_of_manager_tz_script state - ~client ~name ~from ~protocol_kind @@ -440,31 +440,31 @@ let originate_manager_tz_script state ~client ~name ~from ~bake >>= fun origination -> Tezos_client.successful_client_cmd state ~client origination >>= fun _ -> Fmt.kstrf bake "baking `%s` in" name - -let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_rejections ~protocol_kind - ~delegate_key ~delegate_pkh ~random_contract_pkh ~bake () = + +let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account + ~with_rejections ~protocol_kind ~delegate_pkh ~random_contract_pkh ~bake () + = let manager_tz_kt1_account = "manager-tz" in with_ledger_test_reject_and_accept - ~only_success:true - state - ~messages: - MFmt. - [ (fun ppf () -> - wf ppf "Originating manager.tz contract "); - (fun ppf () -> - wf - ppf - "The ledger should be prompting for acknowledgment to provide \ - a signature of an unknown operation." ) ] - (fun ~user_answer -> - originate_manager_tz_script - state - ~client - ~name:manager_tz_kt1_account - ~from:ledger_key - ~bake - ~protocol_kind - ~ledger_account) + ~only_success:true + state + ~messages: + MFmt. + [ (fun ppf () -> wf ppf "Originating manager.tz contract "); + (fun ppf () -> + wf + ppf + "The ledger should be prompting for acknowledgment to provide a \ + signature of an unknown operation.") ] + (fun ~user_answer:_ -> + originate_manager_tz_script + state + ~client + ~name:manager_tz_kt1_account + ~from:ledger_key + ~bake + ~protocol_kind + ~ledger_account) >>= fun () -> Tezos_client.client_cmd state @@ -473,11 +473,14 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ >>= fun (_, proc_result) -> let contract_address = proc_result#out |> String.concat ~sep:"" in let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in - let random_implicit_account = Tezos_protocol.Account.of_name "random-account-for-manager-test" in - let random_acc_pkh = Tezos_protocol.Account.pubkey_hash random_implicit_account in + let random_implicit_account = + Tezos_protocol.Account.of_name "random-account-for-manager-test" + in + let random_acc_pkh = + Tezos_protocol.Account.pubkey_hash random_implicit_account + in let only_success = not with_rejections in - - let manager_tz_test ~contract_arg ~expected ~output_msg = + let manager_tz_test ~contract_arg ~expected ~output_msg = let command = [ "--wait"; "none"; @@ -493,6 +496,8 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ contract_arg; "--burn-cap"; "1"; + "--storage-limit"; + "500"; "--verbose-signing" ] in with_ledger_test_reject_and_accept @@ -500,15 +505,15 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ ~only_success ~messages: MFmt. - [ (fun ppf () -> wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); + [ (fun ppf () -> + wf ppf "Managing account of manager.tz contract `%s`" ledger_pkh); show_command_message command; (fun ppf () -> wf ppf "Note that X is a placeholder for some value that will vary \ between runs"); - (fun ppf () -> ledger_should_display ppf expected) - ] + (fun ppf () -> ledger_should_display ppf expected) ] (fun ~user_answer -> client_async_cmd state @@ -529,66 +534,93 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~with_ `Ledger_reject_or_timeout | `Accept -> `Success )) - in - let set_delegation () = - manager_tz_test - ~contract_arg:(sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; SOME ; SET_DELEGATE ; CONS }" delegate_pkh) - ~expected: - MFmt.[ - ("Manager.tz Delegation", const string ""); - ("Fee", const string "0.00XXX"); - ("Source", const string contract_address); - ("Delegate", const string delegate_pkh); - ("Storage", const int 0) - ] + in + let set_delegation () = + manager_tz_test + ~contract_arg: + (sprintf + "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; SOME ; \ + SET_DELEGATE ; CONS }" + delegate_pkh) + ~expected: + MFmt. + [ ("Manager.tz Delegation", const string ""); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Delegate", const string delegate_pkh); + ("Storage Limit", const int 500) ] ~output_msg:"delegation" in - let remove_delegation () = - manager_tz_test - ~contract_arg:"{ DROP ; NIL operation ; NONE key_hash ; SET_DELEGATE ; CONS }" - ~expected: - MFmt.[ - ("Withdraw Manager.tz Delegation", const string ""); - ("Fee", const string "0.00XXX"); - ("Source", const string contract_address); - ("Delegate", const string "None"); - ("Storage", const int 0) - ] + let remove_delegation () = + manager_tz_test + ~contract_arg: + "{ DROP ; NIL operation ; NONE key_hash ; SET_DELEGATE ; CONS }" + ~expected: + MFmt. + [ ("Withdraw Manager.tz Delegation", const string ""); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Delegate", const string "None"); + ("Storage Limit", const int 500) ] ~output_msg:"delegate-removal" in let manager_tz_to_implicit () = - manager_tz_test - ~contract_arg:(sprintf "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; IMPLICIT_ACCOUNT ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_acc_pkh 10000000) - ~expected: - MFmt.[ - ("Confirm Manager.tz Transaction", const string ""); - ("Amount", const int 10); - ("Fee", const string "0.00XXX"); - ("Source", const string contract_address); - ("Destination", const string random_acc_pkh); - ("Storage", const int 149) - ] + manager_tz_test + ~contract_arg: + (sprintf + "{ DROP ; NIL operation ; PUSH key_hash \"%s\" ; IMPLICIT_ACCOUNT \ + ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" + random_acc_pkh + 10000000) + ~expected: + MFmt. + [ ("Confirm Manager.tz Transaction", const string ""); + ("Amount", const int 10); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Destination", const string random_acc_pkh); + ("Storage Limit", const int 500) ] ~output_msg:"transfer-from-manager-tz-to-implicit" in let manager_tz_to_originated () = - manager_tz_test - ~contract_arg:(sprintf "{ DROP ; NIL operation ; PUSH address \"%s\" ; CONTRACT unit ; ASSERT_SOME ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_contract_pkh 10000000) - ~expected: - MFmt.[ - ("Confirm Manager.tz Transaction", const string ""); - ("Amount", const int 10); - ("Fee", const string "0.00XXX"); - ("Source", const string contract_address); - ("Destination", const string random_contract_pkh); - ("Storage", const int 0) - ] + manager_tz_test + ~contract_arg: + (sprintf + "{ DROP ; NIL operation ; PUSH address \"%s\" ; CONTRACT unit ; \ + ASSERT_SOME ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" + random_contract_pkh + 10000000) + ~expected: + MFmt. + [ ("Confirm Manager.tz Transaction", const string ""); + ("Amount", const int 10); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Destination", const string random_contract_pkh); + ("Storage Limit", const int 500) ] ~output_msg:"transfer-from-manager-tz-to-originated" - in + in return () - >>= fun () -> set_delegation () >>= fun _ -> ksprintf bake "setting delegate of %s" contract_address - >>= fun () -> remove_delegation () >>= fun _ -> ksprintf bake "removing delegate of %s" contract_address - >>= fun () -> manager_tz_to_implicit () >>= fun _ -> ksprintf bake "transferring from %s to %s" contract_address random_acc_pkh - >>= fun () -> manager_tz_to_originated () >>= fun _ -> ksprintf bake "transfering from %s to %s" contract_address random_contract_pkh + >>= fun () -> + set_delegation () + >>= fun _ -> + ksprintf bake "setting delegate of %s" contract_address + >>= fun () -> + remove_delegation () + >>= fun _ -> + ksprintf bake "removing delegate of %s" contract_address + >>= fun () -> + manager_tz_to_implicit () + >>= fun _ -> + ksprintf bake "transferring from %s to %s" contract_address random_acc_pkh + >>= fun () -> + manager_tz_to_originated () + >>= fun _ -> + ksprintf + bake + "transfering from %s to %s" + contract_address + random_contract_pkh let delegation_tests state ~client ~src ~with_rejections ~protocol_kind ~ledger_account ~delegate ~bake () = @@ -858,10 +890,18 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ~pair_string_nat_kt1_account ~ledger_account ~unit_kt1_account ~bake () = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in let only_success = not with_rejections in - let test_transaction ?(storage = 0) ?arguments ~name ~dst_name ~dst_pkh ?entrypoint ?(amount = 15) () = + let test_transaction ?(storage = 0) ?arguments ~name ~dst_name ~dst_pkh + ?entrypoint ?(amount = 15) () = let command = let opt = Option.value_map ~default:[] in - ["--wait"; "none"; "transfer"; (sprintf "%i" amount); "from"; src; "to"; dst_name] + [ "--wait"; + "none"; + "transfer"; + sprintf "%i" amount; + "from"; + src; + "to"; + dst_name ] @ Option.value_map ~default:[] arguments ~f:(fun a -> ["--arg"; a]) @ opt entrypoint ~f:(fun e -> ["--entrypoint"; e]) @ ["--burn-cap"; "100"; "--verbose-signing"] @@ -948,7 +988,6 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ~dst_name:pair_string_nat_kt1_account () - let prepare_origination_of_id_script ?(spendable = false) ?(delegatable = false) ?delegate ?(push_drops = 0) ?(amount = "2") state ~client:_ ~name ~from ~protocol_kind ~parameter ~init_storage = @@ -1498,9 +1537,8 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec manager_tz_delegation_tests state ~client:client_0 - ~ledger_key:(signer.key_name) + ~ledger_key:signer.key_name ~ledger_account - ~delegate_key:(baker_0) ~delegate_pkh:(Tezos_protocol.Account.pubkey_hash baker_0_account) () ~bake -- GitLab From f24018be454c5eb2f7e74a66c035cc7d305c2a0e Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Wed, 23 Oct 2019 13:42:25 -0400 Subject: [PATCH 12/23] Sandbox: added clearer msg for QA --- src/bin_sandbox/command_ledger_wallet.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 471d43e547d0..20cbef98b08c 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -455,7 +455,9 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account wf ppf "The ledger should be prompting for acknowledgment to provide a \ - signature of an unknown operation.") ] + signature of an unknown operation. This is not an actual test, and \ + is only part of the test setup. There is no need for a verification \ + of this hash. Please accept this Unrecognized Operation.") ] (fun ~user_answer:_ -> originate_manager_tz_script state -- GitLab From e854d1122d433917c1567da0302d3a69b616aaf3 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Thu, 24 Oct 2019 08:28:23 -0400 Subject: [PATCH 13/23] Sandbox: added manager-tz test for small transfer --- src/bin_sandbox/command_ledger_wallet.ml | 37 ++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 20cbef98b08c..7e735f892631 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -409,7 +409,7 @@ let originate_manager_tz_script state ~client ~name ~from ~bake ~protocol_kind ["--wait"; "none"; "originate"; "contract"; name] @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon -> []) @ [ "transferring"; - "20"; + "350"; "from"; from; "running"; @@ -584,18 +584,36 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ("Storage Limit", const int 500) ] ~output_msg:"transfer-from-manager-tz-to-implicit" in - let manager_tz_to_originated () = + let manager_tz_to_originated_large () = manager_tz_test ~contract_arg: (sprintf "{ DROP ; NIL operation ; PUSH address \"%s\" ; CONTRACT unit ; \ ASSERT_SOME ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_contract_pkh - 10000000) + (300 * 1000000)) ~expected: MFmt. [ ("Confirm Manager.tz Transaction", const string ""); - ("Amount", const int 10); + ("Amount", const int 300); + ("Fee", const string "0.00XXX"); + ("Source", const string contract_address); + ("Destination", const string random_contract_pkh); + ("Storage Limit", const int 500) ] + ~output_msg:"transfer-from-manager-tz-to-originated" + in + let manager_tz_to_originated_small () = + manager_tz_test + ~contract_arg: + (sprintf + "{ DROP ; NIL operation ; PUSH address \"%s\" ; CONTRACT unit ; \ + ASSERT_SOME ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" + random_contract_pkh + 300) + ~expected: + MFmt. + [ ("Confirm Manager.tz Transaction", const string ""); + ("Amount", const string "0.0003"); ("Fee", const string "0.00XXX"); ("Source", const string contract_address); ("Destination", const string random_contract_pkh); @@ -616,7 +634,15 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account >>= fun _ -> ksprintf bake "transferring from %s to %s" contract_address random_acc_pkh >>= fun () -> - manager_tz_to_originated () + manager_tz_to_originated_large () + >>= fun _ -> + ksprintf + bake + "transfering from %s to %s" + contract_address + random_contract_pkh + >>= fun () -> + manager_tz_to_originated_small () >>= fun _ -> ksprintf bake @@ -624,6 +650,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account contract_address random_contract_pkh + let delegation_tests state ~client ~src ~with_rejections ~protocol_kind ~ledger_account ~delegate ~bake () = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in -- GitLab From 35c29956aac36343d4280e03c58d9c0842a6181b Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Thu, 24 Oct 2019 09:23:42 -0400 Subject: [PATCH 14/23] Sandbox: made manager txn test even smaller --- src/bin_sandbox/command_ledger_wallet.ml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 7e735f892631..538706a10450 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -546,7 +546,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account delegate_pkh) ~expected: MFmt. - [ ("Manager.tz Delegation", const string ""); + [ ("Confirm Delegation", const string ""); ("Fee", const string "0.00XXX"); ("Source", const string contract_address); ("Delegate", const string delegate_pkh); @@ -559,7 +559,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account "{ DROP ; NIL operation ; NONE key_hash ; SET_DELEGATE ; CONS }" ~expected: MFmt. - [ ("Withdraw Manager.tz Delegation", const string ""); + [ ("Withdraw Delegation", const string ""); ("Fee", const string "0.00XXX"); ("Source", const string contract_address); ("Delegate", const string "None"); @@ -576,7 +576,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account 10000000) ~expected: MFmt. - [ ("Confirm Manager.tz Transaction", const string ""); + [ ("Confirm Transaction", const string ""); ("Amount", const int 10); ("Fee", const string "0.00XXX"); ("Source", const string contract_address); @@ -594,7 +594,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account (300 * 1000000)) ~expected: MFmt. - [ ("Confirm Manager.tz Transaction", const string ""); + [ ("Confirm Transaction", const string ""); ("Amount", const int 300); ("Fee", const string "0.00XXX"); ("Source", const string contract_address); @@ -609,11 +609,11 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account "{ DROP ; NIL operation ; PUSH address \"%s\" ; CONTRACT unit ; \ ASSERT_SOME ; PUSH mutez %d ; UNIT ; TRANSFER_TOKENS ; CONS }" random_contract_pkh - 300) + 3) ~expected: MFmt. - [ ("Confirm Manager.tz Transaction", const string ""); - ("Amount", const string "0.0003"); + [ ("Confirm Transaction", const string ""); + ("Amount", const string "0.000003"); ("Fee", const string "0.00XXX"); ("Source", const string contract_address); ("Destination", const string random_contract_pkh); -- GitLab From 0e7c748918a0b9b2a2be69891e2920da96ecef28 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Thu, 24 Oct 2019 14:03:17 -0400 Subject: [PATCH 15/23] Sandbox: add txn test with fee and storage limits --- src/bin_sandbox/command_ledger_wallet.ml | 34 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 538706a10450..30cd0e97624d 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -919,10 +919,14 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ~pair_string_nat_kt1_account ~ledger_account ~unit_kt1_account ~bake () = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in let only_success = not with_rejections in - let test_transaction ?(storage = 0) ?arguments ~name ~dst_name ~dst_pkh - ?entrypoint ?(amount = 15) () = + let test_transaction ?storage_limit ?arguments ~name ~dst_name ~dst_pkh + ?entrypoint ?(amount = 15) ?fee () = let command = let opt = Option.value_map ~default:[] in + let storage = match storage_limit with + None -> [] + | Some limit -> ["--storage-limit"; (sprintf "%d" limit)] + in [ "--wait"; "none"; "transfer"; @@ -932,6 +936,9 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind "to"; dst_name ] @ Option.value_map ~default:[] arguments ~f:(fun a -> ["--arg"; a]) + @ Option.value_map ~default:[] fee ~f:(fun f -> ["--fee"; (sprintf "%d" f)]) + @ storage + @ ["--fee-cap"; "10"] @ opt entrypoint ~f:(fun e -> ["--entrypoint"; e]) @ ["--burn-cap"; "100"; "--verbose-signing"] in @@ -953,10 +960,10 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ledger_should_display ppf [ ("Amount", const int amount); - ("Fee", const string "0.00XXX"); + ("Fee", const string @@ Option.value_map ~default:"0.00XXX" fee ~f:(sprintf "%d")); ("Source", const string ledger_pkh); ("Destination", const string dst_pkh); - ("Storage", const int storage) ] + ("Storage Limit", const int @@ match storage_limit with None -> 0 | Some s -> s) ] | _ (* some arguments *) -> please_check_the_hash ppf ()) ] (fun ~user_answer -> @@ -994,16 +1001,31 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ~name:"transaction-to-random-tz1" ~dst_pkh:(Acc.pubkey_hash random_account) ~dst_name:(Acc.pubkey_hash random_account) - ~storage:277 + ~storage_limit:277 (* First time: there is a reveal *) () >>= fun () -> test_transaction ~name:"transaction-to-random-tz1-again" ~dst_pkh:(Acc.pubkey_hash random_account) ~dst_name:(Acc.pubkey_hash random_account) - ~storage:0 + ~storage_limit:0 (* no moa reveal *) () >>= fun () -> + test_transaction + ~name:"transaction-to-random-tz1-fee-no-storage-limit" + ~dst_pkh:(Acc.pubkey_hash random_account) + ~dst_name:(Acc.pubkey_hash random_account) + ~fee:2 + () + >>= fun () -> + test_transaction + ~name:"transaction-to-random-tz1-fee-storage-limit" + ~dst_pkh:(Acc.pubkey_hash random_account) + ~dst_name:(Acc.pubkey_hash random_account) + ~fee:2 + ~storage_limit:500 + () + >>= fun () -> test_transaction ~name:"parameterless-transaction-to-kt1" ~dst_pkh:"KT1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -- GitLab From e4811ca03d61ab5fd424216c39ff98fc122885ee Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Wed, 13 May 2020 14:39:28 -0400 Subject: [PATCH 16/23] Sandbox: finish bump to CNET --- src/bin_sandbox/command_ledger_wallet.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 30cd0e97624d..ddde1cfda269 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -401,13 +401,13 @@ let originate_manager_tz_script state ~client ~name ~from ~bake ~protocol_kind \ }\n\ \ };" in - let tmp = Filename.temp_file "manager" ".tz" in + let tmp = Caml.Filename.temp_file "manager" ".tz" in System.write_file state tmp ~content:manager_tz_script >>= fun () -> let origination = let opt = Option.value_map ~default:[] in ["--wait"; "none"; "originate"; "contract"; name] - @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon -> []) + @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon | `Carthage -> []) @ [ "transferring"; "350"; "from"; @@ -522,7 +522,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~client ~f:(fun _ proc -> find_and_print_signature_hash - ~display_expectation:(protocol_kind = `Babylon) + ~display_expectation:Poly.(protocol_kind = `Babylon) state proc) command -- GitLab From 8fe033b0d4cbea809a2a068b8f54e6a5878cfb32 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Fri, 22 May 2020 10:51:37 -0400 Subject: [PATCH 17/23] Sandbox: ledger wallet test fixes --- src/bin_sandbox/command_ledger_wallet.ml | 329 ++++++++--------------- 1 file changed, 106 insertions(+), 223 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index ddde1cfda269..016f1c825abf 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -1,6 +1,8 @@ open Flextesa open Internal_pervasives +(********************* TEST UTILS **********************) + let client_async_cmd state ~client args ~f = Running_processes.Async.run_cmdf ~id_base:"client_async_cmd" @@ -67,21 +69,6 @@ module MFmt = More_fmt let failf ?attach fmt = ksprintf (fun s -> fail ?attach (`Scenario_error s)) fmt -let process_should_fail msg f = - Asynchronous_result.bind_on_error - ( f () - >>= fun (proc : Process_result.t) -> - match proc#status with - | Unix.WEXITED 0 -> - failf - "Process should have failed: %s" - msg - ~attach: - [("stdout", `Verbatim proc#out); ("stderr", `Verbatim proc#err)] - | _ -> - return () ) - ~f:(fun ~result:_ _ -> return ()) - let ledger_prompt_notice state ~msgs ?(button = `Checkmark) () = let button_str = match button with @@ -151,41 +138,6 @@ let please_check_the_hash ppf () = tag "prompt" ppf (fun ppf -> wf ppf "The ledger cannot parse this operation, please verify the hash.") -let forge_batch_transactions state ~client ~src ~dest:_ ~n ?(fee = 0.00126) () - = - get_head_block_hash state ~client () - >>= fun branch -> - let json = - `O - [ ("branch", `String branch); - ( "contents", - `A - (List.map (List.range 0 n) ~f:(fun i -> - `O - [ ("kind", `String "transaction"); - ("source", `String src); - ( "destination", - `String "tz2KZPgf2rshxNUBXFcTaCemik1LH1v9qz3F" ); - ("amount", `String (Int.to_string 100)); - ( "fee", - `String (Int.to_string (Float.to_int (fee *. 1000000.))) - ); - ("counter", `String (Int.to_string i)); - ("gas_limit", `String (Int.to_string 127)); - ("storage_limit", `String (Int.to_string 277)) ])) ) ] - in - Tezos_client.rpc - state - ~client - ~path:"/chains/main/blocks/head/helpers/forge/operations" - (`Post (Ezjsonm.to_string json)) - >>= function - | `String operation_bytes -> - let magic_byte = "03" in - return (magic_byte ^ operation_bytes) - | _ -> - failf "Failed to forge operation or parse result" - let expect_from_output ~expectation ~message (proc_res : Process_result.t) = (* let expect_rejection msg (success, (stdout, stderr)) = *) let exp = @@ -234,6 +186,8 @@ let expect_from_output ~expectation ~message (proc_res : Process_result.t) = | (true, _) -> nope "command succeeded??" ) +(********************* TEST SECTIONS ***************************) + let voting_tests state ~client ~src ~with_rejections ~protocol_kind ~ledger_account ~tested_proposal ~go_to_next_period () = let expect_success message v = @@ -308,7 +262,7 @@ let voting_tests state ~client ~src ~with_rejections ~protocol_kind >>= fun () -> go_to_next_period () >>= fun () -> - List_sequential.iteri ["yea"; "nay"] ~f:(fun n vote -> + List_sequential.iter ["yea"; "nay"] ~f:(fun vote -> test_reject_and_accept (Fmt.strf "vote-%s" vote) ~messages: @@ -328,8 +282,8 @@ let voting_tests state ~client ~src ~with_rejections ~protocol_kind "Accept this prompt, regardless of below, then continue."); (fun ppf () -> wf ppf "Voting %s for %s" vote tested_proposal); (fun ppf () -> wf ppf "Source: `%s`" source_display); - (fun ppf () -> wf ppf "Period: `%i`" (n + 1)); - (fun ppf () -> wf ppf "Protocol: `%s`" tested_proposal) ] + (fun ppf () -> wf ppf "Protocol: `%s`" tested_proposal); + (fun ppf () -> wf ppf "Period: `%i`" 1) ] (fun () -> Tezos_client.client_cmd state @@ -337,10 +291,12 @@ let voting_tests state ~client ~src ~with_rejections ~protocol_kind ["submit"; "ballot"; "for"; src; tested_proposal; vote] >>= fun (_, proc) -> return proc)) -let ledger_should_display ppf l = +let ledger_should_display ?title ppf l = let open MFmt in vertical_box ~indent:4 ppf (fun ppf -> wf ppf "Ledger should display:" ; + cut ppf () ; + (match title with None -> () | Some t -> wf ppf t) ; List.iter l ~f:(fun (s, f) -> cut ppf () ; pf ppf "* %s: %a." s f ())) let show_command_message command = @@ -355,12 +311,6 @@ let show_command_message command = ppf ())) -let sign state ~client ~bytes = - Tezos_client.client_cmd - state - ~client:client.Tezos_client.Keyed.client - ["sign"; "bytes"; "0x" ^ bytes; "for"; client.Tezos_client.Keyed.key_name] - let originate_manager_tz_script state ~client ~name ~from ~bake ~protocol_kind ~ledger_account = let prepare_origination_of_manager_tz_script ?(spendable = false) @@ -407,7 +357,11 @@ let originate_manager_tz_script state ~client ~name ~from ~bake ~protocol_kind let origination = let opt = Option.value_map ~default:[] in ["--wait"; "none"; "originate"; "contract"; name] - @ (match protocol_kind with `Athens -> ["for"; from] | `Babylon | `Carthage -> []) + @ ( match protocol_kind with + | `Athens -> + ["for"; from] + | `Babylon | `Carthage -> + [] ) @ [ "transferring"; "350"; "from"; @@ -455,9 +409,10 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account wf ppf "The ledger should be prompting for acknowledgment to provide a \ - signature of an unknown operation. This is not an actual test, and \ - is only part of the test setup. There is no need for a verification \ - of this hash. Please accept this Unrecognized Operation.") ] + signature of an unknown operation. This is not an actual test, \ + and is only part of the test setup. There is no need for a \ + verification of this hash. Please accept this Unrecognized \ + Operation.") ] (fun ~user_answer:_ -> originate_manager_tz_script state @@ -563,7 +518,9 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ("Fee", const string "0.00XXX"); ("Source", const string contract_address); ("Delegate", const string "None"); - ("Storage Limit", const int 500) ] + ("Storage Limit", const int 500); + ( "Delegate Name", + const string "Custom Delegate: please verify the addresss" ) ] ~output_msg:"delegate-removal" in let manager_tz_to_implicit () = @@ -650,9 +607,8 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account contract_address random_contract_pkh - let delegation_tests state ~client ~src ~with_rejections ~protocol_kind - ~ledger_account ~delegate ~bake () = + ~ledger_account ~delegate ~delegate_pkh ~bake () = let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in let only_success = not with_rejections in let self_delegation () = @@ -682,6 +638,7 @@ let delegation_tests state ~client ~src ~with_rejections ~protocol_kind between runs"); (fun ppf () -> ledger_should_display + ~title:"Confirm Delegation" ppf [ ("Fee", const string "0.00XXX"); ("Source", const string ledger_pkh); @@ -737,11 +694,15 @@ let delegation_tests state ~client ~src ~with_rejections ~protocol_kind between runs"); (fun ppf () -> ledger_should_display + ~title:"Confirm Delegation" ppf [ ("Fee", const string "0.00XXX"); ("Source", const string ledger_pkh); - ("Delegate", const string delegate); - ("Storage", const int 0) ]) ] + ("Delegate", const string delegate_pkh); + ( "Delegate Name", + const string "Custom Delegate: please verify the address" + ); + ("Storage Limit", const int 0) ]) ] (fun ~user_answer -> client_async_cmd state @@ -765,153 +726,9 @@ let delegation_tests state ~client ~src ~with_rejections ~protocol_kind >>= fun _ -> ksprintf bake "setting delegate of %s" src (* Self-delegate deletion is forbidden for both Athens and Babylon *) in - let run_command_and_check state ~client ~command ~message ~user_answer = - Tezos_client.client_cmd state ~client command - >>= fun (_, res) -> - expect_from_output - ~message - res - ~expectation: - ( match user_answer with - | `Reject -> - `Ledger_reject_or_timeout - | `Accept -> - `Success ) - in - let delegate_with_scriptless_account () = - let originated_account_name = "ledginated" in - let amount = "200" in - let burn_cap = "0.257" in - let command = - [ "--wait"; - "none"; - "originate"; - "account"; - originated_account_name; - "for"; - src; - "transferring"; - "200"; - "from"; - src; - "--delegatable"; - "--burn-cap"; - burn_cap; - "--force" ] - in - with_ledger_test_reject_and_accept - state - ~only_success - ~messages: - MFmt. - [ (fun ppf () -> - wf ppf "Originating account `%s`" originated_account_name); - (fun ppf () -> - ledger_should_display - ppf - [ ("Amount", const string amount); - ("Fee", const string (strf "≤ %S" burn_cap)); - ("Source", const string ledger_pkh); - ("Manager", const string ledger_pkh); - ("Delegation", const string "Any"); - ("Storage", const int 277) ]) ] - (fun ~user_answer -> - run_command_and_check - state - ~client - ~command - ~message:"account origination" - ~user_answer) - >>= fun _ -> - ksprintf bake "origination of %s" originated_account_name - >>= fun () -> - Tezos_client.client_cmd - state - ~client - ["show"; "known"; "contract"; originated_account_name] - >>= fun (_, proc_result) -> - let contract_address = proc_result#out |> String.concat ~sep:"" in - Tezos_client.client_cmd state ~client ["show"; "address"; delegate] - >>= fun (_, proc_result) -> - let delegate_address = - List.hd_exn proc_result#out - |> String.split ~on:' ' |> List.last - |> Option.value ~default:delegate - in - let command = - [ "--wait"; - "none"; - "set"; - "delegate"; - "for"; - originated_account_name; - "to"; - delegate ] - in - with_ledger_test_reject_and_accept - state - ~only_success - ~messages: - MFmt. - [ (fun ppf () -> - wf - ppf - "Setting `%s` as delegate for `%s`" - delegate - originated_account_name); - (fun ppf () -> - ledger_should_display - ppf - [ ("Source", const string contract_address); - ("Fee", const string "≤ 0.001"); - ("Delegate", const string delegate_address); - ("Storage", const int 0) ]) ] - (fun ~user_answer -> - run_command_and_check - state - ~client - ~command - ~message:"setting delegate of KT1" - ~user_answer) - >>= fun () -> - ksprintf bake "setting delegate of %s" originated_account_name - >>= fun () -> - let withdraw_command = - [ "--wait"; - "none"; - "withdraw"; - "delegate"; - "from"; - originated_account_name ] - in - with_ledger_test_reject_and_accept - state - ~only_success - ~messages: - MFmt. - [ (fun ppf () -> - wf ppf "Withdrawing delegate from `%s`" originated_account_name); - show_command_message withdraw_command; - (fun ppf () -> - ledger_should_display - ppf - [ ("Source", const string contract_address); - ("Fee", const string "≤ 0.001"); - ("Delegate", const string "None"); - ("Storage", const int 0) ]) ] - (fun ~user_answer -> - run_command_and_check - state - ~client - ~command:withdraw_command - ~message:"withdrawing delegate from originated account" - ~user_answer) - >>= fun () -> - ksprintf bake "withdrawing delegate of %s" originated_account_name - in match protocol_kind with | `Athens -> - self_delegation () >>= fun () -> delegate_with_scriptless_account () + self_delegation () | `Babylon | `Carthage -> tz_account_delegation () >>= fun () -> self_delegation () @@ -923,9 +740,12 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ?entrypoint ?(amount = 15) ?fee () = let command = let opt = Option.value_map ~default:[] in - let storage = match storage_limit with - None -> [] - | Some limit -> ["--storage-limit"; (sprintf "%d" limit)] + let storage = + match storage_limit with + | None -> + [] + | Some limit -> + ["--storage-limit"; sprintf "%d" limit] in [ "--wait"; "none"; @@ -936,9 +756,9 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind "to"; dst_name ] @ Option.value_map ~default:[] arguments ~f:(fun a -> ["--arg"; a]) - @ Option.value_map ~default:[] fee ~f:(fun f -> ["--fee"; (sprintf "%d" f)]) - @ storage - @ ["--fee-cap"; "10"] + @ Option.value_map ~default:[] fee ~f:(fun f -> + ["--fee"; sprintf "%d" f]) + @ storage @ ["--fee-cap"; "10"] @ opt entrypoint ~f:(fun e -> ["--entrypoint"; e]) @ ["--burn-cap"; "100"; "--verbose-signing"] in @@ -960,10 +780,18 @@ let transaction_tests state ~client ~src ~with_rejections ~protocol_kind ledger_should_display ppf [ ("Amount", const int amount); - ("Fee", const string @@ Option.value_map ~default:"0.00XXX" fee ~f:(sprintf "%d")); + ( "Fee", + const string + @@ Option.value_map + ~default:"0.00XXX" + fee + ~f:(sprintf "%d") ); ("Source", const string ledger_pkh); ("Destination", const string dst_pkh); - ("Storage Limit", const int @@ match storage_limit with None -> 0 | Some s -> s) ] + ( "Storage Limit", + const int + @@ match storage_limit with None -> 0 | Some s -> s ) + ] | _ (* some arguments *) -> please_check_the_hash ppf ()) ] (fun ~user_answer -> @@ -1491,6 +1319,43 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec in let batch_test ~with_rejections = let n = 50 in + let forge_batch_transactions state ~client ~src ~dest:_ ~n ?(fee = 0.00126) + () = + get_head_block_hash state ~client () + >>= fun branch -> + let json = + `O + [ ("branch", `String branch); + ( "contents", + `A + (List.map (List.range 0 n) ~f:(fun i -> + `O + [ ("kind", `String "transaction"); + ("source", `String src); + ( "destination", + `String "tz2KZPgf2rshxNUBXFcTaCemik1LH1v9qz3F" ); + ("amount", `String (Int.to_string 100)); + ( "fee", + `String + (Int.to_string (Float.to_int (fee *. 1000000.))) + ); + ("counter", `String (Int.to_string i)); + ("gas_limit", `String (Int.to_string 127)); + ("storage_limit", `String (Int.to_string 277)) ])) ) + ] + in + Tezos_client.rpc + state + ~client + ~path:"/chains/main/blocks/head/helpers/forge/operations" + (`Post (Ezjsonm.to_string json)) + >>= function + | `String operation_bytes -> + let magic_byte = "03" in + return (magic_byte ^ operation_bytes) + | _ -> + failf "Failed to forge operation or parse result" + in forge_batch_transactions state ~client:(client 0) @@ -1505,6 +1370,16 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec |> (fun x -> [x]) |> Blake2B.hash_bytes |> Blake2B.to_string |> Base58.raw_encode) in + let sign state ~client ~bytes = + Tezos_client.client_cmd + state + ~client:client.Tezos_client.Keyed.client + [ "sign"; + "bytes"; + "0x" ^ bytes; + "for"; + client.Tezos_client.Keyed.key_name ] + in with_ledger_test_reject_and_accept state ~only_success:(not with_rejections) @@ -1536,6 +1411,7 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec ~client:client_0 ~ledger_account ~delegate:baker_0.Tezos_client.Keyed.key_name + ~delegate_pkh:(Tezos_protocol.Account.pubkey_hash baker_0_account) ~src:signer.key_name () ~bake @@ -1649,7 +1525,14 @@ let run state ~pp_error ~protocol ~protocol_kind ~node_exec ~client_exec run manager_tz_delegation_tests | Some `All -> run delegation_tests - >>= fun () -> run batch_test >>= fun () -> run voting_test + >>= fun () -> + run manager_tz_delegation_tests + >>= fun () -> + run batch_test + >>= fun () -> + run transactions_test + >>= fun () -> + run voting_test >>= fun () -> run contracts_test | Some `Batch_transactions -> run batch_test | Some `Transactions -> -- GitLab From 3875af380aff3a6eb92ba57e24e1dca12542073e Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Thu, 28 May 2020 11:25:20 -0400 Subject: [PATCH 18/23] Sandbox: baking; cleanup old tests --- src/bin_sandbox/command_ledger_baking.ml | 74 +++++++++--------------- 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/src/bin_sandbox/command_ledger_baking.ml b/src/bin_sandbox/command_ledger_baking.ml index 4fae842a5005..a58a128d7195 100644 --- a/src/bin_sandbox/command_ledger_baking.ml +++ b/src/bin_sandbox/command_ledger_baking.ml @@ -87,13 +87,16 @@ let assert_hwms state ~client ~uri ~main ~test = assert_eq Int.to_string ~actual:main_actual ~expected:main >>= fun () -> assert_eq Int.to_string ~actual:test_actual ~expected:test -let get_chain_id state ~client = +let get_chain_id_string state ~client = Tezos_client.rpc state ~client `Get ~path:"/chains/main/chain_id" - >>= (function - | `String x -> - return x - | _ -> - failf "Failed to parse chain_id JSON from node") + >>= function + | `String x -> + return x + | _ -> + failf "Failed to parse chain_id JSON from node" + +let get_chain_id state ~client = + get_chain_id_string state ~client >>= fun chain_id_string -> return (Tezos_crypto.Chain_id.of_b58check_exn chain_id_string) @@ -169,26 +172,6 @@ let sign state ~client ~bytes () = ["sign"; "bytes"; "0x" ^ bytes; "for"; client.Tezos_client.Keyed.key_name] >>= fun _ -> return () -let originate_account_from state ~client ~account = - let orig_account_name = - Tezos_protocol.Account.name account ^ "-originated-account" - in - Tezos_client.successful_client_cmd - state - ~client - [ "originate"; - "account"; - orig_account_name; - "for"; - Tezos_protocol.Account.name account; - "transferring"; - Int.to_string 1000; - "from"; - Tezos_protocol.Account.name account; - "--burn-cap"; - Float.to_string 0.257 ] - >>= fun _ -> return orig_account_name - let setup_baking_ledger state uri ~client ~protocol = Console.say state EF.(wf "Setting up the ledger device %S" uri) >>= fun () -> @@ -251,17 +234,18 @@ let setup_baking_ledger state uri ~client ~protocol = in test_invalid_delegations () >>= fun () -> + get_chain_id_string state ~client + >>= fun cid -> with_ledger_test_reject_and_succeed state EF.( - wf - "Setting up %S for baking.\n\ - Address: %S\n\ - Chain: mainnet\n\ - Main Chain HWM: 0\n\ - Test Chain HWM: 0" - uri - (Tezos_protocol.Account.pubkey_hash account)) + list + [ wf "Setting up %S for baking" uri; + wf "Setup Baking?"; + wf "Address: %S\n" (Tezos_protocol.Account.pubkey_hash account); + wf "Chain: %S" cid; + wf "Main Chain HWM: 0"; + wf "Test Chain HWM: 0" ]) (fun () -> Tezos_client.successful_client_cmd state @@ -360,7 +344,7 @@ let run state ~protocol ~node_exec ~client_exec ~admin_exec ~size ~base_port let set_hwm_ level () = with_ledger_prompt state - EF.(wf "Setting HWM to %d" level) + EF.(list [wf "Reset HWM"; wf "%d" level]) `Succeeds ~f:(fun () -> Tezos_client.Ledger.set_hwm state ~client:(client 0) ~uri ~level) @@ -381,11 +365,13 @@ let run state ~protocol ~node_exec ~client_exec ~admin_exec ~size ~base_port let endorse () = Tezos_client.Keyed.endorse state baker "Endorsed by ledger" in + get_chain_id_string state ~client:(client 0) + >>= fun cid -> let ask_hwm ~main ~test () = assert_hwms_ ~main ~test () >>= ask_assert state - EF.(wf "Is 'Chain' = %S and 'Last Block Level' = %d" "mainnet" main) + EF.(wf "Is 'Chain' = %S and 'Last Block Level' = %d" cid main) in ( if enable_deterministic_nonce_tests then (* Test determinism of nonces *) @@ -403,14 +389,6 @@ let run state ~protocol ~node_exec ~client_exec ~admin_exec ~size ~base_port >>= fun () -> assert_ Poly.(thisNonce1 <> thatNonce1) else return () ) >>= fun () -> - assert_failure - state - "originating an account from the Tezos Baking app should fail" - (fun () -> - originate_account_from state ~client:(client 0) ~account:ledger_account - >>= fun _ -> return ()) - () - >>= fun () -> let fee = 0.00126 in let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in forge_delegation @@ -423,14 +401,18 @@ let run state ~protocol ~node_exec ~client_exec ~admin_exec ~size ~base_port >>= fun forged_delegation_bytes -> with_ledger_test_reject_and_succeed state - EF.(wf "Self delegating address %s with fee %f" ledger_pkh fee) + EF.( + list + [ wf "Register as delegate?"; + wf "Address %s" ledger_pkh; + wf "Fee %f" fee ]) (sign state ~client:baker ~bytes:forged_delegation_bytes) >>= bake >>= ask_hwm ~main:3 ~test:0 >>= fun () -> (let level = 1 in with_ledger_test_reject_and_succeed state - EF.(wf "Setting HWM to %d" level) + EF.(list [wf "Reset HWM"; wf "%d" level]) (fun () -> Tezos_client.Ledger.set_hwm state ~client:(client 0) ~uri ~level)) >>= assert_hwms_ ~main:1 ~test:1 -- GitLab From 220e0b3a6b4ffcebc5feb59ad0236a1dd27e686f Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Thu, 28 May 2020 13:50:51 -0400 Subject: [PATCH 19/23] Sandbox: fix origination test --- src/bin_sandbox/command_ledger_baking.ml | 107 +++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/src/bin_sandbox/command_ledger_baking.ml b/src/bin_sandbox/command_ledger_baking.ml index a58a128d7195..2dd3e0fa2fef 100644 --- a/src/bin_sandbox/command_ledger_baking.ml +++ b/src/bin_sandbox/command_ledger_baking.ml @@ -172,6 +172,105 @@ let sign state ~client ~bytes () = ["sign"; "bytes"; "0x" ^ bytes; "for"; client.Tezos_client.Keyed.key_name] >>= fun _ -> return () +(* let prepare_origination_of_id_script ?(spendable = false) *) +(* ?(delegatable = false) ?delegate ?(push_drops = 0) ?(amount = "2") state *) +(* ~client:_ ~name ~from ~protocol_kind ~parameter ~init_storage = *) +(* let id_script parameter = *) +(* Fmt.strf *) +(* "parameter %s;\n\ *) +(* storage %s;\n\ *) +(* code\n\ *) +(* \ {\n\ *) +(* \ %s\n\ *) +(* \ { CAR; NIL operation; PAIR }\n\ *) +(* \ };\n" *) +(* parameter *) +(* parameter *) +(* ( match push_drops with *) +(* | 0 -> *) +(* "# No push-drops" *) +(* | n -> *) +(* Fmt.strf *) +(* "# %d push-drop%s\n %s" *) +(* n *) +(* (if n > 1 then "s" else "") *) +(* ( List.init push_drops ~f:(fun ith -> *) +(* Fmt.strf *) +(* "{ PUSH string %S ; DROP } ;" *) +(* (Fmt.strf *) +(* "push-dropping %d adds stupid bytes to the contract" *) +(* ith)) *) +(* |> String.concat ~sep:"\n " ) ) *) +(* in *) +(* let tmp = Caml.Filename.temp_file "little-id-script" ".tz" in *) +(* System.write_file state tmp ~content:(id_script parameter) *) +(* >>= fun () -> *) +(* Dbg.e EF.(wf "id_script %s: %s" parameter tmp) ; *) +(* let origination = *) +(* let opt = Option.value_map ~default:[] in *) +(* ["--wait"; "none"; "originate"; "contract"; name] *) +(* @ ( match protocol_kind with *) +(* | `Athens -> *) +(* ["for"; from] *) +(* | `Babylon | `Carthage -> *) +(* [] ) *) +(* @ [ "transferring"; *) +(* amount; *) +(* "from"; *) +(* from; *) +(* "running"; *) +(* tmp; *) +(* "--init"; *) +(* init_storage; *) +(* "--force"; *) +(* "--burn-cap"; *) +(* "300000000000"; *) +(* (1* ; "--fee-cap" ; "20000000000000" *1) *) +(* "--gas-limit"; *) +(* "1000000000000000"; *) +(* "--storage-limit"; *) +(* "20000000000000"; *) +(* "--verbose-signing" ] *) +(* @ opt delegate ~f:(fun s -> (1* Baby & Aths *1) ["--delegate"; s]) *) +(* @ (if delegatable then [(1* Aths *1) "--delegatable"] else []) *) +(* @ if spendable then [(1* Aths *1) "--spendable"] else [] *) +(* in *) +let originate_account_from state ~client ~account = + let orig_account_name = "-originated-account" in + let id_script parameter = + Fmt.strf + "parameter %s;\n\ + storage %s;\n\ + code\n\ + \ {\n\ + \ %s\n\ + \ { CAR; NIL operation; PAIR }\n\ + \ };\n" + parameter + parameter + "# No push-drops" + in + let tmp = Caml.Filename.temp_file "little-id-script" ".tz" in + System.write_file state tmp ~content:(id_script "unit") + >>= fun () -> + Tezos_client.successful_client_cmd + state + ~client + [ "originate"; + "contract"; + orig_account_name; + "transferring"; + Int.to_string 1000; + "from"; + Tezos_protocol.Account.pubkey_hash account; + "running"; + tmp; + "--init"; + "Unit"; + "--burn-cap"; + Float.to_string 0.257 ] + >>= fun _ -> return orig_account_name + let setup_baking_ledger state uri ~client ~protocol = Console.say state EF.(wf "Setting up the ledger device %S" uri) >>= fun () -> @@ -389,6 +488,14 @@ let run state ~protocol ~node_exec ~client_exec ~admin_exec ~size ~base_port >>= fun () -> assert_ Poly.(thisNonce1 <> thatNonce1) else return () ) >>= fun () -> + assert_failure + state + "originating an account from the Tezos Baking app should fail" + (fun () -> + originate_account_from state ~client:(client 0) ~account:ledger_account + >>= fun _ -> return ()) + () + >>= fun () -> let fee = 0.00126 in let ledger_pkh = Tezos_protocol.Account.pubkey_hash ledger_account in forge_delegation -- GitLab From abf14e2f6cc274803df9c79de8a7d1c9fb29bf27 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Thu, 28 May 2020 13:55:17 -0400 Subject: [PATCH 20/23] Sandbox: remove commented code --- src/bin_sandbox/command_ledger_baking.ml | 63 ------------------------ 1 file changed, 63 deletions(-) diff --git a/src/bin_sandbox/command_ledger_baking.ml b/src/bin_sandbox/command_ledger_baking.ml index 2dd3e0fa2fef..1373e3ee2ab2 100644 --- a/src/bin_sandbox/command_ledger_baking.ml +++ b/src/bin_sandbox/command_ledger_baking.ml @@ -172,69 +172,6 @@ let sign state ~client ~bytes () = ["sign"; "bytes"; "0x" ^ bytes; "for"; client.Tezos_client.Keyed.key_name] >>= fun _ -> return () -(* let prepare_origination_of_id_script ?(spendable = false) *) -(* ?(delegatable = false) ?delegate ?(push_drops = 0) ?(amount = "2") state *) -(* ~client:_ ~name ~from ~protocol_kind ~parameter ~init_storage = *) -(* let id_script parameter = *) -(* Fmt.strf *) -(* "parameter %s;\n\ *) -(* storage %s;\n\ *) -(* code\n\ *) -(* \ {\n\ *) -(* \ %s\n\ *) -(* \ { CAR; NIL operation; PAIR }\n\ *) -(* \ };\n" *) -(* parameter *) -(* parameter *) -(* ( match push_drops with *) -(* | 0 -> *) -(* "# No push-drops" *) -(* | n -> *) -(* Fmt.strf *) -(* "# %d push-drop%s\n %s" *) -(* n *) -(* (if n > 1 then "s" else "") *) -(* ( List.init push_drops ~f:(fun ith -> *) -(* Fmt.strf *) -(* "{ PUSH string %S ; DROP } ;" *) -(* (Fmt.strf *) -(* "push-dropping %d adds stupid bytes to the contract" *) -(* ith)) *) -(* |> String.concat ~sep:"\n " ) ) *) -(* in *) -(* let tmp = Caml.Filename.temp_file "little-id-script" ".tz" in *) -(* System.write_file state tmp ~content:(id_script parameter) *) -(* >>= fun () -> *) -(* Dbg.e EF.(wf "id_script %s: %s" parameter tmp) ; *) -(* let origination = *) -(* let opt = Option.value_map ~default:[] in *) -(* ["--wait"; "none"; "originate"; "contract"; name] *) -(* @ ( match protocol_kind with *) -(* | `Athens -> *) -(* ["for"; from] *) -(* | `Babylon | `Carthage -> *) -(* [] ) *) -(* @ [ "transferring"; *) -(* amount; *) -(* "from"; *) -(* from; *) -(* "running"; *) -(* tmp; *) -(* "--init"; *) -(* init_storage; *) -(* "--force"; *) -(* "--burn-cap"; *) -(* "300000000000"; *) -(* (1* ; "--fee-cap" ; "20000000000000" *1) *) -(* "--gas-limit"; *) -(* "1000000000000000"; *) -(* "--storage-limit"; *) -(* "20000000000000"; *) -(* "--verbose-signing" ] *) -(* @ opt delegate ~f:(fun s -> (1* Baby & Aths *1) ["--delegate"; s]) *) -(* @ (if delegatable then [(1* Aths *1) "--delegatable"] else []) *) -(* @ if spendable then [(1* Aths *1) "--spendable"] else [] *) -(* in *) let originate_account_from state ~client ~account = let orig_account_name = "-originated-account" in let id_script parameter = -- GitLab From 6b85a1518df9c79f1d57703f59a73eafe83634c3 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Fri, 29 May 2020 15:09:46 -0400 Subject: [PATCH 21/23] Sandbox: Removed Withdraw delegate test --- src/bin_sandbox/command_ledger_baking.ml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/bin_sandbox/command_ledger_baking.ml b/src/bin_sandbox/command_ledger_baking.ml index 1373e3ee2ab2..cf28a5ef87da 100644 --- a/src/bin_sandbox/command_ledger_baking.ml +++ b/src/bin_sandbox/command_ledger_baking.ml @@ -205,7 +205,7 @@ let originate_account_from state ~client ~account = "--init"; "Unit"; "--burn-cap"; - Float.to_string 0.257 ] + Float.to_string 0.300 ] >>= fun _ -> return orig_account_name let setup_baking_ledger state uri ~client ~protocol = @@ -296,19 +296,6 @@ let setup_baking_ledger state uri ~client ~protocol = "0"; "--test-hwm"; "0" ]) - >>= assert_failure - state - "signing a 'Withdraw delegate' operation in Baking App should fail" - (fun () -> - Tezos_client.successful_client_cmd - state - ~client - [ "--wait"; - "none"; - "withdraw"; - "delegate"; - "from"; - Tezos_protocol.Account.pubkey_hash account ]) >>= assert_baking_key (Some uri) >>= test_invalid_delegations >>= fun () -> return (baker, account) -- GitLab From 1e46b859e746377bd36f740815a414bdcf214146 Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Tue, 2 Jun 2020 09:22:13 -0400 Subject: [PATCH 22/23] Sandbox: delegation prompt fixes --- src/bin_sandbox/command_ledger_wallet.ml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index 016f1c825abf..a7f707c53746 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -405,11 +405,12 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ~messages: MFmt. [ (fun ppf () -> wf ppf "Originating manager.tz contract "); + (fun ppf () -> wf ppf "Sign Hash"); (fun ppf () -> wf ppf "The ledger should be prompting for acknowledgment to provide a \ - signature of an unknown operation. This is not an actual test, \ + signature of an unknown operation. THIS IS NOT AN ACTUAL TEST, \ and is only part of the test setup. There is no need for a \ verification of this hash. Please accept this Unrecognized \ Operation.") ] @@ -505,6 +506,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ("Fee", const string "0.00XXX"); ("Source", const string contract_address); ("Delegate", const string delegate_pkh); + ("Delegate Name", const string "Custom Delegate: please verify the addresss"); ("Storage Limit", const int 500) ] ~output_msg:"delegation" in @@ -518,9 +520,9 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ("Fee", const string "0.00XXX"); ("Source", const string contract_address); ("Delegate", const string "None"); - ("Storage Limit", const int 500); ( "Delegate Name", - const string "Custom Delegate: please verify the addresss" ) ] + const string "Custom Delegate: please verify the address" ); + ("Storage Limit", const int 500); ] ~output_msg:"delegate-removal" in let manager_tz_to_implicit () = @@ -643,6 +645,7 @@ let delegation_tests state ~client ~src ~with_rejections ~protocol_kind [ ("Fee", const string "0.00XXX"); ("Source", const string ledger_pkh); ("Delegate", const string ledger_pkh); + ("Delegate Name", const string "Obsidian"); ("Storage", const int 0) ]) ] (fun ~user_answer -> client_async_cmd @@ -699,7 +702,7 @@ let delegation_tests state ~client ~src ~with_rejections ~protocol_kind [ ("Fee", const string "0.00XXX"); ("Source", const string ledger_pkh); ("Delegate", const string delegate_pkh); - ( "Delegate Name", + ("Delegate Name", const string "Custom Delegate: please verify the address" ); ("Storage Limit", const int 0) ]) ] -- GitLab From e5f03b8a72410f331a70e94b356a75f11e35569c Mon Sep 17 00:00:00 2001 From: Jacquin Mininger Date: Tue, 2 Jun 2020 13:34:31 -0400 Subject: [PATCH 23/23] Sandbox: make voting test expectations more clear --- src/bin_sandbox/command_ledger_wallet.ml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bin_sandbox/command_ledger_wallet.ml b/src/bin_sandbox/command_ledger_wallet.ml index a7f707c53746..3418f6e0952c 100644 --- a/src/bin_sandbox/command_ledger_wallet.ml +++ b/src/bin_sandbox/command_ledger_wallet.ml @@ -190,7 +190,7 @@ let expect_from_output ~expectation ~message (proc_res : Process_result.t) = let voting_tests state ~client ~src ~with_rejections ~protocol_kind ~ledger_account ~tested_proposal ~go_to_next_period () = - let expect_success message v = + let expect_failure message v = expect_from_output ~expectation:`Not_a_delegate ~message v in let expect_rejection message v = @@ -203,7 +203,7 @@ let voting_tests state ~client ~src ~with_rejections ~protocol_kind else return () ) >>= fun () -> ledger_prompt_notice_expectation state ~messages ~user_answer:`Accept - >>= fun () -> action () >>= fun res -> expect_success name res + >>= fun () -> action () >>= fun res -> expect_failure name res in let source_display = Tezos_protocol.Account.pubkey_hash ledger_account in let submit_proposals ~display_expectation proposals () = @@ -243,6 +243,8 @@ let voting_tests state ~client ~src ~with_rejections ~protocol_kind Tezos_protocol.Protocol_kind.pp protocol_kind ; cut ppf () ; + wf ppf "* Confirm Proposal" ; + cut ppf () ; wf ppf "* Source: `%s`" source_display ; cut ppf () ; wf ppf "* Period: `0`" ; @@ -263,6 +265,8 @@ let voting_tests state ~client ~src ~with_rejections ~protocol_kind go_to_next_period () >>= fun () -> List_sequential.iter ["yea"; "nay"] ~f:(fun vote -> + Console.say state EF.(haf "EXPECTING THE NEXT COMMAND TO FAIL") + >>= fun _ -> test_reject_and_accept (Fmt.strf "vote-%s" vote) ~messages: @@ -506,7 +510,8 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ("Fee", const string "0.00XXX"); ("Source", const string contract_address); ("Delegate", const string delegate_pkh); - ("Delegate Name", const string "Custom Delegate: please verify the addresss"); + ( "Delegate Name", + const string "Custom Delegate: please verify the addresss" ); ("Storage Limit", const int 500) ] ~output_msg:"delegation" in @@ -522,7 +527,7 @@ let manager_tz_delegation_tests state ~client ~ledger_key ~ledger_account ("Delegate", const string "None"); ( "Delegate Name", const string "Custom Delegate: please verify the address" ); - ("Storage Limit", const int 500); ] + ("Storage Limit", const int 500) ] ~output_msg:"delegate-removal" in let manager_tz_to_implicit () = @@ -702,7 +707,7 @@ let delegation_tests state ~client ~src ~with_rejections ~protocol_kind [ ("Fee", const string "0.00XXX"); ("Source", const string ledger_pkh); ("Delegate", const string delegate_pkh); - ("Delegate Name", + ( "Delegate Name", const string "Custom Delegate: please verify the address" ); ("Storage Limit", const int 0) ]) ] -- GitLab