From 0ad509bd104f64cbfac286146f74496876d6fc9c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 23 Aug 2022 12:09:22 +0200 Subject: fix profit drain test, remove obsolete test 33 (aggregator now dies on inconsistency, before it looped); fixes #4960 --- src/auditor/taler-helper-auditor-wire.c | 10 +++++- src/auditor/test-auditor.sh | 55 +++++--------------------------- src/exchange/taler-exchange-aggregator.c | 14 ++++++-- 3 files changed, 28 insertions(+), 51 deletions(-) diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c index f9c87b6f0..28a87a391 100644 --- a/src/auditor/taler-helper-auditor-wire.c +++ b/src/auditor/taler-helper-auditor-wire.c @@ -1297,6 +1297,10 @@ complain_out_not_found (void *cls, /* not a profit drain */ break; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Profit drain of %s to %s found!\n", + TALER_amount2s (&amount), + payto_uri); if (GNUNET_OK != TALER_exchange_offline_profit_drain_verify ( &roi->details.wtid, @@ -1377,7 +1381,11 @@ complain_out_not_found (void *cls, } GNUNET_free (account_section); GNUNET_free (payto_uri); - break; + /* profit drain was correct */ + TALER_ARL_amount_add (&total_drained, + &total_drained, + &amount); + return GNUNET_OK; } } diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh index c65552233..f7c0948ff 100755 --- a/src/auditor/test-auditor.sh +++ b/src/auditor/test-auditor.sh @@ -229,7 +229,6 @@ function run_audit () { break done echo "... DONE." - # FIXME-MS: need to make sure here that the target IBAN exists! taler-exchange-offline -L DEBUG -c "${CONF}.tmp" \ drain TESTKUDOS:0.1 exchange-account-1 payto://iban/SANDBOXX/DE360679?receiver-name=Exchange+Drain \ upload \ @@ -244,10 +243,13 @@ function run_audit () { echo -n "Running taler-exchange-transfer ..." taler-exchange-transfer -L INFO -t -c $CONF 2> drain-transfer.log || exit_fail "FAIL" echo " DONE" - # FIXME-MS: transfer tool is happy here, but - # the wire transfer triggered here does NOT - # show up during the audit. Do we have to - # trigger some libeufin/sandbox job first? + + export LIBEUFIN_NEXUS_USERNAME=exchange + export LIBEUFIN_NEXUS_PASSWORD=x + export LIBEUFIN_NEXUS_URL=http://localhost:8082/ + PAIN_UUID=`libeufin-cli accounts list-payments exchange-nexus | jq .initiatedPayments[] | jq 'select(.submitted==false)' | jq -r .paymentInitiationId` + libeufin-cli accounts submit-payments --payment-uuid $PAIN_UUID exchange-nexus + fi audit_only post_audit @@ -1921,50 +1923,9 @@ fi -# Test where h_payto in the wire_targets table is wrong function test_33() { -echo "===========33: h_payto wrong=================" - -# Check wire transfer lag reported (no aggregator!) -# NOTE: this test is BRAND NEW and expected -# to fail until we implement the check in the auditor! - -# 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 - - # Modify h_payto hash, so it is inconsistent with 'wire' - WTSID=`echo "SELECT wire_target_serial_id FROM exchange.deposits WHERE deposit_serial_id=1;" | psql -Aqt $DB` - echo "UPDATE exchange.wire_targets SET h_payto='\x973e52d193a357940be9ef2939c19b0575ee1101f52188c3c01d9005b7d755c397e92624f09cfa709104b3b65605fe5130c90d7e1b7ee30f8fc570f39c16b853' WHERE wire_target_serial_id=$WTSID" | psql -Aqt $DB - - # The auditor checks h_wire consistency only for - # coins where the wire transfer has happened, hence - # run aggregator first to get this test to work. - run_audit aggregator - - echo -n "Testing inconsistency detection... " - TABLE=`jq -r .row_inconsistencies[0].table < test-audit-aggregation.json` - if test "x$TABLE" != "xwire_targets" - then - exit_fail "Reported table wrong: $TABLE" - fi - echo PASS - - # cannot easily undo aggregator, hence full reload - full_reload - -else - echo "Test skipped (database too new)" -fi -} - - -function test_34() { -echo "===========34: normal run with aggregator and profit drain===========" +echo "===========33: normal run with aggregator and profit drain===========" run_audit aggregator drain echo "Checking output" diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index 81178e1aa..d326b0e8e 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -491,12 +491,12 @@ kyc_satisfied (struct AggregationUnit *au_active) db_plugin->cls, &return_relevant_amounts, (void *) au_active); + if (NULL == requirement) + return true; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "KYC requirement for %s is %s\n", TALER_amount2s (&au_active->total_amount), requirement); - if (NULL == requirement) - return true; qs = db_plugin->insert_kyc_requirement_for_account ( db_plugin->cls, requirement, @@ -622,7 +622,9 @@ do_aggregate (struct AggregationUnit *au) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Aggregation total is %s.\n", TALER_amount2s (&au->total_amount)); - + /* Deposit was 'ready', so clearly the total + aggregated must be non-zero. */ + GNUNET_assert (! TALER_amount_is_zero (&au->total_amount)); /* Subtract wire transfer fee and round to the unit supported by the wire transfer method; Check if after rounding down, we still have an amount to transfer, and if not mark as 'tiny'. */ @@ -783,6 +785,8 @@ run_aggregation (void *cls) } case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: s->work_counter++; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Found ready deposit!\n"); /* continued below */ break; } @@ -862,6 +866,8 @@ run_shard (void *cls) (void) cls; task = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Running aggregation shard\n"); if (GNUNET_SYSERR == db_plugin->preflight (db_plugin->cls)) { @@ -955,6 +961,8 @@ drain_kyc_alerts (void *cls) (void) cls; task = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Draining KYC alerts\n"); memset (&au, 0, sizeof (au)); -- cgit v1.2.3