diff options
author | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-02 02:05:08 -0400 |
---|---|---|
committer | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-02 02:05:08 -0400 |
commit | 03ca8c13996b1222ef11321c31c5e560f44058e4 (patch) | |
tree | 6135bd73dc7cc9eb7079bab90635561c7c456e1c /src/testing/testing_api_cmd_get_tips.c | |
parent | dcd5a4c81f8ac87a8fa103f26e9726b637c6a516 (diff) | |
download | merchant-03ca8c13996b1222ef11321c31c5e560f44058e4.tar.gz merchant-03ca8c13996b1222ef11321c31c5e560f44058e4.tar.bz2 merchant-03ca8c13996b1222ef11321c31c5e560f44058e4.zip |
twister, get tips, instance, and post transfer tests
Diffstat (limited to 'src/testing/testing_api_cmd_get_tips.c')
-rw-r--r-- | src/testing/testing_api_cmd_get_tips.c | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/src/testing/testing_api_cmd_get_tips.c b/src/testing/testing_api_cmd_get_tips.c index 5e939848..ae7ffb02 100644 --- a/src/testing/testing_api_cmd_get_tips.c +++ b/src/testing/testing_api_cmd_get_tips.c @@ -54,6 +54,16 @@ struct GetTipsState */ unsigned int http_status; + /** + * Length of @e tips. + */ + unsigned int tips_length; + + /** + * + */ + const char **tips; + }; /** @@ -89,6 +99,67 @@ get_tips_cb (void *cls, case MHD_HTTP_OK: // FIXME: use gis->product_reference here to // check if the data returned matches that from the POST / PATCH + if (tips_length != gts->tips_length) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Tips length does not match\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + for (unsigned int i = 0; i < tips_length; ++i) + { + const struct TALER_TESTING_Command *tip_cmd; + + tip_cmd = TALER_TESTING_interpreter_lookup_command ( + gts->is, + gts->tips[i]); + { + const struct GNUNET_HashCode *tip_id; + + if (GNUNET_OK != + TALER_TESTING_get_trait_tip_id (tip_cmd, + 0, + &tip_id)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch tip id\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + if (0 != GNUNET_memcmp (tip_id, + &tips[i].tip_id)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Tip id does not match\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + } + { + const struct TALER_Amount *tip_amount; + + if (GNUNET_OK != + TALER_TESTING_get_trait_amount_obj (tip_cmd, + 0, + &tip_amount)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch tip amount\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + if ((GNUNET_OK != TALER_amount_cmp_currency (tip_amount, + &tips[i].tip_amount)) || + (0 != TALER_amount_cmp (tip_amount, + &tips[i].tip_amount))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Tip amount does not match\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + } + } break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -153,11 +224,15 @@ get_tips_cleanup (void *cls, * server the /tip-query request. * @param http_status expected HTTP response code for the * /tip-query request. + * @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) */ struct TALER_TESTING_Command TALER_TESTING_cmd_get_tips (const char *label, const char *merchant_url, - unsigned int http_status) + unsigned int http_status, + ...) { struct GetTipsState *gts; @@ -165,6 +240,19 @@ TALER_TESTING_cmd_get_tips (const char *label, gts->merchant_url = merchant_url; gts->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 (gts->tips, + gts->tips_length, + clabel); + } + va_end (ap); + } + { struct TALER_TESTING_Command cmd = { .cls = gts, .label = label, |