summaryrefslogtreecommitdiff
path: root/test/btc/stress.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/btc/stress.sh')
-rw-r--r--test/btc/stress.sh129
1 files changed, 129 insertions, 0 deletions
diff --git a/test/btc/stress.sh b/test/btc/stress.sh
new file mode 100644
index 0000000..c1749a6
--- /dev/null
+++ b/test/btc/stress.sh
@@ -0,0 +1,129 @@
+#!/bin/bash
+
+## Test btc_wire behavior when ran and stressed concurrently
+
+set -eu
+
+source "${BASH_SOURCE%/*}/../common.sh"
+SCHEMA=btc.sql
+
+echo "----- Setup stressed -----"
+echo "Load config file"
+load_config
+echo "Start database"
+setup_db
+echo "Start bitcoin node"
+init_btc
+echo "Start btc-wire stressed"
+stressed_btc_wire
+echo "Start gateway"
+gateway
+echo ""
+
+SEQ="seq 10 99"
+
+echo "----- Handle incoming -----"
+
+echo -n "Making wire transfer to exchange:"
+for n in `$SEQ`; do
+ btc-wire-cli -d $BTC_DIR transfer 0.000$n > /dev/null
+ mine_btc # Mine transactions
+done
+sleep 3 # Give time for btc_wire worker to process
+next_btc # Confirm all transactions
+sleep 3 # Give time for btc_wire worker to process
+echo " OK"
+
+echo -n "Requesting exchange incoming transaction list:"
+check_delta "incoming?delta=-100" "$SEQ" "0.000"
+echo " OK"
+
+echo -n "Check balance:"
+check_balance 9.95023810 0.04905000
+echo " OK"
+
+echo "----- Handle outgoing -----"
+
+echo -n "Making wire transfer from exchange:"
+for n in `$SEQ`; do
+ taler-exchange-wire-gateway-client \
+ -b $BANK_ENDPOINT \
+ -C payto://bitcoin/$CLIENT \
+ -a BTC:0.0000$n > /dev/null
+done
+sleep 10 # Give time for btc_wire worker to process
+next_btc # Mine transactions
+echo " OK"
+
+echo -n "Requesting exchange outgoing transaction list:"
+check_delta "outgoing?delta=-100" "$SEQ"
+echo " OK"
+
+echo -n "Check balance:"
+check_balance 9.95514310
+echo " OK"
+
+next_btc # Mine transactions
+
+echo "----- Recover DB -----"
+
+echo "Reset database"
+reset_db # Clear database tables
+mine_btc # Trigger worker
+sleep 10
+
+echo -n "Requesting exchange incoming transaction list:"
+check_delta "incoming?delta=-100" "$SEQ" "0.000"
+echo " OK"
+
+echo -n "Requesting exchange outgoing transaction list:"
+check_delta "outgoing?delta=-100" "$SEQ"
+echo " OK"
+
+echo -n "Check balance:"
+# Balance should not have changed
+check_balance 9.95514310
+echo " OK"
+
+echo "----- Handle bounce -----"
+
+echo -n "Clear wire wallet:"
+$BTC_CLI -rpcwallet=wire sendtoaddress $CLIENT `$BTC_CLI -rpcwallet=wire getbalance` "" "" true > /dev/null
+echo " OK"
+
+echo -n "Making incomplete wire transfer to exchange:"
+for n in `$SEQ`; do
+ $BTC_CLI -rpcwallet=client sendtoaddress $WIRE 0.000$n > /dev/null
+ mine_btc
+done
+next_btc
+sleep 10
+mine_btc
+sleep 10
+echo " OK"
+
+echo -n "Check balance:"
+check_balance "*" 0.00090000
+echo " OK"
+
+echo "----- Recover DB -----"
+
+echo "Reset database"
+reset_db # Clear database tables
+mine_btc # Trigger worker
+sleep 20
+
+echo -n "Requesting exchange incoming transaction list:"
+check_delta "incoming?delta=-100" "$SEQ" "0.000"
+echo " OK"
+
+echo -n "Requesting exchange outgoing transaction list:"
+check_delta "outgoing?delta=-100" "$SEQ"
+echo " OK"
+
+echo -n "Check balance:"
+# Balance should not have changed
+check_balance "*" 0.00090000
+echo " OK"
+
+echo "All tests passed" \ No newline at end of file