diff options
author | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-06-25 01:55:15 -0400 |
---|---|---|
committer | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-06-25 01:55:15 -0400 |
commit | 9d0a68e578a77cbe9c1443dc1831de157b8a0fa8 (patch) | |
tree | 13c5f0e7d15086fbc541f7c5eececd19f352d716 /src/testing | |
parent | 0fbdd6c6cda1c7e0ad0b4ffc3f22bac3e1176c1d (diff) | |
download | merchant-9d0a68e578a77cbe9c1443dc1831de157b8a0fa8.tar.gz merchant-9d0a68e578a77cbe9c1443dc1831de157b8a0fa8.tar.bz2 merchant-9d0a68e578a77cbe9c1443dc1831de157b8a0fa8.zip |
wallet get order handles refunds properly
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/test_merchant_api.c | 7 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_wallet_get_order.c | 74 |
2 files changed, 77 insertions, 4 deletions
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 0856757b..b1b518d8 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -562,13 +562,14 @@ run (void *cls, "1r", /* order ID */ "EUR:0.1", MHD_HTTP_OK), - /* TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r", merchant_url, "create-proposal-1r", true, true, - MHD_HTTP_OK),*/ + MHD_HTTP_OK, + "refund-increase-1r", + NULL), #if 0 TALER_TESTING_cmd_poll_payment_conclude ("poll-payment-refund-conclude-1", MHD_HTTP_OK, @@ -662,7 +663,7 @@ run (void *cls, TALER_TESTING_cmd_check_bank_transfer ( "check_bank_transfer-paid-unincreased-refund", EXCHANGE_URL, - "EUR:9.97", /* '4.98 from above', plus 4.99 from 'pay-for-refund-1r' + "EUR:9.88", /* '4.98 from above', plus 4.99 from 'pay-for-refund-1r' and MINUS 0.1 PLUS 0.01 (deposit fee) from 'refund-increase-1r' */ exchange_payto, merchant_payto), diff --git a/src/testing/testing_api_cmd_wallet_get_order.c b/src/testing/testing_api_cmd_wallet_get_order.c index 7cc9c352..86072f4f 100644 --- a/src/testing/testing_api_cmd_wallet_get_order.c +++ b/src/testing/testing_api_cmd_wallet_get_order.c @@ -67,6 +67,16 @@ struct WalletGetOrderState * Whether the order was refunded or not. */ bool refunded; + + /** + * A NULL-terminated list of refunds associated with this order. + */ + const char **refunds; + + /** + * The length of @e refunds. + */ + unsigned int refunds_length; }; @@ -138,6 +148,48 @@ wallet_get_order_cb ( TALER_TESTING_interpreter_fail (gos->is); return; } + if (gos->refunds_length != num_refunds) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Order refunds count does not match\n"); + TALER_TESTING_interpreter_fail (gos->is); + return; + } + for (unsigned int i = 0; i < num_refunds; ++i) + { + const struct TALER_TESTING_Command *refund_cmd; + const char *expected_amount_str; + struct TALER_Amount expected_amount; + + refund_cmd = TALER_TESTING_interpreter_lookup_command ( + gos->is, + gos->refunds[i]); + + if (GNUNET_OK != + TALER_TESTING_get_trait_string (refund_cmd, + 0, + &expected_amount_str)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch refund amount\n"); + TALER_TESTING_interpreter_fail (gos->is); + return; + } + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (expected_amount_str, + &expected_amount)); + if ((GNUNET_OK != + TALER_amount_cmp_currency (&expected_amount, + &refunds[i].refund_amount)) || + (0 != TALER_amount_cmp (&expected_amount, + &refunds[i].refund_amount))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Refund amounts do not match\n"); + TALER_TESTING_interpreter_fail (gos->is); + return; + } + } break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -225,6 +277,10 @@ wallet_get_order_cleanup (void *cls, * @param paid whether the order has been paid for or not. * @param refunded whether the order has been refunded. * @param http_status expected HTTP response code for the request. + * @param ... NULL-terminated list of labels (const char *) of + * refunds (commands) we expect to be aggregated in the transfer + * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false, + * this parameter is ignored. */ struct TALER_TESTING_Command TALER_TESTING_cmd_wallet_get_order (const char *label, @@ -232,7 +288,8 @@ TALER_TESTING_cmd_wallet_get_order (const char *label, const char *order_reference, bool paid, bool refunded, - unsigned int http_status) + unsigned int http_status, + ...) { struct WalletGetOrderState *gos; @@ -242,6 +299,21 @@ TALER_TESTING_cmd_wallet_get_order (const char *label, gos->http_status = http_status; gos->paid = paid; gos->refunded = refunded; + gos->refunds_length = 0; + if (refunded) + { + const char *clabel; + va_list ap; + + va_start (ap, http_status); + while (NULL != (clabel = va_arg (ap, const char *))) + { + GNUNET_array_append (gos->refunds, + gos->refunds_length, + clabel); + } + va_end (ap); + } { struct TALER_TESTING_Command cmd = { .cls = gos, |