commit d2a167cd660f3beae6dc4515b85a71bff9383f5d
parent 6ac06e7f52a197e2b46e08adc9c129076af3158d
Author: Antoine A <>
Date: Wed, 23 Feb 2022 17:43:50 +0100
Clean tests
Diffstat:
24 files changed, 105 insertions(+), 58 deletions(-)
diff --git a/eth-wire/src/loops/worker.rs b/eth-wire/src/loops/worker.rs
@@ -105,6 +105,10 @@ pub fn worker(mut rpc: AutoRpcWallet, mut db: AutoReconnectDb, state: &WireState
if let Err(e) = result {
error!("worker: {}", e);
+ // When we catch an error, we sometimes want to retry immediately (eg. reconnect to RPC or DB).
+ // Rpc error codes are generic. We need to match the msg to get precise ones. Some errors
+ // can resolve themselves when a new block is mined (new fees, new transactions). Our simple
+ // approach is to wait for the next loop when an RPC error is caught to prevent endless logged errors.
skip_notification = !matches!(
e,
LoopError::RPC(rpc::Error::RPC { .. }) | LoopError::Concurrency
diff --git a/makefile b/makefile
@@ -32,6 +32,7 @@ test_eth: install_test
test/eth/reorg.sh
test/eth/hell.sh
test/eth/analysis.sh
+ test/eth/maxfee.sh
test: test_gateway test_eth test_btc
diff --git a/test/btc/analysis.sh b/test/btc/analysis.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=btc.sql
CONFIG=taler_btc.conf
echo "----- Setup -----"
diff --git a/test/btc/bumpfee.sh b/test/btc/bumpfee.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=btc.sql
CONFIG=taler_btc_bump.conf
echo "----- Setup -----"
diff --git a/test/btc/config.sh b/test/btc/config.sh
@@ -4,7 +4,6 @@
set -eu
-SCHEMA=btc.sql
CONFIG=taler_btc.conf
function test() {
diff --git a/test/btc/conflict.sh b/test/btc/conflict.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=btc.sql
CONFIG=taler_btc.conf
echo "----- Setup -----"
diff --git a/test/btc/hell.sh b/test/btc/hell.sh
@@ -6,7 +6,6 @@ set -eu
source "${BASH_SOURCE%/*}/../common.sh"
CONFIG=taler_btc.conf
-SCHEMA=btc.sql
echo "----- Setup -----"
echo "Load config file"
diff --git a/test/btc/lifetime.sh b/test/btc/lifetime.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=btc.sql
CONFIG=taler_btc_lifetime.conf
diff --git a/test/btc/maxfee.sh b/test/btc/maxfee.sh
@@ -1,11 +1,10 @@
#!/bin/bash
-## Test btc-wire ability to handle stuck transaction correctly
+## Test btc-wire handle transaction fees exceeding limits
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=btc.sql
CONFIG=taler_btc.conf
echo "----- Setup -----"
@@ -15,8 +14,6 @@ echo "Start database"
setup_db
echo "Start bitcoin node"
init_btc
-echo "Start second bitcoin node"
-init_btc2
echo "Start btc-wire"
btc_wire
echo "Start gateway"
@@ -25,22 +22,22 @@ echo ""
SEQ="seq 10 30"
-echo -n "Making wire transfer to exchange:"
+echo -n "Making wire transfer to exchange: "
for n in `$SEQ`; do
$WIRE_UTILS transfer 0.$n > /dev/null
mine_btc # Mine transactions
done
next_btc # Trigger btc-wire
check_balance 5.79983389 4.20000000
-echo " OK"
+echo "OK"
echo "----- Too high fees -----"
-echo -n "Set up node"
+echo -n "Set up node: "
restart_btc -maxtxfee=0.0000001 -minrelaytxfee=0.0000001
-echo " OK"
+echo "OK"
-echo -n "Making wire transfer from exchange:"
+echo -n "Making wire transfer from exchange: "
for n in `$SEQ`; do
taler-exchange-wire-gateway-client \
-b $BANK_ENDPOINT \
@@ -49,21 +46,21 @@ for n in `$SEQ`; do
done
sleep 5
mine_btc
-echo " OK"
+echo "OK"
-echo -n "Check no transaction have been made"
+echo -n "Check no transaction have been made: "
check_balance 5.79983389 4.20000000
-echo " OK"
+echo "OK"
echo "----- Good fees -----"
-echo -n "Set up node"
+echo -n "Set up node: "
restart_btc
-echo " OK"
+echo "OK"
-echo -n "Check transaction have been made"
+echo -n "Check transaction have been made: "
sleep 6
check_balance 5.79983389 3.77995821
-echo " OK"
+echo "OK"
echo "All tests passed!"
\ No newline at end of file
diff --git a/test/btc/reconnect.sh b/test/btc/reconnect.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=btc.sql
CONFIG=taler_btc.conf
echo "----- Setup -----"
diff --git a/test/btc/reorg.sh b/test/btc/reorg.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=btc.sql
CONFIG=taler_btc.conf
echo "----- Setup -----"
diff --git a/test/btc/stress.sh b/test/btc/stress.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=btc.sql
CONFIG=taler_btc.conf
echo "----- Setup stressed -----"
diff --git a/test/btc/wire.sh b/test/btc/wire.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=btc.sql
CONFIG=taler_btc.conf
echo "----- Setup -----"
diff --git a/test/common.sh b/test/common.sh
@@ -24,7 +24,7 @@ WIRE_DIR2=$DIR/wire2
DB_DIR=$DIR/db
CONF=$DIR/taler.conf
for dir in $WIRE_DIR $WIRE_DIR2 $DB_DIR log; do
- mkdir -p $dir
+ mkdir -p "$dir"
done
# Clear logs
@@ -86,7 +86,7 @@ function stop_node() {
# ----- Database ----- #
-# Create new postgresql cluster and init database schema
+# Create new postgresql cluster and init database
function setup_db() {
pg_ctl init -D $DB_DIR &>> log/postgres.log
echo "port=5454" >> $DB_DIR/postgresql.conf
@@ -261,9 +261,7 @@ function init_eth() {
# Initialize blockchain
$ETH_CLI init $DIR/genesis.json &>> log/node.log
# Start node
- $ETH_CLI --miner.gasprice 0 $* &>> log/node.log &
- NODE_PID="$!"
- sleep 1
+ start_eth $*
# Create wire address
WIRE=`$WIRE_CLI initwallet | grep -oP '(?<=is ).*'`
echo -e "PAYTO = payto://ethereum/$WIRE" >> $CONF
@@ -274,7 +272,7 @@ function init_eth2() {
# Initialize blockchain
$ETH_CLI2 init $DIR/genesis.json &>> log/node2.log
# Start node
- $ETH_CLI2 --port 30305 --miner.gasprice 0 $* &>> log/node2.log &
+ $ETH_CLI2 --port 30305 $* &>> log/node2.log &
sleep 1
# Create etherbase account for mining
$ETH_CLI2 account new --password <(echo $PASSWORD) &> /dev/null
@@ -297,9 +295,9 @@ function eth_fork() {
}
# Restart an initialized geth dev node
-function resume_eth() {
+function start_eth() {
# Start node
- $ETH_CLI --port 30305 --miner.recommit 0s --miner.gasprice 0 $* &>> log/node2.log &
+ $ETH_CLI $* &>> log/node.log &
NODE_PID="$!"
sleep 1
# Try to connect nodes
@@ -308,7 +306,7 @@ function resume_eth() {
function restart_eth() {
stop_node
- resume_eth $*
+ start_eth $*
}
# Check client and wire balance
diff --git a/test/eth/analysis.sh b/test/eth/analysis.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=eth.sql
CONFIG=taler_eth.conf
echo "----- Setup -----"
@@ -14,9 +13,9 @@ load_config
echo "Start database"
setup_db
echo "Start ethereum node"
-init_eth
+init_eth --miner.gasprice 0
echo "Start second ethereum node"
-init_eth2
+init_eth2 --miner.gasprice 0
echo "Start eth-wire"
eth_wire
echo "Start gateway"
diff --git a/test/eth/hell.sh b/test/eth/hell.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=eth.sql
CONFIG=taler_eth.conf
echo "----- Setup -----"
@@ -14,9 +13,9 @@ load_config
echo "Start database"
setup_db
echo "Start ethereum node"
-init_eth
+init_eth --miner.gasprice 0
echo "Start second ethereum node"
-init_eth2
+init_eth2 --miner.gasprice 0
echo "Start eth-wire"
eth_wire
echo "Start gateway"
@@ -66,9 +65,9 @@ load_config
echo "Start database"
setup_db
echo "Start ethereum node"
-init_eth
+init_eth --miner.gasprice 0
echo "Start second ethereum node"
-init_eth2
+init_eth2 --miner.gasprice 0
echo "Start eth-wire"
eth_wire
echo "Start gateway"
diff --git a/test/eth/lifetime.sh b/test/eth/lifetime.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=eth.sql
CONFIG=taler_eth_lifetime.conf
@@ -15,7 +14,7 @@ load_config
echo "Start database"
setup_db
echo "Start ethereum node"
-init_eth
+init_eth --miner.gasprice 0
echo "Start eth-wire"
eth_wire
echo "Start gateway"
diff --git a/test/eth/maxfee.sh b/test/eth/maxfee.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+## Test eth-wire handle transaction fees exceeding limits
+
+set -eu
+
+source "${BASH_SOURCE%/*}/../common.sh"
+CONFIG=taler_eth.conf
+
+echo "----- Setup -----"
+echo "Load config file"
+load_config
+echo "Start database"
+setup_db
+echo "Start ethereum node"
+init_eth --miner.gasprice 0
+echo "Start eth-wire"
+eth_wire
+echo "Start gateway"
+gateway
+echo ""
+
+SEQ="seq 10 20"
+
+echo -n "Making wire transfer to exchange: "
+$WIRE_UTILS deposit $CLIENT $WIRE 0.000 `$SEQ`
+next_eth # Trigger eth-wire
+sleep 1
+check_delta "incoming?delta=-100" "$SEQ" "0.000"
+check_balance_eth 999835000 165000
+echo "OK"
+
+
+echo "----- Too high fees -----"
+
+echo -n "Set up node: "
+restart_eth --rpc.txfeecap 0.00001
+echo "OK"
+
+echo -n "Making wire transfer from exchange: "
+for n in `$SEQ`; do
+ taler-exchange-wire-gateway-client \
+ -b $BANK_ENDPOINT \
+ -C payto://ethereum/$CLIENT \
+ -a ETH:0.0000$n > /dev/null
+done
+sleep 1
+mine_eth # Mine transactions
+echo "OK"
+
+echo -n "Check no transaction have been made: "
+check_balance_eth 999835000 165000
+echo "OK"
+
+echo "----- Good fees -----"
+
+echo -n "Set up node: "
+restart_eth --miner.gasprice 0
+echo "OK"
+
+echo -n "Check transaction have been made: "
+#check_balance_eth 999851500 148500 TODO recover from bas fees
+echo "OK"
+
+echo "All tests passed!"
+\ No newline at end of file
diff --git a/test/eth/reconnect.sh b/test/eth/reconnect.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=eth.sql
CONFIG=taler_eth.conf
echo "----- Setup -----"
@@ -14,7 +13,7 @@ load_config
echo "Start database"
setup_db
echo "Start ethereum node"
-init_eth
+init_eth --miner.gasprice 0
echo "Start eth-wire"
eth_wire
echo "Start gateway"
@@ -54,7 +53,7 @@ echo "----- Reconnect DB -----"
echo "Start database"
start_db
echo "Resume ethereum node"
-resume_eth
+start_eth --miner.gasprice 0
sleep 6 # Wait for connection to be available
echo -n "Making wire transfer from exchange:"
taler-exchange-wire-gateway-client \
diff --git a/test/eth/reorg.sh b/test/eth/reorg.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=eth.sql
CONFIG=taler_eth.conf
echo "----- Setup -----"
@@ -14,9 +13,9 @@ load_config
echo "Start database"
setup_db
echo "Start ethereum node"
-init_eth
+init_eth --miner.gasprice 0
echo "Start second ethereum node"
-init_eth2
+init_eth2 --miner.gasprice 0
echo "Start eth-wire"
eth_wire
echo "Start gateway"
diff --git a/test/eth/stress.sh b/test/eth/stress.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=eth.sql
CONFIG=taler_eth.conf
echo "----- Setup -----"
@@ -14,7 +13,7 @@ load_config
echo "Start database"
setup_db
echo "Start ethereum node"
-init_eth
+init_eth --miner.gasprice 0
echo "Start stressed eth-wire"
stress_eth_wire
echo "Start gateway"
diff --git a/test/eth/test.sh b/test/eth/test.sh
@@ -3,7 +3,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=eth.sql
CONFIG=taler_eth.conf
echo "----- Setup -----"
@@ -12,7 +11,7 @@ load_config
echo "Start database"
setup_db
echo "Start ethereum node"
-init_eth
+init_eth --miner.gasprice 0
echo ""
echo "----- Test -----"
diff --git a/test/eth/wire.sh b/test/eth/wire.sh
@@ -5,7 +5,6 @@
set -eu
source "${BASH_SOURCE%/*}/../common.sh"
-SCHEMA=eth.sql
CONFIG=taler_eth.conf
echo "----- Setup -----"
@@ -14,7 +13,7 @@ load_config
echo "Start database"
setup_db
echo "Start ethereum node"
-init_eth
+init_eth --miner.gasprice 0
echo "Start eth-wire"
eth_wire
echo "Start gateway"
diff --git a/test/gateway/api.sh b/test/gateway/api.sh
@@ -18,7 +18,6 @@ trap cleanup EXIT
source "${BASH_SOURCE%/*}/../common.sh"
ADDRESS=mpTJZxWPerz1Gife6mQSdHT8mMuJK6FP85
-SCHEMA=btc.sq
CONFIG=taler_btc.conf
echo "----- Setup -----"