Alpha/Tests: typos + useful tez related functions
This commit is contained in:
parent
ffcd0a0c09
commit
9f30b220e4
@ -151,7 +151,8 @@ module Forge = struct
|
|||||||
let contents
|
let contents
|
||||||
?(proof_of_work_nonce = default_proof_of_work_nonce)
|
?(proof_of_work_nonce = default_proof_of_work_nonce)
|
||||||
?(priority = 0) ?seed_nonce_hash () =
|
?(priority = 0) ?seed_nonce_hash () =
|
||||||
{ Block_header.priority ;
|
{
|
||||||
|
Block_header.priority ;
|
||||||
proof_of_work_nonce ;
|
proof_of_work_nonce ;
|
||||||
seed_nonce_hash ;
|
seed_nonce_hash ;
|
||||||
}
|
}
|
||||||
@ -349,12 +350,12 @@ let bake ?policy ?operation ?operations pred =
|
|||||||
Forge.sign_header header >>=? fun header ->
|
Forge.sign_header header >>=? fun header ->
|
||||||
apply header ?operations pred
|
apply header ?operations pred
|
||||||
|
|
||||||
|
(********** Cycles ****************)
|
||||||
|
|
||||||
(* This function is duplicated from Context to avoid a cyclic dependency *)
|
(* This function is duplicated from Context to avoid a cyclic dependency *)
|
||||||
let get_constants b =
|
let get_constants b =
|
||||||
Alpha_services.Constants.all rpc_ctxt b
|
Alpha_services.Constants.all rpc_ctxt b
|
||||||
|
|
||||||
(********** Cycles ****************)
|
|
||||||
|
|
||||||
let bake_n ?policy n b =
|
let bake_n ?policy n b =
|
||||||
Error_monad.fold_left_s
|
Error_monad.fold_left_s
|
||||||
(fun b _ -> bake ?policy b) b (1 -- n)
|
(fun b _ -> bake ?policy b) b (1 -- n)
|
||||||
|
@ -30,4 +30,16 @@ module Tez = struct
|
|||||||
match Tez.of_mutez (Int64.mul (Int64.of_int x) 1_000_000L) with
|
match Tez.of_mutez (Int64.mul (Int64.of_int x) 1_000_000L) with
|
||||||
| None -> invalid_arg "tez_of_int"
|
| None -> invalid_arg "tez_of_int"
|
||||||
| Some x -> x
|
| 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
|
end
|
||||||
|
@ -49,11 +49,6 @@ let n_transactions n b ?fee source dest amount =
|
|||||||
|
|
||||||
let ten_tez = Tez.of_int 10
|
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 *)
|
(* Tests *)
|
||||||
(*********************************************************************)
|
(*********************************************************************)
|
||||||
@ -301,7 +296,7 @@ let balance_too_low fee () =
|
|||||||
Incremental.begin_construction b >>=? fun i ->
|
Incremental.begin_construction b >>=? fun i ->
|
||||||
Context.Contract.balance (I i) contract_1 >>=? fun balance1 ->
|
Context.Contract.balance (I i) contract_1 >>=? fun balance1 ->
|
||||||
Context.Contract.balance (I i) contract_2 >>=? fun balance2 ->
|
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
|
let expect_failure = function
|
||||||
| Alpha_environment.Ecoproto_error (Contract_storage.Balance_too_low _) :: _ ->
|
| Alpha_environment.Ecoproto_error (Contract_storage.Balance_too_low _) :: _ ->
|
||||||
return ()
|
return ()
|
||||||
|
Loading…
Reference in New Issue
Block a user