summaryrefslogtreecommitdiff
path: root/src/lib/testing_api_cmd_payback.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-07-15 21:44:03 +0200
committerChristian Grothoff <christian@grothoff.org>2019-07-15 21:44:03 +0200
commit28f790fac5af5d801d5cb7bd3cdfe53f0ac948d2 (patch)
tree2b10e8a11883852d0869f96f698ff393666ef290 /src/lib/testing_api_cmd_payback.c
parenta497ccffb607c7ac4e6461693630d2d673afff73 (diff)
downloadexchange-28f790fac5af5d801d5cb7bd3cdfe53f0ac948d2.tar.gz
exchange-28f790fac5af5d801d5cb7bd3cdfe53f0ac948d2.tar.bz2
exchange-28f790fac5af5d801d5cb7bd3cdfe53f0ac948d2.zip
fix use of index in testing_api_cmd_refresh.c
Diffstat (limited to 'src/lib/testing_api_cmd_payback.c')
-rw-r--r--src/lib/testing_api_cmd_payback.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/lib/testing_api_cmd_payback.c b/src/lib/testing_api_cmd_payback.c
index 9b49108cd..ac4fd6419 100644
--- a/src/lib/testing_api_cmd_payback.c
+++ b/src/lib/testing_api_cmd_payback.c
@@ -124,7 +124,6 @@ payback_cb (void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
const json_t *full_response)
{
-
struct PaybackState *ps = cls;
struct TALER_TESTING_Interpreter *is = ps->is;
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
@@ -132,6 +131,9 @@ payback_cb (void *cls,
const struct TALER_ReservePrivateKeyP *reserve_priv;
struct TALER_ReservePublicKeyP rp;
struct TALER_Amount expected_amount;
+ char *cref;
+ const char *index;
+ unsigned int idx;
ps->ph = NULL;
if (ps->expected_response_code != http_status)
@@ -148,8 +150,37 @@ payback_cb (void *cls,
return;
}
+ /* We allow command referneces of the form "$LABEL#$INDEX" or
+ just "$LABEL", which implies the index is 0. Figure out
+ which one it is. */
+ index = strchr (ps->coin_reference, '#');
+ if (NULL == index)
+ {
+ idx = 0;
+ cref = GNUNET_strdup (ps->coin_reference);
+ }
+ else
+ {
+ cref = GNUNET_strndup (ps->coin_reference,
+ index - ps->coin_reference);
+ if (1 != sscanf (index,
+ "%u",
+ &idx))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Numeric index (not `%s') required after `#' in command reference of command %s in %s:%u\n",
+ index,
+ cmd->label,
+ __FILE__,
+ __LINE__);
+ TALER_TESTING_interpreter_fail (is);
+ GNUNET_free (cref);
+ return;
+ }
+ }
reserve_cmd = TALER_TESTING_interpreter_lookup_command
- (is, ps->coin_reference);
+ (is, cref);
+ GNUNET_free (cref);
if (NULL == reserve_cmd)
{
@@ -159,7 +190,7 @@ payback_cb (void *cls,
}
if (GNUNET_OK != TALER_TESTING_get_trait_reserve_priv
- (reserve_cmd, 0, &reserve_priv))
+ (reserve_cmd, idx, &reserve_priv))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);