fix ftbfs

This commit is contained in:
Christian Grothoff 2020-01-12 01:03:08 +01:00
parent 85c4aa733c
commit 9b586cd5f0
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 97 additions and 126 deletions

View File

@ -76,6 +76,7 @@ libtalerbanktesting_la_SOURCES = \
testing_api_cmd_transfer.c \ testing_api_cmd_transfer.c \
testing_api_helpers.c testing_api_helpers.c
libtalerbanktesting_la_LIBADD = \ libtalerbanktesting_la_LIBADD = \
libtalerbank.la \
$(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/json/libtalerjson.la \
-lgnunetjson \ -lgnunetjson \
-lgnunetutil \ -lgnunetutil \

View File

@ -50,14 +50,14 @@ struct AdminAddIncomingState
struct TALER_Amount amount; struct TALER_Amount amount;
/** /**
* Base URL of the debit account. * Base URL of the credited account.
*/ */
const char *debit_url; const char *exchange_credit_url;
/** /**
* Money receiver account URL. * Money sender account URL.
*/ */
const char *payto_credit_account; const char *payto_debit_account;
/** /**
* Username to use for authentication. * Username to use for authentication.
@ -120,7 +120,7 @@ struct AdminAddIncomingState
/** /**
* Was this command modified via * Was this command modified via
* #TALER_TESTING_cmd_fakebank_transfer_with_retry to * #TALER_TESTING_cmd_admin_add_incoming_with_retry to
* enable retries? * enable retries?
*/ */
int do_retry; int do_retry;
@ -135,13 +135,13 @@ struct AdminAddIncomingState
* @param is interpreter state. * @param is interpreter state.
*/ */
static void static void
fakebank_transfer_run (void *cls, admin_add_incoming_run (void *cls,
const struct TALER_TESTING_Command *cmd, const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is); struct TALER_TESTING_Interpreter *is);
/** /**
* Task scheduled to re-try #fakebank_transfer_run. * Task scheduled to re-try #admin_add_incoming_run.
* *
* @param cls a `struct AdminAddIncomingState` * @param cls a `struct AdminAddIncomingState`
*/ */
@ -151,9 +151,9 @@ do_retry (void *cls)
struct AdminAddIncomingState *fts = cls; struct AdminAddIncomingState *fts = cls;
fts->retry_task = NULL; fts->retry_task = NULL;
fakebank_transfer_run (fts, admin_add_incoming_run (fts,
NULL, NULL,
fts->is); fts->is);
} }
@ -231,9 +231,9 @@ confirmation_cb (void *cls,
* @param is interpreter state. * @param is interpreter state.
*/ */
static void static void
fakebank_transfer_run (void *cls, admin_add_incoming_run (void *cls,
const struct TALER_TESTING_Command *cmd, const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct AdminAddIncomingState *fts = cls; struct AdminAddIncomingState *fts = cls;
@ -335,11 +335,11 @@ fakebank_transfer_run (void *cls,
fts->aih fts->aih
= TALER_BANK_admin_add_incoming = TALER_BANK_admin_add_incoming
(TALER_TESTING_interpreter_get_context (is), (TALER_TESTING_interpreter_get_context (is),
fts->debit_url, fts->exchange_credit_url,
&fts->auth, &fts->auth,
&fts->reserve_pub, &fts->reserve_pub,
&fts->amount, &fts->amount,
fts->payto_credit_account, fts->payto_debit_account,
&confirmation_cb, &confirmation_cb,
fts); fts);
if (NULL == fts->aih) if (NULL == fts->aih)
@ -352,15 +352,15 @@ fakebank_transfer_run (void *cls,
/** /**
* Free the state of a "fakebank transfer" CMD, and possibly * Free the state of a "/admin/add-incoming" CMD, and possibly
* cancel a pending operation thereof. * cancel a pending operation thereof.
* *
* @param cls closure * @param cls closure
* @param cmd current CMD being cleaned up. * @param cmd current CMD being cleaned up.
*/ */
static void static void
fakebank_transfer_cleanup (void *cls, admin_add_incoming_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd) const struct TALER_TESTING_Command *cmd)
{ {
struct AdminAddIncomingState *fts = cls; struct AdminAddIncomingState *fts = cls;
@ -382,7 +382,7 @@ fakebank_transfer_cleanup (void *cls,
/** /**
* Offer internal data from a "fakebank transfer" CMD to other * Offer internal data from a "/admin/add-incoming" CMD to other
* commands. * commands.
* *
* @param cls closure. * @param cls closure.
@ -392,17 +392,16 @@ fakebank_transfer_cleanup (void *cls,
* @return #GNUNET_OK on success. * @return #GNUNET_OK on success.
*/ */
static int static int
fakebank_transfer_traits (void *cls, admin_add_incoming_traits (void *cls,
const void **ret, const void **ret,
const char *trait, const char *trait,
unsigned int index) unsigned int index)
{ {
struct AdminAddIncomingState *fts = cls; struct AdminAddIncomingState *fts = cls;
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_url (1, fts->debit_url), TALER_TESTING_make_trait_url (1, fts->payto_debit_account),
TALER_TESTING_MAKE_TRAIT_ROW_ID (&fts->serial_id), TALER_TESTING_MAKE_TRAIT_ROW_ID (&fts->serial_id),
TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT (fts->payto_credit_account), TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT (fts->exchange_credit_url),
TALER_TESTING_MAKE_TRAIT_DEBIT_ACCOUNT (fts->debit_url),
TALER_TESTING_make_trait_amount_obj (0, &fts->amount), TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp), TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
TALER_TESTING_make_trait_reserve_priv (0, TALER_TESTING_make_trait_reserve_priv (0,
@ -420,33 +419,29 @@ fakebank_transfer_traits (void *cls,
/** /**
* Create fakebank_transfer command, the subject line will be * Create admin/add-incoming command.
* derived from a randomly created reserve priv. Note that that
* reserve priv will then be offered as trait.
* *
* @param label command label. * @param label command label.
* @param amount amount to transfer. * @param amount amount to transfer.
* @param account_base_url base URL of the account that implements this * @param exchange_base_url base URL of the account that receives this
* wire transer (which account gives money). * wire transer (which account receives money).
* @param payto_credit_account which account receives money. * @param payto_debit_account which account sends money.
* @param auth_username username identifying the @a * @param auth authentication data
* debit_account_no at the bank.
* @param auth_password password for @a auth_username.
* @return the command. * @return the command.
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_fakebank_transfer TALER_TESTING_cmd_admin_add_incoming
(const char *label, (const char *label,
const char *amount, const char *amount,
const char *account_base_url, const char *exchange_base_url,
const struct TALER_BANK_AuthenticationData *auth, const struct TALER_BANK_AuthenticationData *auth,
const char *payto_credit_account) const char *payto_debit_account)
{ {
struct AdminAddIncomingState *fts; struct AdminAddIncomingState *fts;
fts = GNUNET_new (struct AdminAddIncomingState); fts = GNUNET_new (struct AdminAddIncomingState);
fts->debit_url = account_base_url; fts->exchange_credit_url = exchange_base_url;
fts->payto_credit_account = payto_credit_account; fts->payto_debit_account = payto_debit_account;
fts->auth = *auth; fts->auth = *auth;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_string_to_amount (amount, TALER_string_to_amount (amount,
@ -463,9 +458,9 @@ TALER_TESTING_cmd_fakebank_transfer
struct TALER_TESTING_Command cmd = { struct TALER_TESTING_Command cmd = {
.cls = fts, .cls = fts,
.label = label, .label = label,
.run = &fakebank_transfer_run, .run = &admin_add_incoming_run,
.cleanup = &fakebank_transfer_cleanup, .cleanup = &admin_add_incoming_cleanup,
.traits = &fakebank_transfer_traits .traits = &admin_add_incoming_traits
}; };
return cmd; return cmd;
@ -474,39 +469,34 @@ TALER_TESTING_cmd_fakebank_transfer
/** /**
* Create "fakebank transfer" CMD, letting the caller specify * Create "/admin/add-incoming" CMD, letting the caller specify
* a reference to a command that can offer a reserve private key. * a reference to a command that can offer a reserve private key.
* This private key will then be used to construct the subject line * This private key will then be used to construct the subject line
* of the wire transfer. * of the wire transfer.
* *
* @param label command label. * @param label command label.
* @param amount the amount to transfer. * @param amount the amount to transfer.
* @param bank_url base URL of the bank running the transfer. * @param account_bank_url base URL of the exchange account receiving the money
* @param debit_account_no which account (expressed as a number) * @param payto_debit_account which account sends money
* gives money. * @param auth authentication data
* @param credit_account_no which account (expressed as a number)
* receives money.
* @param auth_username username identifying the @a
* debit_account_no at the bank.
* @param auth_password password for @a auth_username.
* @param ref reference to a command that can offer a reserve * @param ref reference to a command that can offer a reserve
* private key. * private key.
* @return the command. * @return the command.
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_fakebank_transfer_with_ref TALER_TESTING_cmd_admin_add_incoming_with_ref
(const char *label, (const char *label,
const char *amount, const char *amount,
const char *account_base_url, const char *account_base_url,
const struct TALER_BANK_AuthenticationData *auth, const struct TALER_BANK_AuthenticationData *auth,
const char *payto_credit_account, const char *payto_debit_account,
const char *ref) const char *ref)
{ {
struct AdminAddIncomingState *fts; struct AdminAddIncomingState *fts;
fts = GNUNET_new (struct AdminAddIncomingState); fts = GNUNET_new (struct AdminAddIncomingState);
fts->debit_url = account_base_url; fts->exchange_credit_url = account_base_url;
fts->payto_credit_account = payto_credit_account; fts->payto_debit_account = payto_debit_account;
fts->auth = *auth; fts->auth = *auth;
fts->reserve_reference = ref; fts->reserve_reference = ref;
if (GNUNET_OK != if (GNUNET_OK !=
@ -523,9 +513,9 @@ TALER_TESTING_cmd_fakebank_transfer_with_ref
struct TALER_TESTING_Command cmd = { struct TALER_TESTING_Command cmd = {
.cls = fts, .cls = fts,
.label = label, .label = label,
.run = &fakebank_transfer_run, .run = &admin_add_incoming_run,
.cleanup = &fakebank_transfer_cleanup, .cleanup = &admin_add_incoming_cleanup,
.traits = &fakebank_transfer_traits .traits = &admin_add_incoming_traits
}; };
return cmd; return cmd;
@ -534,7 +524,7 @@ TALER_TESTING_cmd_fakebank_transfer_with_ref
/** /**
* Create "fakebank transfer" CMD, letting the caller specifying * Create "/admin/add-incoming" CMD, letting the caller specifying
* the merchant instance. This version is useful when a tip * the merchant instance. This version is useful when a tip
* reserve should be topped up, in fact the interpreter will need * reserve should be topped up, in fact the interpreter will need
* the "tipping instance" in order to get the instance public key * the "tipping instance" in order to get the instance public key
@ -542,17 +532,11 @@ TALER_TESTING_cmd_fakebank_transfer_with_ref
* *
* @param label command label. * @param label command label.
* @param amount amount to transfer. * @param amount amount to transfer.
* @param bank_url base URL of the bank that implements this * @param account_bank_url base URL of the exchange bank account
* wire transer. For simplicity, both credit and debit * that receives the wire transfer
* bank account exist at the same bank. * @param payto_debit_account which account (expressed as a number)
* @param debit_account_no which account (expressed as a number) * gives money
* gives money. * @param auth authentication data
* @param credit_account_no which account (expressed as a number)
* receives money.
*
* @param auth_username username identifying the @a
* debit_account_no at the bank.
* @param auth_password password for @a auth_username.
* @param instance the instance that runs the tipping. Under this * @param instance the instance that runs the tipping. Under this
* instance, the configuration file will provide the private * instance, the configuration file will provide the private
* key of the tipping reserve. This data will then used to * key of the tipping reserve. This data will then used to
@ -561,20 +545,20 @@ TALER_TESTING_cmd_fakebank_transfer_with_ref
* @return the command. * @return the command.
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_fakebank_transfer_with_instance TALER_TESTING_cmd_admin_add_incoming_with_instance
(const char *label, (const char *label,
const char *amount, const char *amount,
const char *account_base_url, const char *account_base_url,
const struct TALER_BANK_AuthenticationData *auth, const struct TALER_BANK_AuthenticationData *auth,
const char *payto_credit_account, const char *payto_debit_account,
const char *instance, const char *instance,
const char *config_filename) const char *config_filename)
{ {
struct AdminAddIncomingState *fts; struct AdminAddIncomingState *fts;
fts = GNUNET_new (struct AdminAddIncomingState); fts = GNUNET_new (struct AdminAddIncomingState);
fts->debit_url = account_base_url; fts->exchange_credit_url = account_base_url;
fts->payto_credit_account = payto_credit_account; fts->payto_debit_account = payto_debit_account;
fts->auth = *auth; fts->auth = *auth;
fts->instance = instance; fts->instance = instance;
fts->config_filename = config_filename; fts->config_filename = config_filename;
@ -592,9 +576,9 @@ TALER_TESTING_cmd_fakebank_transfer_with_instance
struct TALER_TESTING_Command cmd = { struct TALER_TESTING_Command cmd = {
.cls = fts, .cls = fts,
.label = label, .label = label,
.run = &fakebank_transfer_run, .run = &admin_add_incoming_run,
.cleanup = &fakebank_transfer_cleanup, .cleanup = &admin_add_incoming_cleanup,
.traits = &fakebank_transfer_traits .traits = &admin_add_incoming_traits
}; };
return cmd; return cmd;
@ -611,11 +595,11 @@ TALER_TESTING_cmd_fakebank_transfer_with_instance
* @return the command with retries enabled * @return the command with retries enabled
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_fakebank_transfer_retry (struct TALER_TESTING_Command cmd) TALER_TESTING_cmd_admin_add_incoming_retry (struct TALER_TESTING_Command cmd)
{ {
struct AdminAddIncomingState *fts; struct AdminAddIncomingState *fts;
GNUNET_assert (&fakebank_transfer_run == cmd.run); GNUNET_assert (&admin_add_incoming_run == cmd.run);
fts = cmd.cls; fts = cmd.cls;
fts->do_retry = GNUNET_YES; fts->do_retry = GNUNET_YES;
return cmd; return cmd;

View File

@ -59,13 +59,12 @@ enum BenchmarkError
#define FIRST_INSTRUCTION -1 #define FIRST_INSTRUCTION -1
#define CMD_TRANSFER_TO_EXCHANGE(label, amount) \ #define CMD_TRANSFER_TO_EXCHANGE(label, amount) \
TALER_TESTING_cmd_fakebank_transfer_retry \ TALER_TESTING_cmd_admin_add_incoming_retry \
(TALER_TESTING_cmd_fakebank_transfer (label, amount, \ (TALER_TESTING_cmd_admin_add_incoming (label, amount, \
user_bank_account.details. \ exchange_bank_account.details. \
x_taler_bank.account_base_url, \ x_taler_bank.account_base_url, \
exchange_payto_url, \ NULL, \
"dummy_user", \ user_payto_url))
"dummy_password"))
/** /**
@ -98,7 +97,7 @@ static struct TALER_Account exchange_bank_account;
/** /**
* Hold information about a user at the bank. * Hold information about a user at the bank.
*/ */
static struct TALER_Account user_bank_account; static char *user_payto_url;
/** /**
* Time snapshot taken right before executing the CMDs. * Time snapshot taken right before executing the CMDs.
@ -821,32 +820,17 @@ main (int argc,
return BAD_CLI_ARG; return BAD_CLI_ARG;
} }
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string
(cfg,
"benchmark",
"user-url",
&user_payto_url))
{ {
char *user_payto_url; GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"benchmark",
if (GNUNET_OK != "user-url");
GNUNET_CONFIGURATION_get_value_string return BAD_CONFIG_FILE;
(cfg,
"benchmark",
"user-url",
&user_payto_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"benchmark",
"user-url");
return BAD_CONFIG_FILE;
}
if (TALER_EC_NONE !=
TALER_WIRE_payto_to_account (user_payto_url,
&user_bank_account))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_ ("Malformed payto:// URL `%s' in configuration\n"),
user_payto_url);
GNUNET_free (user_payto_url);
return BAD_CONFIG_FILE;
}
GNUNET_free (user_payto_url);
} }
{ {

View File

@ -169,24 +169,26 @@ TALER_TESTING_cmd_transfer (const char *label,
const char *exchange_base_url); const char *exchange_base_url);
/* ***** Commands ONLY for testing (/admin-API) **** */
/** /**
* Create /admin/add-incoming command. * Create /admin/add-incoming command.
* *
* @param label command label. * @param label command label.
* @param amount amount to transfer. * @param amount amount to transfer.
* @param account_base_url base URL of the account that implements this * @param exchange_base_url base URL of the exchange account that receives this
* wire transer (which account gives money). * wire transer (which account receives money).
* @param payto_credit_account which account receives money. * @param payto_debit_account which account sends money.
* @param auth authentication data * @param auth authentication data
* @return the command. * @return the command.
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_admin_add_incoming (const char *label, TALER_TESTING_cmd_admin_add_incoming (const char *label,
const char *amount, const char *amount,
const char *account_base_url, const char *exchange_base_url,
const struct const struct
TALER_BANK_AuthenticationData *auth, TALER_BANK_AuthenticationData *auth,
const char *payto_credit_account); const char *payto_debit_account);
/** /**
@ -198,8 +200,8 @@ TALER_TESTING_cmd_admin_add_incoming (const char *label,
* @param label command label. * @param label command label.
* @param amount the amount to transfer. * @param amount the amount to transfer.
* @param account_base_url base URL of the account that implements this * @param account_base_url base URL of the account that implements this
* wire transer (which account gives money). * wire transer (which account receives money).
* @param payto_credit_account which account receives money. * @param payto_debit_account which account sends money.
* @param auth authentication data * @param auth authentication data
* @param ref reference to a command that can offer a reserve * @param ref reference to a command that can offer a reserve
* private key. * private key.
@ -212,7 +214,7 @@ TALER_TESTING_cmd_admin_add_incoming_with_ref (const char *label,
const struct const struct
TALER_BANK_AuthenticationData * TALER_BANK_AuthenticationData *
auth, auth,
const char *payto_credit_account, const char *payto_debit_account,
const char *ref); const char *ref);
@ -226,8 +228,8 @@ TALER_TESTING_cmd_admin_add_incoming_with_ref (const char *label,
* @param label command label. * @param label command label.
* @param amount amount to transfer. * @param amount amount to transfer.
* @param account_base_url base URL of the account that implements this * @param account_base_url base URL of the account that implements this
* wire transer (which account gives money). * wire transer (which account receives money).
* @param payto_credit_account which account receives money. * @param payto_debit_account which account sends money.
* @param auth authentication data * @param auth authentication data
* @param instance the instance that runs the tipping. Under this * @param instance the instance that runs the tipping. Under this
* instance, the configuration file will provide the private * instance, the configuration file will provide the private
@ -244,7 +246,7 @@ TALER_TESTING_cmd_admin_add_incoming_with_instance (const char *label,
TALER_BANK_AuthenticationData TALER_BANK_AuthenticationData
*auth, *auth,
const char * const char *
payto_credit_account, payto_debit_account,
const char *instance, const char *instance,
const char *config_filename); const char *config_filename);