summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_deposit.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-05-07 20:22:02 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-05 16:35:00 +0200
commit4f82885560d5d468ef5230f7ec383c612cc9625c (patch)
tree6a463d7f0fec1b301659e21d4d62e6b8633f5d99 /src/testing/testing_api_cmd_deposit.c
parent727b7b04f3ae23fd49da7479fe4b4258513aef83 (diff)
downloadexchange-4f82885560d5d468ef5230f7ec383c612cc9625c.tar.gz
exchange-4f82885560d5d468ef5230f7ec383c612cc9625c.tar.bz2
exchange-4f82885560d5d468ef5230f7ec383c612cc9625c.zip
towards changing timestamp in deposit confirmation (tests failing)
Diffstat (limited to 'src/testing/testing_api_cmd_deposit.c')
-rw-r--r--src/testing/testing_api_cmd_deposit.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c
index 9468e7ac..049f36f2 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -91,9 +91,9 @@ struct DepositState
struct TALER_EXCHANGE_DepositHandle *dh;
/**
- * Timestamp of the /deposit operation.
+ * Timestamp of the /deposit operation in the wallet (contract signing time).
*/
- struct GNUNET_TIME_Absolute timestamp;
+ struct GNUNET_TIME_Absolute wallet_timestamp;
/**
* Interpreter state.
@@ -127,6 +127,11 @@ struct DepositState
int deposit_succeeded;
/**
+ * When did the exchange receive the deposit?
+ */
+ struct GNUNET_TIME_Absolute exchange_timestamp;
+
+ /**
* Signing key used by the exchange to sign the
* deposit confirmation.
*/
@@ -198,6 +203,7 @@ do_retry (void *cls)
*
* @param cls closure.
* @param hr HTTP response details
+ * @param exchange_timestamp when did the exchange receive the deposit permission
* @param exchange_sig signature provided by the exchange
* (NULL on errors)
* @param exchange_pub public key of the exchange,
@@ -206,6 +212,7 @@ do_retry (void *cls)
static void
deposit_cb (void *cls,
const struct TALER_EXCHANGE_HttpResponse *hr,
+ const struct GNUNET_TIME_Absolute exchange_timestamp,
const struct TALER_ExchangeSignatureP *exchange_sig,
const struct TALER_ExchangePublicKeyP *exchange_pub)
{
@@ -254,6 +261,7 @@ deposit_cb (void *cls,
if (MHD_HTTP_OK == hr->http_status)
{
ds->deposit_succeeded = GNUNET_YES;
+ ds->exchange_timestamp = exchange_timestamp;
ds->exchange_pub = *exchange_pub;
ds->exchange_sig = *exchange_sig;
}
@@ -305,7 +313,7 @@ deposit_run (void *cls,
ds->coin_index = ods->coin_index;
ds->wire_details = json_incref (ods->wire_details);
ds->contract_terms = json_incref (ods->contract_terms);
- ds->timestamp = ods->timestamp;
+ ds->wallet_timestamp = ods->wallet_timestamp;
ds->refund_deadline = ods->refund_deadline;
ds->amount = ods->amount;
ds->merchant_priv = ods->merchant_priv;
@@ -379,7 +387,7 @@ deposit_run (void *cls,
}
else
{
- ds->refund_deadline = ds->timestamp;
+ ds->refund_deadline = ds->wallet_timestamp;
wire_deadline = GNUNET_TIME_relative_to_absolute
(GNUNET_TIME_UNIT_ZERO);
}
@@ -388,6 +396,7 @@ deposit_run (void *cls,
(void) GNUNET_TIME_round_abs (&wire_deadline);
+ // FIXME: This should be part of TALER_EXCHANGE_deposit()!
{
struct TALER_DepositRequestPS dr;
@@ -400,7 +409,7 @@ deposit_run (void *cls,
GNUNET_assert (GNUNET_OK ==
TALER_JSON_merchant_wire_signature_hash (ds->wire_details,
&dr.h_wire));
- dr.timestamp = GNUNET_TIME_absolute_hton (ds->timestamp);
+ dr.wallet_timestamp = GNUNET_TIME_absolute_hton (ds->wallet_timestamp);
dr.refund_deadline = GNUNET_TIME_absolute_hton
(ds->refund_deadline);
TALER_amount_hton (&dr.amount_with_fee,
@@ -421,7 +430,7 @@ deposit_run (void *cls,
&coin_pub,
denom_pub_sig,
&denom_pub->key,
- ds->timestamp,
+ ds->wallet_timestamp,
&merchant_pub,
ds->refund_deadline,
&coin_sig,
@@ -534,6 +543,8 @@ deposit_traits (void *cls,
&ds->merchant_priv),
TALER_TESTING_make_trait_amount_obj (0,
&ds->amount),
+ TALER_TESTING_make_trait_absolute_time (0,
+ &ds->exchange_timestamp),
TALER_TESTING_trait_end ()
};
@@ -599,12 +610,12 @@ TALER_TESTING_cmd_deposit (const char *label,
label);
GNUNET_assert (0);
}
- ds->timestamp = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&ds->timestamp);
+ 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->timestamp));
+ GNUNET_JSON_from_time_abs (ds->wallet_timestamp));
if (0 != refund_deadline.rel_value_us)
{
ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline);
@@ -687,12 +698,12 @@ TALER_TESTING_cmd_deposit_with_ref (const char *label,
label);
GNUNET_assert (0);
}
- ds->timestamp = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&ds->timestamp);
+ 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->timestamp));
+ GNUNET_JSON_from_time_abs (ds->wallet_timestamp));
if (0 != refund_deadline.rel_value_us)
{
ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline);