aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_get_reserves.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-06-03 23:42:39 +0200
committerChristian Grothoff <christian@grothoff.org>2023-06-03 23:42:39 +0200
commitc75ed08b4dbeb70959e10861a7eeb78c545a2fc8 (patch)
tree482ade5ae8da19c81710925c7025fd2b386b00dc /src/testing/testing_api_cmd_get_reserves.c
parent7f8c111f1383805d64ab7f754cb6456d3dfb7250 (diff)
address more FIXMEs
Diffstat (limited to 'src/testing/testing_api_cmd_get_reserves.c')
-rw-r--r--src/testing/testing_api_cmd_get_reserves.c170
1 files changed, 91 insertions, 79 deletions
diff --git a/src/testing/testing_api_cmd_get_reserves.c b/src/testing/testing_api_cmd_get_reserves.c
index ea860c27..309a7881 100644
--- a/src/testing/testing_api_cmd_get_reserves.c
+++ b/src/testing/testing_api_cmd_get_reserves.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -68,112 +68,124 @@ struct GetReservesState
static void
get_reserves_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int reserves_length,
- const struct TALER_MERCHANT_ReserveSummary reserves[])
+ const struct TALER_MERCHANT_ReservesGetResponse *rgr)
{
struct GetReservesState *grs = cls;
- bool matched[reserves_length];
- bool fail = false;
grs->rgh = NULL;
- if (grs->http_status != hr->http_status)
+ if (grs->http_status != rgr->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u (%d) to command %s\n",
- hr->http_status,
- (int) hr->ec,
+ rgr->hr.http_status,
+ (int) rgr->hr.ec,
TALER_TESTING_interpreter_get_current_label (grs->is));
TALER_TESTING_interpreter_fail (grs->is);
return;
}
- switch (hr->http_status)
+ switch (rgr->hr.http_status)
{
case MHD_HTTP_OK:
- if (reserves_length != grs->reserves_length)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Length of reserves found does not match\n");
- TALER_TESTING_interpreter_fail (grs->is);
- return;
- }
- /* check if the data returned matches that from the POST / PATCH */
- memset (matched, 0, sizeof (matched));
- for (unsigned int i = 0; i < reserves_length; ++i)
- for (unsigned int j = 0; j < reserves_length; ++j)
+ bool matched[GNUNET_NZL (rgr->details.ok.reserves_length)];
+ bool fail = false;
+
+ if (rgr->details.ok.reserves_length != grs->reserves_length)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Length of reserves found does not match\n");
+ TALER_TESTING_interpreter_fail (grs->is);
+ return;
+ }
+ /* check if the data returned matches that from the POST / PATCH */
+ memset (matched,
+ 0,
+ sizeof (matched));
+ for (unsigned int i = 0; i < rgr->details.ok.reserves_length; ++i)
{
- const struct TALER_TESTING_Command *reserve_cmd;
- bool match = true;
+ const struct TALER_MERCHANT_ReserveSummary *reserve
+ = &rgr->details.ok.reserves[i];
- reserve_cmd = TALER_TESTING_interpreter_lookup_command (
- grs->is,
- grs->reserves[j]);
+ for (unsigned int j = 0; j < grs->reserves_length; ++j)
{
- const struct TALER_ReservePublicKeyP *reserve_pub;
+ const struct TALER_TESTING_Command *reserve_cmd;
+ bool match = true;
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_reserve_pub (reserve_cmd,
- &reserve_pub))
+ reserve_cmd = TALER_TESTING_interpreter_lookup_command (
+ grs->is,
+ grs->reserves[j]);
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not fetch reserve public key\n");
- TALER_TESTING_interpreter_fail (grs->is);
- return;
- }
- if (0 != GNUNET_memcmp (&reserves[i].reserve_pub,
- reserve_pub))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Reserve public key does not match, got %s\n",
- TALER_B2S (&reserves[i].reserve_pub));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Reserve public key does not match, expected %s\n",
- TALER_B2S (reserve_pub));
- match = false;
- }
- }
- {
- const struct TALER_Amount *initial;
+ const struct TALER_ReservePublicKeyP *reserve_pub;
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_amount (reserve_cmd,
- &initial))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not fetch reserve initial balance\n");
- TALER_TESTING_interpreter_fail (grs->is);
- return;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_reserve_pub (reserve_cmd,
+ &reserve_pub))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch reserve public key\n");
+ TALER_TESTING_interpreter_fail (grs->is);
+ return;
+ }
+ if (0 != GNUNET_memcmp (&reserve->reserve_pub,
+ reserve_pub))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Reserve public key does not match, got %s\n",
+ TALER_B2S (&reserve->reserve_pub));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Reserve public key does not match, expected %s\n",
+ TALER_B2S (reserve_pub));
+ match = false;
+ }
}
- if ((GNUNET_OK !=
- TALER_amount_cmp_currency (&reserves[i].merchant_initial_amount,
- initial)) ||
- (0 != TALER_amount_cmp (&reserves[i].merchant_initial_amount,
- initial)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Reserve initial amount does not match, got %s\n",
- TALER_amount2s (&reserves[i].merchant_initial_amount));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Reserve initial amount does not match, wanted %s\n",
- TALER_amount2s (initial));
- match = false;
+ const struct TALER_Amount *initial;
+
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_amount (reserve_cmd,
+ &initial))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch reserve initial balance\n");
+ TALER_TESTING_interpreter_fail (grs->is);
+ return;
+ }
+ if ((GNUNET_OK !=
+ TALER_amount_cmp_currency (
+ &reserve->merchant_initial_amount,
+ initial)) ||
+ (0 != TALER_amount_cmp (&reserve->merchant_initial_amount,
+ initial)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Reserve initial amount does not match, got %s\n",
+ TALER_amount2s (
+ &reserve->merchant_initial_amount));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Reserve initial amount does not match, wanted %s\n",
+ TALER_amount2s (initial));
+ match = false;
+ }
}
+ if (match)
+ matched[i] = true;
}
- if (match)
- matched[i] = true;
}
- for (unsigned int i = 0; i < reserves_length; ++i)
- if (! matched[i])
- fail = true;
- if (fail)
- {
- TALER_TESTING_interpreter_fail (grs->is);
- return;
+ for (unsigned int i = 0; i < rgr->details.ok.reserves_length; ++i)
+ if (! matched[i])
+ fail = true;
+ if (fail)
+ {
+ TALER_TESTING_interpreter_fail (grs->is);
+ return;
+ }
+ break;
}
- break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unhandled HTTP status.\n");
+ "Unhandled HTTP status %u.\n",
+ rgr->hr.http_status);
+ break;
}
TALER_TESTING_interpreter_next (grs->is);
}