summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_purse_deposit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_purse_deposit.c')
-rw-r--r--src/testing/testing_api_cmd_purse_deposit.c118
1 files changed, 68 insertions, 50 deletions
diff --git a/src/testing/testing_api_cmd_purse_deposit.c b/src/testing/testing_api_cmd_purse_deposit.c
index b10c6d329..048c6d736 100644
--- a/src/testing/testing_api_cmd_purse_deposit.c
+++ b/src/testing/testing_api_cmd_purse_deposit.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2022, 2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@@ -39,6 +39,16 @@ struct Coin
char *command_ref;
/**
+ * Entry in the coin's history generated by this operation.
+ */
+ struct TALER_EXCHANGE_CoinHistoryEntry che;
+
+ /**
+ * Public key of the deposited coin.
+ */
+ struct TALER_CoinSpendPublicKeyP coin_pub;
+
+ /**
* index of the specific coin in the traits of @e command_ref.
*/
unsigned int coin_index;
@@ -137,23 +147,16 @@ deposit_cb (void *cls,
ds->dh = NULL;
if (ds->expected_response_code != dr->hr.http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- dr->hr.http_status,
- ds->is->commands[ds->is->ip].label,
- __FILE__,
- __LINE__);
- json_dumpf (dr->hr.reply,
- stderr,
- JSON_INDENT (2));
- TALER_TESTING_interpreter_fail (ds->is);
+ TALER_TESTING_unexpected_status (ds->is,
+ dr->hr.http_status,
+ ds->expected_response_code);
return;
}
if (MHD_HTTP_OK == dr->hr.http_status)
{
if (-1 !=
- TALER_amount_cmp (&dr->details.success.total_deposited,
- &dr->details.success.purse_value_after_fees))
+ TALER_amount_cmp (&dr->details.ok.total_deposited,
+ &dr->details.ok.purse_value_after_fees))
{
const struct TALER_TESTING_Command *purse_cmd;
const struct TALER_ReserveSignatureP *reserve_sig;
@@ -163,7 +166,7 @@ deposit_cb (void *cls,
purse_cmd = TALER_TESTING_interpreter_lookup_command (ds->is,
ds->purse_ref);
-
+ GNUNET_assert (NULL != purse_cmd);
if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_sig (purse_cmd,
&reserve_sig))
@@ -202,10 +205,10 @@ deposit_cb (void *cls,
/* Deposits complete, create trait! */
ds->reserve_history.type = TALER_EXCHANGE_RTT_MERGE;
{
- const struct TALER_EXCHANGE_Keys *keys;
+ struct TALER_EXCHANGE_Keys *keys;
const struct TALER_EXCHANGE_GlobalFee *gf;
- keys = TALER_EXCHANGE_get_keys (ds->is->exchange);
+ keys = TALER_TESTING_get_keys (ds->is);
GNUNET_assert (NULL != keys);
gf = TALER_EXCHANGE_get_global_fee (keys,
*merge_timestamp);
@@ -213,7 +216,7 @@ deposit_cb (void *cls,
/* Note: change when flags below changes! */
ds->reserve_history.amount
- = dr->details.success.purse_value_after_fees;
+ = dr->details.ok.purse_value_after_fees;
if (true)
{
ds->reserve_history.details.merge_details.purse_fee = gf->fees.purse;
@@ -226,7 +229,7 @@ deposit_cb (void *cls,
}
}
ds->reserve_history.details.merge_details.h_contract_terms
- = dr->details.success.h_contract_terms;
+ = dr->details.ok.h_contract_terms;
ds->reserve_history.details.merge_details.merge_pub
= *merge_pub;
ds->reserve_history.details.merge_details.purse_pub
@@ -236,7 +239,7 @@ deposit_cb (void *cls,
ds->reserve_history.details.merge_details.merge_timestamp
= *merge_timestamp;
ds->reserve_history.details.merge_details.purse_expiration
- = dr->details.success.purse_expiration;
+ = dr->details.ok.purse_expiration;
ds->reserve_history.details.merge_details.min_age
= ds->min_age;
ds->reserve_history.details.merge_details.flags
@@ -267,9 +270,9 @@ deposit_run (void *cls,
(void) cmd;
ds->is = is;
-
purse_cmd = TALER_TESTING_interpreter_lookup_command (is,
ds->purse_ref);
+ GNUNET_assert (NULL != purse_cmd);
if (GNUNET_OK !=
TALER_TESTING_get_trait_purse_pub (purse_cmd,
&purse_pub))
@@ -281,7 +284,7 @@ deposit_run (void *cls,
ds->purse_pub = *purse_pub;
for (unsigned int i = 0; i<ds->num_coin_references; i++)
{
- const struct Coin *cr = &ds->coin_references[i];
+ struct Coin *cr = &ds->coin_references[i];
struct TALER_EXCHANGE_PurseDeposit *pd = &deposits[i];
const struct TALER_TESTING_Command *coin_cmd;
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
@@ -291,13 +294,7 @@ deposit_run (void *cls,
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
cr->command_ref);
- if (NULL == coin_cmd)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (is);
- return;
- }
-
+ GNUNET_assert (NULL != coin_cmd);
if ( (GNUNET_OK !=
TALER_TESTING_get_trait_coin_priv (coin_cmd,
cr->coin_index,
@@ -320,6 +317,16 @@ deposit_run (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
+ GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
+ &cr->coin_pub.eddsa_pub);
+ cr->che.type = TALER_EXCHANGE_CTT_PURSE_DEPOSIT;
+ cr->che.amount = cr->deposit_with_fee;
+ cr->che.details.purse_deposit.purse_pub = *purse_pub;
+ cr->che.details.purse_deposit.exchange_base_url
+ = TALER_TESTING_get_exchange_url (is);
+ TALER_age_commitment_hash (
+ &age_commitment_proof->commitment,
+ &cr->che.details.purse_deposit.phac);
pd->age_commitment_proof = age_commitment_proof;
pd->denom_sig = *denom_pub_sig;
pd->coin_priv = *coin_priv;
@@ -328,8 +335,10 @@ deposit_run (void *cls,
}
ds->dh = TALER_EXCHANGE_purse_deposit (
- is->exchange,
- NULL, /* FIXME: WADs support: purse exchange URL */
+ TALER_TESTING_interpreter_get_context (is),
+ TALER_TESTING_get_exchange_url (is),
+ TALER_TESTING_get_keys (is),
+ NULL, /* FIXME #7271: WADs support: purse exchange URL */
&ds->purse_pub,
ds->min_age,
ds->num_coin_references,
@@ -362,10 +371,8 @@ deposit_cleanup (void *cls,
if (NULL != ds->dh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Command %u (%s) did not complete\n",
- ds->is->ip,
- cmd->label);
+ TALER_TESTING_command_incomplete (ds->is,
+ cmd->label);
TALER_EXCHANGE_purse_deposit_cancel (ds->dh);
ds->dh = NULL;
}
@@ -392,21 +399,31 @@ deposit_traits (void *cls,
unsigned int index)
{
struct PurseDepositState *ds = cls;
- struct TALER_TESTING_Trait traits[] = {
- /* history entry MUST be first due to response code logic below! */
- TALER_TESTING_make_trait_reserve_history (0,
- &ds->reserve_history),
- TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub),
- TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
- TALER_TESTING_trait_end ()
- };
-
- return TALER_TESTING_get_trait (ds->purse_complete
- ? &traits[0] /* we have reserve history */
- : &traits[1], /* skip reserve history */
- ret,
- trait,
- index);
+
+ if (index >= ds->num_coin_references)
+ return GNUNET_NO;
+ {
+ const struct Coin *co = &ds->coin_references[index];
+ struct TALER_TESTING_Trait traits[] = {
+ /* history entry MUST be first due to response code logic below! */
+ TALER_TESTING_make_trait_reserve_history (0,
+ &ds->reserve_history),
+ TALER_TESTING_make_trait_coin_history (index,
+ &co->che),
+ TALER_TESTING_make_trait_coin_pub (index,
+ &co->coin_pub),
+ TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub),
+ TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (ds->purse_complete
+ ? &traits[0] /* we have reserve history */
+ : &traits[1], /* skip reserve history */
+ ret,
+ trait,
+ index);
+ }
}
@@ -444,7 +461,8 @@ TALER_TESTING_cmd_purse_deposit_coins (
{
struct Coin *c = &ds->coin_references[i++];
- GNUNET_assert (NULL != (val = va_arg (ap, const char *)));
+ GNUNET_assert (NULL != (val = va_arg (ap,
+ const char *)));
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_parse_coin_reference (
ref,