summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/setup.sh22
-rw-r--r--script/test_btc_fail.sh38
-rw-r--r--script/test_btc_stress.sh63
-rw-r--r--script/test_btc_wire.sh16
-rw-r--r--script/test_recover_db.sh12
5 files changed, 108 insertions, 43 deletions
diff --git a/script/setup.sh b/script/setup.sh
index 827ff56..5ef9d1e 100644
--- a/script/setup.sh
+++ b/script/setup.sh
@@ -46,7 +46,6 @@ function setup_btc() {
WIRE=`$BTC_CLI -rpcwallet=wire getnewaddress`
mine_btc 101
$BTC_CLI -rpcwallet=reserve sendtoaddress $CLIENT 10 > /dev/null
- $BTC_CLI -rpcwallet=reserve sendtoaddress $WIRE 1 > /dev/null
mine_btc
}
@@ -67,10 +66,14 @@ function next_btc() {
# Check client and wire balance
function check_balance() {
- CLIENT_BALANCE=`$BTC_CLI -rpcwallet=client getbalance`
- WIRE_BALANCE=`$BTC_CLI -rpcwallet=wire getbalance`
- if [ "$CLIENT_BALANCE" != "$1" ] || [ "$WIRE_BALANCE" != "${2:-$WIRE_BALANCE}" ]; then
- echo "expected: client $1 wire ${2:-$WIRE_BALANCE} got: client $CLIENT_BALANCE wire $WIRE_BALANCE"
+ local CLIENT_BALANCE=`$BTC_CLI -rpcwallet=client getbalance`
+ local WIRE_BALANCE=`$BTC_CLI -rpcwallet=wire getbalance`
+ local CLIENT="${1:-*}"
+ if [ "$1" == "*" ]; then
+ local CLIENT="$CLIENT_BALANCE"
+ fi
+ if [ "$CLIENT_BALANCE" != "$CLIENT" ] || [ "$WIRE_BALANCE" != "${2:-$WIRE_BALANCE}" ]; then
+ echo "expected: client $CLIENT wire ${2:-$WIRE_BALANCE} got: client $CLIENT_BALANCE wire $WIRE_BALANCE"
exit 1
fi
}
@@ -109,16 +112,17 @@ function gateway() {
# usage: check_delta endpoint nb_txs amount_sequence
function check_delta() {
ALL=`curl -s ${BANK_ENDPOINT}history/$1`
+ PRE=${3:-0.0000}
for n in `$2`; do
- if ! `echo $ALL | grep BTC:0.0000$n > /dev/null`; then
- echo -n " missing tx with amount: BTC:0.0000$n"
+ if ! `echo $ALL | grep BTC:$PRE$n > /dev/null`; then
+ echo -n " missing tx with amount: BTC:$PRE$n"
return 1
fi
done
- NB=`echo $ALL | grep -o BTC:0.0000 | wc -l`
+ NB=`echo $ALL | grep -o BTC:$PRE | wc -l`
EXPECTED=`$2 | wc -w`
if [ "$EXPECTED" != "$NB" ]; then
echo -n " expected: $EXPECTED txs found $NB"
return 1
fi
-} \ No newline at end of file
+}
diff --git a/script/test_btc_fail.sh b/script/test_btc_fail.sh
index 3602364..c9fa930 100644
--- a/script/test_btc_fail.sh
+++ b/script/test_btc_fail.sh
@@ -35,26 +35,22 @@ echo ""
SEQ="seq 10 40"
-function check() {
- check_delta "$1?delta=-100" "$SEQ"
-}
-
echo "----- Handle incoming -----"
echo -n "Making wire transfer to exchange:"
for n in `$SEQ`; do
- btc-wire-cli -d $BTC_DIR transfer 0.0000$n
+ btc-wire-cli -d $BTC_DIR transfer 0.000$n
mine_btc # Mine transactions
done
next_btc # Trigger btc_wire
echo " OK"
echo -n "Requesting exchange incoming transaction list:"
-check incoming
+check_delta "incoming?delta=-100" "$SEQ" "0.000"
echo " OK"
echo -n "Check balance:"
-check_balance 9.99897979 1.00077500
+check_balance 9.99200479 0.00775000
echo " OK"
echo "----- Handle outgoing -----"
@@ -66,14 +62,34 @@ for n in `$SEQ`; do
-C payto://bitcoin/$CLIENT \
-a BTC:0.0000$n > /dev/null
done
-sleep 15
+sleep 20
mine_btc # Mine transactions
echo " OK"
echo -n "Requesting exchange outgoing transaction list:"
-check outgoing
+check_delta "outgoing?delta=-100" "$SEQ"
+echo " OK"
+
+echo -n "Check balance:"
+check_balance 9.99277979 0.00691331
+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
+sleep 20
echo " OK"
echo -n "Check balance:"
-check_balance 9.99975479
-echo " OK" \ No newline at end of file
+check_balance "*" 0.00031000
+echo " OK"
+
+echo "All tests passed" \ No newline at end of file
diff --git a/script/test_btc_stress.sh b/script/test_btc_stress.sh
index b3b6ed7..6b6023f 100644
--- a/script/test_btc_stress.sh
+++ b/script/test_btc_stress.sh
@@ -28,22 +28,18 @@ init_btc
echo "Init bitcoin regtest"
setup_btc
echo "Start btc-wire stressed"
-stressed_btc_wire
+btc_wire
echo "Start gateway"
gateway
echo ""
SEQ="seq 10 99"
-function check() {
- check_delta "$1?delta=-100" "$SEQ"
-}
-
echo "----- Handle incoming -----"
echo -n "Making wire transfer to exchange:"
for n in `$SEQ`; do
- btc-wire-cli -d $BTC_DIR transfer 0.0000$n
+ btc-wire-cli -d $BTC_DIR transfer 0.000$n
mine_btc # Mine transactions
done
sleep 3 # Give time for btc_wire worker to process
@@ -52,11 +48,11 @@ sleep 3 # Give time for btc_wire worker to process
echo " OK"
echo -n "Requesting exchange incoming transaction list:"
-check incoming
+check_delta "incoming?delta=-100" "$SEQ" "0.000"
echo " OK"
echo -n "Check balance:"
-check_balance 9.99438310 1.00490500
+check_balance 9.95023810 0.04905000
echo " OK"
echo "----- Handle outgoing -----"
@@ -73,32 +69,71 @@ next_btc # Mine transactions
echo " OK"
echo -n "Requesting exchange outgoing transaction list:"
-check outgoing
+check_delta "outgoing?delta=-100" "$SEQ"
echo " OK"
echo -n "Check balance:"
-check_balance 9.99928810
+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
+sleep 20
+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 3
+sleep 10
echo -n "Requesting exchange incoming transaction list:"
-check incoming
+check_delta "incoming?delta=-100" "$SEQ" "0.000"
echo " OK"
echo -n "Requesting exchange outgoing transaction list:"
-check outgoing
+check_delta "outgoing?delta=-100" "$SEQ"
echo " OK"
echo -n "Check balance:"
# Balance should not have changed
-check_balance 9.99928810
+check_balance "*" 0.00090000
echo " OK"
echo "All tests passed" \ No newline at end of file
diff --git a/script/test_btc_wire.sh b/script/test_btc_wire.sh
index 7795a0e..442dcf3 100644
--- a/script/test_btc_wire.sh
+++ b/script/test_btc_wire.sh
@@ -33,25 +33,33 @@ echo "Start gateway"
gateway
echo ""
-echo "---- Gateway API -----"
+echo "---- Receive -----"
echo -n "Making wire transfer to exchange:"
btc-wire-cli -d $BTC_DIR transfer 0.00004
next_btc
-check_balance 9.99995209 1.00004000
+check_balance 9.99995209 0.00004000
echo " OK"
echo -n "Requesting exchange incoming transaction list:"
taler-exchange-wire-gateway-client -b $BANK_ENDPOINT -i | grep BTC:0.00004 > /dev/null
echo " OK"
+echo "---- Bounce-----"
+$BTC_CLI -rpcwallet=client sendtoaddress $WIRE 0.00042
+next_btc
+check_balance 9.99993883 0.00005000
+
+echo "---- Send -----"
+
echo -n "Making wire transfer from exchange:"
taler-exchange-wire-gateway-client \
-b $BANK_ENDPOINT \
-C payto://bitcoin/$CLIENT \
-a BTC:0.00002 > /dev/null
-next_btc
-check_balance 9.99997209 1.00001801
+sleep 0.3
+mine_btc
+check_balance 9.99995883 0.00002801
echo " OK"
echo -n "Requesting exchange's outgoing transaction list:"
diff --git a/script/test_recover_db.sh b/script/test_recover_db.sh
index 3bfc9f9..d90a541 100644
--- a/script/test_recover_db.sh
+++ b/script/test_recover_db.sh
@@ -37,7 +37,7 @@ echo "----- With DB -----"
echo "Making wire transfer to exchange:"
btc-wire-cli -d $BTC_DIR transfer 0.000042
next_btc
-check_balance 9.99995009 1.00004200
+check_balance 9.99995009 0.00004200
echo -n "Requesting exchange incoming transaction list:"
taler-exchange-wire-gateway-client -b $BANK_ENDPOINT -i | grep BTC:0.000042 > /dev/null && echo " OK" || echo " Failed"
@@ -45,10 +45,12 @@ echo "----- Without DB -----"
echo "Stop database"
sudo service postgresql stop > /dev/null
+echo "Making incomplete wire transfer to exchange"
+$BTC_CLI -rpcwallet=client sendtoaddress $WIRE 0.00042 &> /dev/null
echo "Making wire transfer to exchange:"
btc-wire-cli -d $BTC_DIR transfer 0.00004
next_btc
-check_balance 9.99990218 1.00008200
+check_balance 9.99948077 0.00050200
echo -n "Requesting exchange incoming transaction list:"
taler-exchange-wire-gateway-client -b $BANK_ENDPOINT -i 2>&1 | grep -q "504" && echo " OK" || echo " Failed"
@@ -65,8 +67,8 @@ taler-exchange-wire-gateway-client \
-C payto://bitcoin/$CLIENT \
-a BTC:0.00002 > /dev/null
sleep 1
-next_btc
-check_balance 9.99992218 1.00006001
+mine_btc
+check_balance 9.99990892 0.00007001
echo " OK"
echo -n "Requesting exchange's outgoing transaction list:"
@@ -95,6 +97,6 @@ done
echo ""
# Balance should not have changed
-check_balance 9.99992218 1.00006001
+check_balance 9.99990892 0.00007001
echo "All tests passed" \ No newline at end of file