[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] 266/277: get reserve and tip testing commands use varia
From: |
gnunet |
Subject: |
[taler-merchant] 266/277: get reserve and tip testing commands use variadic args |
Date: |
Sun, 05 Jul 2020 20:52:59 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
commit e24dd4856b91c4958df7c578275f60cdc11401f2
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Mon Jun 29 16:10:14 2020 -0400
get reserve and tip testing commands use variadic args
---
src/include/taler_merchant_testing_lib.h | 13 +++++---
src/testing/test_merchant_api.c | 14 ++++----
src/testing/testing_api_cmd_get_reserve.c | 43 +++++++++++++++++-------
src/testing/testing_api_cmd_merchant_get_tip.c | 45 ++++++++++++++++++--------
4 files changed, 79 insertions(+), 36 deletions(-)
diff --git a/src/include/taler_merchant_testing_lib.h
b/src/include/taler_merchant_testing_lib.h
index 219997d..5b4b835 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -749,7 +749,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
@@ -757,7 +759,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[]);
+ ...);
/**
@@ -852,13 +854,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,
+ ...);
/**
* Define a GET /tips/$TIP_ID CMD.
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index adae22d..2f30ca7 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -49,14 +49,10 @@
*/
#define EXCHANGE_URL "http://localhost:8081/"
-static const char *tip_refs[] = {"authorize-tip-1", "authorize-tip-2", NULL};
-
static const char *pickup_amounts_1[] = {"EUR:5", NULL};
static const char *pickup_amounts_2[] = {"EUR:0.01", NULL};
-static const char *pickup_refs[] = {"pickup-tip-1", "pickup-tip-4", NULL};
-
/**
* Payto URI of the customer (payer).
*/
@@ -762,7 +758,9 @@ run (void *cls,
merchant_url,
MHD_HTTP_OK,
"create-reserve-tip-1",
- tip_refs),
+ "authorize-tip-1",
+ "authorize-tip-2",
+ NULL),
TALER_TESTING_cmd_tip_pickup ("pickup-tip-1",
merchant_url,
MHD_HTTP_OK,
@@ -794,8 +792,10 @@ run (void *cls,
TALER_TESTING_cmd_merchant_get_tip_with_pickups ("merchant-get-tip-2",
merchant_url,
"authorize-tip-1",
- pickup_refs,
- MHD_HTTP_OK),
+ MHD_HTTP_OK,
+ "pickup-tip-1",
+ "pickup-tip-4",
+ NULL),
/* This command tests the authorization of tip
* against a reserve that does not exist. This is
diff --git a/src/testing/testing_api_cmd_get_reserve.c
b/src/testing/testing_api_cmd_get_reserve.c
index 8c626f8..06ebb47 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,
diff --git a/src/testing/testing_api_cmd_merchant_get_tip.c
b/src/testing/testing_api_cmd_merchant_get_tip.c
index 085f957..6695d3b 100644
--- a/src/testing/testing_api_cmd_merchant_get_tip.c
+++ b/src/testing/testing_api_cmd_merchant_get_tip.c
@@ -48,10 +48,15 @@ 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,8 +369,20 @@ 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,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-merchant] 258/277: excluded doc/doxygen from gitignore, (continued)
- [taler-merchant] 258/277: excluded doc/doxygen from gitignore, gnunet, 2020/07/05
- [taler-merchant] 257/277: updated doxygen generation, gnunet, 2020/07/05
- [taler-merchant] 260/277: fix #6236, gnunet, 2020/07/05
- [taler-merchant] 262/277: deduplicate logic, gnunet, 2020/07/05
- [taler-merchant] 264/277: filler max_upload values for all POST/PATCH handlers, gnunet, 2020/07/05
- [taler-merchant] 265/277: got tips test working again, gnunet, 2020/07/05
- [taler-merchant] 261/277: removed hardcoded row numbers from backenddb tests, gnunet, 2020/07/05
- [taler-merchant] 263/277: long polling test for GET /private/orders, gnunet, 2020/07/05
- [taler-merchant] 270/277: twister, get tips, instance, and post transfer tests, gnunet, 2020/07/05
- [taler-merchant] 259/277: more docs/thorough checks for backend db & long polling for merchant get order, gnunet, 2020/07/05
- [taler-merchant] 266/277: get reserve and tip testing commands use variadic args,
gnunet <=
- [taler-merchant] 267/277: get pay-again and pay-abort working again, gnunet, 2020/07/05
- [taler-merchant] 272/277: more merchant benchmark cleanup, gnunet, 2020/07/05
- [taler-merchant] 273/277: use improved rewind API, gnunet, 2020/07/05
- [taler-merchant] 274/277: test GET /private/transfers, gnunet, 2020/07/05
- [taler-merchant] 275/277: fix compiler warnings for test_merchantdb.c, gnunet, 2020/07/05
- [taler-merchant] 268/277: improved db tests for transfers, gnunet, 2020/07/05
- [taler-merchant] 269/277: removed outdated test code, gnunet, 2020/07/05
- [taler-merchant] 271/277: some clean up of merchant benchmark code, gnunet, 2020/07/05
- [taler-merchant] 276/277: avoid allocation, gnunet, 2020/07/05
- [taler-merchant] 277/277: GNUNET_free_non_null -> GNUNET_free rename, gnunet, 2020/07/05