summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_batch_deposit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_batch_deposit.c')
-rw-r--r--src/testing/testing_api_cmd_batch_deposit.c134
1 files changed, 83 insertions, 51 deletions
diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c
index 967a5ac33..5139d3524 100644
--- a/src/testing/testing_api_cmd_batch_deposit.c
+++ b/src/testing/testing_api_cmd_batch_deposit.c
@@ -59,17 +59,33 @@ struct Coin
struct TALER_Amount deposit_fee;
/**
+ * Our coin signature.
+ */
+ struct TALER_CoinSpendSignatureP coin_sig;
+
+ /**
* Reference to any command that is able to provide a coin,
* possibly using $LABEL#$INDEX notation.
*/
char *coin_reference;
/**
+ * Denomination public key of the coin.
+ */
+ const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
+
+ /**
* The command being referenced.
*/
const struct TALER_TESTING_Command *coin_cmd;
/**
+ * Expected entry in the coin history created by this
+ * coin.
+ */
+ struct TALER_EXCHANGE_CoinHistoryEntry che;
+
+ /**
* Index of the coin at @e coin_cmd.
*/
unsigned int coin_idx;
@@ -151,10 +167,9 @@ struct BatchDepositState
struct GNUNET_SCHEDULER_Task *retry_task;
/**
- * Array of @e num_coins signatures from the exchange on the
- * deposit confirmation.
+ * Deposit confirmation signature from the exchange.
*/
- struct TALER_ExchangeSignatureP *exchange_sigs;
+ struct TALER_ExchangeSignatureP exchange_sig;
/**
* Reference to previous deposit operation.
@@ -198,33 +213,17 @@ batch_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 (ds->num_coins != dr->details.success.num_signatures)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (ds->is);
- return;
- }
ds->deposit_succeeded = GNUNET_YES;
- ds->exchange_timestamp = dr->details.success.deposit_timestamp;
- ds->exchange_pub = *dr->details.success.exchange_pub;
- ds->exchange_sigs = GNUNET_memdup (dr->details.success.exchange_sigs,
- dr->details.success.num_signatures
- * sizeof (struct
- TALER_ExchangeSignatureP));
+ ds->exchange_timestamp = dr->details.ok.deposit_timestamp;
+ ds->exchange_pub = *dr->details.ok.exchange_pub;
+ ds->exchange_sig = *dr->details.ok.exchange_sig;
}
TALER_TESTING_interpreter_next (ds->is);
}
@@ -243,7 +242,6 @@ batch_deposit_run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct BatchDepositState *ds = cls;
- const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
const struct TALER_DenominationSignature *denom_pub_sig;
struct TALER_MerchantPublicKeyP merchant_pub;
struct TALER_PrivateContractHashP h_contract_terms;
@@ -259,8 +257,15 @@ batch_deposit_run (void *cls,
&wire_salt),
GNUNET_JSON_spec_end ()
};
+ const char *exchange_url
+ = TALER_TESTING_get_exchange_url (is);
(void) cmd;
+ if (NULL == exchange_url)
+ {
+ GNUNET_break (0);
+ return;
+ }
memset (cdds,
0,
sizeof (cdds));
@@ -340,7 +345,7 @@ batch_deposit_run (void *cls,
(GNUNET_OK !=
TALER_TESTING_get_trait_denom_pub (coin->coin_cmd,
coin->coin_idx,
- &denom_pub)) ||
+ &coin->denom_pub)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_denom_sig (coin->coin_cmd,
coin->coin_idx,
@@ -355,23 +360,38 @@ batch_deposit_run (void *cls,
TALER_age_commitment_hash (&age_commitment_proof->commitment,
&cdd->h_age_commitment);
}
- coin->deposit_fee = denom_pub->fees.deposit;
+ coin->deposit_fee = coin->denom_pub->fees.deposit;
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
&cdd->coin_pub.eddsa_pub);
cdd->denom_sig = *denom_pub_sig;
- cdd->h_denom_pub = denom_pub->h_key;
+ cdd->h_denom_pub = coin->denom_pub->h_key;
TALER_wallet_deposit_sign (&coin->amount,
- &denom_pub->fees.deposit,
+ &coin->denom_pub->fees.deposit,
&h_wire,
&h_contract_terms,
+ NULL, /* wallet_data_hash */
&cdd->h_age_commitment,
- NULL, /* FIXME #7270: add hash of extensions */
- &denom_pub->h_key,
+ NULL, /* hash of extensions */
+ &coin->denom_pub->h_key,
ds->wallet_timestamp,
&merchant_pub,
ds->refund_deadline,
coin_priv,
&cdd->coin_sig);
+ coin->coin_sig = cdd->coin_sig;
+ coin->che.type = TALER_EXCHANGE_CTT_DEPOSIT;
+ coin->che.amount = coin->amount;
+ coin->che.details.deposit.h_wire = h_wire;
+ coin->che.details.deposit.h_contract_terms = h_contract_terms;
+ coin->che.details.deposit.no_h_policy = true;
+ coin->che.details.deposit.no_wallet_data_hash = true;
+ coin->che.details.deposit.wallet_timestamp = ds->wallet_timestamp;
+ coin->che.details.deposit.merchant_pub = merchant_pub;
+ coin->che.details.deposit.refund_deadline = ds->refund_deadline;
+ coin->che.details.deposit.sig = cdd->coin_sig;
+ coin->che.details.deposit.no_hac = GNUNET_is_zero (&cdd->h_age_commitment);
+ coin->che.details.deposit.hac = cdd->h_age_commitment;
+ coin->che.details.deposit.deposit_fee = coin->denom_pub->fees.deposit;
}
GNUNET_assert (NULL == ds->dh);
@@ -381,19 +401,22 @@ batch_deposit_run (void *cls,
.merchant_payto_uri = payto_uri,
.wire_salt = wire_salt,
.h_contract_terms = h_contract_terms,
- .extension_details = NULL /* FIXME #7270-OEC */,
- .timestamp = ds->wallet_timestamp,
+ .policy_details = NULL /* FIXME #7270-OEC */,
+ .wallet_timestamp = ds->wallet_timestamp,
.merchant_pub = merchant_pub,
.refund_deadline = ds->refund_deadline
};
- ds->dh = TALER_EXCHANGE_batch_deposit (is->exchange,
- &dcd,
- ds->num_coins,
- cdds,
- &batch_deposit_cb,
- ds,
- &ec);
+ ds->dh = TALER_EXCHANGE_batch_deposit (
+ TALER_TESTING_interpreter_get_context (is),
+ exchange_url,
+ TALER_TESTING_get_keys (is),
+ &dcd,
+ ds->num_coins,
+ cdds,
+ &batch_deposit_cb,
+ ds,
+ &ec);
}
if (NULL == ds->dh)
{
@@ -422,10 +445,8 @@ batch_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_batch_deposit_cancel (ds->dh);
ds->dh = NULL;
}
@@ -437,7 +458,6 @@ batch_deposit_cleanup (void *cls,
for (unsigned int i = 0; i<ds->num_coins; i++)
GNUNET_free (ds->coins[i].coin_reference);
GNUNET_free (ds->coins);
- GNUNET_free (ds->exchange_sigs);
json_decref (ds->wire_details);
json_decref (ds->contract_terms);
GNUNET_free (ds);
@@ -460,9 +480,10 @@ batch_deposit_traits (void *cls,
unsigned int index)
{
struct BatchDepositState *ds = cls;
- struct Coin *coin = &ds->coins[index];
+ const struct Coin *coin = &ds->coins[index];
/* Will point to coin cmd internals. */
const struct TALER_CoinSpendPrivateKeyP *coin_spent_priv;
+ struct TALER_CoinSpendPublicKeyP coin_spent_pub;
const struct TALER_AgeCommitmentProof *age_commitment_proof;
if (index >= ds->num_coins)
@@ -489,27 +510,38 @@ batch_deposit_traits (void *cls,
TALER_TESTING_interpreter_fail (ds->is);
return GNUNET_NO;
}
+
+ GNUNET_CRYPTO_eddsa_key_get_public (&coin_spent_priv->eddsa_priv,
+ &coin_spent_pub.eddsa_pub);
+
{
struct TALER_TESTING_Trait traits[] = {
/* First two traits are only available if
ds->traits is #GNUNET_YES */
- TALER_TESTING_make_trait_exchange_pub (index,
+ TALER_TESTING_make_trait_exchange_pub (0,
&ds->exchange_pub),
- TALER_TESTING_make_trait_exchange_sig (index,
- &ds->exchange_sigs[index]),
+ TALER_TESTING_make_trait_exchange_sig (0,
+ &ds->exchange_sig),
/* These traits are always available */
TALER_TESTING_make_trait_wire_details (ds->wire_details),
TALER_TESTING_make_trait_contract_terms (ds->contract_terms),
TALER_TESTING_make_trait_merchant_priv (&ds->merchant_priv),
TALER_TESTING_make_trait_age_commitment_proof (index,
age_commitment_proof),
+ TALER_TESTING_make_trait_coin_history (index,
+ &coin->che),
+ TALER_TESTING_make_trait_coin_pub (index,
+ &coin_spent_pub),
+ TALER_TESTING_make_trait_denom_pub (index,
+ coin->denom_pub),
TALER_TESTING_make_trait_coin_priv (index,
coin_spent_priv),
+ TALER_TESTING_make_trait_coin_sig (index,
+ &coin->coin_sig),
TALER_TESTING_make_trait_deposit_amount (index,
&coin->amount),
TALER_TESTING_make_trait_deposit_fee_amount (index,
&coin->deposit_fee),
-
TALER_TESTING_make_trait_timestamp (index,
&ds->exchange_timestamp),
TALER_TESTING_make_trait_wire_deadline (index,