summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-11 00:31:59 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-11 00:31:59 +0200
commit19c56c7eb81efc272d864d6765d7d61943141ce2 (patch)
treee566702badb4bae31a3d424cbdf523a8e44004d1
parent6d978efe14aa90564ce9257a23bcb2854ba07036 (diff)
downloadmerchant-19c56c7eb81efc272d864d6765d7d61943141ce2.tar.gz
merchant-19c56c7eb81efc272d864d6765d7d61943141ce2.tar.bz2
merchant-19c56c7eb81efc272d864d6765d7d61943141ce2.zip
adding test for #5985
-rw-r--r--src/backend/taler-merchant-httpd.c16
-rw-r--r--src/backend/taler-merchant-httpd_poll-payment.c6
-rw-r--r--src/backend/taler-merchant-httpd_refund_increase.c5
-rw-r--r--src/lib/test_merchant_api.c9
-rw-r--r--src/lib/testing_api_cmd_poll_payment.c1
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; i<MAX_RETRIES; i++)
{
+ pprc->refunded = 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);