diff --git a/src/ligo/test/coase_tests.ml b/src/ligo/test/coase_tests.ml index f1d180e2c..f0ca9cacd 100644 --- a/src/ligo/test/coase_tests.ml +++ b/src/ligo/test/coase_tests.ml @@ -27,9 +27,8 @@ let card_ty = ez_t_record [ let card_ez owner = card (e_a_empty_address owner) -let make_cards lst = +let make_cards assoc_lst = let card_id_ty = t_nat () in - let assoc_lst = List.mapi (fun i x -> (e_a_empty_nat i , x)) lst in e_a_empty_map assoc_lst card_id_ty card_ty let card_pattern (coeff , qtt) = @@ -62,20 +61,29 @@ let storage cards_patterns cards next_id = let storage_ez cps cs next_id = storage (make_card_patterns cps) (make_cards cs) (e_a_empty_nat next_id) -let basic a b n next_id = +let cards_ez owner n = + List.mapi (fun i x -> (e_a_empty_nat i , x)) + @@ List.map card_ez + @@ List.map (Function.constant owner) + @@ List.range n + +let first_owner = + let open Tezos_utils.Memory_proto_alpha in + let id = List.nth dummy_environment.identities 0 in + let kt = id.implicit_contract in + Alpha_context.Contract.to_b58check kt + +let second_owner = + let open Tezos_utils.Memory_proto_alpha in + let id = List.nth dummy_environment.identities 1 in + let kt = id.implicit_contract in + Alpha_context.Contract.to_b58check kt + +let basic a b cards next_id = let card_patterns = List.map card_pattern_ez [ (100 , a) ; (20 , b) ; ] in - let owner = - let open Tezos_utils.Memory_proto_alpha in - let id = List.hd dummy_environment.identities in - let kt = id.implicit_contract in - Alpha_context.Contract.to_b58check kt in - let cards = - List.map card_ez - @@ List.map (Function.constant owner) - @@ List.range n in storage_ez card_patterns cards next_id let buy () = @@ -86,20 +94,29 @@ let buy () = let buy_action = ez_e_a_empty_record [ ("card_to_buy" , e_a_empty_nat 0) ; ] in - let storage = basic 100 1000 n (2 * n) in + let storage = basic 100 1000 (cards_ez first_owner n) (2 * n) in e_a_empty_pair buy_action storage in + let expected = + let ops = e_a_empty_list [] (t_operation ()) in + let storage = + let cards = + cards_ez first_owner n @ + [(e_a_empty_nat (2 * n) , card (e_a_empty_address second_owner))] + in + basic 101 1000 cards ((2 * n) + 1) in + e_a_empty_pair ops storage + in let%bind amount = trace_option (simple_error "getting amount for run") @@ Tezos_utils.Memory_proto_alpha.Alpha_context.Tez.of_mutez @@ Int64.of_int 10000000000 in let%bind result = easy_run_typed ~amount "buy_single" program input in Format.printf "\nResult : %a\n" Ast_typed.PP.value result ; - let expected = e_a_empty_bool (n = 0) in AST_Typed.assert_value_eq (expected, result) in let%bind _ = bind_list @@ List.map aux - @@ [0 ; 2 ; 7 ; 12] in + @@ [2 ; (* 0 ; 7 ; 12 *)] in ok () let main = "Coase (End to End)", [ diff --git a/src/ligo/test/test.ml b/src/ligo/test/test.ml index 3dbd250cb..2cb1ec87d 100644 --- a/src/ligo/test/test.ml +++ b/src/ligo/test/test.ml @@ -9,6 +9,6 @@ let () = Transpiler_tests.main ; Typer_tests.main ; Heap_tests.main ; - (* Coase_tests.main ; *) + Coase_tests.main ; ] ; ()