From 0d5a3d7b6f4d60997eccee7463c81844366a1506 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 8 Oct 2019 18:49:25 +0200 Subject: more comprehensive test-auditor.sh, including generate-auditor-basedb now --- src/auditor/auditor.conf | 4 +- src/auditor/generate-auditor-basedb.sh | 40 +++- src/auditor/test-auditor.sh | 387 ++++++++++++++++++--------------- 3 files changed, 252 insertions(+), 179 deletions(-) (limited to 'src/auditor') diff --git a/src/auditor/auditor.conf b/src/auditor/auditor.conf index a099f9b72..f90d4dbb0 100644 --- a/src/auditor/auditor.conf +++ b/src/auditor/auditor.conf @@ -1,7 +1,7 @@ # This file is in the public domain. # [auditor] -# Which database backend do we use for the auditor? +# Which database backend do we use for the auditor? DB = postgres # Option specifying which amount is considered 'tiny' @@ -26,4 +26,4 @@ UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http UNIXPATH_MODE = 660 # HTTP port the auditor listens to -PORT = 8082 +PORT = 8083 diff --git a/src/auditor/generate-auditor-basedb.sh b/src/auditor/generate-auditor-basedb.sh index 2654ffedc..0fe205707 100755 --- a/src/auditor/generate-auditor-basedb.sh +++ b/src/auditor/generate-auditor-basedb.sh @@ -41,7 +41,7 @@ cp generate-auditor-basedb-template.conf $CONF echo -n "Testing for taler-bank-manage" taler-bank-manage -h >/dev/null /dev/null taler-exchange-httpd.log & taler-merchant-httpd -c $CONF 2> taler-merchant-httpd.log & taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log & - - -# FIXME: also launch taler-auditor-httpd! - -# FIXME: interactive test here instead of waiting! -sleep 10 +taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log & + +# Wait for all services to be available +for n in `seq 1 20` +do + echo -n "." + sleep 0.1 + OK=0 + # exchange + wget http://localhost:8081/ -o /dev/null -O /dev/null >/dev/null || continue + # merchant + wget http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue + # bank + wget http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || continue + # Auditor + wget http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || continue + OK=1 + break +done + +if [ 1 != $OK ] +then + kill `jobs -p` + exit_skip "Failed to launch services" +fi +echo " DONE" # run wallet CLI echo "Running wallet" @@ -123,3 +143,9 @@ dropdb $TARGET_DB rm -f e2a.dat a2e.dat rm -rf $DATA_DIR || true rm $CONF + +echo "=====================================" +echo " Finished generation of $BASEDB" +echo "=====================================" + +exit 0 diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index ffcbffb7e..7e9f826dd 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -802,16 +802,6 @@ function test_14() { echo "===========14: wire-fee disagreement===========" - -# Wire fees are only checked/generated once there are -# actual outgoing wire transfers, so we need to run the -# aggregator here. -pre_audit aggregator -echo "UPDATE wire_fee SET wire_fee_frac=100;" | psql -Aqt $DB -audit_only -post_audit - - # Check wire transfer lag reported (no aggregator!) # NOTE: This test is EXPECTED to fail for ~1h after # re-generating the test database as we do not @@ -819,6 +809,15 @@ post_audit # taler-wire-auditor.c) if [ $DATABASE_AGE -gt 3600 ] then + + # Wire fees are only checked/generated once there are + # actual outgoing wire transfers, so we need to run the + # aggregator here. + pre_audit aggregator + echo "UPDATE wire_fee SET wire_fee_frac=100;" | psql -Aqt $DB + audit_only + post_audit + echo -n "Testing inconsistency detection... " TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json` if test "x$TABLE" != "xwire-fee" @@ -831,15 +830,16 @@ then exit_fail "Reported diagnostic wrong: $DIAG" fi echo PASS + + # cannot easily undo aggregator, hence full reload + echo -n "Reloading database ..." + full_reload + echo "DONE" + else - echo "Inconsistency detection: SKIP (database too new)" + echo "Test skipped (database too new)" fi -# cannot easily undo aggregator, hence full reload -echo -n "Reloading database ..." -full_reload -echo "DONE" - } @@ -847,21 +847,24 @@ echo "DONE" # Test where h_wire in the deposit table is wrong function test_15() { echo "===========15: deposit wire hash wrong=================" -# Modify h_wire hash, so it is inconsistent with 'wire' -echo "UPDATE deposits SET h_wire='\x973e52d193a357940be9ef2939c19b0575ee1101f52188c3c01d9005b7d755c397e92624f09cfa709104b3b65605fe5130c90d7e1b7ee30f8fc570f39c16b853' WHERE deposit_serial_id=1" | psql -Aqt $DB - -# The auditor checks h_wire consistency only for -# coins where the wire transfer has happened, hence -# run aggregator first to get this test to work. -run_audit aggregator # Check wire transfer lag reported (no aggregator!) + # NOTE: This test is EXPECTED to fail for ~1h after # re-generating the test database as we do not # report lag of less than 1h (see GRACE_PERIOD in # taler-wire-auditor.c) if [ $DATABASE_AGE -gt 3600 ] then + + # Modify h_wire hash, so it is inconsistent with 'wire' + echo "UPDATE deposits SET h_wire='\x973e52d193a357940be9ef2939c19b0575ee1101f52188c3c01d9005b7d755c397e92624f09cfa709104b3b65605fe5130c90d7e1b7ee30f8fc570f39c16b853' WHERE deposit_serial_id=1" | psql -Aqt $DB + + # The auditor checks h_wire consistency only for + # coins where the wire transfer has happened, hence + # run aggregator first to get this test to work. + run_audit aggregator + echo -n "Testing inconsistency detection... " TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json` if test "x$TABLE" != "xaggregation" -a "x$TABLE" != "xdeposits" @@ -869,14 +872,15 @@ then exit_fail "Reported table wrong: $TABLE" fi echo PASS + + # cannot easily undo aggregator, hence full reload + echo -n "Reloading database ..." + full_reload + echo "DONE" + else - echo "Inconsistency detection: SKIP (database too new)" + echo "Test skipped (database too new)" fi - -# cannot easily undo aggregator, hence full reload -echo -n "Reloading database ..." -full_reload -echo "DONE" } @@ -884,20 +888,6 @@ echo "DONE" function test_16() { echo "===========16: incorrect wire_out amount=================" -# First, we need to run the aggregator so we even -# have a wire_out to modify. -pre_audit aggregator - -# Modify wire amount, such that it is inconsistent with 'aggregation' -# (exchange account is #2, so the logic below should select the outgoing -# wire transfer): -OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt` -OLD_AMOUNT=`echo "SELECT amount FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt` -NEW_AMOUNT="TESTKUDOS:50" -echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB - -audit_only - # Check wire transfer lag reported (no aggregator!) # NOTE: This test is EXPECTED to fail for ~1h after # re-generating the test database as we do not @@ -905,6 +895,21 @@ audit_only # taler-wire-auditor.c) if [ $DATABASE_AGE -gt 3600 ] then + + # First, we need to run the aggregator so we even + # have a wire_out to modify. + pre_audit aggregator + + # Modify wire amount, such that it is inconsistent with 'aggregation' + # (exchange account is #2, so the logic below should select the outgoing + # wire transfer): + OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt` + OLD_AMOUNT=`echo "SELECT amount FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt` + NEW_AMOUNT="TESTKUDOS:50" + echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB + + audit_only + echo -n "Testing inconsistency detection... " AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json` @@ -928,46 +933,47 @@ then exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT" fi echo PASS -else - echo "Inconsistency detection: SKIP (database too new)" -fi - -echo "Second modification: wire nothing" -NEW_AMOUNT="TESTKUDOS:0" -echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB + echo "Second modification: wire nothing" + NEW_AMOUNT="TESTKUDOS:0" + echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB -audit_only + audit_only -echo -n "Testing inconsistency detection... " + echo -n "Testing inconsistency detection... " -AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json` -if test "x$AMOUNT" != "x$OLD_AMOUNT" -then - exit_fail "Reported justified amount wrong: $AMOUNT" -fi -AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_wired < test-wire-audit.json` -if test "x$AMOUNT" != "x$NEW_AMOUNT" -then - exit_fail "Reported wired amount wrong: $AMOUNT" -fi -TOTAL_AMOUNT=`jq -r .total_wire_out_delta_minus < test-wire-audit.json` -if test "x$TOTAL_AMOUNT" != "x$OLD_AMOUNT" -then - exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT (wanted $OLD_AMOUNT)" -fi -TOTAL_AMOUNT=`jq -r .total_wire_out_delta_plus < test-wire-audit.json` -if test "x$TOTAL_AMOUNT" != "xTESTKUDOS:0" -then - exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT" -fi -echo PASS + AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json` + if test "x$AMOUNT" != "x$OLD_AMOUNT" + then + exit_fail "Reported justified amount wrong: $AMOUNT" + fi + AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_wired < test-wire-audit.json` + if test "x$AMOUNT" != "x$NEW_AMOUNT" + then + exit_fail "Reported wired amount wrong: $AMOUNT" + fi + TOTAL_AMOUNT=`jq -r .total_wire_out_delta_minus < test-wire-audit.json` + if test "x$TOTAL_AMOUNT" != "x$OLD_AMOUNT" + then + exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT (wanted $OLD_AMOUNT)" + fi + TOTAL_AMOUNT=`jq -r .total_wire_out_delta_plus < test-wire-audit.json` + if test "x$TOTAL_AMOUNT" != "xTESTKUDOS:0" + then + exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT" + fi + echo PASS -post_audit + post_audit + # cannot easily undo aggregator, hence full reload + echo -n "Reloading database ..." + full_reload + echo "DONE" +else + echo "Test skipped (database too new)" +fi -# Undo -echo "UPDATE app_banktransaction SET amount='${OLD_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB } @@ -977,38 +983,53 @@ echo "UPDATE app_banktransaction SET amount='${OLD_AMOUNT}' WHERE id='${OLD_ID}' function test_17() { echo "===========17: incorrect wire_out timestamp=================" -# First, we need to run the aggregator so we even -# have a wire_out to modify. -pre_audit aggregator +# Check wire transfer lag reported (no aggregator!) +# NOTE: This test is EXPECTED to fail for ~1h after +# re-generating the test database as we do not +# report lag of less than 1h (see GRACE_PERIOD in +# taler-wire-auditor.c) +if [ $DATABASE_AGE -gt 3600 ] +then -# Modify wire amount, such that it is inconsistent with 'aggregation' -# (exchange account is #2, so the logic below should select the outgoing -# wire transfer): -OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt` -OLD_DATE=`echo "SELECT date FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt` -# Note: need - interval '1h' as "NOW()" may otherwise be exactly what is already in the DB -# (due to rounding, if this machine is fast...) -echo "UPDATE app_banktransaction SET date=NOW()- interval '1 hour' WHERE id='${OLD_ID}';" | psql -Aqt $DB + # First, we need to run the aggregator so we even + # have a wire_out to modify. + pre_audit aggregator -audit_only -post_audit + # Modify wire amount, such that it is inconsistent with 'aggregation' + # (exchange account is #2, so the logic below should select the outgoing + # wire transfer): + OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt` + OLD_DATE=`echo "SELECT date FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt` + # Note: need - interval '1h' as "NOW()" may otherwise be exactly what is already in the DB + # (due to rounding, if this machine is fast...) + echo "UPDATE app_banktransaction SET date=NOW()- interval '1 hour' WHERE id='${OLD_ID}';" | psql -Aqt $DB -echo -n "Testing inconsistency detection... " -TABLE=`jq -r .row_minor_inconsistencies[0].table < test-wire-audit.json` -if test "x$TABLE" != "xwire_out" -then - exit_fail "Reported table wrong: $TABLE" -fi -DIAG=`jq -r .row_minor_inconsistencies[0].diagnostic < test-wire-audit.json` -DIAG=`echo "$DIAG" | awk '{print $1 " " $2 " " $3}'` -if test "x$DIAG" != "xexecution date missmatch" -then - exit_fail "Reported diagnostic wrong: $DIAG" + audit_only + post_audit + + echo -n "Testing inconsistency detection... " + TABLE=`jq -r .row_minor_inconsistencies[0].table < test-wire-audit.json` + if test "x$TABLE" != "xwire_out" + then + exit_fail "Reported table wrong: $TABLE" + fi + DIAG=`jq -r .row_minor_inconsistencies[0].diagnostic < test-wire-audit.json` + DIAG=`echo "$DIAG" | awk '{print $1 " " $2 " " $3}'` + if test "x$DIAG" != "xexecution date missmatch" + then + exit_fail "Reported diagnostic wrong: $DIAG" + fi + echo PASS + + # cannot easily undo aggregator, hence full reload + echo -n "Reloading database ..." + full_reload + echo "DONE" + +else + echo "Test skipped (database too new)" fi -echo PASS -# Undo -echo "UPDATE app_banktransaction SET date='${OLD_DATE}' WHERE id='${OLD_ID}';" | psql -Aqt $DB } @@ -1069,44 +1090,57 @@ echo "DONE" function test_19() { echo "===========19: outgoing wire subject malformed=================" -# Need to first run the aggregator so the outgoing transfer exists -pre_audit aggregator +# Check wire transfer lag reported (no aggregator!) +# NOTE: This test is EXPECTED to fail for ~1h after +# re-generating the test database as we do not +# report lag of less than 1h (see GRACE_PERIOD in +# taler-wire-auditor.c) +if [ $DATABASE_AGE -gt 3600 ] +then -# Generate mal-formed wire transfer subject -SUBJECT=YDVD2XBQT62553Z2TX8MM -# Account #2 = exchange, pick outgoing transfer -OLD_SUBJECT=`echo "SELECT subject FROM app_banktransaction WHERE debit_account_id=2;" | psql $DB -Aqt` -echo "UPDATE app_banktransaction SET subject='${SUBJECT}' WHERE debit_account_id=2;" | psql -Aqt $DB + # Need to first run the aggregator so the outgoing transfer exists + pre_audit aggregator -audit_only -post_audit + # Generate mal-formed wire transfer subject + SUBJECT=YDVD2XBQT62553Z2TX8MM + # Account #2 = exchange, pick outgoing transfer + OLD_SUBJECT=`echo "SELECT subject FROM app_banktransaction WHERE debit_account_id=2;" | psql $DB -Aqt` + echo "UPDATE app_banktransaction SET subject='${SUBJECT}' WHERE debit_account_id=2;" | psql -Aqt $DB + audit_only + post_audit -echo -n "Testing wire transfer subject malformed detection... " -DIAGNOSTIC=`jq -r .wire_format_inconsistencies[0].diagnostic < test-wire-audit.json` -WANT="malformed subject \`${SUBJECT}'" -if test "x$DIAGNOSTIC" != "x$WANT" -then - exit_fail "Reported diagnostic: $DIAGNOSTIC, wanted $WANT" -fi -jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null || exit_fail "Falsly claimed wire transfer not detected" + echo -n "Testing wire transfer subject malformed detection... " -DELTA=`jq -r .total_wire_out_delta_minus < test-wire-audit.json` -if test $DELTA == "TESTKUDOS:0" -then - exit_fail "Expected total wire delta minus wrong, got $DELTA" -fi -DELTA=`jq -r .total_wire_format_amount < test-wire-audit.json` -if test $DELTA == "TESTKUDOS:0" -then - exit_fail "Expected total format amount wrong, got $DELTA" -fi + DIAGNOSTIC=`jq -r .wire_format_inconsistencies[0].diagnostic < test-wire-audit.json` + WANT="malformed subject \`${SUBJECT}'" + if test "x$DIAGNOSTIC" != "x$WANT" + then + exit_fail "Reported diagnostic: $DIAGNOSTIC, wanted $WANT" + fi + jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null || exit_fail "Falsly claimed wire transfer not detected" -echo "PASS" + DELTA=`jq -r .total_wire_out_delta_minus < test-wire-audit.json` + if test $DELTA == "TESTKUDOS:0" + then + exit_fail "Expected total wire delta minus wrong, got $DELTA" + fi + DELTA=`jq -r .total_wire_format_amount < test-wire-audit.json` + if test $DELTA == "TESTKUDOS:0" + then + exit_fail "Expected total format amount wrong, got $DELTA" + fi -# Undo -echo "UPDATE app_banktransaction SET subject='${OLD_SUBJECT}' WHERE debit_account_id=2;" | psql -Aqt $DB + echo "PASS" + + # cannot easily undo aggregator, hence full reload + echo -n "Reloading database ..." + full_reload + echo "DONE" +else + echo "Test skipped (database too new)" +fi } @@ -1114,34 +1148,46 @@ echo "UPDATE app_banktransaction SET subject='${OLD_SUBJECT}' WHERE debit_accoun function test_20() { echo "===========20: reserve closure done properly =================" -OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` -OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` -RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` -OLD_EXP=`echo "SELECT expiration_date FROM reserves WHERE reserve_pub='${RES_PUB}';" | psql $DB -Aqt` -VAL_DELTA=1 -NEW_TIME=`expr $OLD_TIME - 3024000000000` # 5 weeks -NEW_EXP=`expr $OLD_EXP - 3024000000000` # 5 weeks -NEW_CREDIT=`expr $OLD_VAL + $VAL_DELTA` -echo "UPDATE reserves_in SET execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB -echo "UPDATE reserves SET current_balance_val=${VAL_DELTA}+current_balance_val,expiration_date='${NEW_EXP}' WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB +# NOTE: This test is EXPECTED to fail for ~1h after +# re-generating the test database as we do not +# report lag of less than 1h (see GRACE_PERIOD in +# taler-wire-auditor.c) +if [ $DATABASE_AGE -gt 3600 ] +then -# Need to run with the aggregator so the reserve closure happens -run_audit aggregator + OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` + OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` + RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt` + OLD_EXP=`echo "SELECT expiration_date FROM reserves WHERE reserve_pub='${RES_PUB}';" | psql $DB -Aqt` + VAL_DELTA=1 + NEW_TIME=`expr $OLD_TIME - 3024000000000` # 5 weeks + NEW_EXP=`expr $OLD_EXP - 3024000000000` # 5 weeks + NEW_CREDIT=`expr $OLD_VAL + $VAL_DELTA` + echo "UPDATE reserves_in SET execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB + echo "UPDATE reserves SET current_balance_val=${VAL_DELTA}+current_balance_val,expiration_date='${NEW_EXP}' WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB -echo -n "Testing reserve closure was done correctly... " + # Need to run with the aggregator so the reserve closure happens + run_audit aggregator -jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected reserve not closed inconsistency detected" + echo -n "Testing reserve closure was done correctly... " -echo "PASS" + jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected reserve not closed inconsistency detected" -echo -n "Testing no bogus transfers detected... " -jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null && exit_fail "Unexpected wire out inconsistency detected in run with reserve closure" + echo "PASS" -echo "PASS" + echo -n "Testing no bogus transfers detected... " + jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null && exit_fail "Unexpected wire out inconsistency detected in run with reserve closure" -# Undo -echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB -echo "UPDATE reserves SET expiration_date='${OLD_EXP}',current_balance_val=current_balance_val-${VAL_DELTA} WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB + echo "PASS" + + # cannot easily undo aggregator, hence full reload + echo -n "Reloading database ..." + full_reload + echo "DONE" + +else + echo "Test skipped (database too new)" +fi } @@ -1225,9 +1271,10 @@ then echo "PASS" - # Undo - echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB - echo "UPDATE reserves SET expiration_date='${OLD_EXP}',current_balance_val=current_balance_val-${VAL_DELTA} WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB + # cannot easily undo aggregator, hence full reload + echo -n "Reloading database ..." + full_reload + echo "DONE" else echo "Test skipped (database too new)" fi @@ -1249,6 +1296,8 @@ fi # *************** Main test loop starts here ************** +# Run all the tests against the database given in $1. +# Sets $fail to 0 on success, non-zero on failure. check_with_database() { BASEDB=$1 @@ -1283,20 +1332,13 @@ check_with_database() break fi done + echo "Cleanup (disabled)" + # dropdb $DB + # rm -r $WIRE_FEE_DIR + # rm -f test-audit.log test-wire-audit.log } -echo "Cleanup (disabled)" -# dropdb $DB -# rm -r $WIRE_FEE_DIR -# rm -f test-audit.log test-wire-audit.log - -# if test -n "${MYDIR:-}" -# then -# rm -rf $MYDIR -# fi - - # *************** Main logic starts here ************** @@ -1320,21 +1362,26 @@ if test -n "${1:-}" then echo "Custom run, will only run on existing DB." else - echo "Testing for taler-wallet-cli" + echo -n "Testing for taler-wallet-cli" if taler-wallet-cli -h >/dev/null /dev/null then MYDIR=`mktemp -d /tmp/taler-auditor-basedbXXXXXX` echo " FOUND. Generating fresh database at $MYDIR" if ./generate-auditor-basedb.sh $MYDIR/basedb then - check_with_database $MYDIR + check_with_database $MYDIR/basedb if test x$fail != x0 then exit $fail + else + echo "Cleaning up $MYDIR..." + rm -rf $MYDIR || echo "Removing $MYDIR failed" fi else echo "Generation failed, running only on existing DB" fi + else + echo " NOT FOUND, running only on existing DB" fi fi -- cgit v1.2.3