From 9f30b220e427332255dd0f972ed4c0ce59b5cad6 Mon Sep 17 00:00:00 2001 From: bruno Date: Mon, 25 Jun 2018 21:57:58 +0200 Subject: [PATCH] Alpha/Tests: typos + useful tez related functions --- src/proto_alpha/lib_protocol/test/helpers/block.ml | 7 ++++--- .../lib_protocol/test/helpers/test_tez.ml | 12 ++++++++++++ src/proto_alpha/lib_protocol/test/transfer.ml | 7 +------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 31d95d422..0ec951c81 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -151,7 +151,8 @@ module Forge = struct let contents ?(proof_of_work_nonce = default_proof_of_work_nonce) ?(priority = 0) ?seed_nonce_hash () = - { Block_header.priority ; + { + Block_header.priority ; proof_of_work_nonce ; seed_nonce_hash ; } @@ -349,12 +350,12 @@ let bake ?policy ?operation ?operations pred = Forge.sign_header header >>=? fun header -> apply header ?operations pred +(********** Cycles ****************) + (* This function is duplicated from Context to avoid a cyclic dependency *) let get_constants b = Alpha_services.Constants.all rpc_ctxt b -(********** Cycles ****************) - let bake_n ?policy n b = Error_monad.fold_left_s (fun b _ -> bake ?policy b) b (1 -- n) diff --git a/src/proto_alpha/lib_protocol/test/helpers/test_tez.ml b/src/proto_alpha/lib_protocol/test/helpers/test_tez.ml index 35e7a45f6..5bad1992f 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/test_tez.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/test_tez.ml @@ -30,4 +30,16 @@ module Tez = struct match Tez.of_mutez (Int64.mul (Int64.of_int x) 1_000_000L) with | None -> invalid_arg "tez_of_int" | Some x -> x + + let of_mutez_exn x = + match Tez.of_mutez x with + | None -> invalid_arg "tez_of_mutez" + | Some x -> x + + + let max_tez = + match Tez.of_mutez Int64.max_int with + | None -> assert false + | Some p -> p + end diff --git a/src/proto_alpha/lib_protocol/test/transfer.ml b/src/proto_alpha/lib_protocol/test/transfer.ml index 872439787..86b981750 100644 --- a/src/proto_alpha/lib_protocol/test/transfer.ml +++ b/src/proto_alpha/lib_protocol/test/transfer.ml @@ -49,11 +49,6 @@ let n_transactions n b ?fee source dest amount = let ten_tez = Tez.of_int 10 -let max_tez = - match Tez.of_mutez Int64.max_int with - | None -> assert false - | Some p -> p - (*********************************************************************) (* Tests *) (*********************************************************************) @@ -301,7 +296,7 @@ let balance_too_low fee () = Incremental.begin_construction b >>=? fun i -> Context.Contract.balance (I i) contract_1 >>=? fun balance1 -> Context.Contract.balance (I i) contract_2 >>=? fun balance2 -> - Op.transaction ~fee (I i) contract_1 contract_2 max_tez >>=? fun op -> + Op.transaction ~fee (I i) contract_1 contract_2 Tez.max_tez >>=? fun op -> let expect_failure = function | Alpha_environment.Ecoproto_error (Contract_storage.Balance_too_low _) :: _ -> return ()