From 9ef69b45026e1dc94bb0b9c9161c6232af08f66a Mon Sep 17 00:00:00 2001 From: Pietro Date: Wed, 28 Feb 2018 14:57:22 +0100 Subject: [PATCH] Client, test: Add two more protocol injection tests (from alpha) --- .gitlab-ci.yml | 10 +++++ scripts/sandbox.json | 2 + src/bin_client/main_client.ml | 2 +- src/bin_client/test/jbuild | 36 ++++++++++++++++- src/bin_client/test/sandbox.json | 2 + src/bin_client/test/test_fork.sh | 45 +++++++++++++++++++++ src/bin_client/test/test_injection.sh | 5 ++- src/bin_client/test/test_injection_alpha.sh | 45 +++++++++++++++++++++ 8 files changed, 144 insertions(+), 3 deletions(-) create mode 100755 src/bin_client/test/test_fork.sh create mode 100755 src/bin_client/test/test_injection_alpha.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 974c49b97..933dee026 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -201,6 +201,16 @@ test:inject.sh: script: - jbuilder build @src/bin_client/runtest_injection.sh +test:inject_alpha.sh: + <<: *test_definition + script: + - jbuilder build @src/bin_client/runtest_injection_alpha.sh + +test:fork.sh: + <<: *test_definition + script: + - jbuilder build @src/bin_client/runtest_fork.sh + test:proto:sandbox: <<: *test_definition script: diff --git a/scripts/sandbox.json b/scripts/sandbox.json index be31b0762..fb5ad847e 100644 --- a/scripts/sandbox.json +++ b/scripts/sandbox.json @@ -1,6 +1,8 @@ { "genesis_pubkey": "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2", + "dictator_pubkey": + "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2", "bootstrap_keys": [ "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", "edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9", diff --git a/src/bin_client/main_client.ml b/src/bin_client/main_client.ml index 6a1a205c2..65605461d 100644 --- a/src/bin_client/main_client.ml +++ b/src/bin_client/main_client.ml @@ -19,7 +19,7 @@ let get_commands_for_version ctxt block protocol = if not (Protocol_hash.equal version given_version) then Format.eprintf "@[@{@{Warning@}@}@,\ - The protocol provided via `-protocol` (%a)@,\ + The protocol provided via `--protocol` (%a)@,\ is not the one retrieved from the node (%a).@]@\n@." Protocol_hash.pp_short given_version Protocol_hash.pp_short version ; diff --git a/src/bin_client/test/jbuild b/src/bin_client/test/jbuild index 30bcab81f..82f8bd7ad 100644 --- a/src/bin_client/test/jbuild +++ b/src/bin_client/test/jbuild @@ -66,9 +66,43 @@ ${bin:tezos-admin-client} )))) +(alias + ((name runtest_fork.sh) + (locks (/tcp-port/18731 + /tcp-port/19731)) + (deps (sandbox.json + test_lib.inc.sh + (glob_files demo/*) + )) + (action (run bash ${path:test_fork.sh} + ${bin:tezos-sandboxed-node.sh} + ${bin:tezos-node} + ${bin:tezos-init-sandboxed-client.sh} + ${bin:tezos-client} + ${bin:tezos-admin-client} + )))) + +(alias + ((name runtest_injection_alpha.sh) + (locks (/tcp-port/18731 + /tcp-port/19731)) + (deps (sandbox.json + test_lib.inc.sh + (glob_files demo/*) + )) + (action (run bash ${path:test_injection_alpha.sh} + ${bin:tezos-sandboxed-node.sh} + ${bin:tezos-node} + ${bin:tezos-init-sandboxed-client.sh} + ${bin:tezos-client} + ${bin:tezos-admin-client} + )))) + (alias ((name runtest) (deps ((alias runtest_basic.sh) (alias runtest_contracts.sh) (alias runtest_multinode.sh) - (alias runtest_injection.sh))))) + (alias runtest_injection.sh) + (alias runtest_injection_alpha.sh) + (alias runtest_fork.sh))))) diff --git a/src/bin_client/test/sandbox.json b/src/bin_client/test/sandbox.json index e1e382b24..87c0b22ff 100644 --- a/src/bin_client/test/sandbox.json +++ b/src/bin_client/test/sandbox.json @@ -1,6 +1,8 @@ { "genesis_pubkey": "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2", + "dictator_pubkey": + "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2", "bootstrap_keys": [ "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", "edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9", diff --git a/src/bin_client/test/test_fork.sh b/src/bin_client/test/test_fork.sh new file mode 100755 index 000000000..eee5143a8 --- /dev/null +++ b/src/bin_client/test/test_fork.sh @@ -0,0 +1,45 @@ +#! /usr/bin/env bash + +## from alpha to demo + +set -e + +test_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)")" +source $test_dir/test_lib.inc.sh "$@" + +start_node 1 + +$client list understood protocols + +activate_alpha + +show_logs="no" + +sleep 2 + +dictator_secret="edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6" + +# autogenerated from the demo source +protocol_version="Ps1ZDZdgRP4PFDkzmFpiYtE7gJHioavCMxC96i9zJsK6URwSXSJ" +protocol_short="Ps1ZDZdgRP4PFD" + +$client bake for bootstrap1 -max-priority 512 + +$client list understood protocols + +$admin_client inject protocol "$test_dir/demo" +$admin_client list protocols + +$client fork test protocol $protocol_version with key $dictator_secret + +$admin_client list protocols + +#these commands cannot be used in this case because the client does not +#know about the new protocol +#$client --protocol $protocol_short bake for bootstrap1 -max-priority 512 +#$client --protocol $protocol_version rpc call /blocks/head with {} + +echo +echo End of test +echo + diff --git a/src/bin_client/test/test_injection.sh b/src/bin_client/test/test_injection.sh index 4d981fcf5..8eb16b8b6 100755 --- a/src/bin_client/test/test_injection.sh +++ b/src/bin_client/test/test_injection.sh @@ -1,5 +1,7 @@ #! /usr/bin/env bash +## from genesis to demo + set -e test_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)")" @@ -7,6 +9,8 @@ source $test_dir/test_lib.inc.sh "$@" start_node 1 +show_logs="no" + sleep 2 # autogenerated from the demo source @@ -25,4 +29,3 @@ echo echo End of test echo -show_logs="no" diff --git a/src/bin_client/test/test_injection_alpha.sh b/src/bin_client/test/test_injection_alpha.sh new file mode 100755 index 000000000..dc4e1d73b --- /dev/null +++ b/src/bin_client/test/test_injection_alpha.sh @@ -0,0 +1,45 @@ +#! /usr/bin/env bash + +## from alpha to demo + +set -e + +test_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)")" +source $test_dir/test_lib.inc.sh "$@" + +start_node 1 + +$client list understood protocols + +activate_alpha + +show_logs="no" + +sleep 2 + +dictator_secret="edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6" + +# autogenerated from the demo source +protocol_version="Ps1ZDZdgRP4PFDkzmFpiYtE7gJHioavCMxC96i9zJsK6URwSXSJ" +protocol_short="Ps1ZDZdgRP4PFD" + +$client bake for bootstrap1 -max-priority 512 + +$client list understood protocols + +$admin_client inject protocol "$test_dir/demo" +$admin_client list protocols + +$client activate protocol $protocol_version with key $dictator_secret + +$admin_client list protocols + +#these commands cannot be used in this case because the client does not +#know about the new protocol +#$client --protocol $protocol_short bake for bootstrap1 -max-priority 512 +#$client --protocol $protocol_version rpc call /blocks/head with {} + +echo +echo End of test +echo +