summaryrefslogtreecommitdiff
path: root/tests/chutney/arti-bench
blob: 905d7a7945c67a6a0cd13db603a87dd014fdc29b (plain)
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
#!/usr/bin/env bash
set -xeuo pipefail

# Set and fully resolve chutney bin if not already set.
: "${CHUTNEY_BIN:=$(type -P chutney)}"
if [ -z "${CHUTNEY_BIN:-}" ]; then
    echo "Couldn't locate chutney bin. Ensure it's on PATH or set CHUTNEY_BIN."
    echo "You can install with:"
    echo "python3 -m pip install git+https://gitlab.torproject.org/tpo/core/chutney.git"
    exit 1
elif [ ! -x "$CHUTNEY_BIN" ]; then
    echo "CHUTNEY_BIN='$CHUTNEY_BIN' doesn't exist or isn't executable"
    exit 1
else
    # CHUTNEY_BIN is set; tell the user so.
    echo "Using chutney at '${CHUTNEY_BIN}'"
fi

export CHUTNEY_DATA_DIR="${CHUTNEY_DATA_DIR:-$(pwd)}"

if [ -z "${RUST_LOG:-}" ]; then
    echo "Setting RUST_LOG=info for your convenience."
    export RUST_LOG=info
fi

target="basic"
cd "$(git rev-parse --show-toplevel)"

# Try to ensure we tear down the network on exit, including failure, ctrl-c, etc.
function teardown() {
    "${CHUTNEY_BIN}" stop "$target"
}
trap teardown EXIT

./tests/chutney/setup -n "$target"

cargo run -p arti-bench --locked --release -- -c "${CHUTNEY_DATA_DIR}/nodes/arti.toml" "$@"

"${CHUTNEY_BIN}" stop "$target"