aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-05 22:05:38 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-05 22:05:38 +0200
commitbf8c5982a2e79f0b5198a0033dd41e9702d093f9 (patch)
tree93b62feb9b7e24ae3d4f73b1a5f883a8fc368bfe /src
parent5059da7108fb2d65fc3844ffe695574c532f8dff (diff)
make exchange API more uniform in how information is returned
Diffstat (limited to 'src')
-rw-r--r--src/include/taler_auditor_service.h68
-rw-r--r--src/include/taler_error_codes.h13
-rw-r--r--src/include/taler_exchange_service.h177
-rw-r--r--src/include/taler_json_lib.h11
-rw-r--r--src/include/taler_testing_lib.h10
-rw-r--r--src/json/json.c30
-rw-r--r--src/lib/auditor_api_deposit_confirmation.c35
-rw-r--r--src/lib/auditor_api_exchanges.c47
-rw-r--r--src/lib/auditor_api_handle.c42
-rw-r--r--src/lib/exchange_api_deposit.c87
-rw-r--r--src/lib/exchange_api_deposits_get.c48
-rw-r--r--src/lib/exchange_api_handle.c54
-rw-r--r--src/lib/exchange_api_handle.h8
-rw-r--r--src/lib/exchange_api_link.c47
-rw-r--r--src/lib/exchange_api_melt.c54
-rw-r--r--src/lib/exchange_api_recoup.c69
-rw-r--r--src/lib/exchange_api_refreshes_reveal.c44
-rw-r--r--src/lib/exchange_api_refund.c47
-rw-r--r--src/lib/exchange_api_reserves_get.c44
-rw-r--r--src/lib/exchange_api_transfers_get.c59
-rw-r--r--src/lib/exchange_api_wire.c67
-rw-r--r--src/lib/exchange_api_withdraw.c56
-rw-r--r--src/testing/Makefile.am2
-rw-r--r--src/testing/test_auditor_api_version.c3
-rw-r--r--src/testing/testing_api_cmd_auditor_deposit_confirmation.c61
-rw-r--r--src/testing/testing_api_cmd_auditor_exchanges.c47
-rw-r--r--src/testing/testing_api_cmd_deposit.c32
-rw-r--r--src/testing/testing_api_cmd_deposits_get.c33
-rw-r--r--src/testing/testing_api_cmd_recoup.c28
-rw-r--r--src/testing/testing_api_cmd_refresh.c230
-rw-r--r--src/testing/testing_api_cmd_refund.c23
-rw-r--r--src/testing/testing_api_cmd_status.c20
-rw-r--r--src/testing/testing_api_cmd_transfer_get.c86
-rw-r--r--src/testing/testing_api_cmd_wire.c28
-rw-r--r--src/testing/testing_api_cmd_withdraw.c46
-rw-r--r--src/testing/testing_api_helpers_auditor.c4
-rw-r--r--src/testing/testing_api_loop.c32
37 files changed, 957 insertions, 835 deletions
diff --git a/src/include/taler_auditor_service.h b/src/include/taler_auditor_service.h
index 0f69da11b..fdce76cd2 100644
--- a/src/include/taler_auditor_service.h
+++ b/src/include/taler_auditor_service.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2018 Taler Systems SA
+ Copyright (C) 2014-2020 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -107,17 +107,58 @@ enum TALER_AUDITOR_VersionCompatibility
/**
+ * General information about the HTTP response we obtained
+ * from the auditor for a request.
+ */
+struct TALER_AUDITOR_HttpResponse
+{
+
+ /**
+ * The complete JSON reply. NULL if we failed to parse the
+ * reply (too big, invalid JSON).
+ */
+ const json_t *reply;
+
+ /**
+ * Set to the human-readable 'hint' that is optionally
+ * provided by the exchange together with errors. NULL
+ * if no hint was provided or if there was no error.
+ */
+ const char *hint;
+
+ /**
+ * HTTP status code for the response. 0 if the
+ * HTTP request failed and we did not get any answer, or
+ * if the answer was invalid and we set @a ec to a
+ * client-side error code.
+ */
+ unsigned int http_status;
+
+ /**
+ * Taler error code. #TALER_EC_NONE if everything was
+ * OK. Usually set to the "code" field of an error
+ * response, but may be set to values created at the
+ * client side, for example when the response was
+ * not in JSON format or was otherwise ill-formed.
+ */
+ enum TALER_ErrorCode ec;
+
+};
+
+
+/**
* Function called with information about the auditor.
*
* @param cls closure
+ * @param hr HTTP response data
* @param vi basic information about the auditor
* @param compat protocol compatibility information
*/
typedef void
(*TALER_AUDITOR_VersionCallback) (
void *cls,
- const struct
- TALER_AUDITOR_VersionInformation *vi,
+ const struct TALER_AUDITOR_HttpResponse *hr,
+ const struct TALER_AUDITOR_VersionInformation *vi,
enum TALER_AUDITOR_VersionCompatibility compat);
@@ -169,15 +210,12 @@ struct TALER_AUDITOR_DepositConfirmationHandle;
* auditor's /deposit-confirmation handler.
*
* @param cls closure
- * @param http_status HTTP status code, 200 on success
- * @param ec taler protocol error status code, 0 on success
- * @param json raw json response
+ * @param hr HTTP response data
*/
typedef void
-(*TALER_AUDITOR_DepositConfirmationResultCallback)(void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const json_t *json);
+(*TALER_AUDITOR_DepositConfirmationResultCallback)(
+ void *cls,
+ const struct TALER_AUDITOR_HttpResponse *hr);
/**
@@ -274,20 +312,16 @@ struct TALER_AUDITOR_ExchangeInfo
* Function called with the result from /exchagnes.
*
* @param cls closure
- * @param http_status the HTTP status code, 200 on success
- * @param ec detailed Taler error status code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param num_exchanges length of array at @a ei
* @param ei information about exchanges returned by the auditor
- * @param raw_response raw JSON response
*/
typedef void
(*TALER_AUDITOR_ListExchangesResultCallback)(
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_AUDITOR_HttpResponse *hr,
unsigned int num_exchanges,
- const struct TALER_AUDITOR_ExchangeInfo *ei,
- const json_t *raw_response);
+ const struct TALER_AUDITOR_ExchangeInfo *ei);
/**
* Submit an /exchanges request to the auditor and get the
diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h
index 94475f19c..cbf01b8f1 100644
--- a/src/include/taler_error_codes.h
+++ b/src/include/taler_error_codes.h
@@ -118,6 +118,13 @@ enum TALER_ErrorCode
TALER_EC_HOLE_IN_WIRE_FEE_STRUCTURE = 13,
/**
+ * The version string given does not follow the expected
+ * CURRENT:REVISION:AGE Format. Generated as an error on the client
+ * side.
+ */
+ TALER_EC_VERSION_MALFORMED = 14,
+
+ /**
* The exchange failed to even just initialize its connection to the
* database. This response is provided with HTTP status code
* #MHD_HTTP_INTERNAL_SERVER_ERROR.
@@ -1111,6 +1118,12 @@ enum TALER_ErrorCode
TALER_EC_KEYS_TIMETRAVEL_FORBIDDEN = 1902,
/**
+ * The keys response was malformed. This error is generated client-
+ * side.
+ */
+ TALER_EC_KEYS_INVALID = 1903,
+
+ /**
* The backend could not find the merchant instance specified in the
* request. This response is provided with HTTP status code
* #MHD_HTTP_NOT_FOUND.
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index 5f7cf6033..68f0cea38 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -352,25 +352,61 @@ enum TALER_EXCHANGE_VersionCompatibility
/**
+ * General information about the HTTP response we obtained
+ * from the exchange for a request.
+ */
+struct TALER_EXCHANGE_HttpResponse
+{
+
+ /**
+ * The complete JSON reply. NULL if we failed to parse the
+ * reply (too big, invalid JSON).
+ */
+ const json_t *reply;
+
+ /**
+ * Set to the human-readable 'hint' that is optionally
+ * provided by the exchange together with errors. NULL
+ * if no hint was provided or if there was no error.
+ */
+ const char *hint;
+
+ /**
+ * HTTP status code for the response. 0 if the
+ * HTTP request failed and we did not get any answer, or
+ * if the answer was invalid and we set @a ec to a
+ * client-side error code.
+ */
+ unsigned int http_status;
+
+ /**
+ * Taler error code. #TALER_EC_NONE if everything was
+ * OK. Usually set to the "code" field of an error
+ * response, but may be set to values created at the
+ * client side, for example when the response was
+ * not in JSON format or was otherwise ill-formed.
+ */
+ enum TALER_ErrorCode ec;
+
+};
+
+
+/**
* Function called with information about who is auditing
* a particular exchange and what key the exchange is using.
*
* @param cls closure
+ * @param hr HTTP response data
* @param keys information about the various keys used
* by the exchange, NULL if /keys failed
* @param compat protocol compatibility information
- * @param ec error code, #TALER_EC_NONE on success
- * @param http_status status returned by /keys, #MHD_HTTP_OK on success
- * @param full_reply JSON body of /keys request, NULL if reply was not in JSON
*/
typedef void
(*TALER_EXCHANGE_CertificationCallback) (
void *cls,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_EXCHANGE_Keys *keys,
- enum TALER_EXCHANGE_VersionCompatibility compat,
- enum TALER_ErrorCode ec,
- unsigned int http_status,
- const json_t *full_reply);
+ enum TALER_EXCHANGE_VersionCompatibility compat);
/**
@@ -650,21 +686,16 @@ struct TALER_EXCHANGE_WireAccount
* exchange, @a http_status will also be zero.
*
* @param cls closure
- * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful request;
- * 0 if the exchange's reply is bogus (fails to follow the protocol)
- * @param ec taler-specific error code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param accounts_len length of the @a accounts array
* @param accounts list of wire accounts of the exchange, NULL on error
- * @param full_reply the complete reply from the exchange (if it was in JSON)
*/
typedef void
(*TALER_EXCHANGE_WireCallback) (
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int accounts_len,
- const struct TALER_EXCHANGE_WireAccount *accounts,
- const json_t *full_reply);
+ const struct TALER_EXCHANGE_WireAccount *accounts);
/**
@@ -722,21 +753,16 @@ struct TALER_EXCHANGE_DepositHandle;
* deposit permission request to a exchange.
*
* @param cls closure
- * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful deposit;
- * 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param hr HTTP response data
* @param exchange_sig signature provided by the exchange
* @param sign_key exchange key used to sign @a obj, or NULL
- * @param obj the received JSON reply, should be kept as proof (and, in case of errors,
- * be forwarded to the customer)
*/
typedef void
(*TALER_EXCHANGE_DepositResultCallback) (
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_ExchangeSignatureP *exchange_sig,
- const struct TALER_ExchangePublicKeyP *sign_key,
- const json_t *obj);
+ const struct TALER_ExchangePublicKeyP *sign_key);
/**
@@ -822,20 +848,14 @@ struct TALER_EXCHANGE_RefundHandle;
* refund request to an exchange.
*
* @param cls closure
- * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful deposit;
- * 0 if the exchange's reply is bogus (fails to follow the protocol)
- * @param ec taler-specific error code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param sign_key exchange key used to sign @a obj, or NULL
- * @param obj the received JSON reply, should be kept as proof (and, in particular,
- * be forwarded to the customer)
*/
typedef void
(*TALER_EXCHANGE_RefundCallback) (
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const struct TALER_ExchangePublicKeyP *sign_key,
- const json_t *obj);
+ const struct TALER_EXCHANGE_HttpResponse *hr,
+ const struct TALER_ExchangePublicKeyP *sign_key);
/**
@@ -1120,10 +1140,7 @@ struct TALER_EXCHANGE_ReserveHistory
* reserve status request to a exchange.
*
* @param cls closure
- * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
- * 0 if the exchange's reply is bogus (fails to follow the protocol)
- * @param ec taler-specific error code, #TALER_EC_NONE on success
- * @param json original response in JSON format (useful only for diagnostics)
+ * @param hr HTTP response data
* @param balance current balance in the reserve, NULL on error
* @param history_length number of entries in the transaction history, 0 on error
* @param history detailed transaction history, NULL on error
@@ -1131,11 +1148,8 @@ struct TALER_EXCHANGE_ReserveHistory
typedef void
(*TALER_EXCHANGE_ReservesGetCallback) (
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const json_t *json,
- const struct
- TALER_Amount *balance,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
+ const struct TALER_Amount *balance,
unsigned int history_length,
const struct TALER_EXCHANGE_ReserveHistory *history);
@@ -1189,19 +1203,14 @@ struct TALER_EXCHANGE_WithdrawHandle;
* withdraw request to a exchange.
*
* @param cls closure
- * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
- * 0 if the exchange's reply is bogus (fails to follow the protocol)
- * @param ec taler-specific error code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param sig signature over the coin, NULL on error
- * @param full_response full response from the exchange (for logging, in case of errors)
*/
typedef void
(*TALER_EXCHANGE_WithdrawCallback) (
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const struct TALER_DenominationSignature *sig,
- const json_t *full_response);
+ const struct TALER_EXCHANGE_HttpResponse *hr,
+ const struct TALER_DenominationSignature *sig);
/**
@@ -1345,21 +1354,17 @@ struct TALER_EXCHANGE_MeltHandle;
* #TALER_EXCHANGE_refreshes_reveal().
*
* @param cls closure
- * @param http_status HTTP response code, never #MHD_HTTP_OK (200) as for successful intermediate response this callback is skipped.
- * 0 if the exchange's reply is bogus (fails to follow the protocol)
- * @param ec taler-specific error code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param noreveal_index choice by the exchange in the cut-and-choose protocol,
* UINT32_MAX on error
* @param sign_key exchange key used to sign @a full_response, or NULL
- * @param full_response full response from the exchange (for logging, in case of errors)
*/
typedef void
-(*TALER_EXCHANGE_MeltCallback) (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- uint32_t noreveal_index,
- const struct TALER_ExchangePublicKeyP *sign_key,
- const json_t *full_response);
+(*TALER_EXCHANGE_MeltCallback) (
+ void *cls,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
+ uint32_t noreveal_index,
+ const struct TALER_ExchangePublicKeyP *sign_key);
/**
@@ -1412,23 +1417,18 @@ TALER_EXCHANGE_melt_cancel (struct TALER_EXCHANGE_MeltHandle *mh);
* the original request specified the respective denomination keys.
*
* @param cls closure
- * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
- * 0 if the exchange's reply is bogus (fails to follow the protocol)
- * @param ec taler-specific error code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed
* @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error
* @param sigs array of signature over @a num_coins coins, NULL on error
- * @param full_response full response from the exchange (for logging, in case of errors)
*/
typedef void
(*TALER_EXCHANGE_RefreshesRevealCallback)(
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int num_coins,
const struct TALER_PlanchetSecretsP *coin_privs,
- const struct TALER_DenominationSignature *sigs,
- const json_t *full_response);
+ const struct TALER_DenominationSignature *sigs);
/**
@@ -1496,25 +1496,20 @@ struct TALER_EXCHANGE_LinkHandle;
* created when the original coin was melted.
*
* @param cls closure
- * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
- * 0 if the exchange's reply is bogus (fails to follow the protocol)
- * @param ec taler-specific error code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed
* @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error
* @param sigs array of signature over @a num_coins coins, NULL on error
* @param pubs array of public keys for the @a sigs, NULL on error
- * @param full_response full response from the exchange (for logging, in case of errors)
*/
typedef void
(*TALER_EXCHANGE_LinkCallback) (
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs,
const struct TALER_DenominationSignature *sigs,
- const struct TALER_DenominationPublicKey *pubs,
- const json_t *full_response);
+ const struct TALER_DenominationPublicKey *pubs);
/**
@@ -1560,11 +1555,8 @@ struct TALER_EXCHANGE_TransfersGetHandle;
* of the coin transactions that were combined into the wire transfer.
*
* @param cls closure
- * @param http_status HTTP status code we got, 0 on exchange protocol violation
- * @param ec taler-specific error code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param sign_key exchange key used to sign @a json, or NULL
- * @param json original json reply (may include signatures, those have then been
- * validated already)
* @param h_wire hash of the wire transfer address the transfer went to, or NULL on error
* @param execution_time time when the exchange claims to have performed the wire transfer
* @param total_amount total amount of the wire transfer, or NULL if the exchange could
@@ -1576,10 +1568,8 @@ struct TALER_EXCHANGE_TransfersGetHandle;
typedef void
(*TALER_EXCHANGE_TransfersGetCallback)(
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_ExchangePublicKeyP *sign_key,
- const json_t *json,
const struct GNUNET_HashCode *h_wire,
struct GNUNET_TIME_Absolute execution_time,
const struct TALER_Amount *total_amount,
@@ -1630,11 +1620,8 @@ struct TALER_EXCHANGE_DepositGetHandle;
* Function called with detailed wire transfer data.
*
* @param cls closure
- * @param http_status HTTP status code we got, 0 on exchange protocol violation
- * @param ec taler-specific error code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param sign_key exchange key used to sign @a json, or NULL
- * @param json original json reply (may include signatures, those have then been
- * validated already)
* @param wtid wire transfer identifier used by the exchange, NULL if exchange did not
* yet execute the transaction
* @param execution_time actual or planned execution time for the wire transfer
@@ -1643,13 +1630,10 @@ struct TALER_EXCHANGE_DepositGetHandle;
typedef void
(*TALER_EXCHANGE_DepositGetCallback)(
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_ExchangePublicKeyP *sign_key,
- const json_t *json,
const struct TALER_WireTransferIdentifierRawP *wtid,
- struct GNUNET_TIME_Absolute
- execution_time,
+ struct GNUNET_TIME_Absolute execution_time,
const struct TALER_Amount *coin_contribution);
@@ -1766,24 +1750,19 @@ struct TALER_EXCHANGE_RecoupHandle;
* the original request specified the respective denomination keys.
*
* @param cls closure
- * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
- * 0 if the exchange's reply is bogus (fails to follow the protocol)
- * @param ec taler-specific error code, #TALER_EC_NONE on success
+ * @param hr HTTP response data
* @param amount amount the exchange will wire back for this coin,
* on error the total balance remaining, or NULL
* @param timestamp what time did the exchange receive the /recoup request
* @param reserve_pub public key of the reserve receiving the recoup, NULL if refreshed or on error
* @param old_coin_pub public key of the dirty coin, NULL if not refreshed or on error
- * @param full_response full response from the exchange (for logging, in case of errors)
*/
typedef void
(*TALER_EXCHANGE_RecoupResultCallback) (
void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_CoinSpendPublicKeyP *old_coin_pub,
- const json_t *full_response);
+ const struct TALER_CoinSpendPublicKeyP *old_coin_pub);
/**
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index fa14dc0bc..094cbe2eb 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -133,6 +133,17 @@ TALER_JSON_get_error_code (const json_t *json);
/**
+ * Extract the Taler error hint from the given @a json object.
+ * Note that NULL is returned if no "hint" is present.
+ *
+ * @param json response to extract the error hint from
+ * @return the "hint" value from @a json; only valid as long as @a json is valid
+ */
+const char *
+TALER_JSON_get_error_hint (const json_t *json);
+
+
+/**
* Extract the Taler error code from the given @a data object, which is expected to be in JSON.
* Note that #TALER_EC_INVALID is returned if no "code" is present or if @a data is not in JSON.
*
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index be20e0cd7..dcdbb3c19 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -135,19 +135,15 @@ TALER_TESTING_prepare_exchange (const char *config_filename,
*
* @param cls closure, typically, the "run" method containing
* all the commands to be run, and a closure for it.
+ * @param hr http response details
* @param keys the exchange's keys.
* @param compat protocol compatibility information.
- * @param ec error code, #TALER_EC_NONE on success
- * @param http_status status returned by /keys, #MHD_HTTP_OK on success
- * @param full_reply JSON body of /keys request, NULL if reply was not in JSON
*/
void
TALER_TESTING_cert_cb (void *cls,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_EXCHANGE_Keys *keys,
- enum TALER_EXCHANGE_VersionCompatibility compat,
- enum TALER_ErrorCode ec,
- unsigned int http_status,
- const json_t *full_reply);
+ enum TALER_EXCHANGE_VersionCompatibility compat);
/**
diff --git a/src/json/json.c b/src/json/json.c
index f0c0aff57..67d62605f 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -93,6 +93,36 @@ TALER_JSON_get_error_code (const json_t *json)
/**
+ * Extract the Taler error hint from the given @a json object.
+ * Note that NULL is returned if no "hint" is present.
+ *
+ * @param json response to extract the error hint from
+ * @return the "hint" value from @a json; only valid as long as @a json is valid
+ */
+const char *
+TALER_JSON_get_error_hint (const json_t *json)
+{
+ const json_t *jc;
+
+ if (NULL == json)
+ {
+ GNUNET_break_op (0);
+ return NULL;
+ }
+ jc = json_object_get (json, "hint");
+ if (NULL == jc)
+ return NULL; /* no hint, is allowed */
+ if (! json_is_string (jc))
+ {
+ /* Hints must be strings */
+ GNUNET_break_op (0);
+ return NULL;
+ }
+ return json_string_value (jc);
+}
+
+
+/**
* Extract the Taler error code from the given @a data object, which is expected to be in JSON.
* Note that #TALER_EC_INVALID is returned if no "code" is present or if @a data is not in JSON.
*
diff --git a/src/lib/auditor_api_deposit_confirmation.c b/src/lib/auditor_api_deposit_confirmation.c
index e0135bb44..045102087 100644
--- a/src/lib/auditor_api_deposit_confirmation.c
+++ b/src/lib/auditor_api_deposit_confirmation.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2018 Taler Systems SA
+ Copyright (C) 2014-2020 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 the Free Software
@@ -87,53 +87,58 @@ handle_deposit_confirmation_finished (void *cls,
{
const json_t *json = djson;
struct TALER_AUDITOR_DepositConfirmationHandle *dh = cls;
- enum TALER_ErrorCode ec;
+ struct TALER_AUDITOR_HttpResponse hr = {
+ .reply = json,
+ .http_status = (unsigned int) response_code
+ };
dh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
- ec = TALER_EC_NONE;
+ hr.ec = TALER_EC_NONE;
break;
case MHD_HTTP_BAD_REQUEST:
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
/* This should never happen, either us or the auditor is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_FORBIDDEN:
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
/* Nothing really to verify, auditor says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
/* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- ec);
- GNUNET_break (0);
- response_code = 0;
+ hr.ec);
+ GNUNET_break_op (0);
break;
}
dh->cb (dh->cb_cls,
- response_code,
- ec,
- json);
+ &hr);
TALER_AUDITOR_deposit_confirmation_cancel (dh);
}
diff --git a/src/lib/auditor_api_exchanges.c b/src/lib/auditor_api_exchanges.c
index 4e23267fd..83cbc4bb4 100644
--- a/src/lib/auditor_api_exchanges.c
+++ b/src/lib/auditor_api_exchanges.c
@@ -89,13 +89,16 @@ handle_exchanges_finished (void *cls,
const json_t *ja;
unsigned int ja_len;
struct TALER_AUDITOR_ListExchangesHandle *leh = cls;
- enum TALER_ErrorCode ec;
+ struct TALER_AUDITOR_HttpResponse hr = {
+ .reply = json,
+ .http_status = (unsigned int) response_code
+ };
leh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
ja = json_object_get (json,
@@ -104,8 +107,8 @@ handle_exchanges_finished (void *cls,
(! json_is_array (ja)) )
{
GNUNET_break (0);
- ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
- response_code = 0;
+ hr.ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
+ hr.http_status = 0;
break;
}
@@ -113,8 +116,8 @@ handle_exchanges_finished (void *cls,
if (ja_len > MAX_EXCHANGES)
{
GNUNET_break (0);
- ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
- response_code = 0;
+ hr.ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
+ hr.http_status = 0;
break;
}
{
@@ -138,54 +141,54 @@ handle_exchanges_finished (void *cls,
{
GNUNET_break_op (0);
ok = GNUNET_NO;
- ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
+ hr.ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
+ hr.http_status = 0;
break;
}
}
if (GNUNET_YES != ok)
break;
leh->cb (leh->cb_cls,
- response_code,
- TALER_EC_NONE,
+ &hr,
ja_len,
- ei,
- json);
+ ei);
TALER_AUDITOR_list_exchanges_cancel (leh);
return;
}
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the auditor is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- (int) ec);
- GNUNET_break (0);
- response_code = 0;
+ (int) hr.ec);
+ GNUNET_break_op (0);
break;
}
if (NULL != leh->cb)
leh->cb (leh->cb_cls,
- response_code,
- TALER_JSON_get_error_code (json),
+ &hr,
0,
- NULL,
- json);
+ NULL);
TALER_AUDITOR_list_exchanges_cancel (leh);
}
diff --git a/src/lib/auditor_api_handle.c b/src/lib/auditor_api_handle.c
index 85f42c3f6..99d0a4f9a 100644
--- a/src/lib/auditor_api_handle.c
+++ b/src/lib/auditor_api_handle.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2018 Taler Systems SA
+ Copyright (C) 2014-2020 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 the Free Software
@@ -197,9 +197,9 @@ free_version_info (struct TALER_AUDITOR_VersionInformation *vi)
* @param[in] resp_obj JSON object to parse
* @param[out] vi where to store the results we decoded
* @param[out] vc where to store version compatibility data
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (malformed JSON)
+ * @return #TALER_EC_NONE on success
*/
-static int
+static enum TALER_ErrorCode
decode_version_json (const json_t *resp_obj,
struct TALER_AUDITOR_VersionInformation *vi,
enum TALER_AUDITOR_VersionCompatibility *vc)
@@ -219,7 +219,7 @@ decode_version_json (const json_t *resp_obj,
if (JSON_OBJECT != json_typeof (resp_obj))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return TALER_EC_JSON_INVALID;
}
/* check the version */
if (GNUNET_OK !=
@@ -228,7 +228,7 @@ decode_version_json (const json_t *resp_obj,
NULL, NULL))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return TALER_EC_JSON_INVALID;
}
if (3 != sscanf (ver,
"%u:%u:%u",
@@ -237,7 +237,7 @@ decode_version_json (const json_t *resp_obj,
&age))
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return TALER_EC_VERSION_MALFORMED;
}
vi->version = GNUNET_strdup (ver);
*vc = TALER_AUDITOR_VC_MATCH;
@@ -253,7 +253,7 @@ decode_version_json (const json_t *resp_obj,
if (TALER_PROTOCOL_CURRENT - TALER_PROTOCOL_AGE > current)
*vc |= TALER_AUDITOR_VC_INCOMPATIBLE;
}
- return GNUNET_OK;
+ return TALER_EC_NONE;
}
@@ -283,6 +283,10 @@ version_completed_cb (void *cls,
struct VersionRequest *vr = cls;
struct TALER_AUDITOR_Handle *auditor = vr->auditor;
enum TALER_AUDITOR_VersionCompatibility vc;
+ struct TALER_AUDITOR_HttpResponse hr = {
+ .reply = resp_obj,
+ .http_status = (unsigned int) response_code
+ };
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received version from URL `%s' with status %ld.\n",
@@ -293,6 +297,8 @@ version_completed_cb (void *cls,
{
case 0:
case MHD_HTTP_INTERNAL_SERVER_ERROR:
+ /* NOTE: this design is debatable. We MAY want to throw this error at the
+ client. We may then still additionally internally re-try. */
free_version_request (vr);
auditor->vr = NULL;
GNUNET_assert (NULL == auditor->retry_task);
@@ -306,24 +312,28 @@ version_completed_cb (void *cls,
{
GNUNET_break_op (0);
TALER_LOG_WARNING ("NULL body for a 200-OK /version\n");
- response_code = 0;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
}
- if (GNUNET_OK !=
- decode_version_json (resp_obj,
- &auditor->vi,
- &vc))
+ hr.ec = decode_version_json (resp_obj,
+ &auditor->vi,
+ &vc);
+ if (TALER_EC_NONE != hr.ec)
{
GNUNET_break_op (0);
- response_code = 0;
+ hr.http_status = 0;
break;
}
auditor->retry_delay = GNUNET_TIME_UNIT_ZERO; /* restart quickly */
break;
default:
+ hr.ec = TALER_JSON_get_error_code (resp_obj);
+ hr.hint = TALER_JSON_get_error_hint (resp_obj);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
+ "Unexpected response code %u/%d\n",
+ (unsigned int) response_code,
+ (int) hr.ec);
break;
}
if (MHD_HTTP_OK != response_code)
@@ -338,6 +348,7 @@ version_completed_cb (void *cls,
free_version_info (&auditor->vi);
/* notify application that we failed */
auditor->version_cb (auditor->version_cb_cls,
+ &hr,
NULL,
vc);
return;
@@ -352,6 +363,7 @@ version_completed_cb (void *cls,
auditor);
/* notify application about the key information */
auditor->version_cb (auditor->version_cb_cls,
+ &hr,
&auditor->vi,
vc);
}
diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c
index 54dad7473..e01a3c580 100644
--- a/src/lib/exchange_api_deposit.c
+++ b/src/lib/exchange_api_deposit.c
@@ -156,25 +156,24 @@ auditor_cb (void *cls,
TALER_amount_ntoh (&amount_without_fee,
&dh->depconf.amount_without_fee);
aie = GNUNET_new (struct TEAH_AuditorInteractionEntry);
- aie->dch = TALER_AUDITOR_deposit_confirmation (ah,
- &dh->depconf.h_wire,
- &dh->depconf.h_contract_terms,
- GNUNET_TIME_absolute_ntoh (
- dh->depconf.timestamp),
- GNUNET_TIME_absolute_ntoh (
- dh->depconf.refund_deadline),
- &amount_without_fee,
- &dh->depconf.coin_pub,
- &dh->depconf.merchant,
- &dh->exchange_pub,
- &dh->exchange_sig,
- &key_state->master_pub,
- spk->valid_from,
- spk->valid_until,
- spk->valid_legal,
- &spk->master_sig,
- &TEAH_acc_confirmation_cb,
- aie);
+ aie->dch = TALER_AUDITOR_deposit_confirmation (
+ ah,
+ &dh->depconf.h_wire,
+ &dh->depconf.h_contract_terms,
+ GNUNET_TIME_absolute_ntoh (dh->depconf.timestamp),
+ GNUNET_TIME_absolute_ntoh (dh->depconf.refund_deadline),
+ &amount_without_fee,
+ &dh->depconf.coin_pub,
+ &dh->depconf.merchant,
+ &dh->exchange_pub,
+ &dh->exchange_sig,
+ &key_state->master_pub,
+ spk->valid_from,
+ spk->valid_until,
+ spk->valid_legal,
+ &spk->master_sig,
+ &TEAH_acc_confirmation_cb,
+ aie);
return aie;
}
@@ -305,13 +304,16 @@ handle_deposit_finished (void *cls,
struct TALER_ExchangeSignatureP *es = NULL;
struct TALER_ExchangePublicKeyP *ep = NULL;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
dh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
if (GNUNET_OK !=
@@ -321,66 +323,71 @@ handle_deposit_finished (void *cls,
&exchange_pub))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE;
}
else
{
es = &exchange_sig;
ep = &exchange_pub;
- ec = TALER_EC_NONE;
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_CONFLICT:
/* Double spending; check signatures on transaction history */
- ec = TALER_JSON_get_error_code (j);
if (GNUNET_OK !=
verify_deposit_signature_forbidden (dh,
j))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE;
+ }
+ else
+ {
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
}
break;
case MHD_HTTP_FORBIDDEN:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* Nothing really to verify, this should never
- happen, we should pass the JSON reply to the application */
+ happen, we should pass the JSON reply to the application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- ec);
- GNUNET_break (0);
- response_code = 0;
+ hr.ec);
+ GNUNET_break_op (0);
break;
}
dh->cb (dh->cb_cls,
- response_code,
- ec,
+ &hr,
es,
- ep,
- j);
+ ep);
TALER_EXCHANGE_deposit_cancel (dh);
}
diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c
index 0ab926eab..053f3ac87 100644
--- a/src/lib/exchange_api_deposits_get.c
+++ b/src/lib/exchange_api_deposits_get.c
@@ -151,13 +151,16 @@ handle_deposit_wtid_finished (void *cls,
struct TALER_ExchangePublicKeyP exchange_pub;
struct TALER_ExchangePublicKeyP *ep = NULL;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
dwh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
{
@@ -174,8 +177,8 @@ handle_deposit_wtid_finished (void *cls,
NULL, NULL))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE;
break;
}
wtid = &dwh->depconf.wtid;
@@ -189,13 +192,12 @@ handle_deposit_wtid_finished (void *cls,
&exchange_pub))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_DEPOSITS_INVALID_SIGNATURE_BY_EXCHANGE;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_DEPOSITS_INVALID_SIGNATURE_BY_EXCHANGE;
}
else
{
ep = &exchange_pub;
- ec = TALER_EC_NONE;
}
}
break;
@@ -213,49 +215,51 @@ handle_deposit_wtid_finished (void *cls,
NULL, NULL))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE;
break;
}
- ec = TALER_EC_NONE;
}
break;
case MHD_HTTP_BAD_REQUEST:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_FORBIDDEN:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* Exchange does not know about transaction;
we should pass the reply to the application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
break;
default:
/* unexpected response code */
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
- GNUNET_break (0);
- ec = TALER_JSON_get_error_code (j);
- response_code = 0;
+ "Unexpected response code %u/%d\n",
+ (unsigned int) response_code,
+ (int) hr.ec);
+ GNUNET_break_op (0);
break;
}
dwh->cb (dwh->cb_cls,
- response_code,
- ec,
+ &hr,
ep,
- j,
wtid,
execution_time,
coin_contribution);
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index 8ae5b06d2..5c69ee972 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -265,27 +265,22 @@ struct KeysRequest
* auditor's /deposit-confirmation handler.
*
* @param cls closure of type `struct TEAH_AuditorInteractionEntry *`
- * @param http_status HTTP status code, 200 on success
- * @param ec taler protocol error status code, 0 on success
- * @param json raw json response
+ * @param hr HTTP response
*/
void
TEAH_acc_confirmation_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const json_t *json)
+ const struct TALER_AUDITOR_HttpResponse *hr)
{
struct TEAH_AuditorInteractionEntry *aie = cls;
struct TEAH_AuditorListEntry *ale = aie->ale;
- (void) json;
- if (MHD_HTTP_OK != http_status)
+ if (MHD_HTTP_OK != hr->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to submit deposit confirmation to auditor `%s' with HTTP status %d (EC: %d). This is acceptable if it does not happen often.\n",
ale->auditor_url,
- http_status,
- (int) ec);
+ hr->http_status,
+ hr->ec);
}
GNUNET_CONTAINER_DLL_remove (ale->ai_head,
ale->ai_tail,
@@ -664,12 +659,14 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
* auditor as 'up'.
*
* @param cls closure, a `struct TEAH_AuditorListEntry *`
+ * @param hr http response from the auditor
* @param vi basic information about the auditor
* @param compat protocol compatibility information
*/
static void
auditor_version_cb (
void *cls,
+ const struct TALER_AUDITOR_HttpResponse *hr,
const struct TALER_AUDITOR_VersionInformation *vi,
enum TALER_AUDITOR_VersionCompatibility compat)
{
@@ -1252,6 +1249,10 @@ keys_completed_cb (void *cls,
struct TALER_EXCHANGE_Keys kd_old;
enum TALER_EXCHANGE_VersionCompatibility vc;
const json_t *j = resp_obj;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received keys from URL `%s' with status %ld.\n",
@@ -1328,7 +1329,8 @@ keys_completed_cb (void *cls,
&vc))
{
TALER_LOG_ERROR ("Could not decode /keys response\n");
- response_code = 0;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_KEYS_INVALID;
for (unsigned int i = 0; i<kd.num_auditors; i++)
{
struct TALER_EXCHANGE_AuditorInformation *anew = &kd.auditors[i];
@@ -1354,9 +1356,12 @@ keys_completed_cb (void *cls,
exchange->retry_delay = GNUNET_TIME_UNIT_ZERO;
break;
default:
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
+ "Unexpected response code %u/%d\n",
+ (unsigned int) response_code,
+ (int) hr.ec);
break;
}
exchange->key_data = kd;
@@ -1380,11 +1385,9 @@ keys_completed_cb (void *cls,
free_key_data (&kd_old);
/* notify application that we failed */
exchange->cert_cb (exchange->cert_cb_cls,
+ &hr,
NULL,
- vc,
- TALER_JSON_get_error_code (j),
- response_code,
- j);
+ vc);
return;
}
@@ -1397,11 +1400,9 @@ keys_completed_cb (void *cls,
update_auditors (exchange);
/* notify application about the key information */
exchange->cert_cb (exchange->cert_cb_cls,
+ &hr,
&exchange->key_data,
- vc,
- TALER_EC_NONE,
- MHD_HTTP_OK,
- j);
+ vc);
free_key_data (&kd_old);
}
@@ -1575,6 +1576,11 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_JSON_spec_end ()
};
struct TALER_EXCHANGE_Keys key_data;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .ec = TALER_EC_NONE,
+ .http_status = MHD_HTTP_OK,
+ .reply = data
+ };
if (NULL == data)
return;
@@ -1622,11 +1628,9 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
update_auditors (exchange);
/* notify application about the key information */
exchange->cert_cb (exchange->cert_cb_cls,
+ &hr,
&exchange->key_data,
- vc,
- TALER_EC_NONE,
- MHD_HTTP_OK,
- data);
+ vc);
GNUNET_JSON_parse_free (spec);
}
diff --git a/src/lib/exchange_api_handle.h b/src/lib/exchange_api_handle.h
index 63f789c8e..b4b8ccf54 100644
--- a/src/lib/exchange_api_handle.h
+++ b/src/lib/exchange_api_handle.h
@@ -79,15 +79,11 @@ typedef struct TEAH_AuditorInteractionEntry *
* auditor's /deposit-confirmation handler.
*
* @param cls closure of type `struct TEAH_AuditorInteractionEntry *`
- * @param http_status HTTP status code, 200 on success
- * @param ec taler protocol error status code, 0 on success
- * @param json raw json response
+ * @param hr HTTP response
*/
void
TEAH_acc_confirmation_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const json_t *json);
+ const struct TALER_AUDITOR_HttpResponse *hr);
/**
diff --git a/src/lib/exchange_api_link.c b/src/lib/exchange_api_link.c
index 088e4aa36..c05b2e563 100644
--- a/src/lib/exchange_api_link.c
+++ b/src/lib/exchange_api_link.c
@@ -186,6 +186,10 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,
unsigned int session;
unsigned int num_coins;
int ret;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = json,
+ .http_status = MHD_HTTP_OK
+ };
if (! json_is_array (json))
{
@@ -305,13 +309,11 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,
if (off_coin == num_coins)
{
lh->link_cb (lh->link_cb_cls,
- MHD_HTTP_OK,
- TALER_EC_NONE,
+ &hr,
num_coins,
coin_privs,
sigs,
- pubs,
- json);
+ pubs);
lh->link_cb = NULL;
ret = GNUNET_OK;
}
@@ -350,13 +352,16 @@ handle_link_finished (void *cls,
{
struct TALER_EXCHANGE_LinkHandle *lh = cls;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
lh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
if (GNUNET_OK !=
@@ -364,47 +369,49 @@ handle_link_finished (void *cls,
j))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_LINK_REPLY_MALFORMED;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_LINK_REPLY_MALFORMED;
break;
}
GNUNET_assert (NULL == lh->link_cb);
TALER_EXCHANGE_link_cancel (lh);
return;
case MHD_HTTP_BAD_REQUEST:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
case MHD_HTTP_NOT_FOUND:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* Nothing really to verify, exchange says this coin was not melted; we
should pass the JSON reply to the application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
break;
default:
/* unexpected response code */
+ GNUNET_break_op (0);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
- GNUNET_break (0);
- response_code = 0;
- ec = TALER_JSON_get_error_code (j);
+ "Unexpected response code %u/%d\n",
+ (unsigned int) response_code,
+ (int) hr.ec);
break;
}
if (NULL != lh->link_cb)
lh->link_cb (lh->link_cb_cls,
- response_code,
- ec,
+ &hr,
0,
NULL,
NULL,
- NULL,
- j);
+ NULL);
TALER_EXCHANGE_link_cancel (lh);
}
diff --git a/src/lib/exchange_api_melt.c b/src/lib/exchange_api_melt.c
index d6acf92c7..4d0d21b37 100644
--- a/src/lib/exchange_api_melt.c
+++ b/src/lib/exchange_api_melt.c
@@ -267,13 +267,16 @@ handle_melt_finished (void *cls,
uint32_t noreveal_index = TALER_CNC_KAPPA; /* invalid value */
struct TALER_ExchangePublicKeyP exchange_pub;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
mh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
if (GNUNET_OK !=
@@ -283,30 +286,25 @@ handle_melt_finished (void *cls,
&noreveal_index))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_MELT_INVALID_SIGNATURE_BY_EXCHANGE;
- }
- else
- {
- ec = TALER_EC_NONE;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_MELT_INVALID_SIGNATURE_BY_EXCHANGE;
}
if (NULL != mh->melt_cb)
{
mh->melt_cb (mh->melt_cb_cls,
- response_code,
- ec,
+ &hr,
noreveal_index,
(0 == response_code)
? NULL
- : &exchange_pub,
- j);
+ : &exchange_pub);
mh->melt_cb = NULL;
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_CONFLICT:
/* Double spending; check signatures on transaction history */
@@ -315,46 +313,46 @@ handle_melt_finished (void *cls,
j))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_MELT_INVALID_SIGNATURE_BY_EXCHANGE;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_MELT_INVALID_SIGNATURE_BY_EXCHANGE;
+ hr.hint = TALER_JSON_get_error_hint (j);
}
- else
- ec = TALER_EC_NONE;
break;
case MHD_HTTP_FORBIDDEN:
/* Nothing really to verify, exchange says one of the signatures is
invalid; assuming we checked them, this should never happen, we
should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- ec);
- GNUNET_break (0);
- response_code = 0;
+ hr.ec);
+ GNUNET_break_op (0);
break;
}
if (NULL != mh->melt_cb)
mh->melt_cb (mh->melt_cb_cls,
- response_code,
- ec,
+ &hr,
UINT32_MAX,
- NULL,
- j);
+ NULL);
TALER_EXCHANGE_melt_cancel (mh);
}
diff --git a/src/lib/exchange_api_recoup.c b/src/lib/exchange_api_recoup.c
index a3416b5bc..484d27536 100644
--- a/src/lib/exchange_api_recoup.c
+++ b/src/lib/exchange_api_recoup.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2017 Taler Systems SA
+ Copyright (C) 2017-2020 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 the Free Software
@@ -112,6 +112,10 @@ process_recoup_response (const struct TALER_EXCHANGE_RecoupHandle *ph,
GNUNET_JSON_spec_fixed_auto ("old_coin_pub", &old_coin_pub),
GNUNET_JSON_spec_end ()
};
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = json,
+ .http_status = MHD_HTTP_OK
+ };
if (GNUNET_OK !=
GNUNET_JSON_parse (json,
@@ -127,11 +131,9 @@ process_recoup_response (const struct TALER_EXCHANGE_RecoupHandle *ph,
return GNUNET_SYSERR;
}
ph->cb (ph->cb_cls,
- MHD_HTTP_OK,
- TALER_EC_NONE,
+ &hr,
ph->was_refreshed ? NULL : &reserve_pub,
- ph->was_refreshed ? &old_coin_pub : NULL,
- json);
+ ph->was_refreshed ? &old_coin_pub : NULL);
return GNUNET_OK;
}
@@ -151,23 +153,25 @@ handle_recoup_finished (void *cls,
{
struct TALER_EXCHANGE_RecoupHandle *ph = cls;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
ph->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
- ec = TALER_EC_NONE;
if (GNUNET_OK !=
process_recoup_response (ph,
j))
{
GNUNET_break_op (0);
- ec = TALER_EC_RECOUP_REPLY_MALFORMED;
- response_code = 0;
+ hr.ec = TALER_EC_RECOUP_REPLY_MALFORMED;
+ hr.http_status = 0;
break;
}
TALER_EXCHANGE_recoup_cancel (ph);
@@ -175,7 +179,8 @@ handle_recoup_finished (void *cls,
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_CONFLICT:
{
@@ -195,15 +200,18 @@ handle_recoup_finished (void *cls,
&total))
{
GNUNET_break_op (0);
- response_code = 0;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_RECOUP_REPLY_MALFORMED;
+ }
+ else
+ {
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
}
- ec = TALER_JSON_get_error_code (j);
ph->cb (ph->cb_cls,
- response_code,
- ec,
- NULL,
+ &hr,
NULL,
- j);
+ NULL);
TALER_EXCHANGE_recoup_cancel (ph);
return;
}
@@ -211,39 +219,42 @@ handle_recoup_finished (void *cls,
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_GONE:
/* Kind of normal: the money was already sent to the merchant
(it was too late for the refund). */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
+ "Unexpected response code %u/%d\n",
+ (unsigned int) response_code,
+ (int) hr.ec);
GNUNET_break (0);
- response_code = 0;
break;
}
ph->cb (ph->cb_cls,
- response_code,
- ec,
- NULL,
+ &hr,
NULL,
- j);
+ NULL);
TALER_EXCHANGE_recoup_cancel (ph);
}
diff --git a/src/lib/exchange_api_refreshes_reveal.c b/src/lib/exchange_api_refreshes_reveal.c
index f07dc9047..f8071f5c5 100644
--- a/src/lib/exchange_api_refreshes_reveal.c
+++ b/src/lib/exchange_api_refreshes_reveal.c
@@ -202,13 +202,16 @@ handle_refresh_reveal_finished (void *cls,
{
struct TALER_EXCHANGE_RefreshesRevealHandle *rrh = cls;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = MHD_HTTP_OK
+ };
rrh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
{
@@ -221,19 +224,16 @@ handle_refresh_reveal_finished (void *cls,
sigs);
if (GNUNET_OK != ret)
{
- response_code = 0;
- ec = TALER_EC_REVEAL_REPLY_MALFORMED;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_REVEAL_REPLY_MALFORMED;
}
else
{
- ec = TALER_EC_NONE;
rrh->reveal_cb (rrh->reveal_cb_cls,
- MHD_HTTP_OK,
- ec,
+ &hr,
rrh->md->num_fresh_coins,
rrh->md->fresh_coins[rrh->noreveal_index],
- sigs,
- j);
+ sigs);
rrh->reveal_cb = NULL;
}
for (unsigned int i = 0; i<rrh->md->num_fresh_coins; i++)
@@ -245,37 +245,39 @@ handle_refresh_reveal_finished (void *cls,
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_CONFLICT:
/* Nothing really to verify, exchange says our reveal is inconsistent
with our commitment, so either side is buggy; we
should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
default:
/* unexpected response code */
+ GNUNET_break_op (0);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
- GNUNET_break (0);
- response_code = 0;
- ec = TALER_JSON_get_error_code (j);
+ "Unexpected response code %u/%d\n",
+ (unsigned int) response_code,
+ (int) hr.ec);
break;
}
if (NULL != rrh->reveal_cb)
rrh->reveal_cb (rrh->reveal_cb_cls,
- response_code,
- ec,
+ &hr,
0,
NULL,
- NULL,
- j);
+ NULL);
TALER_EXCHANGE_refreshes_reveal_cancel (rrh);
}
diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c
index 826c39b17..81127c5a7 100644
--- a/src/lib/exchange_api_refund.c
+++ b/src/lib/exchange_api_refund.c
@@ -145,13 +145,16 @@ handle_refund_finished (void *cls,
struct TALER_ExchangePublicKeyP exchange_pub;
struct TALER_ExchangePublicKeyP *ep = NULL;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
rh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
if (GNUNET_OK !=
@@ -160,67 +163,71 @@ handle_refund_finished (void *cls,
&exchange_pub))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_REFUND_INVALID_SIGNATURE_BY_EXCHANGE;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_REFUND_INVALID_SIGNATURE_BY_EXCHANGE;
}
else
{
ep = &exchange_pub;
- ec = TALER_EC_NONE;
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_FORBIDDEN:
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_GONE:
/* Kind of normal: the money was already sent to the merchant
(it was too late for the refund). */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_PRECONDITION_FAILED:
/* Client request was inconsistent; might be a currency mismatch
problem. */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_CONFLICT:
/* Two refund requests were made about the same deposit, but
carrying different refund transaction ids. */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (j);
+ GNUNET_break_op (0);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- ec);
- GNUNET_break (0);
- response_code = 0;
+ hr.ec);
break;
}
rh->cb (rh->cb_cls,
- response_code,
- ec,
- ep,
- j);
+ &hr,
+ ep);
TALER_EXCHANGE_refund_cancel (rh);
}
diff --git a/src/lib/exchange_api_reserves_get.c b/src/lib/exchange_api_reserves_get.c
index e44eefad6..0624f0d00 100644
--- a/src/lib/exchange_api_reserves_get.c
+++ b/src/lib/exchange_api_reserves_get.c
@@ -91,6 +91,10 @@ handle_reserves_get_ok (struct TALER_EXCHANGE_ReservesGetHandle *rgh,
TALER_JSON_spec_amount ("balance", &balance),
GNUNET_JSON_spec_end ()
};
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = MHD_HTTP_OK
+ };
if (GNUNET_OK !=
GNUNET_JSON_parse (j,
@@ -141,9 +145,7 @@ handle_reserves_get_ok (struct TALER_EXCHANGE_ReservesGetHandle *rgh,
if (NULL != rgh->cb)
{
rgh->cb (rgh->cb_cls,
- MHD_HTTP_OK,
- TALER_EC_NONE,
- j,
+ &hr,
&balance,
len,
rhistory);
@@ -171,55 +173,59 @@ handle_reserves_get_finished (void *cls,
{
struct TALER_EXCHANGE_ReservesGetHandle *rgh = cls;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
rgh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
- ec = TALER_EC_NONE;
if (GNUNET_OK !=
handle_reserves_get_ok (rgh,
j))
{
- response_code = 0;
- ec = TALER_EC_RESERVE_STATUS_REPLY_MALFORMED;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_RESERVE_STATUS_REPLY_MALFORMED;
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (j);
+ GNUNET_break_op (0);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
- GNUNET_break (0);
- response_code = 0;
+ "Unexpected response code %u/%d\n",
+ (unsigned int) response_code,
+ (int) hr.ec);
break;
}
if (NULL != rgh->cb)
{
rgh->cb (rgh->cb_cls,
- response_code,
- ec,
- j,
+ &hr,
NULL,
0, NULL);
rgh->cb = NULL;
diff --git a/src/lib/exchange_api_transfers_get.c b/src/lib/exchange_api_transfers_get.c
index d3513fb81..2f1e32898 100644
--- a/src/lib/exchange_api_transfers_get.c
+++ b/src/lib/exchange_api_transfers_get.c
@@ -105,6 +105,10 @@ check_transfers_get_response_ok (
GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub),
GNUNET_JSON_spec_end ()
};
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = json,
+ .http_status = MHD_HTTP_OK
+ };
if (GNUNET_OK !=
GNUNET_JSON_parse (json,
@@ -175,10 +179,10 @@ check_transfers_get_response_ok (
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
- GNUNET_CRYPTO_hash_context_read (hash_context,
- &dd,
- sizeof (struct
- TALER_WireDepositDetailP));
+ GNUNET_CRYPTO_hash_context_read (
+ hash_context,
+ &dd,
+ sizeof (struct TALER_WireDepositDetailP));
}
/* Check signature */
wdp.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT);
@@ -200,8 +204,9 @@ check_transfers_get_response_ok (
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
- if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify
- (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT,
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_verify (
+ TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT,
&wdp.purpose,
&exchange_sig.eddsa_signature,
&exchange_pub.eddsa_pub))
@@ -229,10 +234,8 @@ check_transfers_get_response_ok (
return GNUNET_SYSERR;
}
wdh->cb (wdh->cb_cls,
- MHD_HTTP_OK,
- TALER_EC_NONE,
+ &hr,
&exchange_pub,
- json,
&h_wire,
exec_time,
&total_amount,
@@ -261,13 +264,16 @@ handle_transfers_get_finished (void *cls,
{
struct TALER_EXCHANGE_TransfersGetHandle *wdh = cls;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
wdh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
if (GNUNET_OK ==
@@ -275,45 +281,48 @@ handle_transfers_get_finished (void *cls,
j))
return;
GNUNET_break_op (0);
- ec = TALER_EC_TRANSFERS_GET_REPLY_MALFORMED;
- response_code = 0;
+ hr.ec = TALER_EC_TRANSFERS_GET_REPLY_MALFORMED;
+ hr.http_status = 0;
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_FORBIDDEN:
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Exchange does not know about transaction;
we should pass the reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (j);
+ GNUNET_break_op (0);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
- GNUNET_break (0);
- response_code = 0;
+ "Unexpected response code %u/%d\n",
+ (unsigned int) response_code,
+ (int) hr.ec);
break;
}
wdh->cb (wdh->cb_cls,
- response_code,
- ec,
+ &hr,
NULL,
- j,
NULL,
GNUNET_TIME_UNIT_ZERO_ABS,
NULL,
diff --git a/src/lib/exchange_api_wire.c b/src/lib/exchange_api_wire.c
index 3f3998f5b..2602038b7 100644
--- a/src/lib/exchange_api_wire.c
+++ b/src/lib/exchange_api_wire.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2018 Taler Systems SA
+ Copyright (C) 2014-2020 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 the Free Software
@@ -208,15 +208,18 @@ handle_wire_finished (void *cls,
const void *response)
{
struct TALER_EXCHANGE_WireHandle *wh = cls;
- enum TALER_ErrorCode ec;
const json_t *j = response;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
TALER_LOG_DEBUG ("Checking raw /wire response\n");
wh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
{
@@ -238,8 +241,8 @@ handle_wire_finished (void *cls,
{
/* bogus reply */
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_SERVER_JSON_INVALID;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_SERVER_JSON_INVALID;
break;
}
if (0 == (num_accounts = json_array_size (accounts)))
@@ -247,8 +250,8 @@ handle_wire_finished (void *cls,
/* bogus reply */
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
- response_code = 0;
- ec = TALER_EC_SERVER_JSON_INVALID;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_SERVER_JSON_INVALID;
break;
}
if (NULL == (fm = parse_fees (fees)))
@@ -256,12 +259,11 @@ handle_wire_finished (void *cls,
/* bogus reply */
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
- response_code = 0;
- ec = TALER_EC_SERVER_JSON_INVALID;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_SERVER_JSON_INVALID;
break;
}
- ec = TALER_EC_NONE;
key_state = TALER_EXCHANGE_get_keys (wh->exchange);
/* parse accounts */
{
@@ -286,8 +288,8 @@ handle_wire_finished (void *cls,
{
/* bogus reply */
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_SERVER_SIGNATURE_INVALID;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_SERVER_SIGNATURE_INVALID;
break;
}
if (GNUNET_OK !=
@@ -297,16 +299,16 @@ handle_wire_finished (void *cls,
{
/* bogus reply */
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_SERVER_JSON_INVALID;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_SERVER_JSON_INVALID;
break;
}
if (NULL == (method = TALER_payto_get_method (wa->payto_uri)))
{
/* bogus reply */
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_SERVER_JSON_INVALID;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_SERVER_JSON_INVALID;
break;
}
if (NULL == (wa->fees = lookup_fee (fm,
@@ -314,8 +316,8 @@ handle_wire_finished (void *cls,
{
/* bogus reply */
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_SERVER_JSON_INVALID;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_SERVER_JSON_INVALID;
GNUNET_free (method);
break;
}
@@ -325,11 +327,9 @@ handle_wire_finished (void *cls,
(NULL != wh->cb) )
{
wh->cb (wh->cb_cls,
- response_code,
- ec,
+ &hr,
num_accounts,
- was,
- j);
+ was);
wh->cb = NULL;
}
} /* end of 'parse accounts */
@@ -340,36 +340,37 @@ handle_wire_finished (void *cls,
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (j);
+ GNUNET_break_op (0);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- (int) ec);
- GNUNET_break (0);
- response_code = 0;
+ (int) hr.ec);
break;
}
if (NULL != wh->cb)
wh->cb (wh->cb_cls,
- response_code,
- ec,
+ &hr,
0,
- NULL,
- j);
+ NULL);
TALER_EXCHANGE_wire_cancel (wh);
}
diff --git a/src/lib/exchange_api_withdraw.c b/src/lib/exchange_api_withdraw.c
index a9fe477eb..6f7928c65 100644
--- a/src/lib/exchange_api_withdraw.c
+++ b/src/lib/exchange_api_withdraw.c
@@ -116,6 +116,10 @@ reserve_withdraw_ok (struct TALER_EXCHANGE_WithdrawHandle *wh,
&blind_sig),
GNUNET_JSON_spec_end ()
};
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = json,
+ .http_status = MHD_HTTP_OK
+ };
if (GNUNET_OK !=
GNUNET_JSON_parse (json,
@@ -140,10 +144,8 @@ reserve_withdraw_ok (struct TALER_EXCHANGE_WithdrawHandle *wh,
/* signature is valid, return it to the application */
wh->cb (wh->cb_cls,
- MHD_HTTP_OK,
- TALER_EC_NONE,
- &fc.sig,
- json);
+ &hr,
+ &fc.sig);
/* make sure callback isn't called again after return */
wh->cb = NULL;
GNUNET_CRYPTO_rsa_signature_free (fc.sig.rsa_signature);
@@ -277,13 +279,16 @@ handle_reserve_withdraw_finished (void *cls,
{
struct TALER_EXCHANGE_WithdrawHandle *wh = cls;
const json_t *j = response;
- enum TALER_ErrorCode ec;
+ struct TALER_EXCHANGE_HttpResponse hr = {
+ .reply = j,
+ .http_status = (unsigned int) response_code
+ };
wh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
if (GNUNET_OK !=
@@ -291,8 +296,8 @@ handle_reserve_withdraw_finished (void *cls,
j))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_WITHDRAW_REPLY_MALFORMED;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_WITHDRAW_REPLY_MALFORMED;
break;
}
GNUNET_assert (NULL == wh->cb);
@@ -301,7 +306,8 @@ handle_reserve_withdraw_finished (void *cls,
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_CONFLICT:
/* The exchange says that the reserve has insufficient funds;
@@ -311,51 +317,53 @@ handle_reserve_withdraw_finished (void *cls,
j))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_WITHDRAW_REPLY_MALFORMED;
+ hr.http_status = 0;
+ hr.ec = TALER_EC_WITHDRAW_REPLY_MALFORMED;
}
else
{
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
}
break;
case MHD_HTTP_FORBIDDEN:
- GNUNET_break (0);
+ GNUNET_break_op (0);
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, the exchange basically just says
that it doesn't know this reserve. Can happen if we
query before the wire transfer went through.
We should simply pass the JSON reply to the application. */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (j);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (j);
+ GNUNET_break_op (0);
+ hr.ec = TALER_JSON_get_error_code (j);
+ hr.hint = TALER_JSON_get_error_hint (j);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- (int) ec);
- GNUNET_break (0);
- response_code = 0;
+ (int) hr.ec);
break;
}
if (NULL != wh->cb)
{
wh->cb (wh->cb_cls,
- response_code,
- ec,
- NULL,
- j);
+ &hr,
+ NULL);
wh->cb = NULL;
}
TALER_EXCHANGE_withdraw_cancel (wh);
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index cf645aa38..bf8117b3f 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -56,6 +56,7 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_exec_keyup.c \
testing_api_cmd_exec_transfer.c \
testing_api_cmd_exec_wirewatch.c \
+ testing_api_cmd_insert_deposit.c \
testing_api_cmd_recoup.c \
testing_api_cmd_refund.c \
testing_api_cmd_refresh.c \
@@ -69,7 +70,6 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_wait.c \
testing_api_cmd_wire.c \
testing_api_cmd_withdraw.c \
- testing_api_cmd_insert_deposit.c \
testing_api_helpers_auditor.c \
testing_api_helpers_bank.c \
testing_api_helpers_exchange.c \
diff --git a/src/testing/test_auditor_api_version.c b/src/testing/test_auditor_api_version.c
index bf1094e38..204a0d506 100644
--- a/src/testing/test_auditor_api_version.c
+++ b/src/testing/test_auditor_api_version.c
@@ -81,14 +81,17 @@ do_timeout (void *cls)
* Function called with information about the auditor.
*
* @param cls closure
+ * @param hr http response details
* @param vi basic information about the auditor
* @param compat protocol compatibility information
*/
static void
version_cb (void *cls,
+ const struct TALER_AUDITOR_HttpResponse *hr,
const struct TALER_AUDITOR_VersionInformation *vi,
enum TALER_AUDITOR_VersionCompatibility compat)
{
+ (void) hr;
if ( (NULL != vi) &&
(TALER_AUDITOR_VC_MATCH == compat) )
global_ret = 0;
diff --git a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c
index 31c6e850e..247399a9d 100644
--- a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c
+++ b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c
@@ -138,34 +138,30 @@ do_retry (void *cls)
* to check if the response code is acceptable.
*
* @param cls closure.
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
- * @param obj raw response from the auditor.
+ * @param hr HTTP response details
*/
static void
deposit_confirmation_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const json_t *obj)
+ const struct TALER_AUDITOR_HttpResponse *hr)
{
struct DepositConfirmationState *dcs = cls;
dcs->dc = NULL;
- if (dcs->expected_response_code != http_status)
+ if (dcs->expected_response_code != hr->http_status)
{
if (0 != dcs->do_retry)
{
dcs->do_retry--;
- if ( (0 == http_status) ||
- (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
- (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
+ if ( (0 == hr->http_status) ||
+ (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec) ||
+ (MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying deposit confirmation failed with %u/%d\n",
- http_status,
- (int) ec);
+ hr->http_status,
+ (int) hr->ec);
/* on DB conflicts, do not use backoff */
- if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
+ if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec)
dcs->backoff = GNUNET_TIME_UNIT_ZERO;
else
dcs->backoff = GNUNET_TIME_randomized_backoff (dcs->backoff,
@@ -179,11 +175,11 @@ deposit_confirmation_cb (void *cls,
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u to command %s in %s:%u\n",
- http_status,
+ hr->http_status,
dcs->is->commands[dcs->is->ip].label,
__FILE__,
__LINE__);
- json_dumpf (obj, stderr, 0);
+ json_dumpf (hr->reply, stderr, 0);
TALER_TESTING_interpreter_fail (dcs->is);
return;
}
@@ -310,24 +306,23 @@ deposit_confirmation_run (void *cls,
refund_deadline = timestamp;
}
}
- dcs->dc = TALER_AUDITOR_deposit_confirmation
- (dcs->auditor,
- &h_wire,
- &h_contract_terms,
- timestamp,
- refund_deadline,
- &amount_without_fee,
- &coin_pub,
- &merchant_pub,
- exchange_pub,
- exchange_sig,
- &keys->master_pub,
- spk->valid_from,
- spk->valid_until,
- spk->valid_legal,
- &spk->master_sig,
- &deposit_confirmation_cb,
- dcs);
+ dcs->dc = TALER_AUDITOR_deposit_confirmation (dcs->auditor,
+ &h_wire,
+ &h_contract_terms,
+ timestamp,
+ refund_deadline,
+ &amount_without_fee,
+ &coin_pub,
+ &merchant_pub,
+ exchange_pub,
+ exchange_sig,
+ &keys->master_pub,
+ spk->valid_from,
+ spk->valid_until,
+ spk->valid_legal,
+ &spk->master_sig,
+ &deposit_confirmation_cb,
+ dcs);
if (NULL == dcs->dc)
{
diff --git a/src/testing/testing_api_cmd_auditor_exchanges.c b/src/testing/testing_api_cmd_auditor_exchanges.c
index 17099cb89..3c77f7d82 100644
--- a/src/testing/testing_api_cmd_auditor_exchanges.c
+++ b/src/testing/testing_api_cmd_auditor_exchanges.c
@@ -127,38 +127,34 @@ do_retry (void *cls)
* Callback to analyze the /exchanges response.
*
* @param cls closure.
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
+ * @param hr HTTP response details
* @param num_exchanges length of the @a ei array
* @param ei array with information about the exchanges
- * @param raw_response raw response from the auditor.
*/
static void
exchanges_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_AUDITOR_HttpResponse *hr,
unsigned int num_exchanges,
- const struct TALER_AUDITOR_ExchangeInfo *ei,
- const json_t *raw_response)
+ const struct TALER_AUDITOR_ExchangeInfo *ei)
{
struct ExchangesState *es = cls;
es->leh = NULL;
- if (es->expected_response_code != http_status)
+ if (es->expected_response_code != hr->http_status)
{
if (0 != es->do_retry)
{
es->do_retry--;
- if ( (0 == http_status) ||
- (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
- (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
+ if ( (0 == hr->http_status) ||
+ (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec) ||
+ (MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying list exchanges failed with %u/%d\n",
- http_status,
- (int) ec);
+ hr->http_status,
+ (int) hr->ec);
/* on DB conflicts, do not use backoff */
- if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
+ if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec)
es->backoff = GNUNET_TIME_UNIT_ZERO;
else
es->backoff = GNUNET_TIME_randomized_backoff (es->backoff,
@@ -170,14 +166,16 @@ exchanges_cb (void *cls,
return;
}
}
- GNUNET_log
- (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- http_status,
- es->is->commands[es->is->ip].label,
- __FILE__,
- __LINE__);
- json_dumpf (raw_response, stderr, 0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u/%d to command %s in %s:%u\n",
+ hr->http_status,
+ (int) hr->ec,
+ es->is->commands[es->is->ip].label,
+ __FILE__,
+ __LINE__);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (es->is);
return;
}
@@ -193,9 +191,8 @@ exchanges_cb (void *cls,
found = GNUNET_YES;
if (GNUNET_NO == found)
{
- TALER_LOG_ERROR
- ("Exchange '%s' doesn't exist at this auditor\n",
- es->exchange_url);
+ TALER_LOG_ERROR ("Exchange '%s' doesn't exist at this auditor\n",
+ es->exchange_url);
TALER_TESTING_interpreter_fail (es->is);
return;
}
diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c
index fcba7f270..c11c49ac6 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -197,40 +197,36 @@ do_retry (void *cls)
* check if the response code is acceptable.
*
* @param cls closure.
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
+ * @param hr HTTP response details
* @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 obj raw response from the exchange.
*/
static void
deposit_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_ExchangeSignatureP *exchange_sig,
- const struct TALER_ExchangePublicKeyP *exchange_pub,
- const json_t *obj)
+ const struct TALER_ExchangePublicKeyP *exchange_pub)
{
struct DepositState *ds = cls;
ds->dh = NULL;
- if (ds->expected_response_code != http_status)
+ if (ds->expected_response_code != hr->http_status)
{
if (0 != ds->do_retry)
{
ds->do_retry--;
- if ( (0 == http_status) ||
- (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
- (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
+ if ( (0 == hr->http_status) ||
+ (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec) ||
+ (MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying deposit failed with %u/%d\n",
- http_status,
- (int) ec);
+ hr->http_status,
+ (int) hr->ec);
/* on DB conflicts, do not use backoff */
- if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
+ if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec)
ds->backoff = GNUNET_TIME_UNIT_ZERO;
else
ds->backoff = GNUNET_TIME_randomized_backoff (ds->backoff,
@@ -245,15 +241,17 @@ deposit_cb (void *cls,
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u to command %s in %s:%u\n",
- http_status,
+ hr->http_status,
ds->is->commands[ds->is->ip].label,
__FILE__,
__LINE__);
- json_dumpf (obj, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (ds->is);
return;
}
- if (MHD_HTTP_OK == http_status)
+ if (MHD_HTTP_OK == hr->http_status)
{
ds->deposit_succeeded = GNUNET_YES;
ds->exchange_pub = *exchange_pub;
diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c
index 8eab8f51b..fd02e75bb 100644
--- a/src/testing/testing_api_cmd_deposits_get.c
+++ b/src/testing/testing_api_cmd_deposits_get.c
@@ -80,11 +80,8 @@ struct TrackTransactionState
* line matches our expectations.
*
* @param cls closure.
- * @param http_status HTTP status code we got.
- * @param ec taler-specific error code.
+ * @param hr HTTP response details
* @param exchange_pub public key of the exchange
- * @param json original json reply (may include signatures, those
- * have then been validated already).
* @param wtid wire transfer identifier, NULL if exchange did not
* execute the transaction yet.
* @param execution_time actual or planned execution time for the
@@ -94,10 +91,8 @@ struct TrackTransactionState
*/
static void
deposit_wtid_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_ExchangePublicKeyP *exchange_pub,
- const json_t *json,
const struct TALER_WireTransferIdentifierRawP *wtid,
struct GNUNET_TIME_Absolute execution_time,
const struct TALER_Amount *coin_contribution)
@@ -108,22 +103,24 @@ deposit_wtid_cb (void *cls,
(void) coin_contribution;
(void) exchange_pub;
- (void) ec;
(void) execution_time;
tts->tth = NULL;
- if (tts->expected_response_code != http_status)
+ if (tts->expected_response_code != hr->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- http_status,
+ "Unexpected response code %u/%d to command %s in %s:%u\n",
+ hr->http_status,
+ (int) hr->ec,
cmd->label,
__FILE__,
__LINE__);
- json_dumpf (json, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (is);
return;
}
- switch (http_status)
+ switch (hr->http_status)
{
case MHD_HTTP_OK:
tts->wtid = *wtid;
@@ -133,8 +130,9 @@ deposit_wtid_cb (void *cls,
const struct TALER_WireTransferIdentifierRawP *wtid_want;
/* _this_ wire transfer subject line. */
- bank_transfer_cmd = TALER_TESTING_interpreter_lookup_command
- (is, tts->bank_transfer_reference);
+ bank_transfer_cmd
+ = TALER_TESTING_interpreter_lookup_command (is,
+ tts->bank_transfer_reference);
if (NULL == bank_transfer_cmd)
{
GNUNET_break (0);
@@ -143,8 +141,9 @@ deposit_wtid_cb (void *cls,
}
if (GNUNET_OK !=
- TALER_TESTING_get_trait_wtid
- (bank_transfer_cmd, 0, &wtid_want))
+ TALER_TESTING_get_trait_wtid (bank_transfer_cmd,
+ 0,
+ &wtid_want))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
diff --git a/src/testing/testing_api_cmd_recoup.c b/src/testing/testing_api_cmd_recoup.c
index 3bbda8e75..7c4204d9e 100644
--- a/src/testing/testing_api_cmd_recoup.c
+++ b/src/testing/testing_api_cmd_recoup.c
@@ -123,19 +123,15 @@ parse_coin_reference (const char *coin_reference,
* was paid back belonged to the right reserve.
*
* @param cls closure
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
+ * @param hr HTTP response details
* @param reserve_pub public key of the reserve receiving the recoup, NULL if refreshed or on error
* @param old_coin_pub public key of the dirty coin, NULL if not refreshed or on error
- * @param full_response raw response from the exchange.
*/
static void
recoup_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_CoinSpendPublicKeyP *old_coin_pub,
- const json_t *full_response)
+ const struct TALER_CoinSpendPublicKeyP *old_coin_pub)
{
struct RecoupState *ps = cls;
struct TALER_TESTING_Interpreter *is = ps->is;
@@ -145,15 +141,18 @@ recoup_cb (void *cls,
unsigned int idx;
ps->ph = NULL;
- if (ps->expected_response_code != http_status)
+ if (ps->expected_response_code != hr->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- http_status,
+ "Unexpected response code %u/%d to command %s in %s:%u\n",
+ hr->http_status,
+ (int) hr->ec,
cmd->label,
__FILE__,
__LINE__);
- json_dumpf (full_response, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
fprintf (stderr, "\n");
TALER_TESTING_interpreter_fail (is);
return;
@@ -179,7 +178,7 @@ recoup_cb (void *cls,
return;
}
- switch (http_status)
+ switch (hr->http_status)
{
case MHD_HTTP_OK:
/* check old_coin_pub or reserve_pub, respectively */
@@ -256,8 +255,9 @@ recoup_cb (void *cls,
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unmanaged HTTP status code %u.\n",
- http_status);
+ "Unmanaged HTTP status code %u/%d.\n",
+ hr->http_status,
+ (int) hr->ec);
break;
}
TALER_TESTING_interpreter_next (is);
diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c
index cfee28dd1..09228af82 100644
--- a/src/testing/testing_api_cmd_refresh.c
+++ b/src/testing/testing_api_cmd_refresh.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2018 Taler Systems SA
+ Copyright (C) 2018-2020 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
@@ -328,9 +328,8 @@ do_reveal_retry (void *cls)
* code is expected and copies into its command's state the data
* coming from the exchange, namely the fresh coins.
*
- * @param cls closure.
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
+ * @param cls closure, a `struct RefreshRevealState`
+ * @param hr HTTP response details
* @param num_coins number of fresh coins created, length of the
* @a sigs and @a coin_privs arrays, 0 if the operation
* failed.
@@ -338,36 +337,33 @@ do_reveal_retry (void *cls)
* coins that were created, NULL on error.
* @param sigs array of signature over @a num_coins coins,
* NULL on error.
- * @param full_response raw exchange response.
*/
static void
reveal_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int num_coins,
const struct TALER_PlanchetSecretsP *coin_privs,
- const struct TALER_DenominationSignature *sigs,
- const json_t *full_response)
+ const struct TALER_DenominationSignature *sigs)
{
struct RefreshRevealState *rrs = cls;
const struct TALER_TESTING_Command *melt_cmd;
rrs->rrh = NULL;
- if (rrs->expected_response_code != http_status)
+ if (rrs->expected_response_code != hr->http_status)
{
if (0 != rrs->do_retry)
{
rrs->do_retry--;
- if ( (0 == http_status) ||
- (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
- (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
+ if ( (0 == hr->http_status) ||
+ (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec) ||
+ (MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying refresh reveal failed with %u/%d\n",
- http_status,
- (int) ec);
+ hr->http_status,
+ (int) hr->ec);
/* on DB conflicts, do not use backoff */
- if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
+ if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec)
rrs->backoff = GNUNET_TIME_UNIT_ZERO;
else
rrs->backoff = GNUNET_TIME_randomized_backoff (rrs->backoff,
@@ -383,17 +379,19 @@ reveal_cb (void *cls,
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d to command %s in %s:%u\n",
- http_status,
- (int) ec,
+ hr->http_status,
+ (int) hr->ec,
rrs->is->commands[rrs->is->ip].label,
__FILE__,
__LINE__);
- json_dumpf (full_response, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (rrs->is);
return;
}
- melt_cmd = TALER_TESTING_interpreter_lookup_command
- (rrs->is, rrs->melt_reference);
+ melt_cmd = TALER_TESTING_interpreter_lookup_command (rrs->is,
+ rrs->melt_reference);
if (NULL == melt_cmd)
{
GNUNET_break (0);
@@ -401,7 +399,7 @@ reveal_cb (void *cls,
return;
}
rrs->num_fresh_coins = num_coins;
- switch (http_status)
+ switch (hr->http_status)
{
case MHD_HTTP_OK:
rrs->fresh_coins = GNUNET_new_array (num_coins,
@@ -435,8 +433,9 @@ reveal_cb (void *cls,
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unknown HTTP status %d\n",
- http_status);
+ "Unknown HTTP status %u/%d\n",
+ hr->http_status,
+ (int) hr->ec);
}
TALER_TESTING_interpreter_next (rrs->is);
}
@@ -560,8 +559,7 @@ do_link_retry (void *cls)
* withdrawn by the "refresh reveal" CMD.
*
* @param cls closure.
- * @param http_status HTTP response code.
- * @param ec taler-specific error code
+ * @param hr HTTP response details
* @param num_coins number of fresh coins created, length of the
* @a sigs and @a coin_privs arrays, 0 if the operation
* failed.
@@ -571,42 +569,38 @@ do_link_retry (void *cls)
* error.
* @param pubs array of public keys for the @a sigs,
* NULL on error.
- * @param full_response raw response from the exchange.
*/
static void
link_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs,
const struct TALER_DenominationSignature *sigs,
- const struct TALER_DenominationPublicKey *pubs,
- const json_t *full_response)
+ const struct TALER_DenominationPublicKey *pubs)
{
struct RefreshLinkState *rls = cls;
const struct TALER_TESTING_Command *reveal_cmd;
- struct TALER_TESTING_Command *link_cmd
- = &rls->is->commands[rls->is->ip];
+ struct TALER_TESTING_Command *link_cmd = &rls->is->commands[rls->is->ip];
unsigned int found;
const unsigned int *num_fresh_coins;
rls->rlh = NULL;
- if (rls->expected_response_code != http_status)
+ if (rls->expected_response_code != hr->http_status)
{
if (0 != rls->do_retry)
{
rls->do_retry--;
- if ( (0 == http_status) ||
- (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
- (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
+ if ( (0 == hr->http_status) ||
+ (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec) ||
+ (MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying refresh link failed with %u/%d\n",
- http_status,
- (int) ec);
+ hr->http_status,
+ (int) hr->ec);
/* on DB conflicts, do not use backoff */
- if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
+ if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec)
rls->backoff = GNUNET_TIME_UNIT_ZERO;
else
rls->backoff = GNUNET_TIME_randomized_backoff (rls->backoff,
@@ -622,18 +616,19 @@ link_cb (void *cls,
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d to command %s in %s:%u\n",
- http_status,
- (int) ec,
+ hr->http_status,
+ (int) hr->ec,
link_cmd->label,
__FILE__,
__LINE__);
- json_dumpf (full_response, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
- reveal_cmd = TALER_TESTING_interpreter_lookup_command
- (rls->is, rls->reveal_reference);
-
+ reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
+ rls->reveal_reference);
if (NULL == reveal_cmd)
{
GNUNET_break (0);
@@ -641,12 +636,14 @@ link_cb (void *cls,
return;
}
- switch (http_status)
+ switch (hr->http_status)
{
case MHD_HTTP_OK:
/* check that number of coins returned matches */
- if (GNUNET_OK != TALER_TESTING_get_trait_uint
- (reveal_cmd, 0, &num_fresh_coins))
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_uint (reveal_cmd,
+ 0,
+ &num_fresh_coins))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
@@ -666,39 +663,45 @@ link_cb (void *cls,
/* check that the coins match */
for (unsigned int i = 0; i<num_coins; i++)
for (unsigned int j = i + 1; j<num_coins; j++)
- if (0 == GNUNET_memcmp
- (&coin_privs[i], &coin_privs[j]))
+ if (0 ==
+ GNUNET_memcmp (&coin_privs[i],
+ &coin_privs[j]))
GNUNET_break (0);
/* Note: coins might be legitimately permutated in here... */
found = 0;
/* Will point to the pointer inside the cmd state. */
- const struct TALER_TESTING_FreshCoinData *fc = NULL;
-
- if (GNUNET_OK != TALER_TESTING_get_trait_fresh_coins
- (reveal_cmd, 0, &fc))
{
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (rls->is);
- return;
- }
+ const struct TALER_TESTING_FreshCoinData *fc = NULL;
- for (unsigned int i = 0; i<num_coins; i++)
- for (unsigned int j = 0; j<num_coins; j++)
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_fresh_coins (reveal_cmd,
+ 0,
+ &fc))
{
- if ( (0 == GNUNET_memcmp
- (&coin_privs[i], &fc[j].coin_priv)) &&
- (0 == GNUNET_CRYPTO_rsa_signature_cmp
- (fc[i].sig.rsa_signature,
- sigs[j].rsa_signature)) &&
- (0 == GNUNET_CRYPTO_rsa_public_key_cmp
- (fc[i].pk->key.rsa_public_key,
- pubs[j].rsa_public_key)) )
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (rls->is);
+ return;
+ }
+
+ for (unsigned int i = 0; i<num_coins; i++)
+ for (unsigned int j = 0; j<num_coins; j++)
{
- found++;
- break;
+ if ( (0 ==
+ GNUNET_memcmp (&coin_privs[i],
+ &fc[j].coin_priv)) &&
+ (0 ==
+ GNUNET_CRYPTO_rsa_signature_cmp (fc[i].sig.rsa_signature,
+ sigs[j].rsa_signature)) &&
+ (0 ==
+ GNUNET_CRYPTO_rsa_public_key_cmp (fc[i].pk->key.rsa_public_key,
+ pubs[j].rsa_public_key)) )
+ {
+ found++;
+ break;
+ }
}
- }
+ }
if (found != num_coins)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -719,8 +722,9 @@ link_cb (void *cls,
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unknown HTTP response code %u.\n",
- http_status);
+ "Unknown HTTP response code %u/%d.\n",
+ hr->http_status,
+ hr->ec);
}
TALER_TESTING_interpreter_next (rls->is);
}
@@ -746,9 +750,8 @@ refresh_link_run (void *cls,
const struct TALER_TESTING_Command *coin_cmd;
rls->is = is;
- reveal_cmd = TALER_TESTING_interpreter_lookup_command
- (rls->is, rls->reveal_reference);
-
+ reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
+ rls->reveal_reference);
if (NULL == reveal_cmd)
{
GNUNET_break (0);
@@ -756,9 +759,8 @@ refresh_link_run (void *cls,
return;
}
rrs = reveal_cmd->cls;
- melt_cmd = TALER_TESTING_interpreter_lookup_command
- (rls->is, rrs->melt_reference);
-
+ melt_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
+ rrs->melt_reference);
if (NULL == melt_cmd)
{
GNUNET_break (0);
@@ -769,8 +771,8 @@ refresh_link_run (void *cls,
/* find reserve_withdraw command */
{
rms = melt_cmd->cls;
- coin_cmd = TALER_TESTING_interpreter_lookup_command
- (rls->is, rms->coin_reference);
+ coin_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
+ rms->coin_reference);
if (NULL == coin_cmd)
{
GNUNET_break (0);
@@ -789,8 +791,10 @@ refresh_link_run (void *cls,
}
/* finally, use private key from withdraw sign command */
- rls->rlh = TALER_EXCHANGE_link
- (is->exchange, coin_priv, &link_cb, rls);
+ rls->rlh = TALER_EXCHANGE_link (is->exchange,
+ coin_priv,
+ &link_cb,
+ rls);
if (NULL == rls->rlh)
{
@@ -871,39 +875,35 @@ do_melt_retry (void *cls)
* CMD was set to do so.
*
* @param cls closure.
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
+ * @param hr HTTP response details
* @param noreveal_index choice by the exchange in the
* cut-and-choose protocol, UINT16_MAX on error.
* @param exchange_pub public key the exchange used for signing.
- * @param full_response raw response body from the exchange.
*/
static void
melt_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
uint32_t noreveal_index,
- const struct TALER_ExchangePublicKeyP *exchange_pub,
- const json_t *full_response)
+ const struct TALER_ExchangePublicKeyP *exchange_pub)
{
struct RefreshMeltState *rms = cls;
rms->rmh = NULL;
- if (rms->expected_response_code != http_status)
+ if (rms->expected_response_code != hr->http_status)
{
if (0 != rms->do_retry)
{
rms->do_retry--;
- if ( (0 == http_status) ||
- (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
- (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
+ if ( (0 == hr->http_status) ||
+ (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec) ||
+ (MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying refresh melt failed with %u/%d\n",
- http_status,
- (int) ec);
+ hr->http_status,
+ (int) hr->ec);
/* on DB conflicts, do not use backoff */
- if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
+ if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec)
rms->backoff = GNUNET_TIME_UNIT_ZERO;
else
rms->backoff = GNUNET_TIME_randomized_backoff (rms->backoff,
@@ -911,22 +911,22 @@ melt_cb (void *cls,
rms->total_backoff = GNUNET_TIME_relative_add (rms->total_backoff,
rms->backoff);
rms->is->commands[rms->is->ip].num_tries++;
- rms->retry_task = GNUNET_SCHEDULER_add_delayed
- (rms->backoff,
- &do_melt_retry,
- rms);
+ rms->retry_task = GNUNET_SCHEDULER_add_delayed (rms->backoff,
+ &do_melt_retry,
+ rms);
return;
}
}
- GNUNET_log
- (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u/%d to command %s in %s:%u\n",
- http_status,
- (int) ec,
- rms->is->commands[rms->is->ip].label,
- __FILE__,
- __LINE__);
- json_dumpf (full_response, stderr, 0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u/%d to command %s in %s:%u\n",
+ hr->http_status,
+ (int) hr->ec,
+ rms->is->commands[rms->is->ip].label,
+ __FILE__,
+ __LINE__);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
@@ -943,9 +943,11 @@ melt_cb (void *cls,
{
TALER_LOG_DEBUG ("Doubling the melt (%s)\n",
rms->is->commands[rms->is->ip].label);
- rms->rmh = TALER_EXCHANGE_melt
- (rms->is->exchange, rms->refresh_data_length,
- rms->refresh_data, &melt_cb, rms);
+ rms->rmh = TALER_EXCHANGE_melt (rms->is->exchange,
+ rms->refresh_data_length,
+ rms->refresh_data,
+ &melt_cb,
+ rms);
rms->double_melt = GNUNET_NO;
return;
}
diff --git a/src/testing/testing_api_cmd_refund.c b/src/testing/testing_api_cmd_refund.c
index 0150086e0..7dbcc3419 100644
--- a/src/testing/testing_api_cmd_refund.c
+++ b/src/testing/testing_api_cmd_refund.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2018 Taler Systems SA
+ Copyright (C) 2014-2020 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,18 +80,14 @@ struct RefundState
* response code is acceptable.
*
* @param cls closure
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
+ * @param hr HTTP response details
* @param exchange_pub public key the exchange
* used for signing @a obj.
- * @param obj response object.
*/
static void
refund_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const struct TALER_ExchangePublicKeyP *exchange_pub,
- const json_t *obj)
+ const struct TALER_EXCHANGE_HttpResponse *hr,
+ const struct TALER_ExchangePublicKeyP *exchange_pub)
{
struct RefundState *rs = cls;
@@ -99,15 +95,18 @@ refund_cb (void *cls,
refund_cmd = &rs->is->commands[rs->is->ip];
rs->rh = NULL;
- if (rs->expected_response_code != http_status)
+ if (rs->expected_response_code != hr->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- http_status,
+ "Unexpected response code %u/%d to command %s in %s:%u\n",
+ hr->http_status,
+ hr->ec,
refund_cmd->label,
__FILE__,
__LINE__);
- json_dumpf (obj, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (rs->is);
return;
}
diff --git a/src/testing/testing_api_cmd_status.c b/src/testing/testing_api_cmd_status.c
index bd93fe9b3..26c1b813b 100644
--- a/src/testing/testing_api_cmd_status.c
+++ b/src/testing/testing_api_cmd_status.c
@@ -237,9 +237,7 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
* both acceptable.
*
* @param cls closure.
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
- * @param json original JSON response from the exchange
+ * @param hr HTTP response details
* @param balance current balance in the reserve, NULL on error.
* @param history_length number of entries in the transaction
* history, 0 on error.
@@ -247,9 +245,7 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
*/
static void
reserve_status_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const json_t *json,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_Amount *balance,
unsigned int history_length,
const struct TALER_EXCHANGE_ReserveHistory *history)
@@ -259,14 +255,16 @@ reserve_status_cb (void *cls,
struct TALER_Amount eb;
ss->rsh = NULL;
- if (ss->expected_response_code != http_status)
+ if (ss->expected_response_code != hr->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected HTTP response code: %d in %s:%u\n",
- http_status,
+ hr->http_status,
__FILE__,
__LINE__);
- json_dumpf (json, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (ss->is);
return;
}
@@ -287,7 +285,9 @@ reserve_status_cb (void *cls,
{
int found[history_length];
- memset (found, 0, sizeof (found));
+ memset (found,
+ 0,
+ sizeof (found));
for (unsigned int i = 0; i<=is->ip; i++)
{
struct TALER_TESTING_Command *cmd = &is->commands[i];
diff --git a/src/testing/testing_api_cmd_transfer_get.c b/src/testing/testing_api_cmd_transfer_get.c
index 2b133188e..699313e56 100644
--- a/src/testing/testing_api_cmd_transfer_get.c
+++ b/src/testing/testing_api_cmd_transfer_get.c
@@ -44,11 +44,6 @@ struct TrackTransferState
const char *expected_wire_fee;
/**
- * Expected HTTP response code.
- */
- unsigned int expected_response_code;
-
- /**
* Reference to any operation that can provide a WTID.
* Will be the WTID to track.
*/
@@ -70,12 +65,6 @@ struct TrackTransferState
const char *total_amount_reference;
/**
- * Index to the WTID to pick, in case @a wtid_reference has
- * many on offer.
- */
- unsigned int index;
-
- /**
* Handle to a pending "track transfer" operation.
*/
struct TALER_EXCHANGE_TransfersGetHandle *tth;
@@ -84,6 +73,17 @@ struct TrackTransferState
* Interpreter state.
*/
struct TALER_TESTING_Interpreter *is;
+
+ /**
+ * Expected HTTP response code.
+ */
+ unsigned int expected_response_code;
+
+ /**
+ * Index to the WTID to pick, in case @a wtid_reference has
+ * many on offer.
+ */
+ unsigned int index;
};
@@ -120,12 +120,9 @@ track_transfer_cleanup (void *cls,
* wire fees and hashed wire details as well.
*
* @param cls closure.
- * @param http_status HTTP status code we got.
- * @param ec taler-specific error code.
+ * @param hr HTTP response details
* @param exchange_pub public key the exchange used for signing
* the response.
- * @param json original json reply (may include signatures, those
- * have then been validated already).
* @param h_wire hash of the wire transfer address the transfer
* went to, or NULL on error.
* @param execution_time time when the exchange claims to have
@@ -140,10 +137,8 @@ track_transfer_cleanup (void *cls,
*/
static void
track_transfer_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_ExchangePublicKeyP *exchange_pub,
- const json_t *json,
const struct GNUNET_HashCode *h_wire,
struct GNUNET_TIME_Absolute execution_time,
const struct TALER_Amount *total_amount,
@@ -158,20 +153,23 @@ track_transfer_cb (void *cls,
(void) exchange_pub;
tts->tth = NULL;
- if (tts->expected_response_code != http_status)
+ if (tts->expected_response_code != hr->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- http_status,
+ "Unexpected response code %u/%d to command %s in %s:%u\n",
+ hr->http_status,
+ (int) hr->ec,
cmd->label,
__FILE__,
__LINE__);
- json_dumpf (json, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (is);
return;
}
- switch (http_status)
+ switch (hr->http_status)
{
case MHD_HTTP_OK:
if (NULL == tts->expected_total_amount)
@@ -204,7 +202,9 @@ track_transfer_cb (void *cls,
cmd->label,
TALER_amount_to_string (total_amount),
TALER_amount_to_string (&expected_amount));
- json_dumpf (json, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
fprintf (stderr, "\n");
TALER_TESTING_interpreter_fail (is);
return;
@@ -225,7 +225,9 @@ track_transfer_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire fee mismatch to command %s\n",
cmd->label);
- json_dumpf (json, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (is);
return;
}
@@ -242,15 +244,15 @@ track_transfer_cb (void *cls,
const json_t *wire_details;
struct GNUNET_HashCode h_wire_details;
- if (NULL == (wire_details_cmd
- = TALER_TESTING_interpreter_lookup_command
- (is, tts->wire_details_reference)))
+ wire_details_cmd
+ = TALER_TESTING_interpreter_lookup_command (is,
+ tts->wire_details_reference);
+ if (NULL == wire_details_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
-
if (GNUNET_OK !=
TALER_TESTING_get_trait_wire_details (wire_details_cmd,
0,
@@ -260,19 +262,18 @@ track_transfer_cb (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
-
- GNUNET_assert
- (GNUNET_OK ==
- TALER_JSON_merchant_wire_signature_hash (wire_details,
- &h_wire_details));
-
+ GNUNET_assert (GNUNET_OK ==
+ TALER_JSON_merchant_wire_signature_hash (wire_details,
+ &h_wire_details));
if (0 != GNUNET_memcmp (&h_wire_details,
h_wire))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire hash missmath to command %s\n",
cmd->label);
- json_dumpf (json, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (is);
return;
}
@@ -282,15 +283,15 @@ track_transfer_cb (void *cls,
const struct TALER_TESTING_Command *total_amount_cmd;
const struct TALER_Amount *total_amount_from_reference;
- if (NULL == (total_amount_cmd
- = TALER_TESTING_interpreter_lookup_command
- (is, tts->total_amount_reference)))
+ total_amount_cmd
+ = TALER_TESTING_interpreter_lookup_command (is,
+ tts->total_amount_reference);
+ if (NULL == total_amount_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
-
if (GNUNET_OK !=
TALER_TESTING_get_trait_amount_obj (total_amount_cmd,
0,
@@ -300,14 +301,15 @@ track_transfer_cb (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
-
if (0 != TALER_amount_cmp (total_amount,
total_amount_from_reference))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Amount missmath to command %s\n",
cmd->label);
- json_dumpf (json, stderr, 0);
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
TALER_TESTING_interpreter_fail (is);
return;
}
diff --git a/src/testing/testing_api_cmd_wire.c b/src/testing/testing_api_cmd_wire.c
index c8946bb93..4d9a7192c 100644
--- a/src/testing/testing_api_cmd_wire.c
+++ b/src/testing/testing_api_cmd_wire.c
@@ -72,37 +72,31 @@ struct WireState
* that the wire fee is acceptable too.
*
* @param cls closure.
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
+ * @param hr HTTP response details
* @param accounts_len length of the @a accounts array.
* @param accounts list of wire accounts of the exchange,
* NULL on error.
- * @param full_reply the complete response from the exchange
*/
static void
wire_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int accounts_len,
- const struct TALER_EXCHANGE_WireAccount *accounts,
- const json_t *full_reply)
+ const struct TALER_EXCHANGE_WireAccount *accounts)
{
struct WireState *ws = cls;
struct TALER_TESTING_Command *cmd = &ws->is->commands[ws->is->ip];
struct TALER_Amount expected_fee;
- (void) ec;
- (void) full_reply;
TALER_LOG_DEBUG ("Checking parsed /wire response\n");
ws->wh = NULL;
- if (ws->expected_response_code != http_status)
+ if (ws->expected_response_code != hr->http_status)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (ws->is);
return;
}
- if (MHD_HTTP_OK == http_status)
+ if (MHD_HTTP_OK == hr->http_status)
{
for (unsigned int i = 0; i<accounts_len; i++)
{
@@ -115,12 +109,11 @@ wire_cb (void *cls,
ws->method_found = GNUNET_OK;
if (NULL != ws->expected_fee)
{
- GNUNET_assert
- (GNUNET_OK ==
- TALER_string_to_amount (ws->expected_fee,
- &expected_fee));
- const struct TALER_EXCHANGE_WireAggregateFees *waf;
- for (waf = accounts[i].fees;
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (ws->expected_fee,
+ &expected_fee));
+ for (const struct TALER_EXCHANGE_WireAggregateFees *waf
+ = accounts[i].fees;
NULL != waf;
waf = waf->next)
{
@@ -150,7 +143,6 @@ wire_cb (void *cls,
return;
}
}
-
TALER_TESTING_interpreter_next (ws->is);
}
diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c
index 995eca676..e277da143 100644
--- a/src/testing/testing_api_cmd_withdraw.c
+++ b/src/testing/testing_api_cmd_withdraw.c
@@ -172,42 +172,38 @@ do_retry (void *cls)
* in the state.
*
* @param cls closure.
- * @param http_status HTTP response code.
- * @param ec taler-specific error code.
+ * @param hr HTTP response details
* @param sig signature over the coin, NULL on error.
- * @param full_response raw response.
*/
static void
reserve_withdraw_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const struct TALER_DenominationSignature *sig,
- const json_t *full_response)
+ const struct TALER_EXCHANGE_HttpResponse *hr,
+ const struct TALER_DenominationSignature *sig)
{
struct WithdrawState *ws = cls;
struct TALER_TESTING_Interpreter *is = ws->is;
ws->wsh = NULL;
- if (ws->expected_response_code != http_status)
+ if (ws->expected_response_code != hr->http_status)
{
if (0 != ws->do_retry)
{
- if (TALER_EC_WITHDRAW_RESERVE_UNKNOWN != ec)
+ if (TALER_EC_WITHDRAW_RESERVE_UNKNOWN != hr->ec)
ws->do_retry--; /* we don't count reserve unknown as failures here */
- if ( (0 == http_status) ||
- (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
- (TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS == ec) ||
- (TALER_EC_WITHDRAW_RESERVE_UNKNOWN == ec) ||
- (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
+ if ( (0 == hr->http_status) ||
+ (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec) ||
+ (TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS == hr->ec) ||
+ (TALER_EC_WITHDRAW_RESERVE_UNKNOWN == hr->ec) ||
+ (MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying withdraw failed with %u/%d\n",
- http_status,
- (int) ec);
+ hr->http_status,
+ (int) hr->ec);
/* on DB conflicts, do not use backoff */
- if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
+ if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == hr->ec)
ws->backoff = GNUNET_TIME_UNIT_ZERO;
- else if (TALER_EC_WITHDRAW_RESERVE_UNKNOWN != ec)
+ else if (TALER_EC_WITHDRAW_RESERVE_UNKNOWN != hr->ec)
ws->backoff = EXCHANGE_LIB_BACKOFF (ws->backoff);
else
ws->backoff = GNUNET_TIME_relative_max (UNKNOWN_MIN_BACKOFF,
@@ -225,19 +221,19 @@ reserve_withdraw_cb (void *cls,
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d to command %s in %s:%u\n",
- http_status,
- (int) ec,
+ hr->http_status,
+ (int) hr->ec,
TALER_TESTING_interpreter_get_current_label (is),
__FILE__,
__LINE__);
- json_dumpf (full_response,
+ json_dumpf (hr->reply,
stderr,
0);
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
- switch (http_status)
+ switch (hr->http_status)
{
case MHD_HTTP_OK:
if (NULL == sig)
@@ -246,8 +242,8 @@ reserve_withdraw_cb (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
- ws->sig.rsa_signature
- = GNUNET_CRYPTO_rsa_signature_dup (sig->rsa_signature);
+ ws->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_dup (
+ sig->rsa_signature);
if (0 != ws->total_backoff.rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -270,7 +266,7 @@ reserve_withdraw_cb (void *cls,
/* Unsupported status code (by test harness) */
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Withdraw test command does not support status code %u\n",
- http_status);
+ hr->http_status);
GNUNET_break (0);
break;
}
diff --git a/src/testing/testing_api_helpers_auditor.c b/src/testing/testing_api_helpers_auditor.c
index ccfa5e24e..b74258004 100644
--- a/src/testing/testing_api_helpers_auditor.c
+++ b/src/testing/testing_api_helpers_auditor.c
@@ -101,22 +101,24 @@ struct MainWrapperContext
* Function called with information about the auditor.
*
* @param cls closure
+ * @param hr http response details
* @param vi basic information about the auditor
* @param compat protocol compatibility information
*/
static void
auditor_version_cb (void *cls,
+ const struct TALER_AUDITOR_HttpResponse *hr,
const struct TALER_AUDITOR_VersionInformation *vi,
enum TALER_AUDITOR_VersionCompatibility compat)
{
struct TALER_TESTING_Interpreter *is = cls;
+ (void) hr;
if (TALER_AUDITOR_VC_MATCH != compat)
{
TALER_TESTING_interpreter_fail (is);
return;
}
-
is->auditor_working = GNUNET_YES;
}
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index 51cd74a23..9b494da0c 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -589,49 +589,43 @@ sighandler_child_death (void)
*
* @param cls closure, typically, the "run" method containing
* all the commands to be run, and a closure for it.
+ * @param hr HTTP response details
* @param keys the exchange's keys.
* @param compat protocol compatibility information.
- * @param ec error code, #TALER_EC_NONE on success
- * @param http_status status returned by /keys, #MHD_HTTP_OK on success
- * @param full_reply JSON body of /keys request, NULL if reply was not in JSON
*/
void
TALER_TESTING_cert_cb (void *cls,
+ const struct TALER_EXCHANGE_HttpResponse *hr,
const struct TALER_EXCHANGE_Keys *keys,
- enum TALER_EXCHANGE_VersionCompatibility compat,
- enum TALER_ErrorCode ec,
- unsigned int http_status,
- const json_t *full_reply)
+ enum TALER_EXCHANGE_VersionCompatibility compat)
{
struct MainContext *main_ctx = cls;
struct TALER_TESTING_Interpreter *is = main_ctx->is;
(void) compat;
- (void) full_reply;
if (NULL == keys)
{
if (GNUNET_NO == is->working)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Got NULL response for /keys during startup (%u/%d), retrying!\n",
- http_status,
- (int) ec);
+ hr->http_status,
+ (int) hr->ec);
TALER_EXCHANGE_disconnect (is->exchange);
- GNUNET_assert
- (NULL != (is->exchange = TALER_EXCHANGE_connect
- (is->ctx,
- main_ctx->exchange_url,
- &TALER_TESTING_cert_cb,
- main_ctx,
- TALER_EXCHANGE_OPTION_END)));
+ GNUNET_assert (NULL != (is->exchange
+ = TALER_EXCHANGE_connect (is->ctx,
+ main_ctx->exchange_url,
+ &TALER_TESTING_cert_cb,
+ main_ctx,
+ TALER_EXCHANGE_OPTION_END)));
return;
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Got NULL response for /keys during execution (%u/%d)!\n",
- http_status,
- (int) ec);
+ hr->http_status,
+ (int) hr->ec);
}
}
else