From 7ab9d526f23d52d87d47aa195351022db3748d2c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 7 May 2020 20:22:02 +0200 Subject: towards changing timestamp in deposit confirmation (tests failing) --- src/testing/test_taler_exchange_aggregator.c | 24 +++++++++++++++ .../testing_api_cmd_auditor_deposit_confirmation.c | 8 ++++- src/testing/testing_api_cmd_deposit.c | 35 ++++++++++++++-------- src/testing/testing_api_cmd_insert_deposit.c | 26 +++++++++++----- 4 files changed, 72 insertions(+), 21 deletions(-) (limited to 'src/testing') diff --git a/src/testing/test_taler_exchange_aggregator.c b/src/testing/test_taler_exchange_aggregator.c index eaa621cfe..d5c392d3a 100644 --- a/src/testing/test_taler_exchange_aggregator.c +++ b/src/testing/test_taler_exchange_aggregator.c @@ -108,6 +108,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:1", "EUR:0.1"), @@ -126,6 +127,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:1", "EUR:0.1"), @@ -134,6 +136,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:1", "EUR:0.1"), @@ -153,6 +156,7 @@ run (void *cls, &dbc, "bob", "4", + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:1", "EUR:0.1"), @@ -160,6 +164,7 @@ run (void *cls, &dbc, "bob", "5", + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:1", "EUR:0.1"), @@ -167,6 +172,7 @@ run (void *cls, &dbc, "alice", "4", + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:1", "EUR:0.1"), @@ -195,6 +201,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), @@ -204,6 +211,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), @@ -229,6 +237,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), @@ -239,6 +248,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), @@ -263,6 +273,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.102", "EUR:0.1"), @@ -274,6 +285,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.102", "EUR:0.1"), @@ -281,6 +293,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.102", "EUR:0.1"), @@ -292,6 +305,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.102", "EUR:0.1"), @@ -303,6 +317,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.112", "EUR:0.1"), @@ -319,6 +334,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.109", "EUR:0.1"), @@ -330,6 +346,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.119", "EUR:0.1"), @@ -346,6 +363,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.122", "EUR:0.1"), @@ -362,6 +380,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), @@ -375,6 +394,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), @@ -390,6 +410,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.122", "EUR:0.1"), @@ -406,6 +427,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), @@ -419,6 +441,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), @@ -434,6 +457,7 @@ run (void *cls, &dbc, "bob", USER42_ACCOUNT, + GNUNET_TIME_absolute_get (), GNUNET_TIME_UNIT_ZERO, "EUR:0.112", "EUR:0.1"), diff --git a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c index 247399a9d..1442380bf 100644 --- a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c +++ b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c @@ -203,6 +203,7 @@ deposit_confirmation_run (void *cls, const struct TALER_TESTING_Command *deposit_cmd; struct GNUNET_HashCode h_wire; struct GNUNET_HashCode h_contract_terms; + const struct GNUNET_TIME_Absolute *exchange_timestamp = NULL; struct GNUNET_TIME_Absolute timestamp; struct GNUNET_TIME_Absolute refund_deadline; struct TALER_Amount amount_without_fee; @@ -238,6 +239,11 @@ deposit_confirmation_run (void *cls, TALER_TESTING_get_trait_exchange_sig (deposit_cmd, dcs->coin_index, &exchange_sig)); + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_absolute_time (deposit_cmd, + dcs->coin_index, + &exchange_timestamp)); + GNUNET_assert (NULL != exchange_timestamp); keys = TALER_EXCHANGE_get_keys (dcs->is->exchange); GNUNET_assert (NULL != keys); spk = TALER_EXCHANGE_get_signing_key_info (keys, @@ -309,7 +315,7 @@ deposit_confirmation_run (void *cls, dcs->dc = TALER_AUDITOR_deposit_confirmation (dcs->auditor, &h_wire, &h_contract_terms, - timestamp, + *exchange_timestamp, refund_deadline, &amount_without_fee, &coin_pub, 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 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. @@ -126,6 +126,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); diff --git a/src/testing/testing_api_cmd_insert_deposit.c b/src/testing/testing_api_cmd_insert_deposit.c index 356528009..cff2884aa 100644 --- a/src/testing/testing_api_cmd_insert_deposit.c +++ b/src/testing/testing_api_cmd_insert_deposit.c @@ -57,6 +57,11 @@ struct InsertDepositState */ struct GNUNET_TIME_Relative wire_deadline; + /** + * When did the exchange receive the deposit? + */ + struct GNUNET_TIME_Absolute exchange_timestamp; + /** * Amount to deposit, inclusive of deposit fee. */ @@ -210,6 +215,7 @@ insert_deposit_run (void *cls, (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != ids->dbc->plugin->insert_deposit (ids->dbc->plugin->cls, ids->dbc->session, + ids->exchange_timestamp, &deposit)) || (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != ids->dbc->plugin->commit (ids->dbc->plugin->cls, @@ -275,6 +281,7 @@ insert_deposit_traits (void *cls, * @param dbc collects database plugin and session handles. * @param merchant_name Human-readable name of the merchant. * @param merchant_account merchant's account name (NOT a payto:// URI) + * @param exchange_timestamp when did the exchange receive the deposit * @param wire_deadline point in time where the aggregator should have * wired money to the merchant. * @param amount_with_fee amount to deposit (inclusive of deposit fee) @@ -282,21 +289,24 @@ insert_deposit_traits (void *cls, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_insert_deposit (const char *label, - const struct - TALER_TESTING_DatabaseConnection *dbc, - const char *merchant_name, - const char *merchant_account, - struct GNUNET_TIME_Relative wire_deadline, - const char *amount_with_fee, - const char *deposit_fee) +TALER_TESTING_cmd_insert_deposit ( + const char *label, + const struct TALER_TESTING_DatabaseConnection *dbc, + const char *merchant_name, + const char *merchant_account, + struct GNUNET_TIME_Absolute exchange_timestamp, + struct GNUNET_TIME_Relative wire_deadline, + const char *amount_with_fee, + const char *deposit_fee) { struct InsertDepositState *ids; + GNUNET_TIME_round_abs (&exchange_timestamp); ids = GNUNET_new (struct InsertDepositState); ids->dbc = dbc; ids->merchant_name = merchant_name; ids->merchant_account = merchant_account; + ids->exchange_timestamp = exchange_timestamp; ids->wire_deadline = wire_deadline; ids->amount_with_fee = amount_with_fee; ids->deposit_fee = deposit_fee; -- cgit v1.2.3