source source.sh
clean_env() {
+ bitcoin_core_stop
cd ..
rm -rf "$TEST_DIR"
-}
+} > /dev/null 2>&1
setup_env() {
mkdir "$TEST_DIR"
cd "$TEST_DIR"
+ bitcoin_core_start
} > /dev/null 2>&1
reset_env() {
assert() {
if [[ "$1" != "$2" ]]; then
echo -e "Expected:\n$1\nResult:\n$2"
- echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]} failed"
+ echo -e "${BASH_SOURCE[1]}:${BASH_LINENO[0]} \e[31mFAILED\e[0m"
exit 1
fi
}
test_failed() {
- echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]} failed"
+ echo -e "${BASH_SOURCE[1]}:${BASH_LINENO[0]} \e[31mFAILED\e[0m"
exit 1
}
test_succeeded() {
- echo "${BASH_SOURCE[1]} succeeded"
- clean_env
+ echo -e "${BASH_SOURCE[1]}: \e[32mSUCCESS\e[0m"
}
--- /dev/null
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+source setup.sh
+
+setup_env
+
+(wallet_create 1 > result 2>&1)
+EXPECTED="created wallet: wallet1"
+RESULT=$(<result)
+assert "$EXPECTED" "$RESULT"
+
+(wallet_create 2 > result 2>&1)
+EXPECTED="created wallet: wallet2"
+RESULT=$(<result)
+assert "$EXPECTED" "$RESULT"
+
+clean_env
+
+test_succeeded