diff options
author | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-07 05:52:23 -0400 |
---|---|---|
committer | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-07 05:52:23 -0400 |
commit | 5eb0a2e98faecfec89add4845f817548b3fee86b (patch) | |
tree | 113ddae80b46f5f34a2ae7f4159323d98bf021fd /src/testing | |
parent | 002772c388aaa794c068c9239565c8467f6c65a8 (diff) | |
download | merchant-5eb0a2e98faecfec89add4845f817548b3fee86b.tar.gz merchant-5eb0a2e98faecfec89add4845f817548b3fee86b.tar.bz2 merchant-5eb0a2e98faecfec89add4845f817548b3fee86b.zip |
fixed merchant get order with transfer status
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/test_merchant_api.c | 13 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_merchant_get_order.c | 96 |
2 files changed, 108 insertions, 1 deletions
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index d6630a69..eeaec917 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -231,6 +231,10 @@ static void run (void *cls, struct TALER_TESTING_Interpreter *is) { + const char *order_1_transfers[] = { + "post-transfer-1", + NULL + }; struct TALER_TESTING_Command pay[] = { /** * Move money to the exchange's bank account. @@ -395,6 +399,15 @@ run (void *cls, MHD_HTTP_OK, "post-transfer-1", NULL), + TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-2", + merchant_url, + "create-proposal-1", + true, + true, + order_1_transfers, + false, + NULL, + MHD_HTTP_OK), TALER_TESTING_cmd_merchant_delete_order ("delete-order-1", merchant_url, "1", diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c index 76bc75b8..cf0263ba 100644 --- a/src/testing/testing_api_cmd_merchant_get_order.c +++ b/src/testing/testing_api_cmd_merchant_get_order.c @@ -77,6 +77,21 @@ struct MerchantGetOrderState * The length of @e refunds. */ unsigned int refunds_length; + + /** + * Whether the order was wired or not. + */ + bool wired; + + /** + * A NULL-terminated list of transfers associated with this order. + */ + const char **transfers; + + /** + * The length of @e transfers. + */ + unsigned int transfers_length; }; @@ -230,6 +245,14 @@ merchant_get_order_cb ( } } } + + if (gos->wired != osr->details.paid.wired) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Order wired does not match\n"); + TALER_TESTING_interpreter_fail (gos->is); + return; + } } break; default: @@ -278,7 +301,7 @@ merchant_get_order_run (void *cls, gos->merchant_url, order_id, NULL, - false, + true, GNUNET_TIME_UNIT_ZERO, &merchant_get_order_cb, gos); @@ -366,6 +389,77 @@ TALER_TESTING_cmd_merchant_get_order (const char *label, } +/** + * Define a GET /private/orders/$ORDER_ID CMD. + * + * @param label the command label + * @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 wired whether the order has been wired or not. + * @param transfers NULL-terminated list of labels (const char *) of + * wire transfers (commands) we expect to be aggregated in the order + * (assuming @a http_code is #MHD_HTTP_OK). If @e paid is fale, this + * parameter is ignored. + * @param refunded whether the order has been refunded. + * @param refunds NULL-terminated list of labels (const char *) of + * refunds (commands) we expect to be aggregated in the order + * (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false, + * this parameter is ignored. + * @param http_status expected HTTP response code for the request. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_merchant_get_order2 (const char *label, + const char *merchant_url, + const char *order_reference, + bool paid, + bool wired, + const char **transfers, + bool refunded, + const char **refunds, + unsigned int http_status) +{ + struct MerchantGetOrderState *gos; + + gos = GNUNET_new (struct MerchantGetOrderState); + gos->merchant_url = merchant_url; + gos->order_reference = order_reference; + gos->paid = paid; + gos->wired = wired; + gos->refunded = refunded; + gos->http_status = http_status; + /*if (paid) + { + for (const char *clabel = transfers[0]; clabel != NULL; ++clabel) + { + GNUNET_array_append (gos->transfers, + gos->transfers_length, + clabel); + } + } + if (refunded) + { + for (const char *clabel = refunds[0]; clabel != NULL; ++clabel) + { + GNUNET_array_append (gos->refunds, + gos->refunds_length, + clabel); + } + }*/ + { + struct TALER_TESTING_Command cmd = { + .cls = gos, + .label = label, + .run = &merchant_get_order_run, + .cleanup = &merchant_get_order_cleanup + }; + + return cmd; + } +} + + struct MerchantPollOrderConcludeState { /** |