diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-09-30 22:11:24 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-09-30 22:11:24 +0200 |
commit | 11b643dd83fa3e75d5aa3b4918c55065fa6dc4fa (patch) | |
tree | c7cffac849cd47a7512bcfaa2df99a94920f9f06 /src/auditor/test-auditor.sh | |
parent | 6b2a84dfe154e5eb77af8b11c47d93ef61cdeb50 (diff) |
add test for wire transfer subject malformed
Diffstat (limited to 'src/auditor/test-auditor.sh')
-rwxr-xr-x | src/auditor/test-auditor.sh | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index f2edf8299..d7d5b6e16 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -1023,7 +1023,6 @@ fi echo PASS - # cannot easily undo broad DELETE operation, hence full reload echo -n "Reloading database ..." full_reload @@ -1032,6 +1031,53 @@ echo "DONE" +# Test where outgoing wire transfer subject is malformed +function test_19() { +echo "===========19: outgoing wire subject malformed=================" + +# Need to first run the aggregator so the outgoing transfer exists +pre_audit aggregator + +# 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" + +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 + +echo "PASS" + +# Undo +echo "UPDATE app_banktransaction SET subject='${OLD_SUBJECT}' WHERE debit_account_id=2;" | psql -Aqt $DB +} + + + + # ************************************************** # FIXME: Add more tests here! :-) # Specifically: |