summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-07-24 00:13:53 +0200
committerChristian Grothoff <christian@grothoff.org>2019-07-24 00:13:53 +0200
commit5844a20f15cf6d35503386a717e9d582189a7261 (patch)
tree0175ab0041b8e5f01a4f5cdcb561314ac8c3e804 /src/lib
parente75d552227a4c06faad0a0eae7539458ff58f9af (diff)
downloadexchange-5844a20f15cf6d35503386a717e9d582189a7261.tar.gz
exchange-5844a20f15cf6d35503386a717e9d582189a7261.tar.bz2
exchange-5844a20f15cf6d35503386a717e9d582189a7261.zip
implement zombie check
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/test_exchange_api_revocation.c31
-rw-r--r--src/lib/testing_api_cmd_payback.c101
2 files changed, 90 insertions, 42 deletions
diff --git a/src/lib/test_exchange_api_revocation.c b/src/lib/test_exchange_api_revocation.c
index 090b38b25..bd1d91c66 100644
--- a/src/lib/test_exchange_api_revocation.c
+++ b/src/lib/test_exchange_api_revocation.c
@@ -159,16 +159,27 @@ run (void *cls,
"refresh-melt-1",
CONFIG_FILE),
/* Refund coin to original coin */
- TALER_TESTING_cmd_payback ("payback-1",
+ TALER_TESTING_cmd_payback ("payback-1a",
MHD_HTTP_OK,
- "refresh-reveal-1",
- "EUR:5",
+ "refresh-reveal-1#0",
+ "EUR:1",
"refresh-melt-1"),
- /**
- * Melt original coin AGAIN
- * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */
+ TALER_TESTING_cmd_payback ("payback-1b",
+ MHD_HTTP_OK,
+ "refresh-reveal-1#1",
+ "EUR:1",
+ "refresh-melt-1"),
+ TALER_TESTING_cmd_payback ("payback-1c",
+ MHD_HTTP_OK,
+ "refresh-reveal-1#2",
+ "EUR:1",
+ "refresh-melt-1"),
+ /* Melt original coin AGAIN (FIXME: this command
+ is simply WRONG as it neither matches
+ the EUR:3 that were paid back NOR is melt_double
+ precisely right here!) -- it always tries to MELT EUR:4, which is too much! */
TALER_TESTING_cmd_refresh_melt_double
- ("refresh-melt-2", "EUR:4",
+ ("refresh-melt-2", "EUR:3",
"withdraw-coin-1", MHD_HTTP_OK),
/**
* Complete (successful) melt operation, and withdraw the coins
@@ -190,18 +201,18 @@ run (void *cls,
TALER_TESTING_cmd_payback ("payback-2",
MHD_HTTP_OK,
"refresh-melt-2",
- "EUR:5",
+ "EUR:1",
"refresh-melt-2"),
/* Refund original coin to reserve */
TALER_TESTING_cmd_payback ("payback-3",
MHD_HTTP_OK,
"withdraw-coin-1",
- "EUR:5",
+ "EUR:1",
NULL),
/* Check the money is back with the reserve */
TALER_TESTING_cmd_status ("payback-reserve-status-1",
"create-reserve-1",
- "EUR:4.0",
+ "EUR:1.0",
MHD_HTTP_OK),
TALER_TESTING_cmd_end ()
};
diff --git a/src/lib/testing_api_cmd_payback.c b/src/lib/testing_api_cmd_payback.c
index c7ea5091d..de394fe26 100644
--- a/src/lib/testing_api_cmd_payback.c
+++ b/src/lib/testing_api_cmd_payback.c
@@ -107,6 +107,51 @@ struct PaybackState
};
+
+/**
+ * Parser reference to a coin.
+ *
+ * @param coin_reference of format $LABEL['#' $INDEX]?
+ * @param cref[out] where we return a copy of $LABEL
+ * @param idx[out] where we set $INDEX
+ * @return #GNUNET_SYSERR if $INDEX is present but not numeric
+ */
+static int
+parse_coin_reference (const char *coin_reference,
+ char **cref,
+ unsigned int *idx)
+{
+ const char *index;
+
+ /* We allow command references of the form "$LABEL#$INDEX" or
+ just "$LABEL", which implies the index is 0. Figure out
+ which one it is. */
+ index = strchr (coin_reference, '#');
+ if (NULL == index)
+ {
+ *idx = 0;
+ *cref = GNUNET_strdup (coin_reference);
+ return GNUNET_OK;
+ }
+ *cref = GNUNET_strndup (coin_reference,
+ index - coin_reference);
+ if (1 != sscanf (index + 1,
+ "%u",
+ idx))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Numeric index (not `%s') required after `#' in command reference of command in %s:%u\n",
+ index,
+ __FILE__,
+ __LINE__);
+ GNUNET_free (*cref);
+ *cref = NULL;
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
/**
* Check the result of the payback request: checks whether
* the HTTP response code is good, and that the coin that
@@ -137,7 +182,6 @@ payback_cb (void *cls,
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
const struct TALER_TESTING_Command *reserve_cmd;
char *cref;
- const char *index;
unsigned int idx;
ps->ph = NULL;
@@ -155,34 +199,15 @@ payback_cb (void *cls,
return;
}
- /* We allow command references 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)
+ if (GNUNET_OK !=
+ parse_coin_reference (ps->coin_reference,
+ &cref,
+ &idx))
{
- 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;
- }
+ TALER_TESTING_interpreter_fail (is);
+ return;
}
+
reserve_cmd = TALER_TESTING_interpreter_lookup_command
(is, cref);
GNUNET_free (cref);
@@ -309,10 +334,22 @@ payback_run (void *cls,
const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
const struct TALER_DenominationSignature *coin_sig;
struct TALER_PlanchetSecretsP planchet;
+ char *cref;
+ unsigned int idx;
ps->is = is;
+ if (GNUNET_OK !=
+ parse_coin_reference (ps->coin_reference,
+ &cref,
+ &idx))
+ {
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+
coin_cmd = TALER_TESTING_interpreter_lookup_command
- (is, ps->coin_reference);
+ (is, cref);
+ GNUNET_free (cref);
if (NULL == coin_cmd)
{
@@ -322,7 +359,7 @@ payback_run (void *cls,
}
if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
- (coin_cmd, 0, &coin_priv))
+ (coin_cmd, idx, &coin_priv))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
@@ -330,7 +367,7 @@ payback_run (void *cls,
}
if (GNUNET_OK != TALER_TESTING_get_trait_blinding_key
- (coin_cmd, 0, &blinding_key))
+ (coin_cmd, idx, &blinding_key))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
@@ -340,7 +377,7 @@ payback_run (void *cls,
planchet.blinding_key = *blinding_key;
if (GNUNET_OK != TALER_TESTING_get_trait_denom_pub
- (coin_cmd, 0, &denom_pub))
+ (coin_cmd, idx, &denom_pub))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
@@ -348,7 +385,7 @@ payback_run (void *cls,
}
if (GNUNET_OK != TALER_TESTING_get_trait_denom_sig
- (coin_cmd, 0, &coin_sig))
+ (coin_cmd, idx, &coin_sig))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);