diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-09-03 03:14:23 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-09-03 03:14:23 +0200 |
commit | 736927f05a19e0b88addd6829f49a5a9ddb025c4 (patch) | |
tree | fc4a21ae1ef60efcbebac48d943a50d5d2f67008 /src/auditor | |
parent | 67aeb85a13db9acf9505098d82433cf7e7cfa23a (diff) |
another test, more fixes in auditor-report template
Diffstat (limited to 'src/auditor')
-rwxr-xr-x | src/auditor/test-auditor.sh | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index f8370fe46..8122307c5 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -7,25 +7,37 @@ # Requires 'jq' tool and Postgres superuser rights! set -eu -# Which tests should we run, used to make it easy to +# Set of numbers for all the testcases. +# When adding new tests, increase the last number: +ALL_TESTS=`seq 1 4` + +# $TESTS determines which tests we should run. +# This construction is used to make it easy to # only run a subset of the tests. To only run a subset, # pass the numbers of the tests to run as the FIRST -# argument to test-auditor.sh -ALL_TESTS=`seq 1 3` +# argument to test-auditor.sh, i.e.: +# +# $ test-auditor.sh "1 3" +# +# to run tests 1 and 3 only. By default, all tests are run. +# TESTS=${1:-$ALL_TESTS} - +# Exit, with status code "skip" (no 'real' failure) function exit_skip() { echo $1 exit 77 } +# Exit, with error message (hard failure) function exit_fail() { echo $1 kill `jobs -p` exit 1 } +# Run audit process on current database, including report +# generation. function run_audit () { # Launch bank echo "Launching bank" @@ -234,6 +246,51 @@ echo "UPDATE reserves_in SET credit_val=10 WHERE reserve_in_serial_id=1" | psql } +# Check for incoming wire transfer amount given being +# lower than what exchange claims to have received. +test_4() { + +echo "===========4: deposit wire target wrong=================" +# Original target bank account was 43, changing to 44 +echo "UPDATE deposits SET wire='{\"url\":\"payto://x-taler-bank/localhost:8082/44\",\"salt\":\"test-salt (must be constant for aggregation tests)\"}' WHERE deposit_serial_id=1" | psql $DB + +run_audit + +ROW=`jq -e .bad_sig_losses[0].row < test-audit.json` +if test $ROW != 1 +then + exit_fail "Row wrong, got $ROW" +fi + +LOSS=`jq -r .bad_sig_losses[0].loss < test-audit.json` +if test $LOSS != "TESTKUDOS:0.1" +then + exit_fail "Wrong deposit bad signature loss, got $LOSS" +fi + +OP=`jq -r .bad_sig_losses[0].operation < test-audit.json` +if test $OP != "deposit" +then + exit_fail "Wrong operation, got $OP" +fi + +LOSS=`jq -r .total_bad_sig_loss < test-audit.json` +if test $LOSS != "TESTKUDOS:0.1" +then + exit_fail "Wrong total bad sig loss, got $LOSS" +fi + +# Undo: +echo "UPDATE deposits SET wire='{\"url\":\"payto://x-taler-bank/localhost:8082/43\",\"salt\":\"test-salt (must be constant for aggregation tests)\"}' WHERE deposit_serial_id=1" | psql $DB + +} + + + + + +# Add more tests here! :-) + fail=0 for i in $TESTS do |