From 0fbdd6c6cda1c7e0ad0b4ffc3f22bac3e1176c1d Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Wed, 24 Jun 2020 17:38:09 -0400 Subject: got refunds working and tested --- src/testing/testing_api_cmd_wallet_get_order.c | 34 +++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/testing/testing_api_cmd_wallet_get_order.c') diff --git a/src/testing/testing_api_cmd_wallet_get_order.c b/src/testing/testing_api_cmd_wallet_get_order.c index 1dce69c9..7cc9c352 100644 --- a/src/testing/testing_api_cmd_wallet_get_order.c +++ b/src/testing/testing_api_cmd_wallet_get_order.c @@ -57,6 +57,16 @@ struct WalletGetOrderState * Reference to a command that created an order. */ const char *order_reference; + + /** + * Whether the order was paid or not. + */ + bool paid; + + /** + * Whether the order was refunded or not. + */ + bool refunded; }; @@ -95,6 +105,8 @@ wallet_get_order_cb ( { /* FIXME, deeper checks should be implemented here. */ struct WalletGetOrderState *gos = cls; + bool paid_b = (paid == GNUNET_YES); + bool refunded_b = (refunded == GNUNET_YES); gos->ogh = NULL; if (gos->http_status != hr->http_status) @@ -110,8 +122,22 @@ wallet_get_order_cb ( switch (hr->http_status) { case MHD_HTTP_OK: - // FIXME: use gts->tip_reference here to + // FIXME: use gos->order_reference here to // check if the data returned matches that from the POST / PATCH + if (gos->paid != paid_b) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Order paid does not match\n"); + TALER_TESTING_interpreter_fail (gos->is); + return; + } + if (gos->refunded != refunded_b) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Order refunded does not match\n"); + TALER_TESTING_interpreter_fail (gos->is); + return; + } break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -196,12 +222,16 @@ wallet_get_order_cleanup (void *cls, * @param merchant_url base URL of the merchant which will * serve the request. * @param order_reference reference to a command that created an order. + * @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. */ struct TALER_TESTING_Command TALER_TESTING_cmd_wallet_get_order (const char *label, const char *merchant_url, const char *order_reference, + bool paid, + bool refunded, unsigned int http_status) { struct WalletGetOrderState *gos; @@ -210,6 +240,8 @@ TALER_TESTING_cmd_wallet_get_order (const char *label, gos->merchant_url = merchant_url; gos->order_reference = order_reference; gos->http_status = http_status; + gos->paid = paid; + gos->refunded = refunded; { struct TALER_TESTING_Command cmd = { .cls = gos, -- cgit v1.2.3