text stringlengths 0 601k |
|---|
let test_simple_balance_updates ( ) = Random . init 0 ; create_context ( ) >>=? fun ( ctxt , pkh ) -> let src = Contract . implicit_contract pkh in let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let dest = Contract . implicit_contract pkh in let amount = Tez . one in wrap ( Token . transfer ctxt ( ` Contract... |
let test_allocated_and_deallocated ctxt dest initial_status status_when_empty = wrap ( Token . allocated ctxt dest ) >>=? fun allocated -> Assert . equal_bool ~ loc : __LOC__ allocated initial_status >>=? fun ( ) -> let amount = Tez . one in wrap ( Token . transfer ctxt ` Minted dest amount ) >>=? fun ( ctxt ' , _ ) ->... |
let test_allocated_and_deallocated_when_empty ctxt dest = test_allocated_and_deallocated ctxt dest false false |
let test_allocated_and_still_allocated_when_empty ctxt dest initial_status = test_allocated_and_deallocated ctxt dest initial_status true |
let test_allocated ( ) = Random . init 0 ; create_context ( ) >>=? fun ( ctxt , pkh ) -> let dest = ` Delegate_balance pkh in test_allocated_and_still_allocated_when_empty ctxt dest true >>=? fun _ -> let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let dest = ` Contract ( Contract . implicit_contract pkh ) in... |
let check_sink_balances ctxt ctxt ' dest amount = wrap ( Token . balance ctxt dest ) >>=? fun bal_dest -> wrap ( Token . balance ctxt ' dest ) >>=? fun bal_dest ' -> bal_dest +? amount >>?= fun add_bal_dest_amount -> Assert . equal_tez ~ loc : __LOC__ bal_dest ' add_bal_dest_amount |
let test_transferring_to_sink ctxt sink amount expected_bupds = ( match sink with | ` Contract _ | ` Delegate_balance _ -> return_unit | _ -> wrap ( Token . transfer ctxt ` Minted sink Tez . zero ) >>=? fun ( ctxt ' , bupds ) -> check_sink_balances ctxt ctxt ' sink Tez . zero >>=? fun _ -> Assert . equal_bool ~ loc : _... |
let test_transferring_to_contract ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let dest = Contract . implicit_contract pkh in let amount = random_amount ( ) in test_transferring_to_sink ctxt ( ` Contract dest ) amount [ ( Contract dest , Credited amount , Block_application ) ] |
let test_transferring_to_collected_commitments ctxt = let amount = random_amount ( ) in let bpkh = Blinded_public_key_hash . zero in test_transferring_to_sink ctxt ( ` Collected_commitments bpkh ) amount [ ( Commitments bpkh , Credited amount , Block_application ) ] |
let test_transferring_to_delegate_balance ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let dest = Contract . implicit_contract pkh in wrap ( Token . transfer ctxt ` Minted ( ` Contract dest ) Tez . one ) >>=? fun ( ctxt , _ ) -> wrap ( Token . allocated ctxt ( ` Delegate_balance pkh ) ) >>=? fun all... |
let test_transferring_to_frozen_deposits ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let amount = random_amount ( ) in test_transferring_to_sink ctxt ( ` Frozen_deposits pkh ) amount [ ( Deposits pkh , Credited amount , Block_application ) ] |
let test_transferring_to_collected_fees ctxt = let amount = random_amount ( ) in test_transferring_to_sink ctxt ` Block_fees amount [ ( Block_fees , Credited amount , Block_application ) ] |
let test_transferring_to_legacy_deposits ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let amount = random_amount ( ) in let cycle = Cycle . ( add root ( Random . int 10 ) ) in test_transferring_to_sink ctxt ( ` Legacy_deposits ( pkh , cycle ) ) amount [ ( Legacy_deposits ( pkh , cycle ) , Credited a... |
let test_transferring_to_legacy_fees ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let amount = random_amount ( ) in let cycle = Cycle . ( add root ( Random . int 10 ) ) in test_transferring_to_sink ctxt ( ` Legacy_fees ( pkh , cycle ) ) amount [ ( Legacy_fees ( pkh , cycle ) , Credited amount , Bloc... |
let test_transferring_to_legacy_rewards ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let amount = random_amount ( ) in let cycle = Cycle . ( add root ( Random . int 10 ) ) in test_transferring_to_sink ctxt ( ` Legacy_rewards ( pkh , cycle ) ) amount [ ( Legacy_rewards ( pkh , cycle ) , Credited amou... |
let test_transferring_to_burned ctxt = let amount = random_amount ( ) in let minted_bupd = Receipt . ( Minted , Debited amount , Block_application ) in wrap ( Token . transfer ctxt ` Minted ` Burned amount ) >>=? fun ( _ , bupds ) -> Assert . equal_bool ~ loc : __LOC__ ( bupds = [ minted_bupd ; ( Burned , Credited amou... |
let test_transferring_to_sink ( ) = Random . init 0 ; create_context ( ) >>=? fun ( ctxt , _ ) -> test_transferring_to_contract ctxt >>=? fun _ -> test_transferring_to_collected_commitments ctxt >>=? fun _ -> test_transferring_to_delegate_balance ctxt >>=? fun _ -> test_transferring_to_frozen_deposits ctxt >>=? fun _ -... |
let check_src_balances ctxt ctxt ' src amount = wrap ( Token . balance ctxt src ) >>=? fun bal_src -> wrap ( Token . balance ctxt ' src ) >>=? fun bal_src ' -> bal_src ' +? amount >>?= fun add_bal_src ' _amount -> Assert . equal_tez ~ loc : __LOC__ bal_src add_bal_src ' _amount |
let test_transferring_from_unbounded_source ctxt src expected_bupds = wrap ( Token . transfer ctxt src ` Burned Tez . zero ) >>=? fun ( _ , bupds ) -> Assert . equal_bool ~ loc : __LOC__ ( bupds = [ ] ) true >>=? fun ( ) -> let amount = random_amount ( ) in wrap ( Token . transfer ctxt src ` Burned amount ) >>=? fun ( ... |
let test_transferring_from_bounded_source ctxt src amount expected_bupds = ( match src with | ` Contract _ | ` Delegate_balance _ -> return_unit | _ -> wrap ( Token . transfer ctxt src ` Burned Tez . zero ) >>=? fun ( ctxt ' , bupds ) -> check_src_balances ctxt ctxt ' src Tez . zero >>=? fun _ -> Assert . equal_bool ~ ... |
let test_transferring_from_contract ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let src = Contract . implicit_contract pkh in let amount = random_amount ( ) in test_transferring_from_bounded_source ctxt ( ` Contract src ) amount [ ( Contract src , Debited amount , Block_application ) ] |
let test_transferring_from_collected_commitments ctxt = let amount = random_amount ( ) in let bpkh = Blinded_public_key_hash . zero in test_transferring_from_bounded_source ctxt ( ` Collected_commitments bpkh ) amount [ ( Commitments bpkh , Debited amount , Block_application ) ] |
let test_transferring_from_delegate_balance ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let amount = random_amount ( ) in let src = Contract . implicit_contract pkh in wrap ( Token . transfer ctxt ` Minted ( ` Contract src ) Tez . one ) >>=? fun ( ctxt , _ ) -> test_transferring_from_bounded_source... |
let test_transferring_from_frozen_deposits ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let amount = random_amount ( ) in test_transferring_from_bounded_source ctxt ( ` Frozen_deposits pkh ) amount [ ( Deposits pkh , Debited amount , Block_application ) ] |
let test_transferring_from_collected_fees ctxt = let amount = random_amount ( ) in test_transferring_from_bounded_source ctxt ` Block_fees amount [ ( Block_fees , Debited amount , Block_application ) ] |
let test_transferring_from_legacy_deposits ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let amount = random_amount ( ) in let cycle = Cycle . ( add root ( Random . int 10 ) ) in test_transferring_from_bounded_source ctxt ( ` Legacy_deposits ( pkh , cycle ) ) amount [ ( Legacy_deposits ( pkh , cycle ... |
let test_transferring_from_legacy_fees ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let amount = random_amount ( ) in let cycle = Cycle . ( add root ( Random . int 10 ) ) in test_transferring_from_bounded_source ctxt ( ` Legacy_fees ( pkh , cycle ) ) amount [ ( Legacy_fees ( pkh , cycle ) , Debited ... |
let test_transferring_from_legacy_rewards ctxt = let ( pkh , _pk , _sk ) = Signature . generate_key ( ) in let amount = random_amount ( ) in let cycle = Cycle . ( add root ( Random . int 10 ) ) in test_transferring_from_bounded_source ctxt ( ` Legacy_rewards ( pkh , cycle ) ) amount [ ( Legacy_rewards ( pkh , cycle ) ,... |
let test_transferring_from_source ( ) = Random . init 0 ; create_context ( ) >>=? fun ( ctxt , _ ) -> test_transferring_from_unbounded_source ctxt ` Invoice ( fun am -> [ ( Invoice , Debited am , Block_application ) ] ) >>=? fun _ -> test_transferring_from_unbounded_source ctxt ` Bootstrap ( fun am -> [ ( Bootstrap , D... |
let cast_to_container_type x = match x with | ` Burned | ` Invoice | ` Bootstrap | ` Initial_commitments | ` Minted | ` Liquidity_baking_subsidies -> None | ` Contract _ as x -> Some x | ` Collected_commitments _ as x -> Some x | ` Delegate_balance _ as x -> Some x | ` Block_fees as x -> Some x |
let build_test_cases ( ) = create_context ( ) >>=? fun ( ctxt , pkh ) -> let origin = ` Contract ( Contract . implicit_contract pkh ) in let ( user1 , _ , _ ) = Signature . generate_key ( ) in let user1c = ` Contract ( Contract . implicit_contract user1 ) in let ( user2 , _ , _ ) = Signature . generate_key ( ) in let u... |
let check_src_balances ctxt ctxt ' src amount = match cast_to_container_type src with | None -> return_unit | Some src -> check_src_balances ctxt ctxt ' src amount |
let check_sink_balances ctxt ctxt ' dest amount = match cast_to_container_type dest with | None -> return_unit | Some dest -> check_sink_balances ctxt ctxt ' dest amount |
let rec check_balances ctxt ctxt ' src dest amount = match ( cast_to_container_type src , cast_to_container_type dest ) with | ( None , None ) -> return_unit | ( Some ( ` Delegate_balance d ) , Some ( ` Contract c as contract ) ) when Contract . implicit_contract d = c -> check_balances ctxt ctxt ' contract contract am... |
let test_all_combinations_of_sources_and_sinks ( ) = Random . init 0 ; build_test_cases ( ) >>=? fun ( ctxt , cases ) -> List . iter_es ( fun ( ( src , amount ) , dest ) -> ( match cast_to_container_type src with | None -> return ctxt | Some src -> wrap ( Token . transfer ctxt ` Minted src amount ) >>=? fun ( ctxt , _ ... |
let coalesce_balance_updates bu1 bu2 = match ( bu1 , bu2 ) with | ( ( bu1_bal , bu1_balupd , bu1_origin ) , ( bu2_bal , bu2_balupd , bu2_origin ) ) -> ( assert ( bu1_bal = bu2_bal ) ; assert ( bu1_origin = bu2_origin ) ; let open Receipt in match ( bu1_balupd , bu2_balupd ) with | ( Credited bu1_am , Credited bu2_am ) ... |
let check_balances_are_consistent ctxt1 ctxt2 elt = match elt with | # Token . container as elt -> Token . balance ctxt1 elt >>=? fun elt_bal1 -> Token . balance ctxt2 elt >>=? fun elt_bal2 -> assert ( elt_bal1 = elt_bal2 ) ; return_unit | ` Invoice | ` Bootstrap | ` Initial_commitments | ` Minted | ` Liquidity_baking_... |
let test_transfer_n ctxt src dest = Token . transfer_n ctxt src dest >>=? fun ( ctxt1 , bal_updates1 ) -> List . fold_left_es ( fun ( ctxt , bal_updates ) ( src , am ) -> Token . transfer ctxt src ` Burned am >>=? fun ( ctxt , debit_logs ) -> return ( ctxt , bal_updates @ debit_logs ) ) ( ctxt , [ ] ) src >>=? fun ( ct... |
let test_transfer_n_with_empty_source ( ) = Random . init 0 ; create_context ( ) >>=? fun ( ctxt , pkh ) -> wrap ( test_transfer_n ctxt [ ] ` Block_fees ) >>=? fun _ -> let dest = ` Delegate_balance pkh in wrap ( test_transfer_n ctxt [ ] dest ) |
let test_transfer_n_with_non_empty_source ( ) = Random . init 0 ; create_context ( ) >>=? fun ( ctxt , pkh ) -> let origin = ` Contract ( Contract . implicit_contract pkh ) in let ( user1 , _ , _ ) = Signature . generate_key ( ) in let user1c = ` Contract ( Contract . implicit_contract user1 ) in let ( user2 , _ , _ ) ... |
let tests = Tztest . [ tztest " transfer - balances " ` Quick test_simple_balances ; tztest " transfer - balance updates " ` Quick test_simple_balance_updates ; tztest " transfer - test allocated " ` Quick test_allocated ; tztest " transfer - test transfer to sink " ` Quick test_transferring_to_sink ; tztest " transfer... |
module Yaml = struct type t = | Scalar of string | List of t list | Record of ( string * t ) list let scalar str = Scalar str let list lst = List lst let record lst = Record lst module Pretty = Fmlib_pretty . Print let rec to_doc : t -> Pretty . doc = function | Scalar str -> Pretty . text str | List lst -> let open Pr... |
module Token = struct type t = | String of string | Colon | Dash let string str = String str let to_string : t -> string = function | String str -> " " < ^ str ^ " " > | Colon -> " ' ' " : | Dash -> " ' ' " - end |
module Token_plus = struct type t = Position . range * Token . t end |
module Lexer = struct module CP = Character . Make ( Unit ) ( Token_plus ) ( Fmlib_std . Void ) open CP let comment : char t = let * _ = char ' ' # in let * _ = ( charp ( fun c -> c <> ' \ n ' ) " comment character " ) |> skip_zero_or_more in return ' ' # let whitespace : int t = char ' ' </> char ' \ n ' </> comment |... |
module Combinator = struct module TP = Token_parser . Make ( Unit ) ( Token ) ( Yaml ) ( Fmlib_std . Void ) module Parser = TP . Parser open TP let string : string t = step " string " ( fun _ _ tok -> match tok with | Token . String str -> Some ( str , ( ) ) | _ -> None ) let colon : char t = step " ' ' " : ( fun _ _ t... |
module PL = struct include Parse_with_lexer . Make ( Unit ) ( Token ) ( Yaml ) ( Void ) ( Lex ) ( Parse ) let start : t = make Lex . init Combinator . parse end |
let write_error ( str : string ) ( p : PL . t ) : unit = let module Reporter = Error_reporter . Make ( PL ) in Reporter . ( make_syntax p |> run_on_string str |> Pretty . layout 50 |> Pretty . write_to_channel stdout ) let open PL in let str = { | names : - Alice - " Bob " :# category : encryption } | in let p = run_on... |
let test ( ? check = true ) iter n edges = let v = Array . init n V . create in let g = create ( ) in let ( ) = Array . iter ( add_vertex g ) v in let build ( s , t ) = add_edge g v . ( s ) v . ( t ) in List . iter build edges ; let num = Array . make n 0 in let i = ref 0 in iter ( fun v -> incr i ; num . ( V . label v... |
let tests iter = let test = test iter in test 3 [ 0 , 1 ; 1 , 2 ] ; test 3 [ ] ; test 1 [ 0 , 0 ] ; test 2 [ 0 , 1 ; 1 , 0 ] ; test 3 [ 0 , 1 ; 1 , 0 ; 1 , 2 ] ; test 3 [ 2 , 0 ; 0 , 2 ; 0 , 1 ] ; test 3 [ 1 , 2 ; 2 , 1 ; 2 , 0 ] ; test 5 [ 1 , 2 ; 2 , 1 ; 2 , 0 ; 3 , 4 ; 4 , 3 ] ; test 3 [ 1 , 2 ; 2 , 1 ; 0 , 2 ] ; te... |
let ( ) = tests Topological . iter |
let rec pow a = function | 0 -> 1 | 1 -> a | n -> let b = pow a ( n / 2 ) in b * b * ( if n mod 2 = 0 then 1 else a ) |
let ( ) = for n_iter = 0 to 5 do let n = pow 10 n_iter in let el = ref [ ] in el := [ n - 1 , 0 ] ; for i = 0 to n - 2 do el := ( i , i + 1 ) :: ! el done ; test ~ check : false Topological . iter n ! el done |
let transfer_to_itself_and_check_balances ~ loc b ( ? fee = Tez . zero ) contract amount = Context . Contract . balance ( I b ) contract >>=? fun bal -> Op . transaction ( I b ) ~ fee contract contract amount >>=? fun op -> Incremental . add_operation b op >>=? fun b -> Assert . balance_was_debited ~ loc ( I b ) contra... |
let ten_tez = of_int 10 |
let two_over_n_of_balance incr contract n = Context . Contract . balance ( I incr ) contract >>=? fun balance -> Lwt . return ( balance /? n >>? fun res -> res *? 2L ) |
let single_transfer ? fee ? expect_failure amount = Context . init2 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> Incremental . begin_construction b >>=? fun b -> transfer_and_check_balances ~ loc : __LOC__ ? fee ? expect_failure b contract_1 contract_2 amount >>=? fun ( b , _ ) -> Incremental . finalize_block b >>=?... |
let test_block_with_a_single_transfer ( ) = single_transfer Tez . one |
let test_block_with_a_single_transfer_with_fee ( ) = single_transfer ~ fee : Tez . one Tez . one |
let test_transfer_zero_tez ( ) = single_transfer ~ expect_failure ( : function | Environment . Ecoproto_error ( Apply . Empty_transaction _ as e ) :: _ -> Assert . test_error_encodings e ; return_unit | _ -> failwith " Empty transaction should fail " ) Tez . zero |
let test_transfer_zero_implicit ( ) = Context . init 1 >>=? fun ( b , contracts ) -> let dest = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in let account = Account . new_account ( ) in Incremental . begin_construction b >>=? fun i -> let src = Contract . implicit_contract account . Account ... |
let test_transfer_to_originate_with_fee ( ) = Context . init 1 >>=? fun ( b , contracts ) -> let contract = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in Incremental . begin_construction b >>=? fun b -> two_over_n_of_balance b contract 10L >>=? fun fee -> Op . contract_origination ( I b ) ~... |
let test_transfer_amount_of_contract_balance ( ) = Context . init2 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> Context . Contract . pkh contract_1 >>=? fun pkh1 -> Incremental . begin_construction b ~ policy ( : Block . Excluding [ pkh1 ] ) >>=? fun b -> Context . Contract . balance ( I b ) contract_1 >>=? fun bala... |
let test_transfers_to_self ( ) = Context . init 1 >>=? fun ( b , contracts ) -> let contract = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in Incremental . begin_construction b >>=? fun b -> two_over_n_of_balance b contract 3L >>=? fun amount -> transfer_to_itself_and_check_balances ~ loc : ... |
let test_missing_transaction ( ) = Context . init2 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> Context . Contract . pkh contract_1 >>=? fun pkh1 -> Incremental . begin_construction b ~ policy ( : Block . Excluding [ pkh1 ] ) >>=? fun b -> two_over_n_of_balance b contract_1 6L >>=? fun amount -> n_transactions 3 b c... |
let test_transfer_zero_implicit_with_bal_src_as_fee ( ) = Context . init 1 >>=? fun ( b , contracts ) -> let dest = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in let account = Account . new_account ( ) in Incremental . begin_construction b >>=? fun i -> let src = Contract . implicit_contrac... |
let test_transfer_zero_to_originated_with_bal_src_as_fee ( ) = Context . init 1 >>=? fun ( b , contracts ) -> let dest = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in let account = Account . new_account ( ) in Incremental . begin_construction b >>=? fun i -> let src = Contract . implicit_co... |
let test_transfer_one_to_implicit_with_bal_src_as_fee ( ) = Context . init 1 >>=? fun ( b , contracts ) -> let dest = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in let account = Account . new_account ( ) in Incremental . begin_construction b >>=? fun i -> let src = Contract . implicit_contr... |
let test_transfer_from_implicit_to_implicit_contract ( ) = Context . init 1 >>=? fun ( b , contracts ) -> let bootstrap_contract = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in let account_a = Account . new_account ( ) in let account_b = Account . new_account ( ) in Incremental . begin_cons... |
let test_transfer_from_implicit_to_originated_contract ( ) = Context . init 1 >>=? fun ( b , contracts ) -> let bootstrap_contract = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in let contract = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in let account = Account ... |
let multiple_transfer n ? fee amount = Context . init2 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> Incremental . begin_construction b >>=? fun b -> n_transactions n b ? fee contract_1 contract_2 amount >>=? fun b -> Incremental . finalize_block b >>=? fun _ -> return_unit |
let test_block_with_multiple_transfers ( ) = multiple_transfer 99 ( of_int 1000 ) |
let test_block_with_multiple_transfers_pay_fee ( ) = multiple_transfer 10 ~ fee : ten_tez ( of_int 1000 ) |
let test_block_with_multiple_transfers_with_without_fee ( ) = Context . init 8 >>=? fun ( b , contracts ) -> let contracts = Array . of_list contracts in Incremental . begin_construction b >>=? fun b -> let hundred = of_int 100 in let ten = of_int 10 in let twenty = of_int 20 in n_transactions 10 b contracts . ( 0 ) co... |
let test_build_a_chain ( ) = Context . init2 ~ consensus_threshold : 0 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> let ten = of_int 10 in List . fold_left_es ( fun b _ -> Incremental . begin_construction b >>=? fun b -> transfer_and_check_balances ~ loc : __LOC__ b contract_1 contract_2 ten >>=? fun ( b , _ ) -> In... |
let test_empty_implicit ( ) = Context . init 1 >>=? fun ( b , contracts ) -> let dest = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in let account = Account . new_account ( ) in Incremental . begin_construction b >>=? fun incr -> let src = Contract . implicit_contract account . Account . pkh... |
let test_balance_too_low fee ( ) = Context . init2 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> 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 ) con... |
let test_balance_too_low_two_transfers fee ( ) = Context . init 3 >>=? fun ( b , contracts ) -> let contract_1 = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 0 in let contract_2 = WithExceptions . Option . get ~ loc : __LOC__ @@ List . nth contracts 1 in let contract_3 = WithExceptions . Option... |
let invalid_counter ( ) = Context . init2 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> Incremental . begin_construction b >>=? fun b -> Op . transaction ( I b ) contract_1 contract_2 Tez . one >>=? fun op1 -> Op . transaction ( I b ) contract_1 contract_2 Tez . one >>=? fun op2 -> Incremental . add_operation b op1 >... |
let test_add_the_same_operation_twice ( ) = Context . init2 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> Incremental . begin_construction b >>=? fun b -> transfer_and_check_balances ~ loc : __LOC__ b contract_1 contract_2 ten_tez >>=? fun ( b , op_transfer ) -> Op . transaction ( I b ) contract_1 contract_2 ten_tez ... |
let invalid_counter_in_the_future ( ) = Context . init2 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> Incremental . begin_construction b >>=? fun b -> Context . Contract . counter ( I b ) contract_1 >>=? fun cpt -> let counter = Z . add cpt ( Z . of_int 10 ) in Op . transaction ( I b ) contract_1 contract_2 Tez . one... |
let test_ownership_sender ( ) = Context . init2 ( ) >>=? fun ( b , contract_1 , contract_2 ) -> Incremental . begin_construction b >>=? fun b -> Context . Contract . manager ( I b ) contract_1 >>=? fun manager -> let imcontract_1 = Alpha_context . Contract . implicit_contract manager . pkh in transfer_and_check_balance... |
let random_range ( min , max ) = let interv = max - min + 1 in let init = Random . self_init ( ) ; Random . int interv + min in init |
let random_contract contract_array = let i = Random . int ( Array . length contract_array ) in contract_array . ( i ) |
let test_random_transfer ( ) = Context . init 10 >>=? fun ( b , contracts ) -> let contracts = Array . of_list contracts in let source = random_contract contracts in let dest = random_contract contracts in Context . Contract . pkh source >>=? fun source_pkh -> Incremental . begin_construction b ~ policy ( : Block . Exc... |
let test_random_multi_transactions ( ) = let n = random_range ( 1 , 100 ) in multiple_transfer n ( of_int 100 ) |
let test_bad_entrypoint ( ) = Context . init 1 >>=? fun ( b , _cs ) -> Incremental . begin_construction b >>=? fun v -> let ctxt = Incremental . alpha_ctxt v in let storage = " Unit " in let parameter = " Unit " in let entrypoint = Entrypoint . of_string_strict_exn " bad entrypoint " in Contract_helpers . run_script ct... |
let test_bad_parameter ( ) = Context . init 1 >>=? fun ( b , _cs ) -> Incremental . begin_construction b >>=? fun v -> let ctxt = Incremental . alpha_ctxt v in let storage = " Unit " in let parameter = " 1 " in Contract_helpers . run_script ctxt " { parameter unit ; storage unit ; code { CAR ; NIL operation ; PAIR } } ... |
let transfer_to_itself_with_no_such_entrypoint ( ) = let entrypoint = Entrypoint . of_string_strict_exn " bad entrypoint " in Context . init 1 >>=? fun ( b , contract ) -> Incremental . begin_construction b >>=? fun i -> let addr = match contract with [ hd ] -> hd | _ -> assert false in Op . transaction ( B b ) addr ad... |
let tests = [ Tztest . tztest " single transfer " ` Quick test_block_with_a_single_transfer ; Tztest . tztest " single transfer with fee " ` Quick test_block_with_a_single_transfer_with_fee ; Tztest . tztest " single transfer zero tez " ` Quick test_transfer_zero_tez ; Tztest . tztest " transfer zero tez from implicit ... |
let test_parse_and_format kind_name ~ fg test_name ~ input ~ expected = let test_name = Stdlib . Format . sprintf " parse_and_format % s : % s " kind_name test_name in ( test_name , ` Quick , fun ( ) -> let actual = Translation_unit . parse_and_format fg ~ input_name " :< test " > ~ source : input Conf . default |> Res... |
let test_parse_and_format_signature = let make_test = test_parse_and_format " signature " ~ fg : Signature in [ make_test " val " ~ input " : val x :\ n \ nint " ~ expected ( : Ok " val x : int \ n " ) ] |
let test_parse_and_format_use_file = let make_test = test_parse_and_format " use_file " ~ fg : Use_file in [ make_test " let " ~ input " : let x =\ n \ n y " ~ expected ( : Ok " let x = y \ n " ) ] |
let test_parse_and_format_core_type = let make_test = test_parse_and_format " core_type " ~ fg : Core_type in [ make_test " string " ~ input " : string " ~ expected ( : Ok " string \ n " ) ; make_test " int " ~ input " : int " ~ expected ( : Ok " int \ n " ) ; make_test " arrow " ~ input " : int -> int " ~ expected ( :... |
let test_parse_and_format_module_type = let make_test = test_parse_and_format " module_type " ~ fg : Module_type in [ make_test " sig end " ~ input " : sig end " ~ expected ( : Ok " sig end \ n " ) ; make_test " sig end 2 " ~ input : " sig \ n \ n \ \ val x : foo -> bar \ n \ \ \ n \ n \ \ val f : a -> b -> c ->\ n \ n... |
let test_parse_and_format_expression = let make_test = test_parse_and_format " expression " ~ fg : Expression in [ make_test " List . map " ~ input " : List . map ( fun x ->\ nx * x ) [ ( 1 + 9 ) ; 2 ; 3 ] " ~ expected ( : Ok " List . map ( fun x -> x * x ) [ 1 + 9 ; 2 ; 3 ] \ n " ) ] |
let reindent ~ source ~ range indents = let low , high = Range . get range in let lines = String . split_lines source in let low = low - 1 and high = high - 1 in String . concat ~ sep " :\ n " @@ List . mapi lines ~ f ( : fun i line -> if i < low then line else if low <= i && i <= high then let indent = List . nth_exn ... |
let test_numeric = let make_test name ~ source ~ range expected = let test_name = " numeric : " ^ name in ( test_name , ` Quick , fun ( ) -> let range = Range . make ~ range source in let got = Translation_unit . numeric Use_file ~ input_name " : _ " ~ source ~ range Conf . default |> reindent ~ source ~ range in Alcot... |
let foooooooooooo = let foooooooooooooo = |
let woooooooooooooooo = koooooooooooooooo in baaaaaar in hooohoooo } | ~ range ( : 1 , 7 ) { | let foooooooooooo = let foooooooo = foooooooooooo in foooooooooooo |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.