Alpha: drop old tests
This commit is contained in:
parent
ec6db686d9
commit
a09f2cc53e
@ -177,21 +177,6 @@ test:p2p:banned_peers:
|
|||||||
script:
|
script:
|
||||||
- jbuilder build @src/lib_p2p/runtest_p2p_banned_peers
|
- jbuilder build @src/lib_p2p/runtest_p2p_banned_peers
|
||||||
|
|
||||||
# test:client_alpha:transaction:
|
|
||||||
# <<: *test_definition
|
|
||||||
# script:
|
|
||||||
# - jbuilder build @src/proto_alpha/lib_delegate/runtest_transaction
|
|
||||||
|
|
||||||
# test:client_alpha:origination:
|
|
||||||
# <<: *test_definition
|
|
||||||
# script:
|
|
||||||
# - jbuilder build @src/proto_alpha/lib_delegate/runtest_origination
|
|
||||||
|
|
||||||
# test:client_alpha:endorsement:
|
|
||||||
# <<: *test_definition
|
|
||||||
# script:
|
|
||||||
# - jbuilder build @src/proto_alpha/lib_baking/runtest_endorsement
|
|
||||||
|
|
||||||
test:client_alpha:vote:
|
test:client_alpha:vote:
|
||||||
<<: *test_definition
|
<<: *test_definition
|
||||||
script:
|
script:
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
(executables
|
(executables
|
||||||
((names (test_michelson_parser
|
((names (test_michelson_parser
|
||||||
test_origination
|
|
||||||
test_transaction
|
|
||||||
test_rpc
|
test_rpc
|
||||||
test_vote))
|
test_vote))
|
||||||
(libraries (tezos-base
|
(libraries (tezos-base
|
||||||
@ -29,8 +27,6 @@
|
|||||||
(alias
|
(alias
|
||||||
((name buildtest)
|
((name buildtest)
|
||||||
(deps (test_michelson_parser.exe
|
(deps (test_michelson_parser.exe
|
||||||
;test_origination.exe
|
|
||||||
;test_transaction.exe
|
|
||||||
test_rpc.exe
|
test_rpc.exe
|
||||||
test_vote.exe))))
|
test_vote.exe))))
|
||||||
|
|
||||||
@ -38,16 +34,6 @@
|
|||||||
((name runtest_michelson_parser)
|
((name runtest_michelson_parser)
|
||||||
(action (run ${exe:test_michelson_parser.exe}))))
|
(action (run ${exe:test_michelson_parser.exe}))))
|
||||||
|
|
||||||
(alias
|
|
||||||
((name runtest_origination)
|
|
||||||
(locks (/tcp-port/18200))
|
|
||||||
(action (chdir ${ROOT} (run ${exe:test_origination.exe} ${bin:tezos-node} 18200)))))
|
|
||||||
|
|
||||||
(alias
|
|
||||||
((name runtest_transaction)
|
|
||||||
(locks (/tcp-port/18300))
|
|
||||||
(action (chdir ${ROOT} (run ${exe:test_transaction.exe} ${bin:tezos-node} 18300)))))
|
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
((name runtest_vote)
|
((name runtest_vote)
|
||||||
(locks (/tcp-port/18400))
|
(locks (/tcp-port/18400))
|
||||||
@ -61,8 +47,6 @@
|
|||||||
(alias
|
(alias
|
||||||
((name runtest)
|
((name runtest)
|
||||||
(deps ((alias runtest_michelson_parser)
|
(deps ((alias runtest_michelson_parser)
|
||||||
;(alias runtest_origination)
|
|
||||||
;(alias runtest_transaction)
|
|
||||||
(alias runtest_rpc)
|
(alias runtest_rpc)
|
||||||
(alias runtest_vote)))))
|
(alias runtest_vote)))))
|
||||||
|
|
||||||
|
@ -1,100 +0,0 @@
|
|||||||
(**************************************************************************)
|
|
||||||
(* *)
|
|
||||||
(* Copyright (c) 2014 - 2018. *)
|
|
||||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
||||||
(* *)
|
|
||||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
||||||
(* *)
|
|
||||||
(**************************************************************************)
|
|
||||||
|
|
||||||
open Proto_alpha
|
|
||||||
open Alpha_context
|
|
||||||
module Helpers = Proto_alpha_helpers
|
|
||||||
module Assert = Helpers.Assert
|
|
||||||
|
|
||||||
let run blkid ({ b1 ; b2 ; _ } : Helpers.Account.bootstrap_accounts) =
|
|
||||||
|
|
||||||
let cents v =
|
|
||||||
match Tez.( *? ) Tez.one_cent v with
|
|
||||||
| Error _ -> Pervasives.failwith "cents"
|
|
||||||
| Ok r -> r in
|
|
||||||
|
|
||||||
Helpers.Baking.bake blkid b1 [] >>=? fun blkh ->
|
|
||||||
let foo = Helpers.Account.create "foo" in
|
|
||||||
|
|
||||||
(* Origination with amount = 0 tez *)
|
|
||||||
Helpers.Account.originate
|
|
||||||
~src:foo
|
|
||||||
~manager_pkh:foo.pkh
|
|
||||||
~balance:Tez.zero () >>= fun result ->
|
|
||||||
Assert.unknown_contract ~msg:__LOC__ result ;
|
|
||||||
|
|
||||||
(* Origination with amount > 1 tez *)
|
|
||||||
Helpers.Account.originate
|
|
||||||
~src:b1
|
|
||||||
~manager_pkh:foo.pkh
|
|
||||||
~balance:Tez.one () >>=? fun _result ->
|
|
||||||
(* TODO: test if new contract exists *)
|
|
||||||
|
|
||||||
(* Non-delegatable contract *)
|
|
||||||
Helpers.Account.originate
|
|
||||||
~src:b1
|
|
||||||
~manager_pkh:b1.pkh
|
|
||||||
~balance:(cents 1000L) () >>=? fun (_oph, nd_contract) ->
|
|
||||||
|
|
||||||
(* Delegatable contract *)
|
|
||||||
Helpers.Account.originate
|
|
||||||
~src:b1
|
|
||||||
~manager_pkh:b1.pkh
|
|
||||||
~delegate:b1.pkh
|
|
||||||
~balance:(cents 1000L) () >>=? fun (_oph, d_contract) ->
|
|
||||||
|
|
||||||
(* Change delegate of a non-delegatable contract *)
|
|
||||||
let manager_sk = Client_keys.Secret_key_locator.create
|
|
||||||
~scheme:"unencrypted"
|
|
||||||
~location:(Signature.Secret_key.to_b58check b1.sk) in
|
|
||||||
|
|
||||||
Helpers.Account.set_delegate
|
|
||||||
~fee:(cents 5L)
|
|
||||||
~contract:nd_contract
|
|
||||||
~manager_sk
|
|
||||||
~src_pk:b1.pk
|
|
||||||
(Some b2.pkh) >>= fun result ->
|
|
||||||
Assert.non_delegatable ~msg:__LOC__ result ;
|
|
||||||
|
|
||||||
(* Change delegate of a delegatable contract *)
|
|
||||||
Helpers.Account.set_delegate
|
|
||||||
~contract:d_contract
|
|
||||||
~manager_sk
|
|
||||||
~src_pk:b1.pk
|
|
||||||
(Some b2.pkh) >>=? fun _result ->
|
|
||||||
Assert.delegate_equal ~msg:__LOC__ d_contract (Some b2.pkh) >>=? fun () ->
|
|
||||||
|
|
||||||
return blkh
|
|
||||||
|
|
||||||
let exe = try Sys.argv.(1) with _ -> "tezos-node"
|
|
||||||
let sandbox = try Sys.argv.(2) with _ -> "sandbox.json"
|
|
||||||
let rpc_port = try int_of_string Sys.argv.(3) with _ -> 18200
|
|
||||||
|
|
||||||
let main () =
|
|
||||||
Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
|
|
||||||
run (`Hash (genesis, 0)) Helpers.Account.bootstrap_accounts >>=? fun _blkh ->
|
|
||||||
return ()
|
|
||||||
|
|
||||||
let tests = [
|
|
||||||
"main", (fun _ -> main ()) ;
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let wrap (n, f) =
|
|
||||||
Alcotest_lwt.test_case n `Quick begin fun _ () ->
|
|
||||||
f () >>= function
|
|
||||||
| Ok () -> Lwt.return_unit
|
|
||||||
| Error error ->
|
|
||||||
Format.kasprintf Pervasives.failwith "%a" pp_print_error error
|
|
||||||
end
|
|
||||||
|
|
||||||
let () =
|
|
||||||
Alcotest.run ~argv:[|""|] "tezos-client-alpha" [
|
|
||||||
"origination", List.map wrap tests
|
|
||||||
]
|
|
@ -1,124 +0,0 @@
|
|||||||
(**************************************************************************)
|
|
||||||
(* *)
|
|
||||||
(* Copyright (c) 2014 - 2018. *)
|
|
||||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
||||||
(* *)
|
|
||||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
||||||
(* *)
|
|
||||||
(**************************************************************************)
|
|
||||||
|
|
||||||
open Proto_alpha
|
|
||||||
open Alpha_context
|
|
||||||
module Helpers = Proto_alpha_helpers
|
|
||||||
module Assert = Helpers.Assert
|
|
||||||
|
|
||||||
let run blkid ({ b1 ; b2 ; b3 ; _ } : Helpers.Account.bootstrap_accounts) =
|
|
||||||
|
|
||||||
Helpers.Baking.bake blkid b1 [] >>=? fun blkh ->
|
|
||||||
let foo = Helpers.Account.create "foo" in
|
|
||||||
let bar = Helpers.Account.create "bar" in
|
|
||||||
|
|
||||||
let tez v =
|
|
||||||
match Tez.( *? ) Tez.one v with
|
|
||||||
| Error _ -> Pervasives.failwith "cents"
|
|
||||||
| Ok r -> r in
|
|
||||||
|
|
||||||
(* Send from a sender with no balance (never seen). *)
|
|
||||||
(* TODO: Is it OK to get Storage_error and not something more specific? *)
|
|
||||||
Helpers.Account.transfer
|
|
||||||
~account:foo
|
|
||||||
~destination:b1.contract
|
|
||||||
~amount:(tez 1000L) () >>= fun result ->
|
|
||||||
Assert.unknown_contract ~msg:__LOC__ result ;
|
|
||||||
|
|
||||||
(* Send 1000 tz to "foo". *)
|
|
||||||
Helpers.Account.transfer
|
|
||||||
~account:b1
|
|
||||||
~destination:foo.contract
|
|
||||||
~fee:Tez.zero
|
|
||||||
~amount:(tez 1000L) () >>=? fun (_oph, contracts) ->
|
|
||||||
Assert.balance_equal ~msg:__LOC__ foo 1000_000_000L >>=? fun () ->
|
|
||||||
|
|
||||||
(* Check that a basic transfer originates no contracts. *)
|
|
||||||
Assert.equal_int ~msg:__LOC__ 0 (List.length contracts) ;
|
|
||||||
|
|
||||||
(* Check sender/receiver balance post transaction *)
|
|
||||||
Helpers.Account.transfer
|
|
||||||
~account:foo
|
|
||||||
~destination:bar.contract
|
|
||||||
~fee:Tez.zero
|
|
||||||
~amount:(tez 50L) () >>=? fun _contracts ->
|
|
||||||
Assert.balance_equal ~msg:__LOC__ foo 950_000_000L >>=? fun () ->
|
|
||||||
Assert.balance_equal ~msg:__LOC__ bar 50_000_000L >>=? fun () ->
|
|
||||||
|
|
||||||
(* Check balance too low. *)
|
|
||||||
Helpers.Account.transfer
|
|
||||||
~account:bar
|
|
||||||
~destination:foo.contract
|
|
||||||
~amount:(tez 1000L) () >>= fun result ->
|
|
||||||
Assert.balance_too_low ~msg:__LOC__ result ;
|
|
||||||
|
|
||||||
(* Check spendability of a spendable contract *)
|
|
||||||
Helpers.Account.originate
|
|
||||||
~src:foo
|
|
||||||
~manager_pkh:foo.pkh
|
|
||||||
~balance:(tez 50L) () >>=? fun (_oph, spendable) ->
|
|
||||||
Format.printf "Created contract %a@." Contract.pp spendable ;
|
|
||||||
let account = { foo with contract = spendable } in
|
|
||||||
Helpers.Account.transfer
|
|
||||||
~account
|
|
||||||
~destination:foo.contract
|
|
||||||
~amount:(tez 10L) () >>=? fun _contracts ->
|
|
||||||
|
|
||||||
(* Try spending a default account with unmatching pk/sk pairs. *)
|
|
||||||
let account = { b1 with sk = b2.sk } in
|
|
||||||
Helpers.Account.transfer
|
|
||||||
~account
|
|
||||||
~destination:b2.contract
|
|
||||||
~amount:(tez 10L) () >>= fun result ->
|
|
||||||
Assert.generic_economic_error ~msg:__LOC__ result ;
|
|
||||||
|
|
||||||
(* Try spending a default account with keys not matching the
|
|
||||||
contract pkh. *)
|
|
||||||
let account = { b1 with contract = b2.contract } in
|
|
||||||
Helpers.Account.transfer
|
|
||||||
~account
|
|
||||||
~destination:b3.contract
|
|
||||||
~amount:(tez 10L) () >>= fun result ->
|
|
||||||
Assert.inconsistent_public_key ~msg:__LOC__ result ;
|
|
||||||
|
|
||||||
(* Try spending an originated contract without the manager's key. *)
|
|
||||||
let account = { b1 with contract = spendable } in
|
|
||||||
Helpers.Account.transfer
|
|
||||||
~account
|
|
||||||
~destination:b2.contract
|
|
||||||
~amount:(tez 10L) () >>= fun result ->
|
|
||||||
Assert.inconsistent_public_key ~msg:__LOC__ result ;
|
|
||||||
|
|
||||||
return blkh
|
|
||||||
|
|
||||||
let exe = try Sys.argv.(1) with _ -> "tezos-node"
|
|
||||||
let sandbox = try Sys.argv.(2) with _ -> "sandbox.json"
|
|
||||||
let rpc_port = try int_of_string Sys.argv.(3) with _ -> 18300
|
|
||||||
|
|
||||||
let main () =
|
|
||||||
Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
|
|
||||||
run (`Hash (genesis, 0)) Helpers.Account.bootstrap_accounts >>=? fun _blkh ->
|
|
||||||
return ()
|
|
||||||
|
|
||||||
let tests = [
|
|
||||||
"main", (fun _ -> main ()) ;
|
|
||||||
]
|
|
||||||
|
|
||||||
let wrap (n, f) =
|
|
||||||
Alcotest_lwt.test_case n `Quick begin fun _ () ->
|
|
||||||
f () >>= function
|
|
||||||
| Ok () -> Lwt.return_unit
|
|
||||||
| Error error ->
|
|
||||||
Format.kasprintf Pervasives.failwith "%a" pp_print_error error
|
|
||||||
end
|
|
||||||
|
|
||||||
let () =
|
|
||||||
Alcotest.run ~argv:[|""|] "tezos-client-alpha" [
|
|
||||||
"transactions", List.map wrap tests
|
|
||||||
]
|
|
Loading…
Reference in New Issue
Block a user