summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_purse_create_deposit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_purse_create_deposit.c')
-rw-r--r--src/testing/testing_api_cmd_purse_create_deposit.c116
1 files changed, 67 insertions, 49 deletions
diff --git a/src/testing/testing_api_cmd_purse_create_deposit.c b/src/testing/testing_api_cmd_purse_create_deposit.c
index ef98c9055..4740f9801 100644
--- a/src/testing/testing_api_cmd_purse_create_deposit.c
+++ b/src/testing/testing_api_cmd_purse_create_deposit.c
@@ -44,10 +44,20 @@ struct Coin
unsigned int coin_index;
/**
+ * Public key of the deposited coin.
+ */
+ struct TALER_CoinSpendPublicKeyP coin_pub;
+
+ /**
* Amount to deposit (with fee).
*/
struct TALER_Amount deposit_with_fee;
+ /**
+ * Entry in the coin's history generated by this operation.
+ */
+ struct TALER_EXCHANGE_CoinHistoryEntry che;
+
};
@@ -162,22 +172,15 @@ 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,
- 0);
- 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)
{
- ds->exchange_pub = dr->details.success.exchange_pub;
- ds->exchange_sig = dr->details.success.exchange_sig;
+ ds->exchange_pub = dr->details.ok.exchange_pub;
+ ds->exchange_sig = dr->details.ok.exchange_sig;
}
TALER_TESTING_interpreter_next (ds->is);
}
@@ -200,14 +203,19 @@ deposit_run (void *cls,
(void) cmd;
ds->is = is;
+ GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv);
+ GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv);
+ GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv);
+ GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv,
+ &ds->purse_pub.eddsa_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;
const struct TALER_AgeCommitmentProof *age_commitment_proof = NULL;
- struct TALER_AgeCommitmentHash h_age_commitment = {0};
const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
const struct TALER_DenominationSignature *denom_pub_sig;
@@ -242,26 +250,25 @@ deposit_run (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
- if (NULL != age_commitment_proof)
- {
- TALER_age_commitment_hash (&age_commitment_proof->commitment,
- &h_age_commitment);
- }
-#if FIXME_OEC
- pd->age_commitment = *h_age_commitment;
-#endif
+ pd->age_commitment_proof = age_commitment_proof;
pd->denom_sig = *denom_pub_sig;
pd->coin_priv = *coin_priv;
pd->amount = cr->deposit_with_fee;
pd->h_denom_pub = denom_pub->h_key;
+ 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;
+ GNUNET_CRYPTO_eddsa_key_get_public (
+ &ds->purse_priv.eddsa_priv,
+ &cr->che.details.purse_deposit.purse_pub.eddsa_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);
}
- GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv);
- GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv);
- GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv);
- GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv,
- &ds->purse_pub.eddsa_pub);
-
ds->purse_expiration =
GNUNET_TIME_absolute_to_timestamp (
GNUNET_TIME_relative_to_absolute (ds->rel_expiration));
@@ -271,7 +278,9 @@ deposit_run (void *cls,
"pay_deadline",
GNUNET_JSON_from_timestamp (ds->purse_expiration)));
ds->dh = TALER_EXCHANGE_purse_create_with_deposit (
- is->exchange,
+ TALER_TESTING_interpreter_get_context (is),
+ TALER_TESTING_get_exchange_url (is),
+ TALER_TESTING_get_keys (is),
&ds->purse_priv,
&ds->merge_priv,
&ds->contract_priv,
@@ -307,10 +316,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_create_with_deposit_cancel (ds->dh);
ds->dh = NULL;
}
@@ -338,22 +345,33 @@ deposit_traits (void *cls,
unsigned int index)
{
struct PurseCreateDepositState *ds = cls;
- struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_make_trait_merge_priv (&ds->merge_priv),
- TALER_TESTING_make_trait_contract_priv (&ds->contract_priv),
- TALER_TESTING_make_trait_purse_priv (&ds->purse_priv),
- TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
- TALER_TESTING_make_trait_contract_terms (ds->contract_terms),
- TALER_TESTING_make_trait_deposit_amount (&ds->target_amount),
- TALER_TESTING_make_trait_timestamp (index,
- &ds->purse_expiration),
- TALER_TESTING_trait_end ()
- };
-
- return TALER_TESTING_get_trait (traits,
- 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[] = {
+ TALER_TESTING_make_trait_merge_priv (&ds->merge_priv),
+ TALER_TESTING_make_trait_contract_priv (&ds->contract_priv),
+ TALER_TESTING_make_trait_coin_history (index,
+ &co->che),
+ TALER_TESTING_make_trait_coin_pub (index,
+ &co->coin_pub),
+ TALER_TESTING_make_trait_purse_priv (&ds->purse_priv),
+ TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
+ TALER_TESTING_make_trait_contract_terms (ds->contract_terms),
+ TALER_TESTING_make_trait_deposit_amount (0,
+ &ds->target_amount),
+ TALER_TESTING_make_trait_timestamp (index,
+ &ds->purse_expiration),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+ }
}