summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_deposit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_deposit.c')
-rw-r--r--src/testing/testing_api_cmd_deposit.c478
1 files changed, 264 insertions, 214 deletions
diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c
index 58322b1d1..849c78c70 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2018-2021 Taler Systems SA
+ Copyright (C) 2018-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
@@ -69,6 +69,11 @@ struct DepositState
unsigned int coin_index;
/**
+ * Our coin signature.
+ */
+ struct TALER_CoinSpendSignatureP coin_sig;
+
+ /**
* Wire details of who is depositing -- this would be merchant
* wire details in a normal scenario.
*/
@@ -82,7 +87,12 @@ struct DepositState
/**
* Refund deadline. Zero for no refunds.
*/
- struct GNUNET_TIME_Absolute refund_deadline;
+ struct GNUNET_TIME_Timestamp refund_deadline;
+
+ /**
+ * Wire deadline.
+ */
+ struct GNUNET_TIME_Timestamp wire_deadline;
/**
* Set (by the interpreter) to a fresh private key. This
@@ -93,12 +103,17 @@ struct DepositState
/**
* Deposit handle while operation is running.
*/
- struct TALER_EXCHANGE_DepositHandle *dh;
+ struct TALER_EXCHANGE_BatchDepositHandle *dh;
+
+ /**
+ * Denomination public key of the deposited coin.
+ */
+ const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
/**
* Timestamp of the /deposit operation in the wallet (contract signing time).
*/
- struct GNUNET_TIME_Absolute wallet_timestamp;
+ struct GNUNET_TIME_Timestamp wallet_timestamp;
/**
* Interpreter state.
@@ -126,15 +141,21 @@ struct DepositState
unsigned int do_retry;
/**
- * Set to #GNUNET_YES if the /deposit succeeded
+ * Set to true if the /deposit succeeded
* and we now can provide the resulting traits.
*/
- int deposit_succeeded;
+ bool deposit_succeeded;
+
+ /**
+ * Expected entry in the coin history created by this
+ * operation.
+ */
+ struct TALER_EXCHANGE_CoinHistoryEntry che;
/**
* When did the exchange receive the deposit?
*/
- struct GNUNET_TIME_Absolute exchange_timestamp;
+ struct GNUNET_TIME_Timestamp exchange_timestamp;
/**
* Signing key used by the exchange to sign the
@@ -160,7 +181,7 @@ struct DepositState
* When we're referencing another deposit operation,
* this will only be set after the command has been started.
*/
- int command_initialized;
+ bool command_initialized;
/**
* Reference to fetch the merchant private key from.
@@ -194,8 +215,7 @@ do_retry (void *cls)
struct DepositState *ds = cls;
ds->retry_task = NULL;
- ds->is->commands[ds->is->ip].last_req_time
- = GNUNET_TIME_absolute_get ();
+ TALER_TESTING_touch_cmd (ds->is);
deposit_run (ds,
NULL,
ds->is);
@@ -211,7 +231,7 @@ do_retry (void *cls)
*/
static void
deposit_cb (void *cls,
- const struct TALER_EXCHANGE_DepositResult *dr)
+ const struct TALER_EXCHANGE_BatchDepositResult *dr)
{
struct DepositState *ds = cls;
@@ -235,7 +255,8 @@ deposit_cb (void *cls,
else
ds->backoff = GNUNET_TIME_randomized_backoff (ds->backoff,
MAX_BACKOFF);
- ds->is->commands[ds->is->ip].num_tries++;
+ TALER_TESTING_inc_tries (ds->is);
+ GNUNET_assert (NULL == ds->retry_task);
ds->retry_task
= GNUNET_SCHEDULER_add_delayed (ds->backoff,
&do_retry,
@@ -243,24 +264,20 @@ deposit_cb (void *cls,
return;
}
}
- 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_with_body (
+ ds->is,
+ dr->hr.http_status,
+ ds->expected_response_code,
+ dr->hr.reply);
+
return;
}
if (MHD_HTTP_OK == dr->hr.http_status)
{
- ds->deposit_succeeded = GNUNET_YES;
- ds->exchange_timestamp = dr->details.success.deposit_timestamp;
- ds->exchange_pub = *dr->details.success.exchange_pub;
- ds->exchange_sig = *dr->details.success.exchange_sig;
+ ds->deposit_succeeded = true;
+ 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);
}
@@ -282,16 +299,46 @@ deposit_run (void *cls,
const struct TALER_TESTING_Command *coin_cmd;
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
struct TALER_CoinSpendPublicKeyP coin_pub;
- const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
+ const struct TALER_AgeCommitmentHash *phac;
const struct TALER_DenominationSignature *denom_pub_sig;
- struct TALER_CoinSpendSignatureP coin_sig;
- struct GNUNET_TIME_Absolute wire_deadline;
struct TALER_MerchantPublicKeyP merchant_pub;
- struct GNUNET_HashCode h_contract_terms;
+ struct TALER_PrivateContractHashP h_contract_terms;
enum TALER_ErrorCode ec;
+ struct TALER_WireSaltP wire_salt;
+ const char *payto_uri;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("payto_uri",
+ &payto_uri),
+ GNUNET_JSON_spec_fixed_auto ("salt",
+ &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;
+ }
ds->is = is;
+ if (! GNUNET_TIME_absolute_is_zero (ds->refund_deadline.abs_time))
+ {
+ struct GNUNET_TIME_Relative refund_deadline;
+
+ refund_deadline
+ = GNUNET_TIME_absolute_get_remaining (ds->refund_deadline.abs_time);
+ ds->wire_deadline
+ = GNUNET_TIME_relative_to_timestamp (
+ GNUNET_TIME_relative_multiply (refund_deadline,
+ 2));
+ }
+ else
+ {
+ ds->refund_deadline = ds->wallet_timestamp;
+ ds->wire_deadline = GNUNET_TIME_timestamp_get ();
+ }
if (NULL != ds->deposit_reference)
{
/* We're copying another deposit operation, initialize here. */
@@ -310,12 +357,14 @@ deposit_run (void *cls,
ds->coin_reference = ods->coin_reference;
ds->coin_index = ods->coin_index;
ds->wire_details = json_incref (ods->wire_details);
+ GNUNET_assert (NULL != ds->wire_details);
ds->contract_terms = json_incref (ods->contract_terms);
ds->wallet_timestamp = ods->wallet_timestamp;
ds->refund_deadline = ods->refund_deadline;
+ ds->wire_deadline = ods->wire_deadline;
ds->amount = ods->amount;
ds->merchant_priv = ods->merchant_priv;
- ds->command_initialized = GNUNET_YES;
+ ds->command_initialized = true;
}
else if (NULL != ds->merchant_priv_reference)
{
@@ -333,7 +382,6 @@ deposit_run (void *cls,
}
if ( (GNUNET_OK !=
TALER_TESTING_get_trait_merchant_priv (cmd,
- 0,
&merchant_priv)) )
{
GNUNET_break (0);
@@ -342,6 +390,19 @@ deposit_run (void *cls,
}
ds->merchant_priv = *merchant_priv;
}
+ GNUNET_assert (NULL != ds->wire_details);
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (ds->wire_details,
+ spec,
+ NULL, NULL))
+ {
+ json_dumpf (ds->wire_details,
+ stderr,
+ JSON_INDENT (2));
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
GNUNET_assert (ds->coin_reference);
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
ds->coin_reference);
@@ -357,9 +418,13 @@ deposit_run (void *cls,
ds->coin_index,
&coin_priv)) ||
(GNUNET_OK !=
+ TALER_TESTING_get_trait_h_age_commitment (coin_cmd,
+ ds->coin_index,
+ &phac)) ||
+ (GNUNET_OK !=
TALER_TESTING_get_trait_denom_pub (coin_cmd,
ds->coin_index,
- &denom_pub)) ||
+ &ds->denom_pub)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_denom_sig (coin_cmd,
ds->coin_index,
@@ -372,58 +437,79 @@ deposit_run (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
- ds->deposit_fee = denom_pub->fee_deposit;
+
+ ds->deposit_fee = ds->denom_pub->fees.deposit;
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
&coin_pub.eddsa_pub);
- if (0 != ds->refund_deadline.abs_value_us)
- {
- struct GNUNET_TIME_Relative refund_deadline;
-
- refund_deadline = GNUNET_TIME_absolute_get_remaining (ds->refund_deadline);
- wire_deadline = GNUNET_TIME_relative_to_absolute
- (GNUNET_TIME_relative_multiply (refund_deadline, 2));
- }
- else
- {
- ds->refund_deadline = ds->wallet_timestamp;
- wire_deadline = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_ZERO);
- }
GNUNET_CRYPTO_eddsa_key_get_public (&ds->merchant_priv.eddsa_priv,
&merchant_pub.eddsa_pub);
- (void) GNUNET_TIME_round_abs (&wire_deadline);
{
- struct GNUNET_HashCode h_wire;
+ struct TALER_MerchantWireHashP h_wire;
GNUNET_assert (GNUNET_OK ==
TALER_JSON_merchant_wire_signature_hash (ds->wire_details,
&h_wire));
- TALER_EXCHANGE_deposit_permission_sign (&ds->amount,
- &denom_pub->fee_deposit,
- &h_wire,
- &h_contract_terms,
- &denom_pub->h_key,
- coin_priv,
- ds->wallet_timestamp,
- &merchant_pub,
- ds->refund_deadline,
- &coin_sig);
+ TALER_wallet_deposit_sign (&ds->amount,
+ &ds->denom_pub->fees.deposit,
+ &h_wire,
+ &h_contract_terms,
+ NULL, /* wallet data hash */
+ phac,
+ NULL, /* hash of extensions */
+ &ds->denom_pub->h_key,
+ ds->wallet_timestamp,
+ &merchant_pub,
+ ds->refund_deadline,
+ coin_priv,
+ &ds->coin_sig);
+ ds->che.type = TALER_EXCHANGE_CTT_DEPOSIT;
+ ds->che.amount = ds->amount;
+ ds->che.details.deposit.h_wire = h_wire;
+ ds->che.details.deposit.h_contract_terms = h_contract_terms;
+ ds->che.details.deposit.no_h_policy = true;
+ ds->che.details.deposit.no_wallet_data_hash = true;
+ ds->che.details.deposit.wallet_timestamp = ds->wallet_timestamp;
+ ds->che.details.deposit.merchant_pub = merchant_pub;
+ ds->che.details.deposit.refund_deadline = ds->refund_deadline;
+ ds->che.details.deposit.sig = ds->coin_sig;
+ ds->che.details.deposit.no_hac = true;
+ ds->che.details.deposit.deposit_fee = ds->denom_pub->fees.deposit;
+ }
+ GNUNET_assert (NULL == ds->dh);
+ {
+ struct TALER_EXCHANGE_CoinDepositDetail cdd = {
+ .amount = ds->amount,
+ .coin_pub = coin_pub,
+ .coin_sig = ds->coin_sig,
+ .denom_sig = *denom_pub_sig,
+ .h_denom_pub = ds->denom_pub->h_key,
+ .h_age_commitment = {{{0}}},
+ };
+ struct TALER_EXCHANGE_DepositContractDetail dcd = {
+ .wire_deadline = ds->wire_deadline,
+ .merchant_payto_uri = payto_uri,
+ .wire_salt = wire_salt,
+ .h_contract_terms = h_contract_terms,
+ .wallet_timestamp = ds->wallet_timestamp,
+ .merchant_pub = merchant_pub,
+ .refund_deadline = ds->refund_deadline
+ };
+
+ if (NULL != phac)
+ cdd.h_age_commitment = *phac;
+
+ ds->dh = TALER_EXCHANGE_batch_deposit (
+ TALER_TESTING_interpreter_get_context (is),
+ exchange_url,
+ TALER_TESTING_get_keys (is),
+ &dcd,
+ 1,
+ &cdd,
+ &deposit_cb,
+ ds,
+ &ec);
}
- ds->dh = TALER_EXCHANGE_deposit (is->exchange,
- &ds->amount,
- wire_deadline,
- ds->wire_details,
- &h_contract_terms,
- &coin_pub,
- denom_pub_sig,
- &denom_pub->key,
- ds->wallet_timestamp,
- &merchant_pub,
- ds->refund_deadline,
- &coin_sig,
- &deposit_cb,
- ds,
- &ec);
if (NULL == ds->dh)
{
GNUNET_break (0);
@@ -451,11 +537,9 @@ 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_EXCHANGE_deposit_cancel (ds->dh);
+ TALER_TESTING_command_incomplete (ds->is,
+ cmd->label);
+ TALER_EXCHANGE_batch_deposit_cancel (ds->dh);
ds->dh = NULL;
}
if (NULL != ds->retry_task)
@@ -476,10 +560,9 @@ deposit_cleanup (void *cls,
* @param[out] ret result.
* @param trait name of the trait.
* @param index index number of the object to offer.
- *
* @return #GNUNET_OK on success.
*/
-static int
+static enum GNUNET_GenericReturnValue
deposit_traits (void *cls,
const void **ret,
const char *trait,
@@ -489,8 +572,11 @@ deposit_traits (void *cls,
const struct TALER_TESTING_Command *coin_cmd;
/* 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;
+ const struct TALER_AgeCommitmentHash *h_age_commitment;
- if (GNUNET_YES != ds->command_initialized)
+ if (! ds->command_initialized)
{
/* No access to traits yet. */
GNUNET_break (0);
@@ -506,40 +592,63 @@ deposit_traits (void *cls,
TALER_TESTING_interpreter_fail (ds->is);
return GNUNET_NO;
}
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_coin_priv (coin_cmd,
- ds->coin_index,
- &coin_spent_priv))
+ if ( (GNUNET_OK !=
+ TALER_TESTING_get_trait_coin_priv (coin_cmd,
+ ds->coin_index,
+ &coin_spent_priv)) ||
+ (GNUNET_OK !=
+ TALER_TESTING_get_trait_age_commitment_proof (coin_cmd,
+ ds->coin_index,
+ &age_commitment_proof)) ||
+ (GNUNET_OK !=
+ TALER_TESTING_get_trait_h_age_commitment (coin_cmd,
+ ds->coin_index,
+ &h_age_commitment)) )
{
GNUNET_break (0);
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 */
+ ds->traits is true */
TALER_TESTING_make_trait_exchange_pub (0,
&ds->exchange_pub),
TALER_TESTING_make_trait_exchange_sig (0,
&ds->exchange_sig),
/* These traits are always available */
+ TALER_TESTING_make_trait_coin_history (0,
+ &ds->che),
TALER_TESTING_make_trait_coin_priv (0,
coin_spent_priv),
- TALER_TESTING_make_trait_wire_details (0,
- ds->wire_details),
- TALER_TESTING_make_trait_contract_terms (0,
- ds->contract_terms),
- TALER_TESTING_make_trait_merchant_priv (0,
- &ds->merchant_priv),
- TALER_TESTING_make_trait_amount_obj (
- TALER_TESTING_CMD_DEPOSIT_TRAIT_IDX_DEPOSIT_VALUE,
- &ds->amount),
- TALER_TESTING_make_trait_amount_obj (
- TALER_TESTING_CMD_DEPOSIT_TRAIT_IDX_DEPOSIT_FEE,
- &ds->deposit_fee),
- TALER_TESTING_make_trait_absolute_time (0,
- &ds->exchange_timestamp),
+ TALER_TESTING_make_trait_coin_pub (0,
+ &coin_spent_pub),
+ TALER_TESTING_make_trait_denom_pub (0,
+ ds->denom_pub),
+ TALER_TESTING_make_trait_coin_sig (0,
+ &ds->coin_sig),
+ TALER_TESTING_make_trait_age_commitment_proof (0,
+ age_commitment_proof),
+ TALER_TESTING_make_trait_h_age_commitment (0,
+ h_age_commitment),
+ 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_deposit_amount (0,
+ &ds->amount),
+ TALER_TESTING_make_trait_deposit_fee_amount (0,
+ &ds->deposit_fee),
+ TALER_TESTING_make_trait_timestamp (0,
+ &ds->exchange_timestamp),
+ TALER_TESTING_make_trait_wire_deadline (0,
+ &ds->wire_deadline),
+ TALER_TESTING_make_trait_refund_deadline (0,
+ &ds->refund_deadline),
TALER_TESTING_trait_end ()
};
@@ -553,46 +662,24 @@ deposit_traits (void *cls,
}
-/**
- * Create a "deposit" command.
- *
- * @param label command label.
- * @param coin_reference reference to any operation that can
- * provide a coin.
- * @param coin_index if @a withdraw_reference offers an array of
- * coins, this parameter selects which one in that array.
- * This value is currently ignored, as only one-coin
- * withdrawals are implemented.
- * @param target_account_payto target account for the "deposit"
- * request.
- * @param contract_terms contract terms to be signed over by the
- * coin.
- * @param refund_deadline refund deadline, zero means 'no refunds'.
- * Note, if time were absolute, then it would have come
- * one day and disrupt tests meaning.
- * @param amount how much is going to be deposited.
- * @param expected_response_code expected HTTP response code.
- *
- * @return the command.
- */
struct TALER_TESTING_Command
-TALER_TESTING_cmd_deposit (const char *label,
- const char *coin_reference,
- unsigned int coin_index,
- const char *target_account_payto,
- const char *contract_terms,
- struct GNUNET_TIME_Relative refund_deadline,
- const char *amount,
- unsigned int expected_response_code)
+TALER_TESTING_cmd_deposit (
+ const char *label,
+ const char *coin_reference,
+ unsigned int coin_index,
+ const char *target_account_payto,
+ const char *contract_terms,
+ struct GNUNET_TIME_Relative refund_deadline,
+ const char *amount,
+ unsigned int expected_response_code)
{
struct DepositState *ds;
- json_t *wire_details;
- wire_details = TALER_TESTING_make_wire_details (target_account_payto);
ds = GNUNET_new (struct DepositState);
ds->coin_reference = coin_reference;
ds->coin_index = coin_index;
- ds->wire_details = wire_details;
+ ds->wire_details = TALER_TESTING_make_wire_details (target_account_payto);
+ GNUNET_assert (NULL != ds->wire_details);
ds->contract_terms = json_loads (contract_terms,
JSON_REJECT_DUPLICATES,
NULL);
@@ -605,25 +692,26 @@ TALER_TESTING_cmd_deposit (const char *label,
label);
GNUNET_assert (0);
}
- ds->wallet_timestamp = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&ds->wallet_timestamp);
-
- json_object_set_new (ds->contract_terms,
- "timestamp",
- GNUNET_JSON_from_time_abs (ds->wallet_timestamp));
- if (0 != refund_deadline.rel_value_us)
+ ds->wallet_timestamp = GNUNET_TIME_timestamp_get ();
+ GNUNET_assert (0 ==
+ json_object_set_new (ds->contract_terms,
+ "timestamp",
+ GNUNET_JSON_from_timestamp (
+ ds->wallet_timestamp)));
+ if (! GNUNET_TIME_relative_is_zero (refund_deadline))
{
- ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline);
- (void) GNUNET_TIME_round_abs (&ds->refund_deadline);
- json_object_set_new (ds->contract_terms,
- "refund_deadline",
- GNUNET_JSON_from_time_abs (ds->refund_deadline));
+ ds->refund_deadline = GNUNET_TIME_relative_to_timestamp (refund_deadline);
+ GNUNET_assert (0 ==
+ json_object_set_new (ds->contract_terms,
+ "refund_deadline",
+ GNUNET_JSON_from_timestamp (
+ ds->refund_deadline)));
}
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (amount,
&ds->amount));
ds->expected_response_code = expected_response_code;
- ds->command_initialized = GNUNET_YES;
+ ds->command_initialized = true;
{
struct TALER_TESTING_Command cmd = {
.cls = ds,
@@ -638,50 +726,26 @@ TALER_TESTING_cmd_deposit (const char *label,
}
-/**
- * Create a "deposit" command that references an existing merchant key.
- *
- * @param label command label.
- * @param coin_reference reference to any operation that can
- * provide a coin.
- * @param coin_index if @a withdraw_reference offers an array of
- * coins, this parameter selects which one in that array.
- * This value is currently ignored, as only one-coin
- * withdrawals are implemented.
- * @param target_account_payto target account for the "deposit"
- * request.
- * @param contract_terms contract terms to be signed over by the
- * coin.
- * @param refund_deadline refund deadline, zero means 'no refunds'.
- * Note, if time were absolute, then it would have come
- * one day and disrupt tests meaning.
- * @param amount how much is going to be deposited.
- * @param expected_response_code expected HTTP response code.
- * @param merchant_priv_reference reference to another operation
- * that has a merchant private key trait
- *
- * @return the command.
- */
struct TALER_TESTING_Command
-TALER_TESTING_cmd_deposit_with_ref (const char *label,
- const char *coin_reference,
- unsigned int coin_index,
- const char *target_account_payto,
- const char *contract_terms,
- struct GNUNET_TIME_Relative refund_deadline,
- const char *amount,
- unsigned int expected_response_code,
- const char *merchant_priv_reference)
+TALER_TESTING_cmd_deposit_with_ref (
+ const char *label,
+ const char *coin_reference,
+ unsigned int coin_index,
+ const char *target_account_payto,
+ const char *contract_terms,
+ struct GNUNET_TIME_Relative refund_deadline,
+ const char *amount,
+ unsigned int expected_response_code,
+ const char *merchant_priv_reference)
{
struct DepositState *ds;
- json_t *wire_details;
- wire_details = TALER_TESTING_make_wire_details (target_account_payto);
ds = GNUNET_new (struct DepositState);
ds->merchant_priv_reference = merchant_priv_reference;
ds->coin_reference = coin_reference;
ds->coin_index = coin_index;
- ds->wire_details = wire_details;
+ ds->wire_details = TALER_TESTING_make_wire_details (target_account_payto);
+ GNUNET_assert (NULL != ds->wire_details);
ds->contract_terms = json_loads (contract_terms,
JSON_REJECT_DUPLICATES,
NULL);
@@ -693,25 +757,26 @@ TALER_TESTING_cmd_deposit_with_ref (const char *label,
label);
GNUNET_assert (0);
}
- ds->wallet_timestamp = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&ds->wallet_timestamp);
-
- json_object_set_new (ds->contract_terms,
- "timestamp",
- GNUNET_JSON_from_time_abs (ds->wallet_timestamp));
+ ds->wallet_timestamp = GNUNET_TIME_timestamp_get ();
+ GNUNET_assert (0 ==
+ json_object_set_new (ds->contract_terms,
+ "timestamp",
+ GNUNET_JSON_from_timestamp (
+ ds->wallet_timestamp)));
if (0 != refund_deadline.rel_value_us)
{
- ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline);
- (void) GNUNET_TIME_round_abs (&ds->refund_deadline);
- json_object_set_new (ds->contract_terms,
- "refund_deadline",
- GNUNET_JSON_from_time_abs (ds->refund_deadline));
+ ds->refund_deadline = GNUNET_TIME_relative_to_timestamp (refund_deadline);
+ GNUNET_assert (0 ==
+ json_object_set_new (ds->contract_terms,
+ "refund_deadline",
+ GNUNET_JSON_from_timestamp (
+ ds->refund_deadline)));
}
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (amount,
&ds->amount));
ds->expected_response_code = expected_response_code;
- ds->command_initialized = GNUNET_YES;
+ ds->command_initialized = true;
{
struct TALER_TESTING_Command cmd = {
.cls = ds,
@@ -726,19 +791,11 @@ TALER_TESTING_cmd_deposit_with_ref (const char *label,
}
-/**
- * Create a "deposit" command that repeats an existing
- * deposit command.
- *
- * @param label command label.
- * @param deposit_reference which deposit command should we repeat
- * @param expected_response_code expected HTTP response code.
- * @return the command.
- */
struct TALER_TESTING_Command
-TALER_TESTING_cmd_deposit_replay (const char *label,
- const char *deposit_reference,
- unsigned int expected_response_code)
+TALER_TESTING_cmd_deposit_replay (
+ const char *label,
+ const char *deposit_reference,
+ unsigned int expected_response_code)
{
struct DepositState *ds;
@@ -759,13 +816,6 @@ TALER_TESTING_cmd_deposit_replay (const char *label,
}
-/**
- * Modify a deposit command to enable retries when we get transient
- * errors from the exchange.
- *
- * @param cmd a deposit command
- * @return the command with retries enabled
- */
struct TALER_TESTING_Command
TALER_TESTING_cmd_deposit_with_retry (struct TALER_TESTING_Command cmd)
{