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 * @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" @@ -124,6 +129,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. */ @@ -331,6 +363,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. */ @@ -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;idetails.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;jdetails.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)