diff options
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/Makefile.am | 2 | ||||
-rw-r--r-- | src/testing/test_auditor_api_version.c | 3 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_auditor_deposit_confirmation.c | 61 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_auditor_exchanges.c | 47 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_deposit.c | 32 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_deposits_get.c | 33 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_recoup.c | 28 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_refresh.c | 230 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_refund.c | 23 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_status.c | 20 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_transfer_get.c | 86 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_wire.c | 28 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_withdraw.c | 46 | ||||
-rw-r--r-- | src/testing/testing_api_helpers_auditor.c | 4 | ||||
-rw-r--r-- | src/testing/testing_api_loop.c | 32 |
15 files changed, 327 insertions, 348 deletions
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 |