aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-11-02 06:09:12 +0100
committerChristian Grothoff <christian@grothoff.org>2024-11-05 10:37:37 +0100
commitce276176567ce728b8206dca3744be3729b7bc37 (patch)
tree9fbfc7739306b3421f001c3e5c55e2172d15b01b
parentdfa639d10c1c65ecbb6460a76714f8c22e172782 (diff)
start with testing
-rw-r--r--src/include/taler_util.h2
-rw-r--r--src/testing/testing_api_cmd_age_withdraw.c10
-rw-r--r--src/testing/testing_api_cmd_bank_admin_add_incoming.c24
-rw-r--r--src/testing/testing_api_cmd_bank_admin_add_kycauth.c16
-rw-r--r--src/testing/testing_api_cmd_bank_admin_check.c20
-rw-r--r--src/testing/testing_api_cmd_bank_check.c33
-rw-r--r--src/util/payto.c6
7 files changed, 58 insertions, 53 deletions
diff --git a/src/include/taler_util.h b/src/include/taler_util.h
index a8198e02e..994e09544 100644
--- a/src/include/taler_util.h
+++ b/src/include/taler_util.h
@@ -581,7 +581,7 @@ TALER_full_payto_normalize_and_hash (
* payto URL
*/
char *
-TALER_xtalerbank_account_from_payto (const char *payto);
+TALER_xtalerbank_account_from_payto (const struct TALER_FullPayto payto);
/**
diff --git a/src/testing/testing_api_cmd_age_withdraw.c b/src/testing/testing_api_cmd_age_withdraw.c
index 3192fc9b1..1a424fb4a 100644
--- a/src/testing/testing_api_cmd_age_withdraw.c
+++ b/src/testing/testing_api_cmd_age_withdraw.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2023 Taler Systems SA
+ Copyright (C) 2023, 2024 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
@@ -80,7 +80,7 @@ struct AgeWithdrawState
/**
* URI of the reserve we are withdrawing from.
*/
- char *reserve_payto_uri;
+ struct TALER_NormalizedPayto reserve_payto_uri;
/**
* Private key of the reserve we are withdrawing from.
@@ -151,7 +151,7 @@ struct AgeWithdrawState
* Set to the KYC requirement payto hash *if* the exchange replied with a
* request for KYC.
*/
- struct TALER_PaytoHashP h_payto;
+ struct TALER_NormalizedPaytoHashP h_payto;
/**
* Set to the KYC requirement row *if* the exchange replied with
@@ -374,7 +374,7 @@ age_withdraw_cleanup (
}
GNUNET_free (aws->coin_outputs);
GNUNET_free (aws->exchange_url);
- GNUNET_free (aws->reserve_payto_uri);
+ GNUNET_free (aws->reserve_payto_uri.normalized_payto);
GNUNET_free (aws);
}
@@ -417,7 +417,7 @@ age_withdraw_traits (
*/
TALER_TESTING_make_trait_h_blinded_coin (idx,
&aws->blinded_coin_hs[idx]),
- TALER_TESTING_make_trait_payto_uri (aws->reserve_payto_uri),
+ TALER_TESTING_make_trait_normalized_payto_uri (&aws->reserve_payto_uri),
TALER_TESTING_make_trait_exchange_url (aws->exchange_url),
TALER_TESTING_make_trait_coin_priv (idx,
&details->coin_priv),
diff --git a/src/testing/testing_api_cmd_bank_admin_add_incoming.c b/src/testing/testing_api_cmd_bank_admin_add_incoming.c
index 39550977b..005fd9c62 100644
--- a/src/testing/testing_api_cmd_bank_admin_add_incoming.c
+++ b/src/testing/testing_api_cmd_bank_admin_add_incoming.c
@@ -67,7 +67,7 @@ struct AdminAddIncomingState
/**
* Money sender payto URL.
*/
- const char *payto_debit_account;
+ struct TALER_FullPayto payto_debit_account;
/**
* Username to use for authentication.
@@ -356,7 +356,7 @@ admin_add_incoming_run (
fts->reserve_history.type = TALER_EXCHANGE_RTT_CREDIT;
fts->reserve_history.amount = fts->amount;
fts->reserve_history.details.in_details.sender_url
- = (char *) fts->payto_debit_account; /* remember to NOT free this one... */
+ = fts->payto_debit_account; /* remember to NOT free this one... */
fts->aih
= TALER_BANK_admin_add_incoming (
TALER_TESTING_interpreter_get_context (is),
@@ -422,7 +422,9 @@ admin_add_incoming_traits (void *cls,
unsigned int index)
{
struct AdminAddIncomingState *fts = cls;
- static const char *void_uri = "payto://void/the-exchange";
+ static struct TALER_FullPayto void_uri = {
+ .full_payto = (char *) "payto://void/the-exchange?receiver=name=exchange"
+ };
if (MHD_HTTP_OK !=
fts->expected_http_status)
@@ -431,10 +433,10 @@ admin_add_incoming_traits (void *cls,
{
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
- TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account),
- TALER_TESTING_make_trait_payto_uri (fts->payto_debit_account),
+ TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account),
+ TALER_TESTING_make_trait_full_payto_uri (&fts->payto_debit_account),
/* Used as a marker, content does not matter */
- TALER_TESTING_make_trait_credit_payto_uri (void_uri),
+ TALER_TESTING_make_trait_credit_payto_uri (&void_uri),
TALER_TESTING_make_trait_exchange_bank_account_url (
fts->exchange_credit_url),
TALER_TESTING_make_trait_amount (&fts->amount),
@@ -462,9 +464,9 @@ admin_add_incoming_traits (void *cls,
{
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
- TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account),
+ TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account),
/* Used as a marker, content does not matter */
- TALER_TESTING_make_trait_credit_payto_uri (void_uri),
+ TALER_TESTING_make_trait_credit_payto_uri (&void_uri),
TALER_TESTING_make_trait_exchange_bank_account_url (
fts->exchange_credit_url),
TALER_TESTING_make_trait_amount (&fts->amount),
@@ -499,7 +501,7 @@ admin_add_incoming_traits (void *cls,
static struct AdminAddIncomingState *
make_fts (const char *amount,
const struct TALER_BANK_AuthenticationData *auth,
- const char *payto_debit_account)
+ const struct TALER_FullPayto payto_debit_account)
{
struct AdminAddIncomingState *fts;
@@ -549,7 +551,7 @@ TALER_TESTING_cmd_admin_add_incoming (
const char *label,
const char *amount,
const struct TALER_BANK_AuthenticationData *auth,
- const char *payto_debit_account)
+ const struct TALER_FullPayto payto_debit_account)
{
return make_command (label,
make_fts (amount,
@@ -563,7 +565,7 @@ TALER_TESTING_cmd_admin_add_incoming_with_ref (
const char *label,
const char *amount,
const struct TALER_BANK_AuthenticationData *auth,
- const char *payto_debit_account,
+ const struct TALER_FullPayto payto_debit_account,
const char *ref,
unsigned int http_status)
{
diff --git a/src/testing/testing_api_cmd_bank_admin_add_kycauth.c b/src/testing/testing_api_cmd_bank_admin_add_kycauth.c
index 545e334dc..edacb4d90 100644
--- a/src/testing/testing_api_cmd_bank_admin_add_kycauth.c
+++ b/src/testing/testing_api_cmd_bank_admin_add_kycauth.c
@@ -55,7 +55,7 @@ struct AdminAddKycauthState
/**
* Money sender payto URL.
*/
- const char *payto_debit_account;
+ struct TALER_FullPayto payto_debit_account;
/**
* Username to use for authentication.
@@ -298,15 +298,17 @@ admin_add_kycauth_traits (void *cls,
unsigned int index)
{
struct AdminAddKycauthState *fts = cls;
- static const char *void_uri = "payto://void/the-exchange";
+ static struct TALER_FullPayto void_uri = {
+ .full_payto = (char *) "payto://void/the-exchange?receiver=name=exchange"
+ };
struct TALER_TESTING_Trait traits[] = {
/* must be first! */
TALER_TESTING_make_trait_account_priv (&fts->account_priv),
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
- TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account),
- TALER_TESTING_make_trait_payto_uri (fts->payto_debit_account),
+ TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account),
+ TALER_TESTING_make_trait_full_payto_uri (&fts->payto_debit_account),
/* Used as a marker, content does not matter */
- TALER_TESTING_make_trait_credit_payto_uri (void_uri),
+ TALER_TESTING_make_trait_credit_payto_uri (&void_uri),
TALER_TESTING_make_trait_exchange_bank_account_url (
fts->exchange_credit_url),
TALER_TESTING_make_trait_amount (&fts->amount),
@@ -340,7 +342,7 @@ admin_add_kycauth_traits (void *cls,
static struct AdminAddKycauthState *
make_fts (const char *amount,
const struct TALER_BANK_AuthenticationData *auth,
- const char *payto_debit_account,
+ const struct TALER_FullPayto payto_debit_account,
const char *account_ref)
{
struct AdminAddKycauthState *fts;
@@ -369,7 +371,7 @@ TALER_TESTING_cmd_admin_add_kycauth (
const char *label,
const char *amount,
const struct TALER_BANK_AuthenticationData *auth,
- const char *payto_debit_account,
+ const struct TALER_FullPayto payto_debit_account,
const char *account_ref)
{
struct TALER_TESTING_Command cmd = {
diff --git a/src/testing/testing_api_cmd_bank_admin_check.c b/src/testing/testing_api_cmd_bank_admin_check.c
index 6406fe2c2..096ab0f62 100644
--- a/src/testing/testing_api_cmd_bank_admin_check.c
+++ b/src/testing/testing_api_cmd_bank_admin_check.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2018-2020 Taler Systems SA
+ Copyright (C) 2018-2020, 2024 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
@@ -43,12 +43,12 @@ struct BankAdminCheckState
/**
* Expected debit bank account.
*/
- const char *debit_payto;
+ struct TALER_FullPayto debit_payto;
/**
* Expected credit bank account.
*/
- const char *credit_payto;
+ struct TALER_FullPayto credit_payto;
/**
* Command providing the reserve public key trait to use.
@@ -78,8 +78,8 @@ check_bank_admin_transfer_run (void *cls,
struct TALER_Amount amount;
char *debit_account;
char *credit_account;
- const char *debit_payto;
- const char *credit_payto;
+ struct TALER_FullPayto debit_payto;
+ struct TALER_FullPayto credit_payto;
const struct TALER_ReservePublicKeyP *reserve_pub;
const struct TALER_TESTING_Command *cmd_ref;
struct TALER_FAKEBANK_Handle *fakebank;
@@ -141,7 +141,7 @@ check_bank_admin_transfer_run (void *cls,
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_payto.full_payto,
debit_account);
if (GNUNET_OK !=
TALER_FAKEBANK_check_credit (fakebank,
@@ -191,11 +191,11 @@ check_bank_admin_transfer_cleanup (void *cls,
* @return the command
*/
struct TALER_TESTING_Command
-TALER_TESTING_cmd_check_bank_admin_transfer
- (const char *label,
+TALER_TESTING_cmd_check_bank_admin_transfer (
+ const char *label,
const char *amount,
- const char *debit_payto,
- const char *credit_payto,
+ struct TALER_FullPayto debit_payto,
+ struct TALER_FullPayto credit_payto,
const char *reserve_pub_ref)
{
struct BankAdminCheckState *bcs;
diff --git a/src/testing/testing_api_cmd_bank_check.c b/src/testing/testing_api_cmd_bank_check.c
index 77d120e09..7b61ea6e7 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-2022 Taler Systems SA
+ Copyright (C) 2018-2024 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
@@ -49,12 +49,12 @@ struct BankCheckState
/**
* Expected debit bank account.
*/
- const char *debit_payto;
+ struct TALER_FullPayto debit_payto;
/**
* Expected credit bank account.
*/
- const char *credit_payto;
+ struct TALER_FullPayto credit_payto;
/**
* Binary form of the wire transfer subject.
@@ -92,8 +92,8 @@ check_bank_transfer_run (void *cls,
char *debit_account;
char *credit_account;
const char *exchange_base_url;
- const char *debit_payto;
- const char *credit_payto;
+ const struct TALER_FullPayto *debit_payto;
+ const struct TALER_FullPayto *credit_payto;
struct TALER_FAKEBANK_Handle *fakebank;
(void) cmd;
@@ -121,8 +121,8 @@ check_bank_transfer_run (void *cls,
if (NULL == bcs->deposit_reference)
{
TALER_LOG_INFO ("Deposit reference NOT given\n");
- debit_payto = bcs->debit_payto;
- credit_payto = bcs->credit_payto;
+ debit_payto = &bcs->debit_payto;
+ credit_payto = &bcs->credit_payto;
exchange_base_url = bcs->exchange_base_url;
if (GNUNET_OK !=
@@ -167,15 +167,15 @@ check_bank_transfer_run (void *cls,
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);
+ 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_payto->full_payto,
debit_account);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"converted credit_payto (%s) to credit_account (%s)\n",
- credit_payto,
+ credit_payto->full_payto,
credit_account);
if (GNUNET_OK !=
TALER_FAKEBANK_check_debit (fakebank,
@@ -246,11 +246,12 @@ check_bank_transfer_traits (void *cls,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_check_bank_transfer (const char *label,
- const char *exchange_base_url,
- const char *amount,
- const char *debit_payto,
- const char *credit_payto)
+TALER_TESTING_cmd_check_bank_transfer (
+ const char *label,
+ const char *exchange_base_url,
+ const char *amount,
+ const struct TALER_FullPayto debit_payto,
+ const struct TALER_FullPayto credit_payto)
{
struct BankCheckState *bcs;
diff --git a/src/util/payto.c b/src/util/payto.c
index ff14dfb0e..a0034b074 100644
--- a/src/util/payto.c
+++ b/src/util/payto.c
@@ -171,21 +171,21 @@ TALER_payto_get_method (const char *payto_uri)
char *
-TALER_xtalerbank_account_from_payto (const char *payto)
+TALER_xtalerbank_account_from_payto (const struct TALER_FullPayto payto)
{
const char *host;
const char *beg;
const char *nxt;
const char *end;
- if (0 != strncasecmp (payto,
+ if (0 != strncasecmp (payto.full_payto,
PAYTO "x-taler-bank/",
strlen (PAYTO "x-taler-bank/")))
{
GNUNET_break_op (0);
return NULL;
}
- host = &payto[strlen (PAYTO "x-taler-bank/")];
+ host = &payto.full_payto[strlen (PAYTO "x-taler-bank/")];
beg = strchr (host,
'/');
if (NULL == beg)