BITCOIN_CLI="bitcoin-cli -datadir=$DATA_DIRECTORY -chain=regtest"
bitcoin_core_start() {
+ RUNNING=`ps -A | ( grep bitcoind > /dev/null && echo "1" ) || echo "0"`
+ if [[ "$RUNNING" -gt 0 ]]; then
+ log_error "ERROR: bitcoin core already running\nexitting..."
+ exit 1
+ fi
+
log_info "starting bitcoin core..."
mkdir -p "$DATA_DIRECTORY"
bitcoind -daemonwait -datadir="$DATA_DIRECTORY" -chain=regtest &> /dev/null
}
bitcoin_core_stop() {
+ RUNNING=`ps -A | ( grep bitcoind > /dev/null && echo "1" ) || echo "0"`
+ if [[ "$RUNNING" -eq 0 ]]; then
+ log_error "ERROR: bitcoin core not running\nexitting..."
+ exit 1
+ fi
+
log_info "stopping bitcoin core..."
local CMD="$BITCOIN_CLI stop"
eval "$CMD" &> /dev/null
}
depends() {
+ PATH="$PATH:/sbin"
+
detect base64
detect bitcoind
detect bitcoin-cli
-# detect cryptsetup
+ detect cryptsetup
detect eject
detect jq
-# detect mkfs.ext4
+ detect mkfs.ext4
detect nmcli
detect shred
-# detect wipefs
+ detect wipefs
}
detect() {
}
network_off() {
- echo "turn networking off"
- exit 1
+ nmcli networking off
}
parse_arguments() {
bitcoin_core_start
+ network_off
+
wallets
multisig_create
--- /dev/null
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+source setup.sh
+
+mkdir "$TEST_DIR"
+cd "$TEST_DIR"
+
+(bitcoin_core_start > result)
+EXPECTED=$'starting bitcoin core...\nbitcoin core started'
+RESULT=$(<result)
+assert "$EXPECTED" "$RESULT"
+
+set +e
+(bitcoin_core_start > result 2>&1)
+assert "1" "$?"
+set -e
+EXPECTED=$'ERROR: bitcoin core already running\nexitting...'
+RESULT=$(<result)
+assert "$EXPECTED" "$RESULT"
+
+clean_env
+
+test_succeeded
--- /dev/null
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+source setup.sh
+
+setup_env
+
+(bitcoin_core_stop > result)
+EXPECTED=$'stopping bitcoin core...\nbitcoin core stopped'
+RESULT=$(<result)
+assert "$EXPECTED" "$RESULT"
+
+set +e
+(bitcoin_core_stop > result 2>&1)
+assert "1" "$?"
+set -e
+EXPECTED=$'ERROR: bitcoin core not running\nexitting...'
+RESULT=$(<result)
+
+cd ..
+rm -rf "$TEST_DIR"
+
+test_succeeded
--- /dev/null
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+source setup.sh
+
+setup_env
+
+(depends > result)
+
+clean_env
+
+test_succeeded
--- /dev/null
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+source setup.sh
+
+setup_env
+
+(detect "ls" > result)
+(detect "cp" > result)
+(detect "mkdir" > result)
+
+set +e
+(detect "masodifsoidfnaiosdnfokdir" > result 2>&1)
+assert "1" "$?"
+set -e
+EXPECTED="masodifsoidfnaiosdnfokdir: command not found"
+RESULT=$(<result)
+assert "$EXPECTED" "$RESULT"
+
+clean_env
+
+test_succeeded
--- /dev/null
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+source setup.sh
+
+setup_env
+
+mkdir "function_replace_test"
+
+echo "help!" > function_replace_test/foo
+
+(ls function_replace_test > result)
+EXPECTED="foo"
+RESULT=$(<result)
+assert "$EXPECTED" "$RESULT"
+
+ls() {
+ echo "replaced ls function"
+}
+
+(ls function_replace_test > result)
+EXPECTED="replaced ls function"
+RESULT=$(<result)
+assert "$EXPECTED" "$RESULT"
+
+clean_env
+
+test_succeeded
--- /dev/null
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+source setup.sh
+
+setup_env
+
+test_failed
+
+clean_env
+
+test_succeeded