From 19c56c7eb81efc272d864d6765d7d61943141ce2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 11 Apr 2020 00:31:59 +0200 Subject: adding test for #5985 --- src/backend/taler-merchant-httpd.c | 16 +++++++++++++++- src/backend/taler-merchant-httpd_poll-payment.c | 6 ++++-- src/backend/taler-merchant-httpd_refund_increase.c | 5 +++++ src/lib/test_merchant_api.c | 9 +++++++++ src/lib/testing_api_cmd_poll_payment.c | 1 + 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 1f9d439e..b86fde71 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -255,6 +255,11 @@ TMH_compute_pay_key (const char *order_id, GNUNET_CRYPTO_hash (buf, sizeof (buf), key); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Pay key for %s is %s\n", + order_id, + GNUNET_h2s (key)); + } @@ -307,6 +312,9 @@ void TMH_long_poll_suspend (struct TMH_SuspendedConnection *sc, const struct TALER_Amount *min_refund) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Suspending operation on key %s\n", + GNUNET_h2s (&sc->key)); GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (payment_trigger_map, &sc->key, @@ -353,7 +361,12 @@ resume_operation (void *cls, ( (NULL == have_refund) || (1 != TALER_amount_cmp (have_refund, &sc->refund_expected)) ) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Not awaking client, refund amount of %s not yet satisfied\n", + TALER_amount2s (&sc->refund_expected)); return GNUNET_OK; /* skip */ + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resuming operation suspended pending payment on key %s\n", GNUNET_h2s (key)); @@ -365,6 +378,7 @@ resume_operation (void *cls, GNUNET_CONTAINER_heap_remove_node (sc->hn)); sc->hn = NULL; MHD_resume_connection (sc->con); + TMH_trigger_daemon (); return GNUNET_OK; } @@ -596,7 +610,7 @@ static int triggered; * Call MHD to process pending requests and then go back * and schedule the next run. * - * @param cls the `struct MHD_Daemon` of the HTTP server to run + * @param cls NULL */ static void run_daemon (void *cls) diff --git a/src/backend/taler-merchant-httpd_poll-payment.c b/src/backend/taler-merchant-httpd_poll-payment.c index 49f94896..6ca4fcce 100644 --- a/src/backend/taler-merchant-httpd_poll-payment.c +++ b/src/backend/taler-merchant-httpd_poll-payment.c @@ -459,7 +459,6 @@ MH_handler_poll_payment (struct TMH_RequestHandler *rh, } } /* end of first-time initialization / sanity checks */ - db->preflight (db->cls); /* Check if the order has been paid for. */ @@ -526,6 +525,7 @@ MH_handler_poll_payment (struct TMH_RequestHandler *rh, /* Accumulate refunds, if any. */ for (unsigned int i = 0; irefunded = GNUNET_NO; qs = db->get_refunds_from_contract_terms_hash (db->cls, &mi->pubkey, &pprc->h_contract_terms, @@ -557,7 +557,9 @@ MH_handler_poll_payment (struct TMH_RequestHandler *rh, if (0 != remaining.rel_value_us) { /* yes, indeed suspend */ - pprc->refunded = GNUNET_NO; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Awaiting refund exceeding %s\n", + TALER_amount2s (&pprc->min_refund)); suspend_pprc (pprc); return MHD_YES; } diff --git a/src/backend/taler-merchant-httpd_refund_increase.c b/src/backend/taler-merchant-httpd_refund_increase.c index 6d49dfc4..5324c619 100644 --- a/src/backend/taler-merchant-httpd_refund_increase.c +++ b/src/backend/taler-merchant-httpd_refund_increase.c @@ -258,6 +258,11 @@ process_refund (struct MHD_Connection *connection, } /* Resume /public/poll-payments clients that may wait for this refund */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Awakeing clients on %s waiting for refund of less than %s\n", + order_id, + TALER_amount2s (refund)); + TMH_long_poll_resume (order_id, &mi->pubkey, refund); diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c index 1f3626ec..349be0ae 100644 --- a/src/lib/test_merchant_api.c +++ b/src/lib/test_merchant_api.c @@ -499,6 +499,11 @@ run (void *cls, "EUR:5", "EUR:4.99", "EUR:0.01"), + TALER_TESTING_cmd_poll_payment_start ("poll-payment-refund-1", + merchant_url, + "create-proposal-1r", + "EUR:0.0", + GNUNET_TIME_UNIT_MINUTES), TALER_TESTING_cmd_refund_increase ("refund-increase-1r", merchant_url, "refund test", @@ -506,6 +511,10 @@ run (void *cls, "EUR:0.1", "EUR:0.01", MHD_HTTP_OK), + TALER_TESTING_cmd_poll_payment_conclude ("poll-payment-refund-conclude-1", + MHD_HTTP_OK, + "poll-payment-refund-1", + GNUNET_YES), /* Ordinary refund. */ TALER_TESTING_cmd_refund_lookup ("refund-lookup-1r", merchant_url, diff --git a/src/lib/testing_api_cmd_poll_payment.c b/src/lib/testing_api_cmd_poll_payment.c index 32fcaddf..9575e32e 100644 --- a/src/lib/testing_api_cmd_poll_payment.c +++ b/src/lib/testing_api_cmd_poll_payment.c @@ -441,6 +441,7 @@ poll_payment_conclude_run (void *cls, TALER_TESTING_FAIL (ppc->is); GNUNET_assert (poll_cmd->run == &poll_payment_start_run); cps = poll_cmd->cls; + cps->cs = ppc; if (NULL == cps->cpo) ppc->task = GNUNET_SCHEDULER_add_now (&conclude_task, ppc); -- cgit v1.2.3