2022-05-11 16:41:33 -07:00
#!/usr/bin/env bash
2022-03-02 06:15:24 -08:00
2022-05-11 16:41:33 -07:00
# show the commands we are executing
2022-03-02 06:15:24 -08:00
set -x
2022-05-11 16:41:33 -07:00
# exit if a command fails
set -e
# exit if any command in a pipeline fails
set -o pipefail
2022-03-02 06:15:24 -08:00
2022-05-18 01:54:48 -07:00
# TODO: expand this section if needed (#4363)
2022-05-16 19:32:52 -07:00
echo "Test variables:"
echo " ZEBRA_TEST_LIGHTWALLETD= $ZEBRA_TEST_LIGHTWALLETD "
echo "Hard-coded Zebra full sync directory: /zebrad-cache"
echo " ZEBRA_CACHED_STATE_DIR= $ZEBRA_CACHED_STATE_DIR "
echo " LIGHTWALLETD_DATA_DIR= $LIGHTWALLETD_DATA_DIR "
2022-03-02 06:15:24 -08:00
case " $1 " in
-- | cargo)
2022-05-11 07:06:58 -07:00
# For these tests, we activate the gRPC feature to avoid recompiling `zebrad`,
# but we might not actually run any gRPC tests.
2022-03-05 09:32:46 -08:00
if [ [ " $RUN_ALL_TESTS " -eq "1" ] ] ; then
2022-05-11 07:06:58 -07:00
# Run all the available tests for the current environment.
# If the lightwalletd environmental variables are set, we will also run those tests.
2022-05-18 01:54:48 -07:00
cargo test --locked --release --features lightwalletd-grpc-tests --workspace -- --nocapture --include-ignored
2022-05-11 07:06:58 -07:00
# For these tests, we activate the gRPC feature to avoid recompiling `zebrad`,
# but we don't actually run any gRPC tests.
2022-03-05 09:32:46 -08:00
elif [ [ " $TEST_FULL_SYNC " -eq "1" ] ] ; then
2022-05-11 07:06:58 -07:00
# Run a Zebra full sync test.
2022-05-18 01:54:48 -07:00
cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored full_sync_mainnet
# List directory generated by test
2022-05-16 19:32:52 -07:00
# TODO: replace with $ZEBRA_CACHED_STATE_DIR in Rust and workflows
2022-05-18 01:54:48 -07:00
ls -lh "/zebrad-cache" /*/* || ( echo "No /zebrad-cache/*/*" ; ls -lhR "/zebrad-cache" | head -50 || echo "No /zebrad-cache directory" )
2022-05-04 15:55:02 -07:00
elif [ [ " $TEST_DISK_REBUILD " -eq "1" ] ] ; then
2022-05-11 07:06:58 -07:00
# Run a Zebra sync up to the mandatory checkpoint.
2022-05-11 16:41:33 -07:00
#
# TODO: use environmental variables instead of Rust features (part of #2995)
2022-05-18 01:54:48 -07:00
cargo test --locked --release --features " test_sync_to_mandatory_checkpoint_ ${ NETWORK ,, } ,lightwalletd-grpc-tests " --package zebrad --test acceptance -- --nocapture --include-ignored " sync_to_mandatory_checkpoint_ ${ NETWORK ,, } "
2022-05-16 19:32:52 -07:00
# TODO: replace with $ZEBRA_CACHED_STATE_DIR in Rust and workflows
2022-05-18 01:54:48 -07:00
ls -lh "/zebrad-cache" /*/* || ( echo "No /zebrad-cache/*/*" ; ls -lhR "/zebrad-cache" | head -50 || echo "No /zebrad-cache directory" )
2022-07-25 15:13:25 -07:00
elif [ [ " $TEST_UPDATE_SYNC " -eq "1" ] ] ; then
# Run a Zebra sync starting at the cached tip, and syncing to the latest tip.
#
# List directory used by test
ls -lh " $ZEBRA_CACHED_STATE_DIR " /*/* || ( echo " No $ZEBRA_CACHED_STATE_DIR /*/* " ; ls -lhR " $ZEBRA_CACHED_STATE_DIR " | head -50 || echo " No $ZEBRA_CACHED_STATE_DIR directory " )
cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored zebrad_update_sync
2022-05-04 15:55:02 -07:00
elif [ [ " $TEST_CHECKPOINT_SYNC " -eq "1" ] ] ; then
2022-05-11 07:06:58 -07:00
# Run a Zebra sync starting at the cached mandatory checkpoint, and syncing past it.
2022-05-11 16:41:33 -07:00
#
2022-05-18 01:54:48 -07:00
# List directory used by test
2022-05-16 19:32:52 -07:00
# TODO: replace with $ZEBRA_CACHED_STATE_DIR in Rust and workflows
2022-05-18 01:54:48 -07:00
ls -lh "/zebrad-cache" /*/* || ( echo "No /zebrad-cache/*/*" ; ls -lhR "/zebrad-cache" | head -50 || echo "No /zebrad-cache directory" )
2022-05-11 16:41:33 -07:00
# TODO: use environmental variables instead of Rust features (part of #2995)
2022-05-18 01:54:48 -07:00
cargo test --locked --release --features " test_sync_past_mandatory_checkpoint_ ${ NETWORK ,, } ,lightwalletd-grpc-tests " --package zebrad --test acceptance -- --nocapture --include-ignored " sync_past_mandatory_checkpoint_ ${ NETWORK ,, } "
2022-05-05 02:27:07 -07:00
elif [ [ " $TEST_LWD_RPC_CALL " -eq "1" ] ] ; then
2022-05-16 19:32:52 -07:00
# Starting at a cached Zebra tip, test a JSON-RPC call to Zebra.
2022-05-18 01:54:48 -07:00
ls -lh " $ZEBRA_CACHED_STATE_DIR " /*/* || ( echo " No $ZEBRA_CACHED_STATE_DIR /*/* " ; ls -lhR " $ZEBRA_CACHED_STATE_DIR " | head -50 || echo " No $ZEBRA_CACHED_STATE_DIR directory " )
cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored fully_synced_rpc_test
2022-05-11 07:06:58 -07:00
elif [ [ " $TEST_LWD_FULL_SYNC " -eq "1" ] ] ; then
# Starting at a cached Zebra tip, run a lightwalletd sync to tip.
2022-05-18 01:54:48 -07:00
ls -lh " $ZEBRA_CACHED_STATE_DIR " /*/* || ( echo " No $ZEBRA_CACHED_STATE_DIR /*/* " ; ls -lhR " $ZEBRA_CACHED_STATE_DIR " | head -50 || echo " No $ZEBRA_CACHED_STATE_DIR directory " )
cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored lightwalletd_full_sync
ls -lhR " $LIGHTWALLETD_DATA_DIR /db " || ( echo " No $LIGHTWALLETD_DATA_DIR /db " ; ls -lhR " $LIGHTWALLETD_DATA_DIR " | head -50 || echo " No $LIGHTWALLETD_DATA_DIR directory " )
2022-05-13 15:02:05 -07:00
elif [ [ " $TEST_LWD_UPDATE_SYNC " -eq "1" ] ] ; then
# Starting with a cached Zebra and lightwalletd tip, run a quick update sync.
2022-05-18 01:54:48 -07:00
ls -lh " $ZEBRA_CACHED_STATE_DIR " /*/* || ( echo " No $ZEBRA_CACHED_STATE_DIR /*/* " ; ls -lhR " $ZEBRA_CACHED_STATE_DIR " | head -50 || echo " No $ZEBRA_CACHED_STATE_DIR directory " )
ls -lhR " $LIGHTWALLETD_DATA_DIR /db " || ( echo " No $LIGHTWALLETD_DATA_DIR /db " ; ls -lhR " $LIGHTWALLETD_DATA_DIR " | head -50 || echo " No $LIGHTWALLETD_DATA_DIR directory " )
cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored lightwalletd_update_sync
2022-05-11 07:06:58 -07:00
# These tests actually use gRPC.
2022-05-26 04:38:00 -07:00
elif [ [ " $TEST_LWD_GRPC " -eq "1" ] ] ; then
# Starting with a cached Zebra and lightwalletd tip, test all gRPC calls to lightwalletd, which calls Zebra.
ls -lh " $ZEBRA_CACHED_STATE_DIR " /*/* || ( echo " No $ZEBRA_CACHED_STATE_DIR /*/* " ; ls -lhR " $ZEBRA_CACHED_STATE_DIR " | head -50 || echo " No $ZEBRA_CACHED_STATE_DIR directory " )
ls -lhR " $LIGHTWALLETD_DATA_DIR /db " || ( echo " No $LIGHTWALLETD_DATA_DIR /db " ; ls -lhR " $LIGHTWALLETD_DATA_DIR " | head -50 || echo " No $LIGHTWALLETD_DATA_DIR directory " )
cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored lightwalletd_wallet_grpc_tests
2022-05-05 22:30:38 -07:00
elif [ [ " $TEST_LWD_TRANSACTIONS " -eq "1" ] ] ; then
2022-05-26 04:38:00 -07:00
# Starting with a cached Zebra and lightwalletd tip, test sending transactions gRPC call to lightwalletd, which calls Zebra.
2022-05-18 01:54:48 -07:00
ls -lh " $ZEBRA_CACHED_STATE_DIR " /*/* || ( echo " No $ZEBRA_CACHED_STATE_DIR /*/* " ; ls -lhR " $ZEBRA_CACHED_STATE_DIR " | head -50 || echo " No $ZEBRA_CACHED_STATE_DIR directory " )
ls -lhR " $LIGHTWALLETD_DATA_DIR /db " || ( echo " No $LIGHTWALLETD_DATA_DIR /db " ; ls -lhR " $LIGHTWALLETD_DATA_DIR " | head -50 || echo " No $LIGHTWALLETD_DATA_DIR directory " )
cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored sending_transactions_using_lightwalletd
2022-05-11 07:06:58 -07:00
# These command-lines are provided by the caller.
2022-05-18 01:54:48 -07:00
#
# TODO: test that the following 3 cases actually work, or remove them
2022-03-05 09:32:46 -08:00
else
exec " $@ "
2022-03-02 06:15:24 -08:00
fi
; ;
zebrad)
exec zebrad " $@ "
; ;
*)
exec " $@ "
esac