diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-10-20 20:14:30 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-10-20 20:14:30 +0200 |
commit | 33e80b885a9c97d85eb009027feecfba2928165f (patch) | |
tree | 9160259a367be74989956743778064c6c8439537 | |
parent | ca347c3182afcc934fec2856fff77e788e97e832 (diff) |
implement test for #6466
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 9 | ||||
-rw-r--r-- | src/include/taler_merchant_testing_lib.h | 2 | ||||
-rw-r--r-- | src/testing/test_merchant_api.c | 86 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_wallet_get_order.c | 8 |
4 files changed, 32 insertions, 73 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 9da5f23d..75ff2460 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -357,7 +357,7 @@ do_resume (void *cls) GNUNET_CONTAINER_multihashmap_remove (payment_trigger_map, &sc->key2, sc)); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resuming long polled job due to timeout\n"); MHD_resume_connection (sc->con); TMH_trigger_daemon (); /* we resumed, kick MHD */ @@ -531,8 +531,11 @@ TMH_long_poll_resume (const char *order_id, &mi->merchant_pub, &key); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Resuming operations suspended pending payment on key %s\n", - GNUNET_h2s (&key)); + "Resuming operations suspended pending payment on key %s up to refund %s\n", + GNUNET_h2s (&key), + (NULL != refund_amount) + ? TALER_amount2s (refund_amount) + : "<none>"); ret = GNUNET_CONTAINER_multihashmap_get_multiple (payment_trigger_map, &key, &resume_operation, diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h index 77f4c3e0..708d4d2f 100644 --- a/src/include/taler_merchant_testing_lib.h +++ b/src/include/taler_merchant_testing_lib.h @@ -642,7 +642,7 @@ TALER_TESTING_cmd_wallet_poll_order_start ( const char *merchant_url, const char *order_ref, struct GNUNET_TIME_Relative timeout, - const struct TALER_Amount *await_refund); + const char *await_refund); /** diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 17984079..07e6b61b 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -607,25 +607,6 @@ run (void *cls, "EUR:5", "EUR:4.99", NULL), -#if 0 - TALER_TESTING_cmd_history ("history-0", - merchant_url, - MHD_HTTP_OK, - /** - * all records to be returned; setting date as 0 lets the - * interpreter set it as 'now' + one hour delta, just to - * make sure it surpasses the proposal's timestamp. - */// - GNUNET_TIME_UNIT_ZERO_ABS, - /** - * We only expect ONE result (create-proposal-1) to be - * included in /history response, because create-proposal-3 - * did NOT go through because of double spending. - */// - 1, // nresult - 10, // start - -10), // nrows -#endif TALER_TESTING_cmd_end () }; @@ -668,6 +649,17 @@ run (void *cls, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_FOREVER_ABS, "EUR:5.0"), + TALER_TESTING_cmd_wallet_poll_order_start ("poll-order-wallet-refund-1-low", + merchant_url, + "create-proposal-1r", + GNUNET_TIME_UNIT_MINUTES, + "EUR:0.01"), + TALER_TESTING_cmd_wallet_poll_order_start ( + "poll-order-wallet-refund-1-high", + merchant_url, + "create-proposal-1r", + GNUNET_TIME_UNIT_MINUTES, + "EUR:0.2"), TALER_TESTING_cmd_merchant_pay_order ("pay-for-refund-1r", merchant_url, MHD_HTTP_OK, @@ -686,6 +678,10 @@ run (void *cls, "1r", /* order ID */ "EUR:0.1", MHD_HTTP_OK), + TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude-low", + MHD_HTTP_OK, + "EUR:0.1", + "poll-order-wallet-refund-1-low"), TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r", merchant_url, "create-proposal-1r", @@ -699,6 +695,10 @@ run (void *cls, "1r", /* order ID */ "EUR:1.0", MHD_HTTP_OK), + TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude-high", + MHD_HTTP_OK, + "EUR:1.0", + "poll-order-wallet-refund-1-high"), TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r-2", merchant_url, "create-proposal-1r", @@ -751,7 +751,7 @@ run (void *cls, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_FOREVER_ABS, "EUR:5.0"), - /* Try to increase a non paid proposal. */ + /* Try to increase an unpaid proposal. */ TALER_TESTING_cmd_merchant_order_refund ("refund-increase-unpaid-proposal", merchant_url, "refund test", @@ -811,23 +811,6 @@ run (void *cls, 'refund-increase-1r' and 'refund-increase-1r-2' */ exchange_payto, merchant_payto), - /* Actually try to pick up the refund from the "unincreased proposal". */ -#if 0 - TALER_TESTING_cmd_refund_lookup_with_amount ("refund-lookup-unincreased", - merchant_url, - NULL, - "pay-unincreased-proposal", - "unincreased-proposal", - MHD_HTTP_NOT_FOUND, - /* If a lookup is attempted - * on an unincreased - * proposal, the backend will - * simply respond with a - * empty refunded coin "set", - * but the HTTP response code - * is 200 OK. */// - "EUR:0"), -#endif TALER_TESTING_cmd_end () }; @@ -1009,35 +992,6 @@ run (void *cls, merchant_url, "create-reserve-tip-1", MHD_HTTP_NOT_FOUND), -#if 0 - TALER_TESTING_cmd_merchant_post_orders ("create-proposal-tip-1", - merchant_url_internal ("tip"), - MHD_HTTP_OK, - "{\"max_fee\":\"EUR:0.5\",\ - \"order_id\":\"1-tip\", \ - \"refund_deadline\":{\"t_ms\":0},\ - \"pay_deadline\":{\"t_ms\":\"never\"},\ - \"amount\":\"EUR:5.0\",\ - \"summary\": \"useful product\",\ - \"fulfillment_url\": \"https://example.com/\",\ - \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:5}\"} ] }"), - TALER_TESTING_cmd_merchant_pay_order ("deposit-tip-simple", - merchant_url_external ("tip"), - MHD_HTTP_OK, - "create-proposal-tip-1", - "pickup-tip-1", - "EUR:5", // amount + fee - "EUR:4.99", - NULL), // amount - fee - CMD_EXEC_AGGREGATOR ("aggregator-tip-1"), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-tip-498c", - EXCHANGE_URL, - "EUR:4.98", - exchange_payto, - merchant_payto), - TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-at-tips"), -#endif TALER_TESTING_cmd_end () }; diff --git a/src/testing/testing_api_cmd_wallet_get_order.c b/src/testing/testing_api_cmd_wallet_get_order.c index 3cdba5ff..2f595315 100644 --- a/src/testing/testing_api_cmd_wallet_get_order.c +++ b/src/testing/testing_api_cmd_wallet_get_order.c @@ -601,7 +601,7 @@ wallet_poll_order_start_run (void *cls, pos->wait_for_refund ? &pos->refund_threshold : NULL, - pos->wait_for_refund, + false, /* await_refund_obtained */ &wallet_poll_order_cb, pos); GNUNET_assert (NULL != pos->ogh); @@ -642,7 +642,7 @@ TALER_TESTING_cmd_wallet_poll_order_start ( const char *merchant_url, const char *order_ref, struct GNUNET_TIME_Relative timeout, - const struct TALER_Amount *await_refund) + const char *await_refund) { struct WalletPollOrderStartState *pos; @@ -653,7 +653,9 @@ TALER_TESTING_cmd_wallet_poll_order_start ( if (NULL != await_refund) { pos->wait_for_refund = true; - pos->refund_threshold = *await_refund; + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (await_refund, + &pos->refund_threshold)); } { struct TALER_TESTING_Command cmd = { |