summaryrefslogtreecommitdiff
path: root/test/btc/wire.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/btc/wire.sh')
-rw-r--r--test/btc/wire.sh72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/btc/wire.sh b/test/btc/wire.sh
new file mode 100644
index 0000000..a11bd9a
--- /dev/null
+++ b/test/btc/wire.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+## Test btc_wire correctly receive and sens transactions on the blockchain
+
+set -eu
+
+source "${BASH_SOURCE%/*}/../common.sh"
+SCHEMA=btc.sql
+
+echo "----- Setup -----"
+echo "Load config file"
+load_config
+echo "Start database"
+setup_db
+echo "Start bitcoin node"
+init_btc
+echo "Start btc-wire"
+btc_wire
+echo "Start gateway"
+gateway
+echo ""
+
+SEQ="seq 10 20"
+
+echo "----- Receive -----"
+
+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
+next_btc # Trigger btc_wire
+check_balance 9.99826299 0.00165000
+echo " OK"
+
+echo -n "Requesting exchange incoming transaction list:"
+check_delta "incoming?delta=-100" "$SEQ" "0.000"
+echo " OK"
+
+echo "----- Send -----"
+
+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 1
+mine_btc # Mine transactions
+check_balance 9.99842799 0.00146311
+echo " OK"
+
+echo -n "Requesting exchange's outgoing transaction list:"
+check_delta "outgoing?delta=-100" "$SEQ"
+echo " OK"
+
+echo "----- Bounce -----"
+
+clear_wallet
+
+echo -n "Bounce:"
+for n in `$SEQ`; do
+ $BTC_CLI -rpcwallet=client sendtoaddress $WIRE 0.000$n > /dev/null
+ mine_btc
+done
+next_btc
+sleep 1
+check_balance "*" 0.00011000
+echo " OK"
+
+echo "All tests passed" \ No newline at end of file