From 23353b0e274545aaf8c49521678496ae5859f40a Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Tue, 21 Jan 2020 02:23:56 -0600 Subject: [PATCH] Clarify internal sender/source options --- src/main/run/of_michelson.ml | 2 +- src/test/coase_tests.ml | 8 ++-- src/test/hash_lock_tests.ml | 12 +++--- src/test/id_tests.ml | 24 +++++------ src/test/multisig_v2_tests.ml | 40 +++++++++---------- src/test/replaceable_id_tests.ml | 16 ++++---- .../proto-alpha-utils/x_memory_proto_alpha.ml | 9 +++-- 7 files changed, 56 insertions(+), 55 deletions(-) diff --git a/src/main/run/of_michelson.ml b/src/main/run/of_michelson.ml index 4a9b7e1c3..6e8733e0e 100644 --- a/src/main/run/of_michelson.ml +++ b/src/main/run/of_michelson.ml @@ -75,7 +75,7 @@ let make_dry_run_options (opts : dry_run_options) : options result = match Memory_proto_alpha.Protocol.Alpha_context.Timestamp.of_notation st with | Some t -> ok (Some t) | None -> simple_fail ("\""^st^"\" is a bad timestamp notation") in - ok @@ make_options ?predecessor_timestamp:predecessor_timestamp ~amount ?source:sender ?payer:source () + ok @@ make_options ?predecessor_timestamp:predecessor_timestamp ~amount ?sender ?source () let ex_value_ty_to_michelson (v : ex_typed_value) : Michelson.t result = let (Ex_typed_value (value , ty)) = v in diff --git a/src/test/coase_tests.ml b/src/test/coase_tests.ml index 57e55b495..f335ec45b 100644 --- a/src/test/coase_tests.ml +++ b/src/test/coase_tests.ml @@ -204,8 +204,8 @@ let transfer () = in let%bind () = let amount = Memory_proto_alpha.Protocol.Alpha_context.Tez.zero in - let payer = first_contract in - let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount ~payer () in + let source = first_contract in + let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount ~source () in expect_eq_n_strict_pos_small ~options program "transfer_single" make_input make_expected in ok () in @@ -234,8 +234,8 @@ let sell () = in let%bind () = let amount = Memory_proto_alpha.Protocol.Alpha_context.Tez.zero in - let payer = first_contract in - let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount ~payer () in + let source = first_contract in + let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~amount ~source () in expect_n_strict_pos_small ~options program "sell_single" make_input make_expecter in ok () in diff --git a/src/test/hash_lock_tests.ml b/src/test/hash_lock_tests.ml index bff1e8219..7bfe77c88 100644 --- a/src/test/hash_lock_tests.ml +++ b/src/test/hash_lock_tests.ml @@ -78,7 +78,7 @@ let commit () = let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~predecessor_timestamp - ~payer:first_contract + ~sender:first_contract () in expect_eq ~options program "commit" @@ -127,7 +127,7 @@ let reveal_young_commit () = let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~predecessor_timestamp - ~payer:first_contract + ~sender:first_contract () in expect_string_failwith ~options program "reveal" @@ -159,7 +159,7 @@ let reveal_breaks_commit () = let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~predecessor_timestamp - ~payer:first_contract + ~sender:first_contract () in expect_string_failwith ~options program "reveal" @@ -191,7 +191,7 @@ let reveal_wrong_commit () = let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~predecessor_timestamp - ~payer:first_contract + ~sender:first_contract () in expect_string_failwith ~options program "reveal" @@ -223,7 +223,7 @@ let reveal_no_reuse () = let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~predecessor_timestamp - ~payer:first_contract + ~sender:first_contract () in expect_string_failwith ~options program "reveal" @@ -256,7 +256,7 @@ let reveal () = let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~predecessor_timestamp - ~payer:first_contract + ~sender:first_contract () in expect_eq ~options program "reveal" diff --git a/src/test/id_tests.ml b/src/test/id_tests.ml index dfe5be581..db8b78960 100644 --- a/src/test/id_tests.ml +++ b/src/test/id_tests.ml @@ -48,7 +48,7 @@ let buy_id () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.one) () in let new_website = e_bytes_string "ligolang.org" in @@ -81,7 +81,7 @@ let buy_id_sender_addr () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.one) () in let new_website = e_bytes_string "ligolang.org" in @@ -115,7 +115,7 @@ let buy_id_wrong_amount () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.fifty_cents) () in let param = e_pair owner_website (e_some (e_address new_addr)) in @@ -134,7 +134,7 @@ let update_details_owner () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.zero) () in @@ -175,7 +175,7 @@ let update_details_controller () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.zero) () in @@ -217,7 +217,7 @@ let update_details_nonexistent () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.zero) () in @@ -284,7 +284,7 @@ let update_details_unchanged () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.zero) () in @@ -316,7 +316,7 @@ let update_owner () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.zero) () in @@ -355,7 +355,7 @@ let update_owner_nonexistent () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.zero) () in @@ -386,7 +386,7 @@ let update_owner_wrong_addr () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.zero) () in @@ -416,7 +416,7 @@ let skip () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.one) () in let new_website = e_bytes_string "ligolang.org" in @@ -450,7 +450,7 @@ let skip_wrong_amount () = in let new_addr = first_owner in let options = Proto_alpha_utils.Memory_proto_alpha.make_options - ~payer:first_contract + ~sender:first_contract ~amount:(Memory_proto_alpha.Protocol.Alpha_context.Tez.fifty_cents) () in let new_website = e_bytes_string "ligolang.org" in diff --git a/src/test/multisig_v2_tests.ml b/src/test/multisig_v2_tests.ml index e21736586..0ed619c1d 100644 --- a/src/test/multisig_v2_tests.ml +++ b/src/test/multisig_v2_tests.ml @@ -73,8 +73,8 @@ let wrong_addr () = id_counter_list = [1,0 ; 2,0] ; msg_store_list = [] } in - let source = contract 3 in - let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 3 in + let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in let%bind () = let exp_failwith = "Unauthorized address" in expect_string_failwith ~options program "main" @@ -89,8 +89,8 @@ let message_size_exceeded () = id_counter_list = [1,0] ; msg_store_list = [] } in - let source = contract 1 in - let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in let%bind () = let exp_failwith = "Message size exceed maximum limit" in expect_string_failwith ~options program "main" @@ -107,8 +107,8 @@ let maximum_number_of_proposal () = id_counter_list = [1,1] ; msg_store_list = [(bytes1, e_set [e_address@@ addr 1])] } in - let source = contract 1 in - let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + let options = Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in let%bind () = let exp_failwith = "Maximum number of proposal reached" in expect_string_failwith ~options program "main" @@ -126,8 +126,8 @@ let send_already_accounted () = msg_store_list = [(bytes, e_set [e_address@@ addr 1])] } in let options = - let source = contract 1 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in expect_eq ~options program "main" (e_pair (send_param empty_message) init_storage) (e_pair empty_op_list init_storage) @@ -147,8 +147,8 @@ let send_never_accounted () = msg_store_list = [(bytes, e_set [e_address@@ addr 1])] ; } in let options = - let source = contract 1 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in expect_eq ~options program "main" (e_pair (send_param empty_message) init_storage) (e_pair empty_op_list final_storage) @@ -168,8 +168,8 @@ let withdraw_already_accounted_one () = id_counter_list = [1,0 ; 2,0] ; msg_store_list = [] } in let options = - let source = contract 1 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in expect_eq ~options program "main" (e_pair param init_storage) (e_pair empty_op_list final_storage) @@ -189,8 +189,8 @@ let withdraw_already_accounted_two () = id_counter_list = [1,0 ; 2,1] ; msg_store_list = [(bytes, e_set [e_address@@ addr 2])] } in let options = - let source = contract 1 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in expect_eq ~options program "main" (e_pair param init_storage) (e_pair empty_op_list final_storage) @@ -212,8 +212,8 @@ let counters_reset () = id_counter_list = [1,0 ; 2,0 ; 3,0] ; msg_store_list = [] } in let options = - let source = contract 3 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 3 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in expect_eq ~options program "main" (e_pair param init_storage) (e_pair empty_op_list final_storage) @@ -227,8 +227,8 @@ let withdraw_never_accounted () = msg_store_list = [] ; } in let options = - let source = contract 1 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in expect_eq ~options program "main" (e_pair param init_storage) (e_pair empty_op_list init_storage) @@ -243,8 +243,8 @@ let succeeded_storing () = msg_store_list = [(bytes, e_typed_set [] t_address)] ; } in let options = - let source = contract 1 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in let%bind () = expect_eq_n_trace_aux ~options [1;2] program "main" (fun th -> let init_storage = storage (init_storage th) in diff --git a/src/test/replaceable_id_tests.ml b/src/test/replaceable_id_tests.ml index 6bf09e95a..54d7d1a64 100644 --- a/src/test/replaceable_id_tests.ml +++ b/src/test/replaceable_id_tests.ml @@ -44,8 +44,8 @@ let change_addr_success () = let init_storage = storage 1 in let param = entry_change_addr 2 in let options = - let source = contract 1 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in expect_eq ~options program "main" (e_pair param init_storage) (e_pair empty_op_list (storage 2)) @@ -54,8 +54,8 @@ let change_addr_fail () = let init_storage = storage 1 in let param = entry_change_addr 2 in let options = - let source = contract 3 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 3 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in let exp_failwith = "Unauthorized sender" in expect_string_failwith ~options program "main" (e_pair param init_storage) exp_failwith @@ -65,8 +65,8 @@ let pass_message_success () = let init_storage = storage 1 in let param = entry_pass_message in let options = - let source = contract 1 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 1 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in expect_eq ~options program "main" (e_pair param init_storage) (e_pair empty_op_list init_storage) @@ -75,8 +75,8 @@ let pass_message_fail () = let init_storage = storage 1 in let param = entry_pass_message in let options = - let source = contract 2 in - Proto_alpha_utils.Memory_proto_alpha.make_options ~source () in + let sender = contract 2 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~sender () in let exp_failwith = "Unauthorized sender" in expect_string_failwith ~options program "main" (e_pair param init_storage) exp_failwith diff --git a/vendors/ligo-utils/proto-alpha-utils/x_memory_proto_alpha.ml b/vendors/ligo-utils/proto-alpha-utils/x_memory_proto_alpha.ml index c613c86a4..a8f5aa468 100644 --- a/vendors/ligo-utils/proto-alpha-utils/x_memory_proto_alpha.ml +++ b/vendors/ligo-utils/proto-alpha-utils/x_memory_proto_alpha.ml @@ -1067,9 +1067,9 @@ type options = { let make_options ?(tezos_context = dummy_environment.tezos_context) ?(predecessor_timestamp = dummy_environment.tezos_context.predecessor_timestamp) - ?(source = (List.nth dummy_environment.identities 0).implicit_contract) + ?(sender = (List.nth dummy_environment.identities 0).implicit_contract) ?(self = (List.nth dummy_environment.identities 0).implicit_contract) - ?(payer = (List.nth dummy_environment.identities 1).implicit_contract) + ?(source = (List.nth dummy_environment.identities 1).implicit_contract) ?(amount = Alpha_context.Tez.one) ?(chain_id = Environment.Chain_id.zero) () @@ -1077,9 +1077,10 @@ let make_options let tezos_context = { tezos_context with predecessor_timestamp } in { tezos_context ; - source ; + (* yep *) + source = sender ; + payer = source ; self ; - payer ; amount ; chain_id ; }