fix payto URI conversion

This commit is contained in:
Christian Grothoff 2020-01-15 15:20:48 +01:00
parent da5b3ba8ae
commit e83015c8a3
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 30 additions and 25 deletions

View File

@ -260,10 +260,10 @@ TALER_FAKEBANK_check_debit (struct TALER_FAKEBANK_Handle *h,
} }
} }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Did not find matching transaction!\nI have:\n"); "Did not find matching transaction! I have:\n");
check_log (h); check_log (h);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"I wanted:\n%s -> %s (%s) from %s\n", "I wanted: %s->%s (%s) from %s\n",
want_debit, want_debit,
want_credit, want_credit,
TALER_amount2s (want_amount), TALER_amount2s (want_amount),

View File

@ -1359,16 +1359,16 @@ TALER_TESTING_cmd_track_transfer (const char *label,
* @param exchange_base_url base url of the exchange involved in * @param exchange_base_url base url of the exchange involved in
* the wire transfer. * the wire transfer.
* @param amount the amount expected to be transferred. * @param amount the amount expected to be transferred.
* @param debit_account the account that gave money. * @param debit_payto the account that gave money.
* @param credit_account the account that received money. * @param credit_payto the account that received money.
* @return the command * @return the command
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_check_bank_transfer (const char *label, TALER_TESTING_cmd_check_bank_transfer (const char *label,
const char *exchange_base_url, const char *exchange_base_url,
const char *amount, const char *amount,
const char *debit_account, const char *debit_payto,
const char *credit_account); const char *credit_payto);
/** /**

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as it under the terms of the GNU General Public License as
@ -50,12 +50,12 @@ struct BankCheckState
/** /**
* Expected debit bank account. * Expected debit bank account.
*/ */
const char *debit_account; const char *debit_payto;
/** /**
* Expected credit bank account. * Expected credit bank account.
*/ */
const char *credit_account; const char *credit_payto;
/** /**
* Binary form of the wire transfer subject. * Binary form of the wire transfer subject.
@ -89,15 +89,17 @@ check_bank_transfer_run (void *cls,
{ {
struct BankCheckState *bcs = cls; struct BankCheckState *bcs = cls;
struct TALER_Amount amount; struct TALER_Amount amount;
const char *debit_account; char *debit_account;
const char *credit_account; char *credit_account;
const char *exchange_base_url; const char *exchange_base_url;
const char *debit_payto;
const char *credit_payto;
if (NULL == bcs->deposit_reference) if (NULL == bcs->deposit_reference)
{ {
TALER_LOG_INFO ("Deposit reference NOT given\n"); TALER_LOG_INFO ("Deposit reference NOT given\n");
debit_account = bcs->debit_account; debit_payto = bcs->debit_payto;
credit_account = bcs->credit_account; credit_payto = bcs->credit_payto;
exchange_base_url = bcs->exchange_base_url; exchange_base_url = bcs->exchange_base_url;
if (GNUNET_OK != if (GNUNET_OK !=
@ -112,8 +114,7 @@ check_bank_transfer_run (void *cls,
return; return;
} }
} }
else
if (NULL != bcs->deposit_reference)
{ {
const struct TALER_TESTING_Command *deposit_cmd; const struct TALER_TESTING_Command *deposit_cmd;
const struct TALER_Amount *amount_ptr; const struct TALER_Amount *amount_ptr;
@ -138,19 +139,19 @@ check_bank_transfer_run (void *cls,
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_payto (deposit_cmd, TALER_TESTING_get_trait_payto (deposit_cmd,
TALER_TESTING_PT_DEBIT, TALER_TESTING_PT_DEBIT,
&debit_account)); &debit_payto));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_payto (deposit_cmd, TALER_TESTING_get_trait_payto (deposit_cmd,
TALER_TESTING_PT_CREDIT, TALER_TESTING_PT_CREDIT,
&credit_account)); &credit_payto));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_url (deposit_cmd, TALER_TESTING_get_trait_url (deposit_cmd,
0, /* TODO: check 0 works! */ 0, /* TODO: check 0 works! */
&exchange_base_url)); &exchange_base_url));
} }
debit_account = TALER_xtalerbank_account_from_payto (debit_payto);
credit_account = TALER_xtalerbank_account_from_payto (credit_payto);
if (GNUNET_OK != if (GNUNET_OK !=
TALER_FAKEBANK_check_debit (is->fakebank, TALER_FAKEBANK_check_debit (is->fakebank,
&amount, &amount,
@ -160,9 +161,13 @@ check_bank_transfer_run (void *cls,
&bcs->wtid)) &bcs->wtid))
{ {
GNUNET_break (0); GNUNET_break (0);
GNUNET_free (credit_account);
GNUNET_free (debit_account);
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }
GNUNET_free (credit_account);
GNUNET_free (debit_account);
TALER_TESTING_interpreter_next (is); TALER_TESTING_interpreter_next (is);
} }
@ -222,8 +227,8 @@ check_bank_transfer_traits (void *cls,
* @param exchange_base_url base url of the exchange involved in * @param exchange_base_url base url of the exchange involved in
* the wire transfer. * the wire transfer.
* @param amount the amount expected to be transferred. * @param amount the amount expected to be transferred.
* @param debit_account the account that gave money. * @param debit_payto the account that gave money.
* @param credit_account the account that received money. * @param credit_payto the account that received money.
* *
* @return the command * @return the command
*/ */
@ -232,16 +237,16 @@ TALER_TESTING_cmd_check_bank_transfer
(const char *label, (const char *label,
const char *exchange_base_url, const char *exchange_base_url,
const char *amount, const char *amount,
const char *debit_account, const char *debit_payto,
const char *credit_account) const char *credit_payto)
{ {
struct BankCheckState *bcs; struct BankCheckState *bcs;
bcs = GNUNET_new (struct BankCheckState); bcs = GNUNET_new (struct BankCheckState);
bcs->exchange_base_url = exchange_base_url; bcs->exchange_base_url = exchange_base_url;
bcs->amount = amount; bcs->amount = amount;
bcs->debit_account = debit_account; bcs->debit_payto = debit_payto;
bcs->credit_account = credit_account; bcs->credit_payto = credit_payto;
bcs->deposit_reference = NULL; bcs->deposit_reference = NULL;
{ {
struct TALER_TESTING_Command cmd = { struct TALER_TESTING_Command cmd = {