Jbuilder: install tezos-sandboxed-node.sh/tezos-init-sandboxed-client.sh
This commit is contained in:
parent
be04cb027b
commit
d8d54ce321
12
README.md
12
README.md
@ -141,15 +141,15 @@ Running the node in a sandbox
|
||||
To run a 'localhost-only' instance of a Tezos network, we provide two
|
||||
helper scripts:
|
||||
|
||||
- `./scripts/launch-sandboxed-node.sh`
|
||||
- `./scripts/init-sandboxed-client.sh`
|
||||
- `./bin_node/tezos-sandboxed-node.sh`
|
||||
- `./bin_client/tezos-init-sandboxed-client.sh`
|
||||
|
||||
For instance, if you want to run local network with two nodes, in a
|
||||
first terminal, the following command will initialize a node listening
|
||||
for peers on port `19731` and listening for RPC on port `18731`.
|
||||
|
||||
```
|
||||
./scripts/launch-sandboxed-node.sh 1
|
||||
./bin_node/tezos-sandboxed-node.sh 1
|
||||
```
|
||||
|
||||
This node will store its data in a temporary directory which will be
|
||||
@ -159,7 +159,7 @@ To launch the second node, just run the following command, it will
|
||||
listen on port `19739` and `18739`:
|
||||
|
||||
```
|
||||
./scripts/launch-sandboxed-node.sh 9
|
||||
./bin_node/tezos-sandboxed-node.sh 9
|
||||
```
|
||||
|
||||
You might replace `1` or `9` by any number in between if you want to
|
||||
@ -169,14 +169,14 @@ by lowering the number of expected connection, by running the
|
||||
following command instead:
|
||||
|
||||
```
|
||||
./scripts/launch-sandboxed-node.sh 1 --connections 0
|
||||
./bin_node/tezos-sandboxed-node.sh 1 --connections 0
|
||||
```
|
||||
|
||||
Once your node(s) is/are running, open a new terminal and initialize
|
||||
the "sandboxed" client data:
|
||||
|
||||
```
|
||||
eval `./scripts/init-sandboxed-client.sh 1`
|
||||
eval `./bin_client/tezos-init-sandboxed-client.sh 1`
|
||||
```
|
||||
|
||||
It will initialize the client data in a temporary directory. It will
|
||||
|
@ -13,6 +13,10 @@
|
||||
-open Tezos_client_base
|
||||
-linkall))))
|
||||
|
||||
(install
|
||||
((section bin)
|
||||
(files ((tezos-init-sandboxed-client.sh as tezos-init-sandboxed-client.sh)))))
|
||||
|
||||
(alias
|
||||
((name runtest_indent)
|
||||
(deps ((glob_files *.ml) (glob_files *.mli)))
|
||||
|
65
scripts/client_lib.inc.sh → bin_client/tezos-init-sandboxed-client.sh
Normal file → Executable file
65
scripts/client_lib.inc.sh → bin_client/tezos-init-sandboxed-client.sh
Normal file → Executable file
@ -1,5 +1,7 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
client_dir="${client_dir:=$HOME/.tezos-client}"
|
||||
client="${client:=tezos-client -base-dir $client_dir}"
|
||||
|
||||
@ -13,7 +15,6 @@ init_sandboxed_client() {
|
||||
rpc=$((18730 + id))
|
||||
client_dir="$(mktemp -d -t tezos-client.XXXXXXXX)"
|
||||
client_dirs+=("$client_dir")
|
||||
local_client=${local_client:-$src_dir/_build/default/bin_client/main.exe}
|
||||
client="$local_client -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
|
||||
|
||||
}
|
||||
@ -211,3 +212,65 @@ activate_alpha() {
|
||||
and key dictator
|
||||
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Small script to initialize a client to a local and closed test network with a maximum of 9 nodes."
|
||||
echo
|
||||
echo "Usage: eval \`$0 <id>\`"
|
||||
echo " where <id> should be an integer between 1 and 9."
|
||||
}
|
||||
|
||||
main () {
|
||||
|
||||
local bin_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||
if [ $(basename "$bin_dir") = "bin_client" ]; then
|
||||
local_client="${local_client:-$bin_dir/../_build/default/bin_client/main.exe}"
|
||||
fi
|
||||
|
||||
if [ $# -lt 1 ] || [ "$1" -le 0 ] || [ 10 -le "$1" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
init_sandboxed_client "$1"
|
||||
|
||||
add_sandboxed_bootstrap_identities | sed -e 's/^/## /' 1>&2
|
||||
|
||||
cat <<EOF
|
||||
if type tezos-client-reset >/dev/null 2>&1 ; then tezos-client-reset; fi ;
|
||||
alias tezos-client="$client" ;
|
||||
alias tezos-activate-alpha="$client -block genesis activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK with fitness 1 and passes 1 and key dictator" ;
|
||||
alias tezos-client-reset="rm -rf \"$client_dir\"; unalias tezos-client tezos-activate-alpha tezos-client-reset" ;
|
||||
alias tezos-autocomplete="source \"$script_dir/bash-completion.sh\"" ;
|
||||
trap tezos-client-reset EXIT ;
|
||||
EOF
|
||||
|
||||
(cat | sed -e 's/^/## /') 1>&2 <<EOF
|
||||
|
||||
The client is now properly initialized. In the rest of this shell
|
||||
session, you might now run \`tezos-client\` to communicate with a
|
||||
tezos node launched with \`launch-sandboxed-node $1\`. For instance:
|
||||
|
||||
tezos-client rpc call blocks/head/protocol
|
||||
|
||||
Note: if the current protocol version, as reported by the previous
|
||||
command, is "ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im", you
|
||||
may have to activate in your "sandboxed network" the same economic
|
||||
protocol than used by the alphanet by running:
|
||||
|
||||
tezos-activate-alpha
|
||||
|
||||
Warning: all the client data will be removed when you close this shell
|
||||
or if you run this command a second time.
|
||||
|
||||
Activate tab completion by running:
|
||||
|
||||
tezos-autocomplete
|
||||
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
if [ "$0" == "$BASH_SOURCE" ]; then
|
||||
main "$@"
|
||||
fi
|
@ -24,6 +24,10 @@
|
||||
-open Tezos_node_shell
|
||||
-linkall))))
|
||||
|
||||
(install
|
||||
((section bin)
|
||||
(files ((tezos-sandboxed-node.sh as tezos-sandboxed-node.sh)))))
|
||||
|
||||
(alias
|
||||
((name runtest_indent)
|
||||
(deps ((glob_files *.ml) (glob_files *.mli)))
|
||||
|
38
scripts/node_lib.inc.sh → bin_node/tezos-sandboxed-node.sh
Normal file → Executable file
38
scripts/node_lib.inc.sh → bin_node/tezos-sandboxed-node.sh
Normal file → Executable file
@ -1,5 +1,7 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
node_dirs=()
|
||||
node_pids=()
|
||||
|
||||
@ -20,8 +22,7 @@ start_sandboxed_node() {
|
||||
peers+=("127.0.0.1:$peer_port")
|
||||
done
|
||||
peers+=("--closed")
|
||||
local_node="${local_node:-$src_dir/_build/default/bin_node/main.exe}"
|
||||
node="$local_node"
|
||||
node="${local_node:-tezos-node}"
|
||||
sandbox_file="${sandbox_file:-$script_dir/sandbox.json}"
|
||||
sandbox_param="--sandbox=$sandbox_file"
|
||||
|
||||
@ -44,3 +45,36 @@ cleanup_nodes() {
|
||||
for pid in "${node_pids[@]}" ; do wait "$pid" ; done
|
||||
rm -rf "${node_dirs[@]}"
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
|
||||
local bin_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||
if [ $(basename "$bin_dir") = "bin_node" ]; then
|
||||
local_node="${local_node:-$bin_dir/../_build/default/bin_node/main.exe}"
|
||||
sandbox_file="${sandbox_file:-$bin_dir/../scripts/sandbox.json}"
|
||||
fi
|
||||
|
||||
if [ $# -lt 1 ] || [ "$1" -le 0 ] || [ 10 -le "$1" ]; then
|
||||
echo "Small script to launch local and closed test network with a maximum of 9 nodes."
|
||||
echo
|
||||
echo "Usage: $0 <id>"
|
||||
echo " where <id> should be an integer between 1 and 9."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cleanup () {
|
||||
set +e
|
||||
echo Cleaning up...
|
||||
cleanup_nodes
|
||||
}
|
||||
trap cleanup EXIT INT
|
||||
|
||||
start_sandboxed_node "$@"
|
||||
wait $node_pids
|
||||
|
||||
}
|
||||
|
||||
if [ "$0" == "$BASH_SOURCE" ]; then
|
||||
main "$@"
|
||||
fi
|
@ -4,5 +4,5 @@ COPY . tezos
|
||||
|
||||
RUN sudo chown -R opam /home/opam/tezos && \
|
||||
cd tezos && \
|
||||
opam config exec -- make all && \
|
||||
opam config exec -- make build-test
|
||||
opam config exec -- jbuilder build @install && \
|
||||
opam config exec -- jbuilder install
|
||||
|
@ -39,7 +39,6 @@ RUN sudo chown root:root bin/* && \
|
||||
|
||||
RUN sudo cp scripts/docker_entrypoint.sh /usr/local/bin/tezos && \
|
||||
sudo cp scripts/docker_entrypoint.inc.sh \
|
||||
scripts/client_lib.inc.sh \
|
||||
/usr/local/bin/ && \
|
||||
sudo chmod a+rx /usr/local/bin/tezos
|
||||
|
||||
|
@ -14,17 +14,14 @@ build_image_name="${3:-${image_name}_build:${image_version}}"
|
||||
cleanup () {
|
||||
set +e
|
||||
echo Cleaning up...
|
||||
[ -z "$tmp_container" ] || docker rm -f "$tmp_container"
|
||||
rm -rf Dockerfile bin
|
||||
}
|
||||
trap cleanup EXIT INT
|
||||
|
||||
tmp_container="$(docker run -dit "$build_image_name" /bin/sh -c "mkdir /home/opam/bin && cp /home/opam/tezos/tezos-* /home/opam/bin")"
|
||||
docker run -dit --rm --volume $(pwd)/bin:/home/opam/bin "$build_image_name" \
|
||||
/bin/sh -c "sudo cp -L /home/opam/tezos/_build/install/default/bin/* /home/opam/bin"
|
||||
|
||||
ret=$(docker wait "$tmp_container")
|
||||
if [ "$ret" -ne 0 ]; then exit $ret; fi
|
||||
|
||||
docker cp "$tmp_container":/home/opam/bin/ bin
|
||||
ls bin
|
||||
|
||||
echo
|
||||
echo "### Building minimal docker image..."
|
||||
@ -37,3 +34,5 @@ docker build -t "$image_name:$image_version" .
|
||||
echo
|
||||
echo "### Succesfully build docker image: $image_name:$image_version"
|
||||
echo
|
||||
|
||||
rm -r bin
|
||||
|
@ -12,7 +12,7 @@ export client_dir="$data_dir/client"
|
||||
export node="tezos-node"
|
||||
export client="tezos-client -base-dir $client_dir"
|
||||
|
||||
. "${script_dir}"/client_lib.inc.sh
|
||||
. tezos-init-sandboxed-client.sh
|
||||
. "${script_dir}"/docker_entrypoint.inc.sh
|
||||
|
||||
usage() {
|
||||
|
@ -1,58 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||
src_dir="$(dirname "$script_dir")"
|
||||
cd "$src_dir"
|
||||
|
||||
usage() {
|
||||
echo "Small script to initialize a client to a local and closed test network with a maximum of 9 nodes."
|
||||
echo
|
||||
echo "Usage: eval \`$0 <id>\`"
|
||||
echo " where <id> should be an integer between 1 and 9."
|
||||
}
|
||||
|
||||
if [ $# -lt 1 ] || [ "$1" -le 0 ] || [ 10 -le "$1" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. "$script_dir/client_lib.inc.sh"
|
||||
|
||||
init_sandboxed_client "$1"
|
||||
|
||||
add_sandboxed_bootstrap_identities | sed -e 's/^/## /' 1>&2
|
||||
|
||||
cat <<EOF
|
||||
if type tezos-client-reset >/dev/null 2>&1 ; then tezos-client-reset; fi ;
|
||||
alias tezos-client="$client" ;
|
||||
alias tezos-activate-alpha="$client -block genesis activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK with fitness 1 and passes 1 and key dictator" ;
|
||||
alias tezos-client-reset="rm -rf \"$client_dir\"; unalias tezos-client tezos-activate-alpha tezos-client-reset" ;
|
||||
alias tezos-autocomplete="source \"$script_dir/bash-completion.sh\"" ;
|
||||
trap tezos-client-reset EXIT ;
|
||||
EOF
|
||||
|
||||
(cat | sed -e 's/^/## /') 1>&2 <<EOF
|
||||
|
||||
The client is now properly initialized. In the rest of this shell
|
||||
session, you might now run \`tezos-client\` to communicate with a
|
||||
tezos node launched with \`launch-sandboxed-node $1\`. For instance:
|
||||
|
||||
tezos-client rpc call blocks/head/protocol
|
||||
|
||||
Note: if the current protocol version, as reported by the previous
|
||||
command, is "ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im", you
|
||||
may have to activate in your "sandboxed network" the same economic
|
||||
protocol than used by the alphanet by running:
|
||||
|
||||
tezos-activate-alpha
|
||||
|
||||
Warning: all the client data will be removed when you close this shell
|
||||
or if you run this command a second time.
|
||||
|
||||
Activate tab completion by running:
|
||||
|
||||
tezos-autocomplete
|
||||
|
||||
EOF
|
@ -1,27 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||
src_dir="$(dirname "$script_dir")"
|
||||
cd "$src_dir"
|
||||
|
||||
source $script_dir/node_lib.inc.sh
|
||||
|
||||
if [ $# -lt 1 ] || [ "$1" -le 0 ] || [ 10 -le "$1" ]; then
|
||||
echo "Small script to launch local and closed test network with a maximum of 9 nodes."
|
||||
echo
|
||||
echo "Usage: $0 <id>"
|
||||
echo " where <id> should be an integer between 1 and 9."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cleanup () {
|
||||
set +e
|
||||
echo Cleaning up...
|
||||
cleanup_nodes
|
||||
}
|
||||
trap cleanup EXIT INT
|
||||
|
||||
start_sandboxed_node "$@"
|
||||
wait $node_pids
|
42
test/jbuild
42
test/jbuild
@ -2,50 +2,50 @@
|
||||
|
||||
(alias
|
||||
((name runtest_basic.sh)
|
||||
(deps (../bin_node/main.exe
|
||||
../bin_client/main.exe
|
||||
sandbox.json
|
||||
test_basic.sh
|
||||
(deps (sandbox.json
|
||||
lib/test_lib.inc.sh
|
||||
../scripts/node_lib.inc.sh
|
||||
../scripts/client_lib.inc.sh
|
||||
(glob_files contracts/*)
|
||||
))
|
||||
(locks (/tcp-port/18731
|
||||
/tcp-port/19731))
|
||||
(action (run bash ${path:test_basic.sh}))))
|
||||
(action (run bash ${path:test_basic.sh}
|
||||
${bin:tezos-sandboxed-node.sh}
|
||||
${bin:tezos-node}
|
||||
${bin:tezos-init-sandboxed-client.sh}
|
||||
${bin:tezos-client}
|
||||
))))
|
||||
|
||||
(alias
|
||||
((name runtest_contracts.sh)
|
||||
(deps (../bin_node/main.exe
|
||||
../bin_client/main.exe
|
||||
sandbox.json
|
||||
test_contracts.sh
|
||||
(deps (sandbox.json
|
||||
lib/test_lib.inc.sh
|
||||
../scripts/node_lib.inc.sh
|
||||
../scripts/client_lib.inc.sh
|
||||
(glob_files contracts/*)
|
||||
))
|
||||
(locks (/tcp-port/18731
|
||||
/tcp-port/19731))
|
||||
(action (run bash ${path:test_contracts.sh}))))
|
||||
(action (run bash ${path:test_contracts.sh}
|
||||
${bin:tezos-sandboxed-node.sh}
|
||||
${bin:tezos-node}
|
||||
${bin:tezos-init-sandboxed-client.sh}
|
||||
${bin:tezos-client}
|
||||
))))
|
||||
|
||||
(alias
|
||||
((name runtest_multinode.sh)
|
||||
(deps (../bin_node/main.exe
|
||||
../bin_client/main.exe
|
||||
sandbox.json
|
||||
test_multinode.sh
|
||||
(deps (sandbox.json
|
||||
lib/test_lib.inc.sh
|
||||
../scripts/node_lib.inc.sh
|
||||
../scripts/client_lib.inc.sh
|
||||
(glob_files contracts/*)
|
||||
))
|
||||
(locks (/tcp-port/18731 /tcp-port/18732 /tcp-port/18733 /tcp-port/18734
|
||||
/tcp-port/18735 /tcp-port/18736 /tcp-port/18737 /tcp-port/18738
|
||||
/tcp-port/19731 /tcp-port/19732 /tcp-port/19733 /tcp-port/19734
|
||||
/tcp-port/19735 /tcp-port/19736 /tcp-port/19737 /tcp-port/19738))
|
||||
(action (run bash ${path:test_multinode.sh}))))
|
||||
(action (run bash ${path:test_multinode.sh}
|
||||
${bin:tezos-sandboxed-node.sh}
|
||||
${bin:tezos-node}
|
||||
${bin:tezos-init-sandboxed-client.sh}
|
||||
${bin:tezos-client}
|
||||
))))
|
||||
|
||||
(alias
|
||||
((name runtest)
|
||||
|
@ -6,11 +6,14 @@ src_dir="$(dirname "$test_dir")"
|
||||
cd "$test_dir"
|
||||
|
||||
sandbox_file="$test_dir/sandbox.json"
|
||||
local_node="$src_dir/bin_node/main.exe"
|
||||
local_client="$src_dir/bin_client/main.exe"
|
||||
|
||||
source $src_dir/scripts/node_lib.inc.sh
|
||||
source $src_dir/scripts/client_lib.inc.sh
|
||||
tezos_sandboxed_node="${1:-$test_dir/../bin_node/tezos-sandboxed-node.sh}"
|
||||
local_node="${2:-$test_dir/../_build/default/bin_node/main.exe}"
|
||||
tezos_init_sandboxed_client="${3:-$test_dir/../bin_client/tezos-init-sandboxed-client.sh}"
|
||||
local_client="${4:-$test_dir/../_build/default/bin_client/main.exe}"
|
||||
|
||||
source $tezos_sandboxed_node
|
||||
source $tezos_init_sandboxed_client
|
||||
|
||||
### Log files handling
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
set -e
|
||||
|
||||
test_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)")"
|
||||
source $test_dir/lib/test_lib.inc.sh
|
||||
source $test_dir/lib/test_lib.inc.sh "$@"
|
||||
|
||||
start_node 1
|
||||
activate_alpha
|
||||
|
@ -4,7 +4,7 @@ set -e
|
||||
set -o pipefail
|
||||
|
||||
test_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)")"
|
||||
source $test_dir/lib/test_lib.inc.sh
|
||||
source $test_dir/lib/test_lib.inc.sh "$@"
|
||||
|
||||
start_node 1
|
||||
activate_alpha
|
||||
|
@ -3,7 +3,7 @@
|
||||
set -e
|
||||
|
||||
test_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)")"
|
||||
source $test_dir/lib/test_lib.inc.sh
|
||||
source $test_dir/lib/test_lib.inc.sh "$@"
|
||||
|
||||
expected_connections=4
|
||||
max_peer_id=8
|
||||
|
Loading…
Reference in New Issue
Block a user