aboutsummaryrefslogtreecommitdiff
path: root/src/mint-lib/test_mint_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-09-27 20:32:30 +0200
committerChristian Grothoff <christian@grothoff.org>2015-09-27 20:32:30 +0200
commitbf8b9d1435a196c9b7c3293904da2a3baba7210a (patch)
treeb722367def8d35bff70938db77323de61efd0348 /src/mint-lib/test_mint_api.c
parenta67fefa9fbcf9774d277a9c94aeebdf78d2051d1 (diff)
parent1bfba318ec0f3393de2dfc66821dec6165eef90a (diff)
mention need to audit randomness of gamma
Diffstat (limited to 'src/mint-lib/test_mint_api.c')
-rw-r--r--src/mint-lib/test_mint_api.c341
1 files changed, 239 insertions, 102 deletions
diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c
index 8a9d09ce..7b96f657 100644
--- a/src/mint-lib/test_mint_api.c
+++ b/src/mint-lib/test_mint_api.c
@@ -26,6 +26,15 @@
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
+/**
+ * Is the configuration file is set to include wire format 'test'?
+ */
+#define WIRE_TEST 1
+
+/**
+ * Is the configuration file is set to include wire format 'sepa'?
+ */
+#define WIRE_SEPA 1
/**
* Main execution context for the main loop.
@@ -97,7 +106,12 @@ enum OpCode
* Verify mint's /refresh/link by linking original private key to
* results from #OC_REFRESH_REVEAL step.
*/
- OC_REFRESH_LINK
+ OC_REFRESH_LINK,
+
+ /**
+ * Verify the mint's /wire-method.
+ */
+ OC_WIRE
};
@@ -116,7 +130,7 @@ struct MeltDetails
const char *amount;
/**
- * Reference to withdraw_sign operations for coin to
+ * Reference to reserve_withdraw operations for coin to
* be used for the /refresh/melt operation.
*/
const char *coin_ref;
@@ -228,14 +242,14 @@ struct Command
/**
* Set to the API's handle during the operation.
*/
- struct TALER_MINT_WithdrawStatusHandle *wsh;
+ struct TALER_MINT_ReserveStatusHandle *wsh;
/**
* Expected reserve balance.
*/
const char *expected_balance;
- } withdraw_status;
+ } reserve_status;
/**
* Information for a #OC_WITHDRAW_SIGN command.
@@ -281,9 +295,9 @@ struct Command
/**
* Withdraw handle (while operation is running).
*/
- struct TALER_MINT_WithdrawSignHandle *wsh;
+ struct TALER_MINT_ReserveWithdrawHandle *wsh;
- } withdraw_sign;
+ } reserve_withdraw;
/**
* Information for a #OC_DEPOSIT command.
@@ -297,7 +311,7 @@ struct Command
const char *amount;
/**
- * Reference to a withdraw_sign operation for a coin to
+ * Reference to a reserve_withdraw operation for a coin to
* be used for the /deposit operation.
*/
const char *coin_ref;
@@ -439,6 +453,23 @@ struct Command
} refresh_link;
+ /**
+ * Information for the /wire command.
+ */
+ struct {
+
+ /**
+ * Handle to the wire request.
+ */
+ struct TALER_MINT_WireHandle *wh;
+
+ /**
+ * Format we expect to see, others will be *ignored*.
+ */
+ const char *format;
+
+ } wire;
+
} details;
};
@@ -622,8 +653,8 @@ compare_admin_add_incoming_history (const struct TALER_MINT_ReserveHistory *h,
* @return #GNUNET_OK if they match, #GNUNET_SYSERR if not
*/
static int
-compare_withdraw_sign_history (const struct TALER_MINT_ReserveHistory *h,
- const struct Command *cmd)
+compare_reserve_withdraw_history (const struct TALER_MINT_ReserveHistory *h,
+ const struct Command *cmd)
{
struct TALER_Amount amount;
struct TALER_Amount amount_with_fee;
@@ -634,12 +665,12 @@ compare_withdraw_sign_history (const struct TALER_MINT_ReserveHistory *h,
return GNUNET_SYSERR;
}
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (cmd->details.withdraw_sign.amount,
+ TALER_string_to_amount (cmd->details.reserve_withdraw.amount,
&amount));
GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&amount_with_fee,
&amount,
- &cmd->details.withdraw_sign.pk->fee_withdraw));
+ &cmd->details.reserve_withdraw.pk->fee_withdraw));
if (0 != TALER_amount_cmp (&amount_with_fee,
&h->amount))
{
@@ -651,7 +682,7 @@ compare_withdraw_sign_history (const struct TALER_MINT_ReserveHistory *h,
/**
- * Function called with the result of a /withdraw/status request.
+ * Function called with the result of a /reserve/status request.
*
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
@@ -662,12 +693,12 @@ compare_withdraw_sign_history (const struct TALER_MINT_ReserveHistory *h,
* @param history detailed transaction history, NULL on error
*/
static void
-withdraw_status_cb (void *cls,
- unsigned int http_status,
- json_t *json,
- const struct TALER_Amount *balance,
- unsigned int history_length,
- const struct TALER_MINT_ReserveHistory *history)
+reserve_status_cb (void *cls,
+ unsigned int http_status,
+ json_t *json,
+ const struct TALER_Amount *balance,
+ unsigned int history_length,
+ const struct TALER_MINT_ReserveHistory *history)
{
struct InterpreterState *is = cls;
struct Command *cmd = &is->commands[is->ip];
@@ -676,7 +707,7 @@ withdraw_status_cb (void *cls,
unsigned int j;
struct TALER_Amount amount;
- cmd->details.withdraw_status.wsh = NULL;
+ cmd->details.reserve_status.wsh = NULL;
if (cmd->expected_response_code != http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -700,10 +731,10 @@ withdraw_status_cb (void *cls,
{
case OC_ADMIN_ADD_INCOMING:
if ( ( (NULL != rel->label) &&
- (0 == strcmp (cmd->details.withdraw_status.reserve_reference,
+ (0 == strcmp (cmd->details.reserve_status.reserve_reference,
rel->label) ) ) ||
( (NULL != rel->details.admin_add_incoming.reserve_reference) &&
- (0 == strcmp (cmd->details.withdraw_status.reserve_reference,
+ (0 == strcmp (cmd->details.reserve_status.reserve_reference,
rel->details.admin_add_incoming.reserve_reference) ) ) )
{
if (GNUNET_OK !=
@@ -718,11 +749,11 @@ withdraw_status_cb (void *cls,
}
break;
case OC_WITHDRAW_SIGN:
- if (0 == strcmp (cmd->details.withdraw_status.reserve_reference,
- rel->details.withdraw_sign.reserve_reference))
+ if (0 == strcmp (cmd->details.reserve_status.reserve_reference,
+ rel->details.reserve_withdraw.reserve_reference))
{
if (GNUNET_OK !=
- compare_withdraw_sign_history (&history[j],
+ compare_reserve_withdraw_history (&history[j],
rel))
{
GNUNET_break (0);
@@ -743,10 +774,10 @@ withdraw_status_cb (void *cls,
fail (is);
return;
}
- if (NULL != cmd->details.withdraw_status.expected_balance)
+ if (NULL != cmd->details.reserve_status.expected_balance)
{
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (cmd->details.withdraw_status.expected_balance,
+ TALER_string_to_amount (cmd->details.reserve_status.expected_balance,
&amount));
if (0 != TALER_amount_cmp (&amount,
balance))
@@ -769,7 +800,7 @@ withdraw_status_cb (void *cls,
/**
- * Function called upon completion of our /withdraw/sign request.
+ * Function called upon completion of our /reserve/withdraw request.
*
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
@@ -778,15 +809,15 @@ withdraw_status_cb (void *cls,
* @param full_response full response from the mint (for logging, in case of errors)
*/
static void
-withdraw_sign_cb (void *cls,
- unsigned int http_status,
- const struct TALER_DenominationSignature *sig,
- json_t *full_response)
+reserve_withdraw_cb (void *cls,
+ unsigned int http_status,
+ const struct TALER_DenominationSignature *sig,
+ json_t *full_response)
{
struct InterpreterState *is = cls;
struct Command *cmd = &is->commands[is->ip];
- cmd->details.withdraw_sign.wsh = NULL;
+ cmd->details.reserve_withdraw.wsh = NULL;
if (cmd->expected_response_code != http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -807,7 +838,7 @@ withdraw_sign_cb (void *cls,
fail (is);
return;
}
- cmd->details.withdraw_sign.sig.rsa_signature
+ cmd->details.reserve_withdraw.sig.rsa_signature
= GNUNET_CRYPTO_rsa_signature_dup (sig->rsa_signature);
break;
case MHD_HTTP_PAYMENT_REQUIRED:
@@ -1011,10 +1042,6 @@ link_cb (void *cls,
return;
}
/* check that the coins match */
- fprintf (stderr,
- "Got %u coins\n",
- num_coins);
-
for (i=0;i<num_coins;i++)
for (j=i+1;j<num_coins;j++)
if (0 == memcmp (&coin_privs[i],
@@ -1027,7 +1054,7 @@ link_cb (void *cls,
for (j=0;j<num_coins;j++)
{
const struct FreshCoin *fc;
-
+
fc = &ref->details.refresh_reveal.fresh_coins[j];
if ( (0 == memcmp (&coin_privs[i],
&fc->coin_priv,
@@ -1048,8 +1075,8 @@ link_cb (void *cls,
found,
num_coins);
GNUNET_break (0);
- fail (is);
- return;
+ fail (is);
+ return;
}
break;
default:
@@ -1116,6 +1143,83 @@ find_pk (const struct TALER_MINT_Keys *keys,
/**
+ * Callbacks called with the result(s) of a
+ * wire format inquiry request to the mint.
+ *
+ * The callback is invoked multiple times, once for each supported @a
+ * method. Finally, it is invoked one more time with cls/0/NULL/NULL
+ * to indicate the end of the iteration. If any request fails to
+ * generate a valid response from the mint, @a http_status will also
+ * be zero and the iteration will also end. Thus, the iteration
+ * always ends with a final call with an @a http_status of 0. If the
+ * @a http_status is already 0 on the first call, then the response to
+ * the /wire request was invalid. Later, clients can tell the
+ * difference between @a http_status of 0 indicating a failed
+ * /wire/method request and a regular end of the iteration by @a
+ * method being non-NULL. If the mint simply correctly asserts that
+ * it does not support any methods, @a method will be NULL but the @a
+ * http_status will be #MHD_HTTP_OK for the first call (followed by a
+ * cls/0/NULL/NULL call to signal the end of the iteration).
+ *
+ * @param cls closure with the interpreter state
+ * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful request;
+ * 0 if the mint's reply is bogus (fails to follow the protocol)
+ * @param method wire format method supported, i.e. "test" or "sepa", or NULL
+ * if already the /wire request failed.
+ * @param obj the received JSON reply, if successful this should be the wire
+ * format details as provided by /wire/METHOD/, or NULL if the
+ * reply was not in JSON format (in this case, the client might
+ * want to do an HTTP request to /wire/METHOD/ with a browser to
+ * provide more information to the user about the @a method).
+ */
+static void
+wire_cb (void *cls,
+ unsigned int http_status,
+ const char *method,
+ json_t *obj)
+{
+ struct InterpreterState *is = cls;
+ struct Command *cmd = &is->commands[is->ip];
+
+ if (0 == http_status)
+ {
+ /* 0 always signals the end of the iteration */
+ cmd->details.wire.wh = NULL;
+ }
+ else if ( (NULL != method) &&
+ (0 != strcasecmp (method,
+ cmd->details.wire.format)) )
+ {
+ /* not the method we care about, skip */
+ return;
+ }
+ if (cmd->expected_response_code != http_status)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u to command %s/%s\n",
+ http_status,
+ cmd->label,
+ method);
+ json_dumpf (obj, stderr, 0);
+ fail (is);
+ return;
+ }
+ if (0 == http_status)
+ {
+ /* end of iteration, move to next command */
+ is->ip++;
+ is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
+ is);
+ return;
+ }
+ /* For now, we only support to be called only once
+ with a "positive" result; so we switch to an
+ expected value of 0 for the 2nd iteration */
+ cmd->expected_response_code = 0;
+}
+
+
+/**
* Run the main interpreter loop that performs mint operations.
*
* @param cls contains the `struct InterpreterState`
@@ -1212,44 +1316,44 @@ interpreter_run (void *cls,
return;
case OC_WITHDRAW_STATUS:
GNUNET_assert (NULL !=
- cmd->details.withdraw_status.reserve_reference);
+ cmd->details.reserve_status.reserve_reference);
ref = find_command (is,
- cmd->details.withdraw_status.reserve_reference);
+ cmd->details.reserve_status.reserve_reference);
GNUNET_assert (NULL != ref);
GNUNET_assert (OC_ADMIN_ADD_INCOMING == ref->oc);
GNUNET_CRYPTO_eddsa_key_get_public (&ref->details.admin_add_incoming.reserve_priv.eddsa_priv,
&reserve_pub.eddsa_pub);
- cmd->details.withdraw_status.wsh
- = TALER_MINT_withdraw_status (mint,
- &reserve_pub,
- &withdraw_status_cb,
- is);
+ cmd->details.reserve_status.wsh
+ = TALER_MINT_reserve_status (mint,
+ &reserve_pub,
+ &reserve_status_cb,
+ is);
trigger_context_task ();
return;
case OC_WITHDRAW_SIGN:
GNUNET_assert (NULL !=
- cmd->details.withdraw_sign.reserve_reference);
+ cmd->details.reserve_withdraw.reserve_reference);
ref = find_command (is,
- cmd->details.withdraw_sign.reserve_reference);
+ cmd->details.reserve_withdraw.reserve_reference);
GNUNET_assert (NULL != ref);
GNUNET_assert (OC_ADMIN_ADD_INCOMING == ref->oc);
- if (NULL != cmd->details.withdraw_sign.amount)
+ if (NULL != cmd->details.reserve_withdraw.amount)
{
if (GNUNET_OK !=
- TALER_string_to_amount (cmd->details.withdraw_sign.amount,
+ TALER_string_to_amount (cmd->details.reserve_withdraw.amount,
&amount))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to parse amount `%s' at %u\n",
- cmd->details.withdraw_sign.amount,
+ cmd->details.reserve_withdraw.amount,
is->ip);
fail (is);
return;
}
- cmd->details.withdraw_sign.pk = find_pk (is->keys,
- &amount);
+ cmd->details.reserve_withdraw.pk = find_pk (is->keys,
+ &amount);
}
- if (NULL == cmd->details.withdraw_sign.pk)
+ if (NULL == cmd->details.reserve_withdraw.pk)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to determine denomination key at %u\n",
@@ -1263,23 +1367,22 @@ interpreter_run (void *cls,
struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
priv = GNUNET_CRYPTO_eddsa_key_create ();
- cmd->details.withdraw_sign.coin_priv.eddsa_priv = *priv;
+ cmd->details.reserve_withdraw.coin_priv.eddsa_priv = *priv;
GNUNET_free (priv);
}
- GNUNET_CRYPTO_eddsa_key_get_public (&cmd->details.withdraw_sign.coin_priv.eddsa_priv,
+ GNUNET_CRYPTO_eddsa_key_get_public (&cmd->details.reserve_withdraw.coin_priv.eddsa_priv,
&coin_pub.eddsa_pub);
- cmd->details.withdraw_sign.blinding_key.rsa_blinding_key
- = GNUNET_CRYPTO_rsa_blinding_key_create (GNUNET_CRYPTO_rsa_public_key_len (cmd->details.withdraw_sign.pk->key.rsa_public_key));
-
- cmd->details.withdraw_sign.wsh
- = TALER_MINT_withdraw_sign (mint,
- cmd->details.withdraw_sign.pk,
- &ref->details.admin_add_incoming.reserve_priv,
- &cmd->details.withdraw_sign.coin_priv,
- &cmd->details.withdraw_sign.blinding_key,
- &withdraw_sign_cb,
- is);
- if (NULL == cmd->details.withdraw_sign.wsh)
+ cmd->details.reserve_withdraw.blinding_key.rsa_blinding_key
+ = GNUNET_CRYPTO_rsa_blinding_key_create (GNUNET_CRYPTO_rsa_public_key_len (cmd->details.reserve_withdraw.pk->key.rsa_public_key));
+ cmd->details.reserve_withdraw.wsh
+ = TALER_MINT_reserve_withdraw (mint,
+ cmd->details.reserve_withdraw.pk,
+ &ref->details.admin_add_incoming.reserve_priv,
+ &cmd->details.reserve_withdraw.coin_priv,
+ &cmd->details.reserve_withdraw.blinding_key,
+ &reserve_withdraw_cb,
+ is);
+ if (NULL == cmd->details.reserve_withdraw.wsh)
{
GNUNET_break (0);
fail (is);
@@ -1308,9 +1411,9 @@ interpreter_run (void *cls,
switch (ref->oc)
{
case OC_WITHDRAW_SIGN:
- coin_priv = &ref->details.withdraw_sign.coin_priv;
- coin_pk = ref->details.withdraw_sign.pk;
- coin_pk_sig = &ref->details.withdraw_sign.sig;
+ coin_priv = &ref->details.reserve_withdraw.coin_priv;
+ coin_pk = ref->details.reserve_withdraw.pk;
+ coin_pk_sig = &ref->details.reserve_withdraw.sig;
break;
case OC_REFRESH_REVEAL:
{
@@ -1355,7 +1458,6 @@ interpreter_run (void *cls,
fail (is);
return;
}
-
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
&coin_pub.eddsa_pub);
@@ -1377,6 +1479,7 @@ interpreter_run (void *cls,
{
struct TALER_DepositRequestPS dr;
+ memset (&dr, 0, sizeof (dr));
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
dr.h_contract = h_contract;
@@ -1395,7 +1498,6 @@ interpreter_run (void *cls,
GNUNET_CRYPTO_eddsa_sign (&coin_priv->eddsa_priv,
&dr.purpose,
&coin_sig.eddsa_signature));
-
}
cmd->details.deposit.dh
= TALER_MINT_deposit (mint,
@@ -1454,7 +1556,7 @@ interpreter_run (void *cls,
GNUNET_assert (NULL != ref);
GNUNET_assert (OC_WITHDRAW_SIGN == ref->oc);
- melt_privs[i] = ref->details.withdraw_sign.coin_priv;
+ melt_privs[i] = ref->details.reserve_withdraw.coin_priv;
if (GNUNET_OK !=
TALER_string_to_amount (md->amount,
&melt_amounts[i]))
@@ -1466,8 +1568,8 @@ interpreter_run (void *cls,
fail (is);
return;
}
- melt_sigs[i] = ref->details.withdraw_sign.sig;
- melt_pks[i] = *ref->details.withdraw_sign.pk;
+ melt_sigs[i] = ref->details.reserve_withdraw.sig;
+ melt_pks[i] = *ref->details.reserve_withdraw.pk;
}
for (i=0;i<num_fresh_coins;i++)
{
@@ -1477,7 +1579,7 @@ interpreter_run (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to parse amount `%s' at %u\n",
- cmd->details.withdraw_sign.amount,
+ cmd->details.reserve_withdraw.amount,
is->ip);
fail (is);
return;
@@ -1544,7 +1646,7 @@ interpreter_run (void *cls,
/* find melt command */
ref = find_command (is,
ref->details.refresh_reveal.melt_ref);
- /* find withdraw_sign command */
+ /* find reserve_withdraw command */
{
unsigned int idx;
const struct MeltDetails *md;
@@ -1563,7 +1665,7 @@ interpreter_run (void *cls,
/* finally, use private key from withdraw sign command */
cmd->details.refresh_link.rlh
= TALER_MINT_refresh_link (mint,
- &ref->details.withdraw_sign.coin_priv,
+ &ref->details.reserve_withdraw.coin_priv,
&link_cb,
is);
if (NULL == cmd->details.refresh_link.rlh)
@@ -1574,6 +1676,12 @@ interpreter_run (void *cls,
}
trigger_context_task ();
return;
+ case OC_WIRE:
+ cmd->details.wire.wh = TALER_MINT_wire (mint,
+ &wire_cb,
+ is);
+ trigger_context_task ();
+ return;
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unknown instruction %d at %u (%s)\n",
@@ -1623,35 +1731,35 @@ do_shutdown (void *cls,
}
break;
case OC_WITHDRAW_STATUS:
- if (NULL != cmd->details.withdraw_status.wsh)
+ if (NULL != cmd->details.reserve_status.wsh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
i,
cmd->label);
- TALER_MINT_withdraw_status_cancel (cmd->details.withdraw_status.wsh);
- cmd->details.withdraw_status.wsh = NULL;
+ TALER_MINT_reserve_status_cancel (cmd->details.reserve_status.wsh);
+ cmd->details.reserve_status.wsh = NULL;
}
break;
case OC_WITHDRAW_SIGN:
- if (NULL != cmd->details.withdraw_sign.wsh)
+ if (NULL != cmd->details.reserve_withdraw.wsh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
i,
cmd->label);
- TALER_MINT_withdraw_sign_cancel (cmd->details.withdraw_sign.wsh);
- cmd->details.withdraw_sign.wsh = NULL;
+ TALER_MINT_reserve_withdraw_cancel (cmd->details.reserve_withdraw.wsh);
+ cmd->details.reserve_withdraw.wsh = NULL;
}
- if (NULL != cmd->details.withdraw_sign.sig.rsa_signature)
+ if (NULL != cmd->details.reserve_withdraw.sig.rsa_signature)
{
- GNUNET_CRYPTO_rsa_signature_free (cmd->details.withdraw_sign.sig.rsa_signature);
- cmd->details.withdraw_sign.sig.rsa_signature = NULL;
+ GNUNET_CRYPTO_rsa_signature_free (cmd->details.reserve_withdraw.sig.rsa_signature);
+ cmd->details.reserve_withdraw.sig.rsa_signature = NULL;
}
- if (NULL != cmd->details.withdraw_sign.blinding_key.rsa_blinding_key)
+ if (NULL != cmd->details.reserve_withdraw.blinding_key.rsa_blinding_key)
{
- GNUNET_CRYPTO_rsa_blinding_key_free (cmd->details.withdraw_sign.blinding_key.rsa_blinding_key);
- cmd->details.withdraw_sign.blinding_key.rsa_blinding_key = NULL;
+ GNUNET_CRYPTO_rsa_blinding_key_free (cmd->details.reserve_withdraw.blinding_key.rsa_blinding_key);
+ cmd->details.reserve_withdraw.blinding_key.rsa_blinding_key = NULL;
}
break;
case OC_DEPOSIT:
@@ -1714,6 +1822,13 @@ do_shutdown (void *cls,
cmd->details.refresh_link.rlh = NULL;
}
break;
+ case OC_WIRE:
+ if (NULL != cmd->details.wire.wh)
+ {
+ TALER_MINT_wire_cancel (cmd->details.wire.wh);
+ cmd->details.wire.wh = NULL;
+ }
+ break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unknown instruction %d at %u (%s)\n",
@@ -1880,6 +1995,28 @@ run (void *cls,
};
static struct Command commands[] =
{
+ /* *************** start of /wire testing ************** */
+
+#if WIRE_TEST
+ { .oc = OC_WIRE,
+ .label = "wire-test",
+ /* /wire/test replies with a 302 redirect */
+ .expected_response_code = MHD_HTTP_FOUND,
+ .details.wire.format = "test" },
+#endif
+#if WIRE_SEPA
+ { .oc = OC_WIRE,
+ .label = "wire-sepa",
+ /* /wire/sepa replies with a 200 redirect */
+ .expected_response_code = MHD_HTTP_OK,
+ .details.wire.format = "sepa" },
+#endif
+ /* *************** end of /wire testing ************** */
+
+#if WIRE_TEST
+ /* None of this works if 'test' is not allowed as we do
+ /admin/add/incoming with format 'test' */
+
/* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per config */
{ .oc = OC_ADMIN_ADD_INCOMING,
.label = "create-reserve-1",
@@ -1890,15 +2027,15 @@ run (void *cls,
{ .oc = OC_WITHDRAW_SIGN,
.label = "withdraw-coin-1",
.expected_response_code = MHD_HTTP_OK,
- .details.withdraw_sign.reserve_reference = "create-reserve-1",
- .details.withdraw_sign.amount = "EUR:5" },
+ .details.reserve_withdraw.reserve_reference = "create-reserve-1",
+ .details.reserve_withdraw.amount = "EUR:5" },
/* Check that deposit and withdraw operation are in history, and
that the balance is now at zero */
{ .oc = OC_WITHDRAW_STATUS,
.label = "withdraw-status-1",
.expected_response_code = MHD_HTTP_OK,
- .details.withdraw_status.reserve_reference = "create-reserve-1",
- .details.withdraw_status.expected_balance = "EUR:0" },
+ .details.reserve_status.reserve_reference = "create-reserve-1",
+ .details.reserve_status.expected_balance = "EUR:0" },
/* Try to deposit the 5 EUR coin (in full) */
{ .oc = OC_DEPOSIT,
.label = "deposit-simple",
@@ -1913,8 +2050,8 @@ run (void *cls,
{ .oc = OC_WITHDRAW_SIGN,
.label = "withdraw-coin-2",
.expected_response_code = MHD_HTTP_PAYMENT_REQUIRED,
- .details.withdraw_sign.reserve_reference = "create-reserve-1",
- .details.withdraw_sign.amount = "EUR:5" },
+ .details.reserve_withdraw.reserve_reference = "create-reserve-1",
+ .details.reserve_withdraw.amount = "EUR:5" },
/* Try to double-spend the 5 EUR coin with different wire details */
{ .oc = OC_DEPOSIT,
@@ -1958,8 +2095,8 @@ run (void *cls,
{ .oc = OC_WITHDRAW_SIGN,
.label = "refresh-withdraw-coin-1",
.expected_response_code = MHD_HTTP_OK,
- .details.withdraw_sign.reserve_reference = "refresh-create-reserve-1",
- .details.withdraw_sign.amount = "EUR:5" },
+ .details.reserve_withdraw.reserve_reference = "refresh-create-reserve-1",
+ .details.reserve_withdraw.amount = "EUR:5" },
/* Try to partially spend (deposit) 1 EUR of the 5 EUR coin (in full)
(merchant would receive EUR:0.99 due to 1 ct deposit fee) */
{ .oc = OC_DEPOSIT,
@@ -2024,10 +2161,10 @@ run (void *cls,
.details.refresh_melt.melted_coins = melt_coins_1,
.details.refresh_melt.fresh_amounts = melt_fresh_amounts_1 },
- // FIXME: also test with coin that was already melted
+ // FIXME: also test with coin that was already melted
// (signature differs from coin that was deposited...)
-
/* *************** end of /refresh testing ************** */
+#endif
{ .oc = OC_END }
};