summaryrefslogtreecommitdiff
path: root/src/mint-lib/test_mint_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-08-09 16:21:49 +0200
committerChristian Grothoff <christian@grothoff.org>2015-08-09 16:21:49 +0200
commitbbeb913dc2c78ff3ce951ca17fc0148714865212 (patch)
tree5a0039bbd330fd4f4e2d01dea682292825c0463e /src/mint-lib/test_mint_api.c
parent2da8705c9653729f6e46f7586c049db8cb280a4c (diff)
downloadexchange-bbeb913dc2c78ff3ce951ca17fc0148714865212.tar.gz
exchange-bbeb913dc2c78ff3ce951ca17fc0148714865212.tar.bz2
exchange-bbeb913dc2c78ff3ce951ca17fc0148714865212.zip
-finish reveal_cb
Diffstat (limited to 'src/mint-lib/test_mint_api.c')
-rw-r--r--src/mint-lib/test_mint_api.c99
1 files changed, 74 insertions, 25 deletions
diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c
index 859d41c4b..e7860c66d 100644
--- a/src/mint-lib/test_mint_api.c
+++ b/src/mint-lib/test_mint_api.c
@@ -18,6 +18,11 @@
* @brief testcase to test mint's HTTP API interface
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
* @author Christian Grothoff
+ *
+ * TODO:
+ * - support depositing coins from /refresh/reveal result
+ * - test /refresh/-operations
+ * - check coins returned by link_cb
*/
#include "platform.h"
#include "taler_util.h"
@@ -125,6 +130,33 @@ struct MeltDetails
/**
+ * Information about a fresh coin generated by the refresh operation.
+ */
+struct FreshCoin
+{
+
+ /**
+ * If @e amount is NULL, this specifies the denomination key to
+ * use. Otherwise, this will be set (by the interpreter) to the
+ * denomination PK matching @e amount.
+ */
+ const struct TALER_MINT_DenomPublicKey *pk;
+
+ /**
+ * Set (by the interpreter) to the mint's signature over the
+ * coin's public key.
+ */
+ struct TALER_DenominationSignature sig;
+
+ /**
+ * Set (by the interpreter) to the coin's private key.
+ */
+ struct TALER_CoinSpendPrivateKeyP coin_priv;
+
+};
+
+
+/**
* Details for a mint operation to execute.
*/
struct Command
@@ -332,6 +364,12 @@ struct Command
const char **fresh_amounts;
/**
+ * Array of the public keys corresponding to
+ * the @e fresh_amounts, set by the interpreter.
+ */
+ const struct TALER_MINT_DenomPublicKey **fresh_pks;
+
+ /**
* Melt handle while operation is running.
*/
struct TALER_MINT_RefreshMeltHandle *rmh;
@@ -379,28 +417,7 @@ struct Command
/**
* Information about coins withdrawn, set by the interpreter.
*/
- struct
- {
-
- /**
- * If @e amount is NULL, this specifies the denomination key to
- * use. Otherwise, this will be set (by the interpreter) to the
- * denomination PK matching @e amount.
- */
- const struct TALER_MINT_DenomPublicKey *pk;
-
- /**
- * Set (by the interpreter) to the mint's signature over the
- * coin's public key.
- */
- struct TALER_DenominationSignature sig;
-
- /**
- * Set (by the interpreter) to the coin's private key.
- */
- struct TALER_CoinSpendPrivateKeyP coin_priv;
-
- } *fresh_coins;
+ struct FreshCoin *fresh_coins;
} refresh_reveal;
@@ -900,6 +917,7 @@ reveal_cb (void *cls,
{
struct InterpreterState *is = cls;
struct Command *cmd = &is->commands[is->ip];
+ const struct Command *ref;
unsigned int i;
cmd->details.refresh_reveal.rrh = NULL;
@@ -912,11 +930,24 @@ reveal_cb (void *cls,
fail (is);
return;
}
+ ref = find_command (is,
+ cmd->details.refresh_reveal.melt_ref);
cmd->details.refresh_reveal.num_fresh_coins = num_coins;
switch (http_status)
{
case MHD_HTTP_OK:
- // FIXME: store returned coin keys...
+ cmd->details.refresh_reveal.fresh_coins
+ = GNUNET_new_array (num_coins,
+ struct FreshCoin);
+ for (i=0;i<num_coins;i++)
+ {
+ struct FreshCoin *fc = &cmd->details.refresh_reveal.fresh_coins[i];
+
+ fc->pk = ref->details.refresh_melt.fresh_pks[i];
+ fc->coin_priv = coin_privs[i];
+ fc->sig.rsa_signature
+ = GNUNET_CRYPTO_rsa_signature_dup (sigs[i].rsa_signature);
+ }
break;
default:
break;
@@ -1324,6 +1355,9 @@ interpreter_run (void *cls,
NULL != cmd->details.refresh_melt.fresh_amounts[num_fresh_coins];
num_fresh_coins++) ;
+ cmd->details.refresh_melt.fresh_pks
+ = GNUNET_new_array (num_fresh_coins,
+ const struct TALER_MINT_DenomPublicKey *);
{
struct TALER_CoinSpendPrivateKeyP melt_privs[num_melted_coins];
struct TALER_Amount melt_amounts[num_melted_coins];
@@ -1368,8 +1402,10 @@ interpreter_run (void *cls,
fail (is);
return;
}
- fresh_pks[i] = *find_pk (is->keys,
- &amount);
+ cmd->details.refresh_melt.fresh_pks[i]
+ = find_pk (is->keys,
+ &amount);
+ fresh_pks[i] = *cmd->details.refresh_melt.fresh_pks[i];
}
cmd->details.refresh_melt.refresh_data
= TALER_MINT_refresh_prepare (num_melted_coins,
@@ -1558,6 +1594,8 @@ do_shutdown (void *cls,
TALER_MINT_refresh_melt_cancel (cmd->details.refresh_melt.rmh);
cmd->details.refresh_melt.rmh = NULL;
}
+ GNUNET_free_non_null (cmd->details.refresh_melt.fresh_pks);
+ cmd->details.refresh_melt.fresh_pks = NULL;
GNUNET_free_non_null (cmd->details.refresh_melt.refresh_data);
cmd->details.refresh_melt.refresh_data = NULL;
cmd->details.refresh_melt.refresh_data_length = 0;
@@ -1572,6 +1610,17 @@ do_shutdown (void *cls,
TALER_MINT_refresh_reveal_cancel (cmd->details.refresh_reveal.rrh);
cmd->details.refresh_reveal.rrh = NULL;
}
+ {
+ unsigned int j;
+ struct FreshCoin *fresh_coins;
+
+ fresh_coins = cmd->details.refresh_reveal.fresh_coins;
+ for (j=0;j<cmd->details.refresh_reveal.num_fresh_coins;j++)
+ GNUNET_CRYPTO_rsa_signature_free (fresh_coins[j].sig.rsa_signature);
+ }
+ GNUNET_free_non_null (cmd->details.refresh_reveal.fresh_coins);
+ cmd->details.refresh_reveal.fresh_coins = NULL;
+ cmd->details.refresh_reveal.num_fresh_coins = 0;
break;
case OC_REFRESH_LINK:
if (NULL != cmd->details.refresh_link.rlh)