diff options
author | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-06-29 16:10:14 -0400 |
---|---|---|
committer | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-06-29 16:10:14 -0400 |
commit | e24dd4856b91c4958df7c578275f60cdc11401f2 (patch) | |
tree | 063668c4771aa20b23e9a99b3f5ddf87cb3f269a /src/testing/testing_api_cmd_merchant_get_tip.c | |
parent | f641e252f0ae2e6ebc0cb5520363f69b65427c8b (diff) | |
download | merchant-e24dd4856b91c4958df7c578275f60cdc11401f2.tar.gz merchant-e24dd4856b91c4958df7c578275f60cdc11401f2.tar.bz2 merchant-e24dd4856b91c4958df7c578275f60cdc11401f2.zip |
get reserve and tip testing commands use variadic args
Diffstat (limited to 'src/testing/testing_api_cmd_merchant_get_tip.c')
-rw-r--r-- | src/testing/testing_api_cmd_merchant_get_tip.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/src/testing/testing_api_cmd_merchant_get_tip.c b/src/testing/testing_api_cmd_merchant_get_tip.c index 085f9575..6695d3b7 100644 --- a/src/testing/testing_api_cmd_merchant_get_tip.c +++ b/src/testing/testing_api_cmd_merchant_get_tip.c @@ -49,9 +49,14 @@ struct MerchantTipGetState bool fetch_pickups; /** + * The length of @e pickups. + */ + unsigned int pickups_length; + + /** * The NULL-terminated list of pickup commands associated with the tip. */ - const char **pickup_refs; + const char **pickups; /** * The handle to the current GET /tips/$TIP_ID request. @@ -169,21 +174,20 @@ merchant_get_tip_cb (void *cls, return; } } + if (pickups_length != gts->pickups_length) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Length of pickups array does not match\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } { for (unsigned int i = 0; i < pickups_length; ++i) { const struct TALER_TESTING_Command *pickup_cmd; - if (NULL == gts->pickup_refs[i]) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Length of pickup array does not match\n"); - TALER_TESTING_interpreter_fail (gts->is); - return; - } pickup_cmd = TALER_TESTING_interpreter_lookup_command (gts->is, - gts->pickup_refs[ - i]); + gts->pickups[i]); { const uint64_t *num_planchets; @@ -348,13 +352,16 @@ TALER_TESTING_cmd_merchant_get_tip (const char *label, * @param pickup_refs a NULL-terminated list of pickup commands * associated with the tip. * @param http_status expected HTTP response code for the request. + * @param ... NULL-terminated list of labels (const char *) of + * pickup (commands) we expect to be returned in the list + * (assuming @a http_code is #MHD_HTTP_OK) */ struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_get_tip_with_pickups (const char *label, const char *merchant_url, const char *tip_reference, - const char *pickup_refs[], - unsigned int http_status) + unsigned int http_status, + ...) { struct MerchantTipGetState *tgs; @@ -362,9 +369,21 @@ TALER_TESTING_cmd_merchant_get_tip_with_pickups (const char *label, tgs->merchant_url = merchant_url; tgs->tip_reference = tip_reference; tgs->fetch_pickups = true; - tgs->pickup_refs = pickup_refs; tgs->http_status = http_status; { + const char *clabel; + va_list ap; + + va_start (ap, http_status); + while (NULL != (clabel = va_arg (ap, const char *))) + { + GNUNET_array_append (tgs->pickups, + tgs->pickups_length, + clabel); + } + va_end (ap); + } + { struct TALER_TESTING_Command cmd = { .cls = tgs, .label = label, |