From 8a90c8fbcb7c274cfed3f379f92a00da45313787 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 27 Mar 2020 09:35:48 +0100 Subject: expand test suite --- src/auditor/test-auditor.sh | 37 ++++++++++++++-- src/auditor/test-revocation.sh | 96 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 129 insertions(+), 4 deletions(-) (limited to 'src/auditor') diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index ac498e179..9b9867333 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -352,7 +352,7 @@ echo "OK" # Change amount of wire transfer reported by exchange function test_2() { -echo "===========2: reserves_in inconsitency===========" +echo "===========2: reserves_in inconsistency===========" echo "UPDATE reserves_in SET credit_val=5 WHERE reserve_in_serial_id=1" | psql -Aqt $DB run_audit @@ -396,7 +396,7 @@ echo "UPDATE reserves_in SET credit_val=10 WHERE reserve_in_serial_id=1" | psql # lower than what exchange claims to have received. function test_3() { -echo "===========3: reserves_in inconsitency===========" +echo "===========3: reserves_in inconsistency===========" echo "UPDATE reserves_in SET credit_val=15 WHERE reserve_in_serial_id=1" | psql -Aqt $DB run_audit @@ -1443,7 +1443,6 @@ function test_25() { echo "=========25: inconsistent coin history=========" -# 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 @@ -1729,6 +1728,38 @@ fi } + + + +# Test where denom_sig in known_coins table is wrong +# (=> bad signature) +function test_32() { + +# 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-helper-auditor-wire.c) +if [ $DATABASE_AGE -gt 3600 ] +then + + echo "===========32: known_coins signature wrong w. aggregation=================" + # Modify denom_sig, so it is wrong + OLD_SIG=`echo 'SELECT denom_sig FROM known_coins LIMIT 1;' | psql $DB -Aqt` + COIN_PUB=`echo "SELECT coin_pub FROM known_coins WHERE denom_sig='$OLD_SIG';" | psql $DB -Aqt` + echo "UPDATE known_coins SET denom_sig='\x287369672d76616c200a2028727361200a2020287320233542383731423743393036444643303442424430453039353246413642464132463537303139374131313437353746324632323332394644443146324643333445393939413336363430334233413133324444464239413833353833464536354442374335434445304441453035374438363336434541423834463843323843344446304144363030343430413038353435363039373833434431333239393736423642433437313041324632414132414435413833303432434346314139464635394244434346374436323238344143354544364131373739463430353032323241373838423837363535453434423145443831364244353638303232413123290a2020290a20290b' WHERE coin_pub='$COIN_PUB'" | psql -Aqt $DB + + run_audit aggregation + + # FIXME: test incomplete... + + # Cannot undo aggregation, do full reload + full_reload + +fi +} + + + # *************** Main test loop starts here ************** diff --git a/src/auditor/test-revocation.sh b/src/auditor/test-revocation.sh index 7f9412af7..81844b7a3 100755 --- a/src/auditor/test-revocation.sh +++ b/src/auditor/test-revocation.sh @@ -9,7 +9,7 @@ set -eu # Set of numbers for all the testcases. # When adding new tests, increase the last number: -ALL_TESTS=`seq 0 1` +ALL_TESTS=`seq 0 4` # $TESTS determines which tests we should run. # This construction is used to make it easy to @@ -344,12 +344,106 @@ if test $WIRED != "TESTKUDOS:0" then exit_fail "Expected total missattribution in wrong, got $WIRED" fi + # Database was unmodified, no need to undo echo "OK" } +# Change recoup amount +function test_2() { + +echo "===========2: recoup amount inconsistency===========" +echo "UPDATE recoup SET amount_val=5 WHERE recoup_uuid=1" | psql -Aqt $DB + +run_audit + +# Reserve balance is now wrong +echo -n "Testing inconsistency detection... " +AMOUNT=`jq -r .reserve_balance_summary_wrong_inconsistencies[0].auditor < test-audit-reserves.json` +if test $AMOUNT != "TESTKUDOS:3" +then + exit_fail "Auditor amount $AMOUNT is wrong" +fi +AMOUNT=`jq -r .reserve_balance_summary_wrong_inconsistencies[0].exchange < test-audit-reserves.json` +if test $AMOUNT != "TESTKUDOS:0" +then + exit_fail "Exchange amount $AMOUNT is wrong" +fi +# Coin spent exceeded coin's value +AMOUNT=`jq -r .amount_arithmetic_inconsistencies[0].auditor < test-audit-coins.json` +if test $AMOUNT != "TESTKUDOS:2" +then + exit_fail "Auditor amount $AMOUNT is wrong" +fi +AMOUNT=`jq -r .amount_arithmetic_inconsistencies[0].exchange < test-audit-coins.json` +if test $AMOUNT != "TESTKUDOS:5" +then + exit_fail "Exchange amount $AMOUNT is wrong" +fi +echo OK + +# Undo database modification +echo "UPDATE recoup SET amount_val=2 WHERE recoup_uuid=1" | psql -Aqt $DB + +} + + +# Change recoup-refresh amount +function test_3() { + +echo "===========3: recoup-refresh amount inconsistency===========" +echo "UPDATE recoup_refresh SET amount_val=5 WHERE recoup_refresh_uuid=1" | psql -Aqt $DB + +run_audit + +echo -n "Testing inconsistency detection... " +# Coin spent exceeded coin's value +AMOUNT=`jq -r .total_arithmetic_delta_minus < test-audit-coins.json` +if test $AMOUNT != "TESTKUDOS:5" +then + exit_fail "Arithmetic delta minus amount $AMOUNT is wrong" +fi +AMOUNT=`jq -r .total_arithmetic_delta_plus < test-audit-coins.json` +if test $AMOUNT != "TESTKUDOS:0" +then + exit_fail "Arithmetic delta plus amount $AMOUNT is wrong" +fi +echo OK + +# Undo database modification +echo "UPDATE recoup_refresh SET amount_val=0 WHERE recoup_refresh_uuid=1" | psql -Aqt $DB + +} + + +# Void recoup-refresh entry by 'unrevoking' denomination +function test_4() { + +echo "===========4: invalid recoup===========" +echo "DELETE FROM denomination_revocations;" | psql -Aqt $DB + +run_audit + +echo -n "Testing inconsistency detection... " +# Coin spent exceeded coin's value +jq -e .bad_sig_losses[0] < test-audit-coins.json > /dev/null || exit_fail "Bad recoup not detected" +AMOUNT=`jq -r .total_bad_sig_losses < test-audit-coins.json` +if test $AMOUNT == "TESTKUDOS:0" +then + exit_fail "Total bad sig losses are wrong" +fi +echo OK + +# Undo database modification (can't easily undo DELETE, so full reload) +full_reload + +} + + + + # *************** Main test loop starts here ************** -- cgit v1.2.3