diff options
Diffstat (limited to 'src/testing/testing_api_cmd_bank_check.c')
-rw-r--r-- | src/testing/testing_api_cmd_bank_check.c | 92 |
1 files changed, 41 insertions, 51 deletions
diff --git a/src/testing/testing_api_cmd_bank_check.c b/src/testing/testing_api_cmd_bank_check.c index c01bc709f..77d120e09 100644 --- a/src/testing/testing_api_cmd_bank_check.c +++ b/src/testing/testing_api_cmd_bank_check.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2018-2020 Taler Systems SA + Copyright (C) 2018-2022 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 @@ -74,6 +74,7 @@ struct BankCheckState const char *deposit_reference; }; + /** * Run the command. * @@ -93,8 +94,30 @@ check_bank_transfer_run (void *cls, const char *exchange_base_url; const char *debit_payto; const char *credit_payto; + struct TALER_FAKEBANK_Handle *fakebank; (void) cmd; + { + const struct TALER_TESTING_Command *fakebank_cmd; + + fakebank_cmd + = TALER_TESTING_interpreter_get_command (is, + "fakebank"); + if (NULL == fakebank_cmd) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + if (GNUNET_OK != + TALER_TESTING_get_trait_fakebank (fakebank_cmd, + &fakebank)) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + } if (NULL == bcs->deposit_reference) { TALER_LOG_INFO ("Deposit reference NOT given\n"); @@ -107,9 +130,9 @@ check_bank_transfer_run (void *cls, &amount)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse amount `%s' at %u\n", + "Failed to parse amount `%s' at %s\n", bcs->amount, - is->ip); + TALER_TESTING_interpreter_get_current_label (is)); TALER_TESTING_interpreter_fail (is); return; } @@ -130,41 +153,32 @@ check_bank_transfer_run (void *cls, if (NULL == deposit_cmd) TALER_TESTING_FAIL (is); if ( (GNUNET_OK != - TALER_TESTING_get_trait_amount_obj (deposit_cmd, - 0, - &amount_ptr)) || + TALER_TESTING_get_trait_amount (deposit_cmd, + &amount_ptr)) || (GNUNET_OK != - TALER_TESTING_get_trait_payto (deposit_cmd, - TALER_TESTING_PT_DEBIT, - &debit_payto)) || + TALER_TESTING_get_trait_debit_payto_uri (deposit_cmd, + &debit_payto)) || (GNUNET_OK != - TALER_TESTING_get_trait_payto (deposit_cmd, - TALER_TESTING_PT_CREDIT, - &credit_payto)) || + TALER_TESTING_get_trait_credit_payto_uri (deposit_cmd, + &credit_payto)) || (GNUNET_OK != - TALER_TESTING_get_trait_url (deposit_cmd, - TALER_TESTING_UT_EXCHANGE_BASE_URL, - &exchange_base_url)) ) + TALER_TESTING_get_trait_exchange_url (deposit_cmd, + &exchange_base_url)) ) TALER_TESTING_FAIL (is); amount = *amount_ptr; } - - debit_account = TALER_xtalerbank_account_from_payto (debit_payto); credit_account = TALER_xtalerbank_account_from_payto (credit_payto); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "converted debit_payto (%s) to debit_account (%s)\n", debit_payto, debit_account); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "converted credit_payto (%s) to credit_account (%s)\n", credit_payto, credit_account); - if (GNUNET_OK != - TALER_FAKEBANK_check_debit (is->fakebank, + TALER_FAKEBANK_check_debit (fakebank, &amount, debit_account, credit_account, @@ -209,7 +223,7 @@ check_bank_transfer_cleanup (void *cls, * @param index index number of the object to offer. * @return #GNUNET_OK on success. */ -static int +static enum GNUNET_GenericReturnValue check_bank_transfer_traits (void *cls, const void **ret, const char *trait, @@ -218,10 +232,9 @@ check_bank_transfer_traits (void *cls, struct BankCheckState *bcs = cls; struct TALER_WireTransferIdentifierRawP *wtid_ptr = &bcs->wtid; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_wtid (0, - wtid_ptr), - TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL, - bcs->exchange_base_url), + TALER_TESTING_make_trait_wtid (wtid_ptr), + TALER_TESTING_make_trait_exchange_url ( + bcs->exchange_base_url), TALER_TESTING_trait_end () }; @@ -232,19 +245,6 @@ check_bank_transfer_traits (void *cls, } -/** - * Make a "bank check" CMD. It checks whether a - * particular wire transfer has been made or not. - * - * @param label the command label. - * @param exchange_base_url base url of the exchange involved in - * the wire transfer. - * @param amount the amount expected to be transferred. - * @param debit_payto the account that gave money. - * @param credit_payto the account that received money. - * - * @return the command - */ struct TALER_TESTING_Command TALER_TESTING_cmd_check_bank_transfer (const char *label, const char *exchange_base_url, @@ -274,19 +274,9 @@ TALER_TESTING_cmd_check_bank_transfer (const char *label, } -/** - * Define a "bank check" CMD that takes the input - * data from another CMD that offers it. - * - * @param label command label. - * @param deposit_reference reference to a CMD that is - * able to provide the "check bank transfer" operation - * input data. - * @return the command. - */ struct TALER_TESTING_Command -TALER_TESTING_cmd_check_bank_transfer_with_ref - (const char *label, +TALER_TESTING_cmd_check_bank_transfer_with_ref ( + const char *label, const char *deposit_reference) { struct BankCheckState *bcs; |