From 00def6d20e3ad25d5517f1b3407591ab1c43f5a8 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Mon, 25 Nov 2019 12:13:55 +0100 Subject: [PATCH] Fix a bug, test added: A never accounted message was not adding anything to the map --- src/test/contracts/multisig-v2.ligo | 2 +- src/test/multisig_v2_tests.ml | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/test/contracts/multisig-v2.ligo b/src/test/contracts/multisig-v2.ligo index 7815fcbcf..273df6176 100644 --- a/src/test/contracts/multisig-v2.ligo +++ b/src/test/contracts/multisig-v2.ligo @@ -29,7 +29,7 @@ function send (const param : send_pt; const s : storage_t) : contract_return_t i var new_store : addr_set_t := case map_get(packed_msg, s.message_store) of | Some(voters) -> set_add(sender,voters) - | None -> (set_empty : addr_set_t) end + | None -> set sender end end ; if size(new_store) >= s.threshold then block { diff --git a/src/test/multisig_v2_tests.ml b/src/test/multisig_v2_tests.ml index fcd006641..f70536c08 100644 --- a/src/test/multisig_v2_tests.ml +++ b/src/test/multisig_v2_tests.ml @@ -73,6 +73,22 @@ let already_accounted () = expect_eq ~options program "main" (e_pair param init_storage) (e_pair empty_op_list init_storage) +(* sender message isn't stored in the message store *) +let never_accounted () = + let%bind program,_ = get_program () in + let%bind packed_payload = pack_payload program empty_message in + let%bind bytes = e_bytes_ofbytes packed_payload in + let init_storage = storage 2 [1;2] + [] in + let final_storage = storage 2 [1;2] + [(bytes, e_set [e_address@@ addr 1])] in + let options = + let amount = Memory_proto_alpha.Protocol.Alpha_context.Tez.zero in + let source = contract 1 in + Proto_alpha_utils.Memory_proto_alpha.make_options ~amount ~source () in + expect_eq ~options program "main" + (e_pair param init_storage) (e_pair empty_op_list final_storage) + (* successful storing in the message store *) let succeeded_storing () = let%bind program,_ = get_program () in @@ -102,5 +118,6 @@ let main = test_suite "Multisig v2" [ test "compile" compile_main ; test "wrong_addr" wrong_addr ; test "already_accounted" already_accounted ; + test "never_accounted" never_accounted ; test "succeeded_storing" succeeded_storing ; ]