forked from IntersectMBO/cardano-node-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare_test_env.sh
executable file
·83 lines (72 loc) · 2.04 KB
/
prepare_test_env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
if ! (return 0 2>/dev/null); then
echo "This script is supposed to be sourced, not executed." >&2
exit 1
fi
if [ -z "${IN_NIX_SHELL:-""}" ]; then
echo "This script is supposed to be sourced from nix shell." >&2
return 1
fi
case "${1:-""}" in
"babbage")
export CLUSTER_ERA=babbage
;;
"conway")
export CLUSTER_ERA=conway COMMAND_ERA=conway
;;
*)
echo "Usage: $0 {babbage|conway}"
return 1
;;
esac
_cur_file="$(readlink -m "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}")"
REPODIR="${_cur_file%/*}"
cd "$REPODIR" || return 1
unset _cur_file
export WORKDIR="$REPODIR/dev_workdir"
rm -rf "${WORKDIR:?}"
mkdir -p "$WORKDIR"
# shellcheck disable=SC1091
. "$REPODIR/.github/setup_venv.sh"
export \
CARDANO_NODE_SOCKET_PATH="$PWD/dev_workdir/state-cluster0/bft1.socket" \
TMPDIR="$PWD/dev_workdir/tmp" \
DEV_CLUSTER_RUNNING=1 \
CLUSTERS_COUNT=1 \
FORBID_RESTART=1 \
NO_ARTIFACTS=1
_scripts_dest="$WORKDIR/${CLUSTER_ERA}_fast"
if [ ! -d "$_scripts_dest" ]; then
PYTHONPATH=$PYTHONPATH:$PWD cardano_node_tests/prepare_cluster_scripts.py \
-s "cardano_node_tests/cluster_scripts/${CLUSTER_ERA}_fast" \
-d "$_scripts_dest"
fi
unset _scripts_dest
cat > "$WORKDIR/.source" <<EoF
if [ -z "\${IN_NIX_SHELL:-""}" ]; then
echo "WARNING: This script is supposed to be sourced from nix shell." >&2
fi
source "$VIRTUAL_ENV/bin/activate"
PYTHONPATH="$(echo "\$VIRTUAL_ENV"/lib/python3*/site-packages):\$PYTHONPATH"
export PYTHONPATH
export CARDANO_NODE_SOCKET_PATH="$PWD/dev_workdir/state-cluster0/bft1.socket"
export TMPDIR="$PWD/dev_workdir/tmp"
export DEV_CLUSTER_RUNNING=1
export CLUSTERS_COUNT=1
export FORBID_RESTART=1
export NO_ARTIFACTS=1
export CLUSTER_ERA="$CLUSTER_ERA"
export COMMAND_ERA="${COMMAND_ERA:-""}"
EoF
echo
echo
echo "------------------------"
echo "| Test Env Ready |"
echo "------------------------"
echo
echo "To start local testnet, run:"
echo "$WORKDIR/${CLUSTER_ERA}_fast/start-cluster"
echo
echo "To reuse the test env in another shell, source the env with:"
echo "source $WORKDIR/.source"
echo