diff options
author | priscilla <priscilla.huang@efrei.net> | 2022-11-21 08:37:38 -0500 |
---|---|---|
committer | priscilla <priscilla.huang@efrei.net> | 2022-11-21 08:37:38 -0500 |
commit | 2d358117f71fcaa13790c9c1236699ff21d9192c (patch) | |
tree | 9570b5b6a460d38f77108348e92885befdc6a65f | |
parent | 7347e629808e44679828838c108c6812eb6962b8 (diff) | |
parent | 24b919d917860e5cb2e774d44e8b80990940ba29 (diff) |
Merge branch 'master' of git+ssh://git.taler.net/merchant
-rw-r--r-- | src/testing/testing_api_cmd_post_transfers.c | 91 |
1 files changed, 36 insertions, 55 deletions
diff --git a/src/testing/testing_api_cmd_post_transfers.c b/src/testing/testing_api_cmd_post_transfers.c index 571cfb9a..dee1b183 100644 --- a/src/testing/testing_api_cmd_post_transfers.c +++ b/src/testing/testing_api_cmd_post_transfers.c @@ -55,12 +55,12 @@ struct PostTransfersState const char *merchant_url; /** - * URL of the bank to run history on (set once @e found is set). + * URL of the bank to run history on. */ char *exchange_url; /** - * Credit account of the merchant (set once @e found is set). + * Credit account of the merchant. */ char *credit_account; @@ -75,7 +75,7 @@ struct PostTransfersState struct TALER_BANK_AuthenticationData auth; /** - * Set once we discovered the WTID and thus @e found is true. + * Set once we discovered the WTID. */ struct TALER_WireTransferIdentifierRawP wtid; @@ -111,11 +111,6 @@ struct PostTransfersState unsigned int deposits_length; /** - * Set to true once @e wtid and @e exchange_url are initialized. - */ - bool found; - - /** * When the exchange executed the transfer. */ struct GNUNET_TIME_Timestamp execution_time; @@ -393,38 +388,45 @@ post_transfers_run2 (void *cls, * the bank for the debit transaction history. * * @param cls closure with a `struct PostTransfersState *` - * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request - * 0 if the bank's reply is bogus (fails to follow the protocol), - * #MHD_HTTP_NO_CONTENT if there are no more results; on success the - * last callback is always of this status (even if `abs(num_results)` were - * already returned). - * @param ec detailed error code - * @param serial_id monotonically increasing counter corresponding to the transaction - * @param details details about the wire transfer - * @param json detailed response from the HTTPD, or NULL if reply was not in JSON - * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration + * @param reply details from the HTTP response code */ -static int +static void debit_cb ( void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - uint64_t serial_id, - const struct TALER_BANK_DebitDetails *details, - const json_t *json) + const struct TALER_BANK_DebitHistoryResponse *reply) { struct PostTransfersState *pts = cls; - if (MHD_HTTP_NO_CONTENT == http_status) + pts->dhh = NULL; + switch (reply->http_status) { - pts->dhh = NULL; - if (! pts->found) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (pts->is); - return GNUNET_OK; - } - GNUNET_assert (NULL != pts->exchange_url); + case MHD_HTTP_NO_CONTENT: + GNUNET_break (0); + TALER_TESTING_interpreter_fail (pts->is); + return; + case MHD_HTTP_OK: + /* handled below */ + break; + default: + GNUNET_break (0); + TALER_TESTING_interpreter_fail (pts->is); + return; + } + for (unsigned int i = 0; i<reply->details.success.details_length; i++) + { + const struct TALER_BANK_DebitDetails *details + = &reply->details.success.details[i]; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Bank reports transfer of %s to %s\n", + TALER_amount2s (&details->amount), + details->credit_account_uri); + if (0 != TALER_amount_cmp (&pts->credit_amount, + &details->amount)) + continue; + pts->wtid = details->wtid; + pts->credit_account = GNUNET_strdup (details->credit_account_uri); + pts->exchange_url = GNUNET_strdup (details->exchange_base_url); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Bank transfer found, checking with merchant backend at %s about %s from %s to %s with %s\n", pts->merchant_url, @@ -441,29 +443,8 @@ debit_cb ( &transfers_cb, pts); GNUNET_assert (NULL != pts->pth); - return GNUNET_OK; - } - if (MHD_HTTP_OK != http_status) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (pts->is); - pts->dhh = NULL; - return GNUNET_SYSERR; + break; } - if (pts->found) - return GNUNET_OK; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Bank reports transfer of %s to %s\n", - TALER_amount2s (&details->amount), - details->credit_account_uri); - if (0 != TALER_amount_cmp (&pts->credit_amount, - &details->amount)) - return GNUNET_OK; - pts->found = true; - pts->wtid = details->wtid; - pts->credit_account = GNUNET_strdup (details->credit_account_uri); - pts->exchange_url = GNUNET_strdup (details->exchange_base_url); - return GNUNET_OK; } |