summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_get_reserve.c
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-29 16:10:14 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-29 16:10:14 -0400
commite24dd4856b91c4958df7c578275f60cdc11401f2 (patch)
tree063668c4771aa20b23e9a99b3f5ddf87cb3f269a /src/testing/testing_api_cmd_get_reserve.c
parentf641e252f0ae2e6ebc0cb5520363f69b65427c8b (diff)
downloadmerchant-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_get_reserve.c')
-rw-r--r--src/testing/testing_api_cmd_get_reserve.c43
1 files changed, 31 insertions, 12 deletions
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
@@ -62,9 +62,14 @@ 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,