diff options
Diffstat (limited to 'src/testing/testing_api_cmd_deposit.c')
-rw-r--r-- | src/testing/testing_api_cmd_deposit.c | 35 |
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 9468e7acb..049f36f25 100644 --- a/src/testing/testing_api_cmd_deposit.c +++ b/src/testing/testing_api_cmd_deposit.c | |||
@@ -91,9 +91,9 @@ struct DepositState | |||
91 | struct TALER_EXCHANGE_DepositHandle *dh; | 91 | struct TALER_EXCHANGE_DepositHandle *dh; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Timestamp of the /deposit operation. | 94 | * Timestamp of the /deposit operation in the wallet (contract signing time). |
95 | */ | 95 | */ |
96 | struct GNUNET_TIME_Absolute timestamp; | 96 | struct GNUNET_TIME_Absolute wallet_timestamp; |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Interpreter state. | 99 | * Interpreter state. |
@@ -127,6 +127,11 @@ struct DepositState | |||
127 | int deposit_succeeded; | 127 | int deposit_succeeded; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * When did the exchange receive the deposit? | ||
131 | */ | ||
132 | struct GNUNET_TIME_Absolute exchange_timestamp; | ||
133 | |||
134 | /** | ||
130 | * Signing key used by the exchange to sign the | 135 | * Signing key used by the exchange to sign the |
131 | * deposit confirmation. | 136 | * deposit confirmation. |
132 | */ | 137 | */ |
@@ -198,6 +203,7 @@ do_retry (void *cls) | |||
198 | * | 203 | * |
199 | * @param cls closure. | 204 | * @param cls closure. |
200 | * @param hr HTTP response details | 205 | * @param hr HTTP response details |
206 | * @param exchange_timestamp when did the exchange receive the deposit permission | ||
201 | * @param exchange_sig signature provided by the exchange | 207 | * @param exchange_sig signature provided by the exchange |
202 | * (NULL on errors) | 208 | * (NULL on errors) |
203 | * @param exchange_pub public key of the exchange, | 209 | * @param exchange_pub public key of the exchange, |
@@ -206,6 +212,7 @@ do_retry (void *cls) | |||
206 | static void | 212 | static void |
207 | deposit_cb (void *cls, | 213 | deposit_cb (void *cls, |
208 | const struct TALER_EXCHANGE_HttpResponse *hr, | 214 | const struct TALER_EXCHANGE_HttpResponse *hr, |
215 | const struct GNUNET_TIME_Absolute exchange_timestamp, | ||
209 | const struct TALER_ExchangeSignatureP *exchange_sig, | 216 | const struct TALER_ExchangeSignatureP *exchange_sig, |
210 | const struct TALER_ExchangePublicKeyP *exchange_pub) | 217 | const struct TALER_ExchangePublicKeyP *exchange_pub) |
211 | { | 218 | { |
@@ -254,6 +261,7 @@ deposit_cb (void *cls, | |||
254 | if (MHD_HTTP_OK == hr->http_status) | 261 | if (MHD_HTTP_OK == hr->http_status) |
255 | { | 262 | { |
256 | ds->deposit_succeeded = GNUNET_YES; | 263 | ds->deposit_succeeded = GNUNET_YES; |
264 | ds->exchange_timestamp = exchange_timestamp; | ||
257 | ds->exchange_pub = *exchange_pub; | 265 | ds->exchange_pub = *exchange_pub; |
258 | ds->exchange_sig = *exchange_sig; | 266 | ds->exchange_sig = *exchange_sig; |
259 | } | 267 | } |
@@ -305,7 +313,7 @@ deposit_run (void *cls, | |||
305 | ds->coin_index = ods->coin_index; | 313 | ds->coin_index = ods->coin_index; |
306 | ds->wire_details = json_incref (ods->wire_details); | 314 | ds->wire_details = json_incref (ods->wire_details); |
307 | ds->contract_terms = json_incref (ods->contract_terms); | 315 | ds->contract_terms = json_incref (ods->contract_terms); |
308 | ds->timestamp = ods->timestamp; | 316 | ds->wallet_timestamp = ods->wallet_timestamp; |
309 | ds->refund_deadline = ods->refund_deadline; | 317 | ds->refund_deadline = ods->refund_deadline; |
310 | ds->amount = ods->amount; | 318 | ds->amount = ods->amount; |
311 | ds->merchant_priv = ods->merchant_priv; | 319 | ds->merchant_priv = ods->merchant_priv; |
@@ -379,7 +387,7 @@ deposit_run (void *cls, | |||
379 | } | 387 | } |
380 | else | 388 | else |
381 | { | 389 | { |
382 | ds->refund_deadline = ds->timestamp; | 390 | ds->refund_deadline = ds->wallet_timestamp; |
383 | wire_deadline = GNUNET_TIME_relative_to_absolute | 391 | wire_deadline = GNUNET_TIME_relative_to_absolute |
384 | (GNUNET_TIME_UNIT_ZERO); | 392 | (GNUNET_TIME_UNIT_ZERO); |
385 | } | 393 | } |
@@ -388,6 +396,7 @@ deposit_run (void *cls, | |||
388 | 396 | ||
389 | (void) GNUNET_TIME_round_abs (&wire_deadline); | 397 | (void) GNUNET_TIME_round_abs (&wire_deadline); |
390 | 398 | ||
399 | // FIXME: This should be part of TALER_EXCHANGE_deposit()! | ||
391 | { | 400 | { |
392 | struct TALER_DepositRequestPS dr; | 401 | struct TALER_DepositRequestPS dr; |
393 | 402 | ||
@@ -400,7 +409,7 @@ deposit_run (void *cls, | |||
400 | GNUNET_assert (GNUNET_OK == | 409 | GNUNET_assert (GNUNET_OK == |
401 | TALER_JSON_merchant_wire_signature_hash (ds->wire_details, | 410 | TALER_JSON_merchant_wire_signature_hash (ds->wire_details, |
402 | &dr.h_wire)); | 411 | &dr.h_wire)); |
403 | dr.timestamp = GNUNET_TIME_absolute_hton (ds->timestamp); | 412 | dr.wallet_timestamp = GNUNET_TIME_absolute_hton (ds->wallet_timestamp); |
404 | dr.refund_deadline = GNUNET_TIME_absolute_hton | 413 | dr.refund_deadline = GNUNET_TIME_absolute_hton |
405 | (ds->refund_deadline); | 414 | (ds->refund_deadline); |
406 | TALER_amount_hton (&dr.amount_with_fee, | 415 | TALER_amount_hton (&dr.amount_with_fee, |
@@ -421,7 +430,7 @@ deposit_run (void *cls, | |||
421 | &coin_pub, | 430 | &coin_pub, |
422 | denom_pub_sig, | 431 | denom_pub_sig, |
423 | &denom_pub->key, | 432 | &denom_pub->key, |
424 | ds->timestamp, | 433 | ds->wallet_timestamp, |
425 | &merchant_pub, | 434 | &merchant_pub, |
426 | ds->refund_deadline, | 435 | ds->refund_deadline, |
427 | &coin_sig, | 436 | &coin_sig, |
@@ -534,6 +543,8 @@ deposit_traits (void *cls, | |||
534 | &ds->merchant_priv), | 543 | &ds->merchant_priv), |
535 | TALER_TESTING_make_trait_amount_obj (0, | 544 | TALER_TESTING_make_trait_amount_obj (0, |
536 | &ds->amount), | 545 | &ds->amount), |
546 | TALER_TESTING_make_trait_absolute_time (0, | ||
547 | &ds->exchange_timestamp), | ||
537 | TALER_TESTING_trait_end () | 548 | TALER_TESTING_trait_end () |
538 | }; | 549 | }; |
539 | 550 | ||
@@ -599,12 +610,12 @@ TALER_TESTING_cmd_deposit (const char *label, | |||
599 | label); | 610 | label); |
600 | GNUNET_assert (0); | 611 | GNUNET_assert (0); |
601 | } | 612 | } |
602 | ds->timestamp = GNUNET_TIME_absolute_get (); | 613 | ds->wallet_timestamp = GNUNET_TIME_absolute_get (); |
603 | (void) GNUNET_TIME_round_abs (&ds->timestamp); | 614 | (void) GNUNET_TIME_round_abs (&ds->wallet_timestamp); |
604 | 615 | ||
605 | json_object_set_new (ds->contract_terms, | 616 | json_object_set_new (ds->contract_terms, |
606 | "timestamp", | 617 | "timestamp", |
607 | GNUNET_JSON_from_time_abs (ds->timestamp)); | 618 | GNUNET_JSON_from_time_abs (ds->wallet_timestamp)); |
608 | if (0 != refund_deadline.rel_value_us) | 619 | if (0 != refund_deadline.rel_value_us) |
609 | { | 620 | { |
610 | ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline); | 621 | ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline); |
@@ -687,12 +698,12 @@ TALER_TESTING_cmd_deposit_with_ref (const char *label, | |||
687 | label); | 698 | label); |
688 | GNUNET_assert (0); | 699 | GNUNET_assert (0); |
689 | } | 700 | } |
690 | ds->timestamp = GNUNET_TIME_absolute_get (); | 701 | ds->wallet_timestamp = GNUNET_TIME_absolute_get (); |
691 | (void) GNUNET_TIME_round_abs (&ds->timestamp); | 702 | (void) GNUNET_TIME_round_abs (&ds->wallet_timestamp); |
692 | 703 | ||
693 | json_object_set_new (ds->contract_terms, | 704 | json_object_set_new (ds->contract_terms, |
694 | "timestamp", | 705 | "timestamp", |
695 | GNUNET_JSON_from_time_abs (ds->timestamp)); | 706 | GNUNET_JSON_from_time_abs (ds->wallet_timestamp)); |
696 | if (0 != refund_deadline.rel_value_us) | 707 | if (0 != refund_deadline.rel_value_us) |
697 | { | 708 | { |
698 | ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline); | 709 | ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline); |