]> infiniteadaptability.org Git - cold/commitdiff
...
authoralex <[email protected]>
Fri, 20 May 2022 00:09:49 +0000 (17:09 -0700)
committeralex <[email protected]>
Fri, 20 May 2022 00:09:49 +0000 (17:09 -0700)
test/setup.sh
test/wallet_create.tests.sh [new file with mode: 0755]

index d2d6a6481b95fd3cb6acd206008998ed496a0e52..14eabdaddce1646e31f4c92c2240589712743212 100644 (file)
@@ -5,13 +5,15 @@ TEST_DIR=".testdir"
 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() {
@@ -22,17 +24,16 @@ 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"
 }
diff --git a/test/wallet_create.tests.sh b/test/wallet_create.tests.sh
new file mode 100755 (executable)
index 0000000..fee78df
--- /dev/null
@@ -0,0 +1,21 @@
+#!/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