add logic to generate fresh database
This commit is contained in:
parent
d585c40996
commit
bde4c742de
@ -1,7 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Script to generate the basic database for auditor
|
# Script to generate the basic database for auditor
|
||||||
# testing from a 'correct' interaction between exchange,
|
# testing from a 'correct' interaction between exchange,
|
||||||
# wallet and merchant. Creates 'auditor-basedb.sql'.
|
# wallet and merchant.
|
||||||
|
#
|
||||||
|
# Creates $BASEDB.sql, $BASEDB.fees and $BASEDB.mpub.
|
||||||
|
# Default $BASEDB is "auditor-basedb", override via $1.
|
||||||
#
|
#
|
||||||
# Currently must be run online as it interacts with
|
# Currently must be run online as it interacts with
|
||||||
# bank.test.taler.net; also requires the wallet CLI
|
# bank.test.taler.net; also requires the wallet CLI
|
||||||
|
@ -216,10 +216,7 @@ echo -n "Check for lag detection... "
|
|||||||
# re-generating the test database as we do not
|
# re-generating the test database as we do not
|
||||||
# report lag of less than 1h (see GRACE_PERIOD in
|
# report lag of less than 1h (see GRACE_PERIOD in
|
||||||
# taler-wire-auditor.c)
|
# taler-wire-auditor.c)
|
||||||
AGE=`stat -c %Y ${BASEDB}.fees`
|
if [ $DATABASE_AGE -gt 3600 ]
|
||||||
NOW=`date +%s`
|
|
||||||
DELTA=`expr $NOW - $AGE`
|
|
||||||
if [ $DELTA -gt 3600 ]
|
|
||||||
then
|
then
|
||||||
jq -e .lag_details[0] < test-wire-audit.json > /dev/null || exit_fail "Lag not detected in run without aggregator at age $DELTA"
|
jq -e .lag_details[0] < test-wire-audit.json > /dev/null || exit_fail "Lag not detected in run without aggregator at age $DELTA"
|
||||||
|
|
||||||
@ -230,7 +227,7 @@ then
|
|||||||
fi
|
fi
|
||||||
echo "PASS"
|
echo "PASS"
|
||||||
else
|
else
|
||||||
echo "SKIP"
|
echo "SKIP (database too new)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -814,6 +811,14 @@ echo "UPDATE wire_fee SET wire_fee_frac=100;" | psql -Aqt $DB
|
|||||||
audit_only
|
audit_only
|
||||||
post_audit
|
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
|
||||||
|
# report lag of less than 1h (see GRACE_PERIOD in
|
||||||
|
# taler-wire-auditor.c)
|
||||||
|
if [ $DATABASE_AGE -gt 3600 ]
|
||||||
|
then
|
||||||
echo -n "Testing inconsistency detection... "
|
echo -n "Testing inconsistency detection... "
|
||||||
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
||||||
if test "x$TABLE" != "xwire-fee"
|
if test "x$TABLE" != "xwire-fee"
|
||||||
@ -826,6 +831,9 @@ then
|
|||||||
exit_fail "Reported diagnostic wrong: $DIAG"
|
exit_fail "Reported diagnostic wrong: $DIAG"
|
||||||
fi
|
fi
|
||||||
echo PASS
|
echo PASS
|
||||||
|
else
|
||||||
|
echo "Inconsistency detection: SKIP (database too new)"
|
||||||
|
fi
|
||||||
|
|
||||||
# cannot easily undo aggregator, hence full reload
|
# cannot easily undo aggregator, hence full reload
|
||||||
echo -n "Reloading database ..."
|
echo -n "Reloading database ..."
|
||||||
@ -847,6 +855,13 @@ echo "UPDATE deposits SET h_wire='\x973e52d193a357940be9ef2939c19b0575ee1101f521
|
|||||||
# run aggregator first to get this test to work.
|
# run aggregator first to get this test to work.
|
||||||
run_audit aggregator
|
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
|
||||||
echo -n "Testing inconsistency detection... "
|
echo -n "Testing inconsistency detection... "
|
||||||
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
||||||
if test "x$TABLE" != "xaggregation" -a "x$TABLE" != "xdeposits"
|
if test "x$TABLE" != "xaggregation" -a "x$TABLE" != "xdeposits"
|
||||||
@ -854,6 +869,9 @@ then
|
|||||||
exit_fail "Reported table wrong: $TABLE"
|
exit_fail "Reported table wrong: $TABLE"
|
||||||
fi
|
fi
|
||||||
echo PASS
|
echo PASS
|
||||||
|
else
|
||||||
|
echo "Inconsistency detection: SKIP (database too new)"
|
||||||
|
fi
|
||||||
|
|
||||||
# cannot easily undo aggregator, hence full reload
|
# cannot easily undo aggregator, hence full reload
|
||||||
echo -n "Reloading database ..."
|
echo -n "Reloading database ..."
|
||||||
@ -880,6 +898,13 @@ echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}'
|
|||||||
|
|
||||||
audit_only
|
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
|
||||||
|
# report lag of less than 1h (see GRACE_PERIOD in
|
||||||
|
# taler-wire-auditor.c)
|
||||||
|
if [ $DATABASE_AGE -gt 3600 ]
|
||||||
|
then
|
||||||
echo -n "Testing inconsistency detection... "
|
echo -n "Testing inconsistency detection... "
|
||||||
|
|
||||||
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json`
|
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json`
|
||||||
@ -903,6 +928,10 @@ then
|
|||||||
exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
|
exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
|
||||||
fi
|
fi
|
||||||
echo PASS
|
echo PASS
|
||||||
|
else
|
||||||
|
echo "Inconsistency detection: SKIP (database too new)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "Second modification: wire nothing"
|
echo "Second modification: wire nothing"
|
||||||
NEW_AMOUNT="TESTKUDOS:0"
|
NEW_AMOUNT="TESTKUDOS:0"
|
||||||
@ -1150,6 +1179,14 @@ echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL}
|
|||||||
function test_22() {
|
function test_22() {
|
||||||
echo "===========22: reserve closure missreported ================="
|
echo "===========22: reserve closure missreported ================="
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
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`
|
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`
|
RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
||||||
@ -1191,6 +1228,9 @@ echo "PASS"
|
|||||||
# Undo
|
# 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_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 "UPDATE reserves SET expiration_date='${OLD_EXP}',current_balance_val=current_balance_val-${VAL_DELTA} WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
|
||||||
|
else
|
||||||
|
echo "Test skipped (database too new)"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1206,33 +1246,30 @@ echo "UPDATE reserves SET expiration_date='${OLD_EXP}',current_balance_val=curre
|
|||||||
# **************************************************
|
# **************************************************
|
||||||
|
|
||||||
|
|
||||||
|
# *************** Main test loop starts here **************
|
||||||
|
|
||||||
# *************** Main logic starts here **************
|
|
||||||
|
|
||||||
# ####### Setup globals ######
|
check_with_database()
|
||||||
# Postgres database to use
|
{
|
||||||
DB=taler-auditor-test
|
BASEDB=$1
|
||||||
# Prefix for the data resources to use
|
echo "Running test suite with database $BASEDB"
|
||||||
BASEDB="auditor-basedb"
|
|
||||||
|
# Setup database-specific globals
|
||||||
MASTER_PUB=`cat ${BASEDB}.mpub`
|
MASTER_PUB=`cat ${BASEDB}.mpub`
|
||||||
# Configuration file to use
|
|
||||||
CONF=test-auditor.conf
|
|
||||||
|
|
||||||
# Where to store wire fee details for aggregator
|
# Where to store wire fee details for aggregator
|
||||||
WIRE_FEE_DIR=`taler-config -c $CONF -f -s exchangedb -o WIREFEE_BASE_DIR`
|
WIRE_FEE_DIR=`taler-config -c $CONF -f -s exchangedb -o WIREFEE_BASE_DIR`
|
||||||
mkdir -p $WIRE_FEE_DIR
|
mkdir -p $WIRE_FEE_DIR
|
||||||
cp ${BASEDB}.fees $WIRE_FEE_DIR/x-taler-bank.fee
|
cp ${BASEDB}.fees $WIRE_FEE_DIR/x-taler-bank.fee
|
||||||
|
|
||||||
|
# Determine database age
|
||||||
|
AGE=`stat -c %Y ${BASEDB}.fees`
|
||||||
|
NOW=`date +%s`
|
||||||
|
DATABASE_AGE=`expr $NOW - $AGE`
|
||||||
|
|
||||||
# test required commands exist
|
|
||||||
echo "Testing for jq"
|
|
||||||
jq -h > /dev/null || exit_skip "jq required"
|
|
||||||
echo "Testing for taler-bank-manage"
|
|
||||||
taler-bank-manage -h >/dev/null </dev/null || exit_skip "taler-bank-manage required"
|
|
||||||
echo "Testing for pdflatex"
|
|
||||||
which pdflatex > /dev/null </dev/null || exit_skip "pdflatex required"
|
|
||||||
|
|
||||||
echo -n "Database setup ..."
|
# Load database
|
||||||
|
echo -n "Running initial database setup ..."
|
||||||
full_reload
|
full_reload
|
||||||
echo " DONE"
|
echo " DONE"
|
||||||
|
|
||||||
@ -1246,6 +1283,7 @@ do
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "Cleanup (disabled)"
|
echo "Cleanup (disabled)"
|
||||||
@ -1253,4 +1291,53 @@ echo "Cleanup (disabled)"
|
|||||||
# rm -r $WIRE_FEE_DIR
|
# rm -r $WIRE_FEE_DIR
|
||||||
# rm -f test-audit.log test-wire-audit.log
|
# rm -f test-audit.log test-wire-audit.log
|
||||||
|
|
||||||
|
# if test -n "${MYDIR:-}"
|
||||||
|
# then
|
||||||
|
# rm -rf $MYDIR
|
||||||
|
# fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# *************** Main logic starts here **************
|
||||||
|
|
||||||
|
# ####### Setup globals ######
|
||||||
|
# Postgres database to use
|
||||||
|
DB=taler-auditor-test
|
||||||
|
|
||||||
|
# Configuration file to use
|
||||||
|
CONF=test-auditor.conf
|
||||||
|
|
||||||
|
# test required commands exist
|
||||||
|
echo "Testing for jq"
|
||||||
|
jq -h > /dev/null || exit_skip "jq required"
|
||||||
|
echo "Testing for taler-bank-manage"
|
||||||
|
taler-bank-manage -h >/dev/null </dev/null || exit_skip "taler-bank-manage required"
|
||||||
|
echo "Testing for pdflatex"
|
||||||
|
which pdflatex > /dev/null </dev/null || exit_skip "pdflatex required"
|
||||||
|
|
||||||
|
# check if we should regenerate the database
|
||||||
|
if test -n "${1:-}"
|
||||||
|
then
|
||||||
|
echo "Custom run, will only run on existing DB."
|
||||||
|
else
|
||||||
|
echo "Testing for taler-wallet-cli"
|
||||||
|
if taler-wallet-cli -h >/dev/null </dev/null 2>/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
|
||||||
|
if test x$fail != x0
|
||||||
|
then
|
||||||
|
exit $fail
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Generation failed, running only on existing DB"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_with_database "auditor-basedb"
|
||||||
|
|
||||||
exit $fail
|
exit $fail
|
||||||
|
@ -235,6 +235,20 @@
|
|||||||
#define TALER_SIGNATURE_EXCHANGE_TEST_EDDSA 1303
|
#define TALER_SIGNATURE_EXCHANGE_TEST_EDDSA 1303
|
||||||
|
|
||||||
|
|
||||||
|
/************************/
|
||||||
|
/* Anastasis signatures */
|
||||||
|
/************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EdDSA signature for a policy upload.
|
||||||
|
*/
|
||||||
|
#define TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD 1400
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EdDSA signature for a policy download.
|
||||||
|
*/
|
||||||
|
#define TALER_SIGNATURE_ANASTASIS_POLICY_DOWNLOAD 1401
|
||||||
|
|
||||||
|
|
||||||
GNUNET_NETWORK_STRUCT_BEGIN
|
GNUNET_NETWORK_STRUCT_BEGIN
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user