From e24dd4856b91c4958df7c578275f60cdc11401f2 Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Mon, 29 Jun 2020 16:10:14 -0400 Subject: get reserve and tip testing commands use variadic args --- src/testing/testing_api_cmd_get_reserve.c | 43 ++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'src/testing/testing_api_cmd_get_reserve.c') diff --git a/src/testing/testing_api_cmd_get_reserve.c b/src/testing/testing_api_cmd_get_reserve.c index 8c626f82..06ebb470 100644 --- a/src/testing/testing_api_cmd_get_reserve.c +++ b/src/testing/testing_api_cmd_get_reserve.c @@ -61,10 +61,15 @@ struct GetReserveState */ bool fetch_tips; + /** + * Length of @e tips. + */ + unsigned int tips_length; + /** * The list of references to tips. */ - const char **tip_refs; + const char **tips; }; @@ -118,19 +123,19 @@ get_reserve_cb (void *cls, return; } } + if (tips_length != grs->tips_length) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Number of tips authorized does not match\n"); + TALER_TESTING_interpreter_fail (grs->is); + return; + } for (unsigned int i = 0; i < tips_length; ++i) { const struct TALER_TESTING_Command *tip_cmd; - if (NULL == grs->tip_refs[i]) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Number of tips authorized does not match\n"); - TALER_TESTING_interpreter_fail (grs->is); - return; - } tip_cmd = TALER_TESTING_interpreter_lookup_command (grs->is, - grs->tip_refs[i]); + grs->tips[i]); { const struct GNUNET_HashCode *tip_id; @@ -301,7 +306,9 @@ TALER_TESTING_cmd_merchant_get_reserve (const char *label, * @param http_status expected HTTP response code. * @param reserve_reference reference to a "POST /reserves" that provides the * information we are expecting. - * @param tip_refs a NULL-terminated list of references to tips + * @param ... NULL-terminated list of labels (const char *) of + * tip (commands) we expect to be returned in the list + * (assuming @a http_code is #MHD_HTTP_OK) * @return the command. */ struct TALER_TESTING_Command @@ -309,7 +316,7 @@ TALER_TESTING_cmd_merchant_get_reserve_with_tips (const char *label, const char *merchant_url, unsigned int http_status, const char *reserve_reference, - const char *tip_refs[]) + ...) { struct GetReserveState *grs; @@ -318,7 +325,19 @@ TALER_TESTING_cmd_merchant_get_reserve_with_tips (const char *label, grs->http_status = http_status; grs->reserve_reference = reserve_reference; grs->fetch_tips = true; - grs->tip_refs = tip_refs; + { + const char *clabel; + va_list ap; + + va_start (ap, reserve_reference); + while (NULL != (clabel = va_arg (ap, const char *))) + { + GNUNET_array_append (grs->tips, + grs->tips_length, + clabel); + } + va_end (ap); + } { struct TALER_TESTING_Command cmd = { .cls = grs, -- cgit v1.2.3