diff options
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing_api_cmd_deposit.c | 40 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_deposits_get.c | 24 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_insert_deposit.c | 8 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_withdraw.c | 58 | ||||
-rw-r--r-- | src/testing/testing_api_helpers_bank.c | 10 |
5 files changed, 67 insertions, 73 deletions
diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c index a392884a0..58322b1d1 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-2020 Taler Systems SA + Copyright (C) 2018-2021 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 @@ -207,38 +207,30 @@ do_retry (void *cls) * check if the response code is acceptable. * * @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, - * used for signing the response. + * @param dr deposit response details */ 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) + const struct TALER_EXCHANGE_DepositResult *dr) { struct DepositState *ds = cls; ds->dh = NULL; - if (ds->expected_response_code != hr->http_status) + if (ds->expected_response_code != dr->hr.http_status) { if (0 != ds->do_retry) { ds->do_retry--; - if ( (0 == hr->http_status) || - (TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) ) + if ( (0 == dr->hr.http_status) || + (TALER_EC_GENERIC_DB_SOFT_FAILURE == dr->hr.ec) || + (MHD_HTTP_INTERNAL_SERVER_ERROR == dr->hr.http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying deposit failed with %u/%d\n", - hr->http_status, - (int) hr->ec); + dr->hr.http_status, + (int) dr->hr.ec); /* on DB conflicts, do not use backoff */ - if (TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec) + if (TALER_EC_GENERIC_DB_SOFT_FAILURE == dr->hr.ec) ds->backoff = GNUNET_TIME_UNIT_ZERO; else ds->backoff = GNUNET_TIME_randomized_backoff (ds->backoff, @@ -253,22 +245,22 @@ deposit_cb (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u to command %s in %s:%u\n", - hr->http_status, + dr->hr.http_status, ds->is->commands[ds->is->ip].label, __FILE__, __LINE__); - json_dumpf (hr->reply, + json_dumpf (dr->hr.reply, stderr, 0); TALER_TESTING_interpreter_fail (ds->is); return; } - if (MHD_HTTP_OK == hr->http_status) + if (MHD_HTTP_OK == dr->hr.http_status) { ds->deposit_succeeded = GNUNET_YES; - ds->exchange_timestamp = exchange_timestamp; - ds->exchange_pub = *exchange_pub; - ds->exchange_sig = *exchange_sig; + ds->exchange_timestamp = dr->details.success.deposit_timestamp; + ds->exchange_pub = *dr->details.success.exchange_pub; + ds->exchange_sig = *dr->details.success.exchange_sig; } TALER_TESTING_interpreter_next (ds->is); } diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index f2f3f0e39..61358291b 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2020 Taler Systems SA + Copyright (C) 2014-2021 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 @@ -80,38 +80,36 @@ struct TrackTransactionState * line matches our expectations. * * @param cls closure. - * @param hr HTTP response details - * @param dd data about the wire transfer associated with the deposit + * @param dr GET deposit response details */ static void deposit_wtid_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - const struct TALER_EXCHANGE_DepositData *dd) + const struct TALER_EXCHANGE_GetDepositResponse *dr) { struct TrackTransactionState *tts = cls; struct TALER_TESTING_Interpreter *is = tts->is; struct TALER_TESTING_Command *cmd = &is->commands[is->ip]; tts->tth = NULL; - if (tts->expected_response_code != hr->http_status) + if (tts->expected_response_code != dr->hr.http_status) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u/%d to command %s in %s:%u\n", - hr->http_status, - (int) hr->ec, + dr->hr.http_status, + (int) dr->hr.ec, cmd->label, __FILE__, __LINE__); - json_dumpf (hr->reply, + json_dumpf (dr->hr.reply, stderr, 0); TALER_TESTING_interpreter_fail (is); return; } - switch (hr->http_status) + switch (dr->hr.http_status) { case MHD_HTTP_OK: - tts->wtid = dd->wtid; + tts->wtid = dr->details.success.wtid; if (NULL != tts->bank_transfer_reference) { const struct TALER_TESTING_Command *bank_transfer_cmd; @@ -139,7 +137,7 @@ deposit_wtid_cb (void *cls, } /* Compare that expected and gotten subjects match. */ - if (0 != GNUNET_memcmp (&dd->wtid, + if (0 != GNUNET_memcmp (&dr->details.success.wtid, wtid_want)) { GNUNET_break (0); @@ -147,8 +145,6 @@ deposit_wtid_cb (void *cls, return; } } - - break; case MHD_HTTP_ACCEPTED: /* allowed, nothing to check here */ diff --git a/src/testing/testing_api_cmd_insert_deposit.c b/src/testing/testing_api_cmd_insert_deposit.c index 0d57ab6c4..0a0d5db2f 100644 --- a/src/testing/testing_api_cmd_insert_deposit.c +++ b/src/testing/testing_api_cmd_insert_deposit.c @@ -200,14 +200,18 @@ insert_deposit_run (void *cls, &hc); { char *str; + struct TALER_WireSalt salt; GNUNET_asprintf (&str, "payto://x-taler-bank/localhost/%s", ids->merchant_account); + memset (&salt, + 46, + sizeof (salt)); deposit.receiver_wire_account = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("salt", - "this-is-a-salt-value"), + GNUNET_JSON_pack_data_auto ("salt", + &salt), GNUNET_JSON_pack_string ("payto_uri", str)); GNUNET_free (str); diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c index cfbdc177d..23beb6065 100644 --- a/src/testing/testing_api_cmd_withdraw.c +++ b/src/testing/testing_api_cmd_withdraw.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2020 Taler Systems SA + Copyright (C) 2018-2021 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 @@ -178,38 +178,36 @@ do_retry (void *cls) * in the state. * * @param cls closure. - * @param hr HTTP response details - * @param sig signature over the coin, NULL on error. + * @param wr withdraw response details */ static void reserve_withdraw_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - const struct TALER_DenominationSignature *sig) + const struct TALER_EXCHANGE_WithdrawResponse *wr) { struct WithdrawState *ws = cls; struct TALER_TESTING_Interpreter *is = ws->is; ws->wsh = NULL; - if (ws->expected_response_code != hr->http_status) + if (ws->expected_response_code != wr->hr.http_status) { if (0 != ws->do_retry) { - if (TALER_EC_EXCHANGE_WITHDRAW_RESERVE_UNKNOWN != hr->ec) + if (TALER_EC_EXCHANGE_WITHDRAW_RESERVE_UNKNOWN != wr->hr.ec) ws->do_retry--; /* we don't count reserve unknown as failures here */ - if ( (0 == hr->http_status) || - (TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec) || - (TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS == hr->ec) || - (TALER_EC_EXCHANGE_WITHDRAW_RESERVE_UNKNOWN == hr->ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) ) + if ( (0 == wr->hr.http_status) || + (TALER_EC_GENERIC_DB_SOFT_FAILURE == wr->hr.ec) || + (TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS == wr->hr.ec) || + (TALER_EC_EXCHANGE_WITHDRAW_RESERVE_UNKNOWN == wr->hr.ec) || + (MHD_HTTP_INTERNAL_SERVER_ERROR == wr->hr.http_status) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retrying withdraw failed with %u/%d\n", - hr->http_status, - (int) hr->ec); + wr->hr.http_status, + (int) wr->hr.ec); /* on DB conflicts, do not use backoff */ - if (TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec) + if (TALER_EC_GENERIC_DB_SOFT_FAILURE == wr->hr.ec) ws->backoff = GNUNET_TIME_UNIT_ZERO; - else if (TALER_EC_EXCHANGE_WITHDRAW_RESERVE_UNKNOWN != hr->ec) + else if (TALER_EC_EXCHANGE_WITHDRAW_RESERVE_UNKNOWN != wr->hr.ec) ws->backoff = EXCHANGE_LIB_BACKOFF (ws->backoff); else ws->backoff = GNUNET_TIME_relative_max (UNKNOWN_MIN_BACKOFF, @@ -227,29 +225,23 @@ reserve_withdraw_cb (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u/%d to command %s in %s:%u\n", - hr->http_status, - (int) hr->ec, + wr->hr.http_status, + (int) wr->hr.ec, TALER_TESTING_interpreter_get_current_label (is), __FILE__, __LINE__); - json_dumpf (hr->reply, + json_dumpf (wr->hr.reply, stderr, 0); GNUNET_break (0); TALER_TESTING_interpreter_fail (is); return; } - switch (hr->http_status) + switch (wr->hr.http_status) { case MHD_HTTP_OK: - if (NULL == sig) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } ws->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_dup ( - sig->rsa_signature); + wr->details.success.sig.rsa_signature); if (0 != ws->total_backoff.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -259,23 +251,27 @@ reserve_withdraw_cb (void *cls, GNUNET_YES)); } break; + case MHD_HTTP_ACCEPTED: + /* nothing to check */ + /* TODO: trait for returned uuid! */ + break; case MHD_HTTP_FORBIDDEN: /* nothing to check */ break; + case MHD_HTTP_NOT_FOUND: + /* nothing to check */ + break; case MHD_HTTP_CONFLICT: /* nothing to check */ break; case MHD_HTTP_GONE: /* theoretically could check that the key was actually */ break; - case MHD_HTTP_NOT_FOUND: - /* nothing to check */ - break; default: /* Unsupported status code (by test harness) */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Withdraw test command does not support status code %u\n", - hr->http_status); + wr->hr.http_status); GNUNET_break (0); break; } diff --git a/src/testing/testing_api_helpers_bank.c b/src/testing/testing_api_helpers_bank.c index d7cce01bb..2876c2470 100644 --- a/src/testing/testing_api_helpers_bank.c +++ b/src/testing/testing_api_helpers_bank.c @@ -670,11 +670,17 @@ TALER_TESTING_prepare_fakebank (const char *config_filename, json_t * TALER_TESTING_make_wire_details (const char *payto) { + struct TALER_WireSalt salt; + + /* salt must be constant for aggregation tests! */ + memset (&salt, + 47, + sizeof (salt)); return GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("payto_uri", payto), - GNUNET_JSON_pack_string ("salt", - "test-salt (must be constant for aggregation tests)")); + GNUNET_JSON_pack_data_auto ("salt", + &salt)); } |