summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Zwahlen <cedric.zwahlen@students.bfh.ch>2024-04-21 22:32:31 +0200
committerCedric Zwahlen <cedric.zwahlen@students.bfh.ch>2024-04-21 22:32:31 +0200
commitae182958503a064f307aa635d6a909e0ca38cd3a (patch)
treeaadeedb3388fc3c196a46740126d6f2425ddf34a
parent8d593e3bb3f60d5d5fd1ea4a47d7814fc008302b (diff)
parent7bfa9a3ed79499aa08547bede9fa881a2fed1ed5 (diff)
downloadexchange-ae182958503a064f307aa635d6a909e0ca38cd3a.tar.gz
exchange-ae182958503a064f307aa635d6a909e0ca38cd3a.tar.bz2
exchange-ae182958503a064f307aa635d6a909e0ca38cd3a.zip
Merge remote-tracking branch 'origin/dev/nic/real-time-auditor-zwah' into dev/nic/real-time-auditor-zwah
# Conflicts: # src/auditor/test-auditor.sh
-rwxr-xr-xsrc/auditor/test-auditor.sh286
1 files changed, 163 insertions, 123 deletions
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index da2316ca1..4167d6d56 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -226,24 +226,24 @@ function audit_only () {
2> "${MY_TMP_DIR}/test-audit-reserves-inc.err" \
|| exit_fail "incremental reserves audit failed (see ${MY_TMP_DIR}/test-audit-reserves-inc.*)"
echo -n "."
- $VALGRIND taler-helper-auditor-wire \
- -i \
- -L DEBUG \
- -c "$CONF" \
- -t \
- > "${MY_TMP_DIR}/test-audit-wire.out" \
- 2> "${MY_TMP_DIR}/test-audit-wire.err" \
- || exit_fail "wire audit failed (see ${MY_TMP_DIR}/test-audit-wire.*)"
- echo -n "."
- $VALGRIND taler-helper-auditor-wire \
- -i \
- -L DEBUG \
- -c "$CONF" \
- -t \
- > "${MY_TMP_DIR}/test-audit-wire-inc.out" \
- 2> "${MY_TMP_DIR}/test-audit-wire-inc.err" \
- || exit_fail "wire audit inc failed (see ${MY_TMP_DIR}/test-audit-wire-inc.*)"
- echo -n "."
+ #$VALGRIND taler-helper-auditor-wire \
+ # -i \
+ # -L DEBUG \
+ # -c "$CONF" \
+ # -t \
+ # > "${MY_TMP_DIR}/test-audit-wire.out" \
+ # 2> "${MY_TMP_DIR}/test-audit-wire.err" \
+ # || exit_fail "wire audit failed (see ${MY_TMP_DIR}/test-audit-wire.*)"
+ #echo -n "."
+ #$VALGRIND taler-helper-auditor-wire \
+ # -i \
+ # -L DEBUG \
+ # -c "$CONF" \
+ # -t \
+ # > "${MY_TMP_DIR}/test-audit-wire-inc.out" \
+ # 2> "${MY_TMP_DIR}/test-audit-wire-inc.err" \
+ # || exit_fail "wire audit inc failed (see ${MY_TMP_DIR}/test-audit-wire-inc.*)"
+ #echo -n "."
$VALGRIND taler-helper-auditor-purses \
-i \
-L DEBUG \
@@ -366,29 +366,72 @@ function full_reload()
stop_libeufin
}
+function build_datastructure() {
+ echo -n "Starting auditor..."
+ taler-auditor-httpd \
+ -c "${CONF}" \
+ -L INFO \
+ 2> "${MY_TMP_DIR}/auditor-httpd-drain.err" &
+ EPID=$!
+
+ # Wait for all services to be available
+ for n in $(seq 1 50)
+ do
+ echo -n "."
+ sleep 0.1
+ OK=0
+ # exchange
+ wget "http://localhost:8083/seed" \
+ -o /dev/null \
+ -O /dev/null \
+ >/dev/null \
+ || continue
+ OK=1
+ break
+ done
+ echo "... DONE."
+ export CONF
+ #create request json
+ SUPPRESSED=false
+ ROW_ID=0
+ REQUEST_PARAMS=$( jq -n \
+ --arg rs $SUPPRESSED \
+ --arg id $ROW_ID \
+ '{return_suppressed: $rs, row_id: $id}' )
+
+
+
+}
+
function test_0() {
echo "===========0: normal run with aggregator==========="
run_audit aggregator
+ build_datastructure
echo "Checking output"
+
# if an emergency was detected, that is a bug and we should fail
echo -n "Test for emergencies... "
- jq -e .emergencies[0] < test-audit-coins.json > /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo PASS
+ curl -s -H "Accept: application/json" -o "${MY_TMP_DIR}/test-audit-emergencies.json" 'localhost:8083/emergency'
+ jq -e .emergency[0] < ${MY_TMP_DIR}/test-audit-emergencies.json > /dev/null && exit_fail "Unexpected emergency detected in ordinary run" || echo PASS
echo -n "Test for deposit confirmation emergencies... "
- jq -e .deposit_confirmation_inconsistencies[0] < test-audit-deposits.json > /dev/null && exit_fail "Unexpected deposit confirmation inconsistency detected" || echo PASS
+ curl -s -H "Accept: application/json" -o "${MY_TMP_DIR}/test-audit-deposits.json" 'localhost:8083/deposit-confirmation'
+ jq -e .deposit_confirmation[0] < ${MY_TMP_DIR}/test-audit-deposits.json > /dev/null && exit_fail "Unexpected deposit confirmation inconsistency detected" || echo PASS
+ curl -s -H "Accept: application/json" -o "${MY_TMP_DIR}/test-audit-emergency-by-count.json" 'localhost:8083/emergency-by-count'
echo -n "Test for emergencies by count... "
- jq -e .emergencies_by_count[0] < test-audit-coins.json > /dev/null && exit_fail "Unexpected emergency by count detected in ordinary run" || echo PASS
+ jq -e .emergency_by_count[0] < ${MY_TMP_DIR}/test-audit-emergency-by-count.json > /dev/null && exit_fail "Unexpected emergency by count detected in ordinary run" || echo PASS
echo -n "Test for wire inconsistencies... "
- jq -e .wire_out_amount_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected wire out inconsistency detected in ordinary run"
- jq -e .reserve_in_amount_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected reserve in inconsistency detected in ordinary run"
- jq -e .misattribution_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected misattribution inconsistency detected in ordinary run"
- jq -e .row_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected row inconsistency detected in ordinary run"
- jq -e .denomination_key_validity_withdraw_inconsistencies[0] < test-audit-reserves.json > /dev/null && exit_fail "Unexpected denomination key withdraw inconsistency detected in ordinary run"
- jq -e .row_minor_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected minor row inconsistency detected in ordinary run"
- jq -e .lag_details[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected lag detected in ordinary run"
- jq -e .wire_format_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected wire format inconsistencies detected in ordinary run"
+ #jq -e .wire_out_amount_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected wire out inconsistency detected in ordinary run"
+ #jq -e .reserve_in_amount_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected reserve in inconsistency detected in ordinary run"
+ #jq -e .misattribution_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected misattribution inconsistency detected in ordinary run"
+ #jq -e .row_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected row inconsistency detected in ordinary run"
+ curl -s -H "Accept: application/json" -o "${MY_TMP_DIR}/test-audit-denomination-key-validity-withdraw-inconsistency.json" 'localhost:8083/denomination-key-validity-withdraw-inconsistency'
+ jq -e .denomination_key_validity_withdraw_inconsistency[0] < ${MY_TMP_DIR}/test-audit-denomination-key-validity-withdraw-inconsistency.json > /dev/null && exit_fail "Unexpected denomination key withdraw inconsistency detected in ordinary run"
+ #jq -e .row_minor_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected minor row inconsistency detected in ordinary run"
+ #jq -e .lag_details[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected lag detected in ordinary run"
+ #jq -e .wire_format_inconsistencies[0] < test-audit-wire.json > /dev/null && exit_fail "Unexpected wire format inconsistencies detected in ordinary run"
# TODO: check operation balances are correct (once we have all transaction types and wallet is deterministic)
@@ -396,49 +439,55 @@ function test_0() {
echo PASS
- LOSS=$(jq -r .total_bad_sig_loss < test-audit-aggregation.json)
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong total bad sig loss from aggregation, got unexpected loss of $LOSS"
- fi
- LOSS=$(jq -r .irregular_loss < test-audit-coins.json)
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong total bad sig loss from coins, got unexpected loss of $LOSS"
- fi
- LOSS=$(jq -r .total_bad_sig_loss < test-audit-reserves.json)
- if [ "$LOSS" != "TESTKUDOS:0" ]
- then
- exit_fail "Wrong total bad sig loss from reserves, got unexpected loss of $LOSS"
- fi
-
- echo -n "Test for wire amounts... "
- WIRED=$(jq -r .total_wire_in_delta_plus < test-audit-wire.json)
- if [ "$WIRED" != "TESTKUDOS:0" ]
- then
- exit_fail "Expected total wire delta plus wrong, got $WIRED"
- fi
- WIRED=$(jq -r .total_wire_in_delta_minus < test-audit-wire.json)
- if [ "$WIRED" != "TESTKUDOS:0" ]
- then
- exit_fail "Expected total wire delta minus wrong, got $WIRED"
- fi
- WIRED=$(jq -r .total_wire_out_delta_plus < test-audit-wire.json)
- if [ "$WIRED" != "TESTKUDOS:0" ]
- then
- exit_fail "Expected total wire delta plus wrong, got $WIRED"
- fi
- WIRED=$(jq -r .total_wire_out_delta_minus < test-audit-wire.json)
- if [ "$WIRED" != "TESTKUDOS:0" ]
- then
- exit_fail "Expected total wire delta minus wrong, got $WIRED"
- fi
- WIRED=$(jq -r .total_misattribution_in < test-audit-wire.json)
- if [ "$WIRED" != "TESTKUDOS:0" ]
- then
- exit_fail "Expected total misattribution in wrong, got $WIRED"
- fi
- echo "PASS"
+ # TODO: add filter for bad sig losses
+ #curl -s -H "Accept: application/json" -o "${MY_TMP_DIR}/test-audit-bad-sig-losses.json" 'localhost:8083/bad-sig-losses'
+ #${MY_TMP_DIR}/test-audit-bad-sig-losses.json
+
+ #LOSS=$(jq -r .total_bad_sig_loss < test-audit-aggregation.json)
+ #if [ "$LOSS" != "TESTKUDOS:0" ]
+ #then
+ # exit_fail "Wrong total bad sig loss from aggregation, got unexpected loss of $LOSS"
+ #fi
+ # TODO: think of solution for those auditor run results | maybe get it from auditor_balances?
+ #LOSS=$(jq -r .irregular_loss < test-audit-coins.json)
+ #if [ "$LOSS" != "TESTKUDOS:0" ]
+ #then
+ # exit_fail "Wrong total bad sig loss from coins, got unexpected loss of $LOSS"
+ #fi
+ # TODO: add filter for bad sig losses
+ #LOSS=$(jq -r .total_bad_sig_loss < test-audit-reserves.json)
+ #if [ "$LOSS" != "TESTKUDOS:0" ]
+ #then
+ # exit_fail "Wrong total bad sig loss from reserves, got unexpected loss of $LOSS"
+ #fi
+
+ #echo -n "Test for wire amounts... "
+ #WIRED=$(jq -r .total_wire_in_delta_plus < test-audit-wire.json)
+ #if [ "$WIRED" != "TESTKUDOS:0" ]
+ #then
+ # exit_fail "Expected total wire delta plus wrong, got $WIRED"
+ #fi
+ #WIRED=$(jq -r .total_wire_in_delta_minus < test-audit-wire.json)
+ #if [ "$WIRED" != "TESTKUDOS:0" ]
+ #then
+ # exit_fail "Expected total wire delta minus wrong, got $WIRED"
+ #fi
+ #WIRED=$(jq -r .total_wire_out_delta_plus < test-audit-wire.json)
+ #if [ "$WIRED" != "TESTKUDOS:0" ]
+ #then
+ # exit_fail "Expected total wire delta plus wrong, got $WIRED"
+ #fi
+ #WIRED=$(jq -r .total_wire_out_delta_minus < test-audit-wire.json)
+ #if [ "$WIRED" != "TESTKUDOS:0" ]
+ #then
+ # exit_fail "Expected total wire delta minus wrong, got $WIRED"
+ #fi
+ #WIRED=$(jq -r .total_misattribution_in < test-audit-wire.json)
+ #if [ "$WIRED" != "TESTKUDOS:0" ]
+ #then
+ # exit_fail "Expected total misattribution in wrong, got $WIRED"
+ #fi
+ #echo "PASS"
echo -n "Checking for unexpected arithmetic differences "
LOSS=$(jq -r .total_arithmetic_delta_plus < test-audit-aggregation.json)
@@ -509,31 +558,31 @@ function test_1() {
&& exit_fail "Unexpected emergency by count detected in ordinary run"
echo "PASS"
- echo -n "Test for wire inconsistencies... "
- jq -e .wire_out_amount_inconsistencies[0] \
- < test-audit-wire.json \
- > /dev/null \
- && exit_fail "Unexpected wire out inconsistency detected in ordinary run"
- jq -e .reserve_in_amount_inconsistencies[0] \
- < test-audit-wire.json \
- > /dev/null \
- && exit_fail "Unexpected reserve in inconsistency detected in ordinary run"
- jq -e .misattribution_inconsistencies[0] \
- < test-audit-wire.json \
- > /dev/null \
- && exit_fail "Unexpected misattribution inconsistency detected in ordinary run"
- jq -e .row_inconsistencies[0] \
- < test-audit-wire.json \
- > /dev/null \
- && exit_fail "Unexpected row inconsistency detected in ordinary run"
- jq -e .row_minor_inconsistencies[0] \
- < test-audit-wire.json \
- > /dev/null \
- && exit_fail "Unexpected minor row inconsistency detected in ordinary run"
- jq -e .wire_format_inconsistencies[0] \
- < test-audit-wire.json \
- > /dev/null \
- && exit_fail "Unexpected wire format inconsistencies detected in ordinary run"
+ #echo -n "Test for wire inconsistencies... "
+ #jq -e .wire_out_amount_inconsistencies[0] \
+ # < test-audit-wire.json \
+ # > /dev/null \
+ # && exit_fail "Unexpected wire out inconsistency detected in ordinary run"
+ #jq -e .reserve_in_amount_inconsistencies[0] \
+ # < test-audit-wire.json \
+ # > /dev/null \
+ # && exit_fail "Unexpected reserve in inconsistency detected in ordinary run"
+ #jq -e .misattribution_inconsistencies[0] \
+ # < test-audit-wire.json \
+ # > /dev/null \
+ # && exit_fail "Unexpected misattribution inconsistency detected in ordinary run"
+ #jq -e .row_inconsistencies[0] \
+ # < test-audit-wire.json \
+ # > /dev/null \
+ # && exit_fail "Unexpected row inconsistency detected in ordinary run"
+ #jq -e .row_minor_inconsistencies[0] \
+ # < test-audit-wire.json \
+ # > /dev/null \
+ # && exit_fail "Unexpected minor row inconsistency detected in ordinary run"
+ #jq -e .wire_format_inconsistencies[0] \
+ # < test-audit-wire.json \
+ # > /dev/null \
+ # && exit_fail "Unexpected wire format inconsistencies detected in ordinary run"
# TODO: check operation balances are correct (once we have all transaction types and wallet is deterministic)
# TODO: check revenue summaries are correct (once we have all transaction types and wallet is deterministic)
@@ -2229,45 +2278,36 @@ grep -v host \
> "$TMPDIR/pg_hba.conf.new"
mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf"
"${POSTGRES_PATH}/pg_ctl" \
- -D "$TMPDIR" \
- -l "${MY_TMP_DIR}/postgres.log" \
- start \
- > "${MY_TMP_DIR}/postgres-start.log" \
- 2> "${MY_TMP_DIR}/postgres-start.err"
+ -D "$TMPDIR" \
+ -l "${MY_TMP_DIR}/postgres.log" \
+ start \
+ > "${MY_TMP_DIR}/postgres-start.log" \
+ 2> "${MY_TMP_DIR}/postgres-start.err"
echo " DONE"
PGHOST="$TMPDIR/sockets"
export PGHOST
MYDIR="${MY_TMP_DIR}/basedb"
mkdir -p "${MYDIR}"
+REUSE_BASEDB_DIR=""
if [ -z $REUSE_BASEDB_DIR ]
then
echo "Generating fresh database at $MYDIR"
- if faketime -f '-1 d' ./generate-auditor-basedb.sh -d "$MYDIR/$DB"
+if faketime -f '-1 d' ./generate-auditor-basedb.sh -d "$MYDIR/$DB"
+then
+ echo -n "Reset 'auditor-basedb' database at $PGHOST ..."
+ dropdb "auditor-basedb" >/dev/null 2>/dev/null || true
+ createdb "auditor-basedb" || exit_skip "Could not create database '$BASEDB' at $PGHOST"
+ echo " DONE"
+ check_with_database "$MYDIR/$DB"
+ if [ "$fail" != "0" ]
then
- echo -n "Reset 'auditor-basedb' database at $PGHOST ..."
- dropdb "auditor-basedb" >/dev/null 2>/dev/null || true
- createdb "auditor-basedb" || exit_skip "Could not create database '$BASEDB' at $PGHOST"
- echo " DONE"
- else
- echo "Generation failed"
- exit 1
+ exit "$fail"
fi
else
- echo "Reusing existing database from ${REUSE_BASEDB_DIR}"
- cp -r "${REUSE_BASEDB_DIR}/basedb"/* "${MYDIR}/"
-fi
-
-check_with_database "$MYDIR/$DB"
-if [ "$fail" != "0" ]
-then
- exit "$fail"
-fi
-
-if [ -z $REUSE_BASEDB_DIR ]
-then
- echo "Run 'export REUSE_BASEDB_DIR=${MY_TMP_DIR}' to re-run tests against the same database"
+ echo "Generation failed"
+ exit 1
fi
exit 0