refactor to make it easier to share init logic for test configurations
This commit is contained in:
parent
6b0c121fc9
commit
d842c14f85
@ -35,7 +35,6 @@
|
|||||||
#include "taler_bank_service.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
#include "taler_error_codes.h"
|
#include "taler_error_codes.h"
|
||||||
|
|
||||||
/* Error codes. */
|
/* Error codes. */
|
||||||
@ -94,6 +93,11 @@ enum BenchmarkMode
|
|||||||
*/
|
*/
|
||||||
static struct TALER_Account exchange_bank_account;
|
static struct TALER_Account exchange_bank_account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration of our exchange.
|
||||||
|
*/
|
||||||
|
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hold information about a user at the bank.
|
* Hold information about a user at the bank.
|
||||||
*/
|
*/
|
||||||
@ -318,7 +322,7 @@ run (void *cls,
|
|||||||
withdraw_label,
|
withdraw_label,
|
||||||
0, /* Index of the one withdrawn coin in the traits. */
|
0, /* Index of the one withdrawn coin in the traits. */
|
||||||
TALER_TESTING_make_wire_details
|
TALER_TESTING_make_wire_details
|
||||||
(TALER_TESTING_USER_ACCOUNT_NUMBER,
|
(42 /* FIXME: ugly! */,
|
||||||
exchange_bank_account.details.x_taler_bank.hostname),
|
exchange_bank_account.details.x_taler_bank.hostname),
|
||||||
order_enc,
|
order_enc,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
@ -435,14 +439,12 @@ launch_fakebank (void *cls)
|
|||||||
* @param main_cb main function to run per process
|
* @param main_cb main function to run per process
|
||||||
* @param main_cb_cls closure for @a main_cb
|
* @param main_cb_cls closure for @a main_cb
|
||||||
* @param config_file configuration file to use
|
* @param config_file configuration file to use
|
||||||
* @param exchange_url exchange URL to use
|
|
||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
parallel_benchmark (TALER_TESTING_Main main_cb,
|
parallel_benchmark (TALER_TESTING_Main main_cb,
|
||||||
void *main_cb_cls,
|
void *main_cb_cls,
|
||||||
const char *config_file,
|
const char *config_file)
|
||||||
const char *exchange_url)
|
|
||||||
{
|
{
|
||||||
int result = GNUNET_OK;
|
int result = GNUNET_OK;
|
||||||
pid_t cpids[howmany_clients];
|
pid_t cpids[howmany_clients];
|
||||||
@ -556,11 +558,11 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
|
|||||||
|
|
||||||
/* We always wait for the exchange, no matter if it's running locally or
|
/* We always wait for the exchange, no matter if it's running locally or
|
||||||
remotely */
|
remotely */
|
||||||
if (0 != TALER_TESTING_wait_exchange_ready (exchange_url))
|
if (0 != TALER_TESTING_wait_exchange_ready (ec.exchange_url))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Failed to detect running exchange at `%s'\n",
|
"Failed to detect running exchange at `%s'\n",
|
||||||
exchange_url);
|
ec.exchange_url);
|
||||||
GNUNET_OS_process_kill (exchanged,
|
GNUNET_OS_process_kill (exchanged,
|
||||||
SIGTERM);
|
SIGTERM);
|
||||||
if ( (MODE_BOTH == mode) || (MODE_CLIENT == mode))
|
if ( (MODE_BOTH == mode) || (MODE_CLIENT == mode))
|
||||||
@ -719,8 +721,6 @@ int
|
|||||||
main (int argc,
|
main (int argc,
|
||||||
char *const *argv)
|
char *const *argv)
|
||||||
{
|
{
|
||||||
char *exchange_url = NULL;
|
|
||||||
char *auditor_url = NULL;
|
|
||||||
struct GNUNET_CONFIGURATION_Handle *cfg;
|
struct GNUNET_CONFIGURATION_Handle *cfg;
|
||||||
struct GNUNET_GETOPT_CommandLineOption options[] = {
|
struct GNUNET_GETOPT_CommandLineOption options[] = {
|
||||||
GNUNET_GETOPT_option_mandatory
|
GNUNET_GETOPT_option_mandatory
|
||||||
@ -836,11 +836,9 @@ main (int argc,
|
|||||||
{
|
{
|
||||||
const char *bank_details_section;
|
const char *bank_details_section;
|
||||||
|
|
||||||
GNUNET_CONFIGURATION_iterate_sections
|
GNUNET_CONFIGURATION_iterate_sections (cfg,
|
||||||
(cfg,
|
&pick_exchange_account_cb,
|
||||||
&pick_exchange_account_cb,
|
&bank_details_section);
|
||||||
&bank_details_section);
|
|
||||||
|
|
||||||
if (NULL == bank_details_section)
|
if (NULL == bank_details_section)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
@ -903,11 +901,9 @@ main (int argc,
|
|||||||
GNUNET_OS_process_wait (compute_wire_response);
|
GNUNET_OS_process_wait (compute_wire_response);
|
||||||
GNUNET_OS_process_destroy (compute_wire_response);
|
GNUNET_OS_process_destroy (compute_wire_response);
|
||||||
|
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_prepare_exchange
|
TALER_TESTING_prepare_exchange (cfg_filename,
|
||||||
(cfg_filename,
|
&ec));
|
||||||
&auditor_url,
|
|
||||||
&exchange_url));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -915,7 +911,7 @@ main (int argc,
|
|||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
"exchange",
|
"exchange",
|
||||||
"BASE_URL",
|
"BASE_URL",
|
||||||
&exchange_url))
|
&ec.exchange_url))
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"exchange",
|
"exchange",
|
||||||
@ -950,16 +946,11 @@ main (int argc,
|
|||||||
return BAD_CONFIG_FILE;
|
return BAD_CONFIG_FILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
|
|
||||||
result = parallel_benchmark (&run,
|
result = parallel_benchmark (&run,
|
||||||
NULL,
|
NULL,
|
||||||
cfg_filename,
|
cfg_filename);
|
||||||
exchange_url);
|
|
||||||
|
|
||||||
GNUNET_free_non_null (exchange_url);
|
|
||||||
GNUNET_free_non_null (auditor_url);
|
|
||||||
|
|
||||||
/* If we're the exchange worker, we're done now. No need to print results */
|
/* If we're the exchange worker, we're done now. No need to print results */
|
||||||
if (MODE_EXCHANGE == mode)
|
if (MODE_EXCHANGE == mode)
|
||||||
|
@ -30,8 +30,7 @@ talerinclude_HEADERS = \
|
|||||||
taler_util.h \
|
taler_util.h \
|
||||||
taler_mhd_lib.h \
|
taler_mhd_lib.h \
|
||||||
taler_pq_lib.h \
|
taler_pq_lib.h \
|
||||||
taler_signatures.h \
|
taler_signatures.h
|
||||||
taler_testing_bank_lib.h
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,266 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of TALER
|
|
||||||
(C) 2018-2020 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 the Free Software Foundation; either version 3, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
TALER is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public
|
|
||||||
License along with TALER; see the file COPYING. If not, see
|
|
||||||
<http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file include/taler_testing_bank_lib.h
|
|
||||||
* @brief API for writing test cases to test banks.
|
|
||||||
* @author Marcello Stanisci
|
|
||||||
*/
|
|
||||||
#ifndef TALER_TESTING_BANK_LIB_H
|
|
||||||
#define TALER_TESTING_BANK_LIB_H
|
|
||||||
|
|
||||||
#include "taler_util.h"
|
|
||||||
#include <gnunet/gnunet_json_lib.h>
|
|
||||||
#include "taler_json_lib.h"
|
|
||||||
#include <microhttpd.h>
|
|
||||||
#include "taler_bank_service.h"
|
|
||||||
#include "taler_testing_lib.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* ******** Credentials to log in at the bank ******* */
|
|
||||||
|
|
||||||
/* Note that the same passwords must be set in the script in
|
|
||||||
contrib/taler-bank-manage-testing for the tests to work! */
|
|
||||||
#define TALER_TESTING_BANK_ACCOUNT_NUMBER 1
|
|
||||||
#define TALER_TESTING_BANK_USERNAME "Bank"
|
|
||||||
#define TALER_TESTING_BANK_PASSWORD "x"
|
|
||||||
#define TALER_TESTING_EXCHANGE_ACCOUNT_NUMBER 2
|
|
||||||
#define TALER_TESTING_EXCHANGE_USERNAME "Exchange"
|
|
||||||
#define TALER_TESTING_EXCHANGE_PASSWORD "x"
|
|
||||||
#define TALER_TESTING_USER_ACCOUNT_NUMBER 3
|
|
||||||
#define TALER_TESTING_USER_USERNAME "Tor"
|
|
||||||
#define TALER_TESTING_USER_PASSWORD "x"
|
|
||||||
|
|
||||||
|
|
||||||
/* ********************* Helper functions ********************* */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start the (Python) bank process. Assume the port
|
|
||||||
* is available and the database is clean. Use the "prepare
|
|
||||||
* bank" function to do such tasks.
|
|
||||||
*
|
|
||||||
* @param config_filename configuration filename.
|
|
||||||
* @param bank_url base URL of the bank, used by `wget' to check
|
|
||||||
* that the bank was started right.
|
|
||||||
*
|
|
||||||
* @return the process, or NULL if the process could not
|
|
||||||
* be started.
|
|
||||||
*/
|
|
||||||
struct GNUNET_OS_Process *
|
|
||||||
TALER_TESTING_run_bank (const char *config_filename,
|
|
||||||
const char *bank_url);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs the Fakebank by guessing / extracting the portnumber
|
|
||||||
* from the base URL.
|
|
||||||
*
|
|
||||||
* @param bank_url bank's base URL.
|
|
||||||
* @return the fakebank process handle, or NULL if any
|
|
||||||
* error occurs.
|
|
||||||
*/
|
|
||||||
struct TALER_FAKEBANK_Handle *
|
|
||||||
TALER_TESTING_run_fakebank (const char *bank_url);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare the bank execution. Check if the port is available
|
|
||||||
* and reset database.
|
|
||||||
*
|
|
||||||
* @param config_filename configuration file name.
|
|
||||||
*
|
|
||||||
* @return the base url, or NULL upon errors. Must be freed
|
|
||||||
* by the caller.
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
TALER_TESTING_prepare_bank (const char *config_filename);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Look for substring in a programs' name.
|
|
||||||
*
|
|
||||||
* @param prog program's name to look into
|
|
||||||
* @param marker chunk to find in @a prog
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
TALER_TESTING_has_in_name (const char *prog,
|
|
||||||
const char *marker);
|
|
||||||
|
|
||||||
/* ************** Specific interpreter commands ************ */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make a credit "history" CMD.
|
|
||||||
*
|
|
||||||
* @param label command label.
|
|
||||||
* @param account_url base URL of the account offering the "history"
|
|
||||||
* operation.
|
|
||||||
* @param auth login data to use
|
|
||||||
* @param start_row_reference reference to a command that can
|
|
||||||
* offer a row identifier, to be used as the starting row
|
|
||||||
* to accept in the result.
|
|
||||||
* @param num_results how many rows we want in the result,
|
|
||||||
* and ascending/descending call
|
|
||||||
* @return the command.
|
|
||||||
*/
|
|
||||||
struct TALER_TESTING_Command
|
|
||||||
TALER_TESTING_cmd_bank_credits (const char *label,
|
|
||||||
const char *account_url,
|
|
||||||
const struct
|
|
||||||
TALER_BANK_AuthenticationData *auth,
|
|
||||||
const char *start_row_reference,
|
|
||||||
long long num_results);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make a debit "history" CMD.
|
|
||||||
*
|
|
||||||
* @param label command label.
|
|
||||||
* @param account_url base URL of the account offering the "history"
|
|
||||||
* operation.
|
|
||||||
* @param auth authentication data
|
|
||||||
* @param start_row_reference reference to a command that can
|
|
||||||
* offer a row identifier, to be used as the starting row
|
|
||||||
* to accept in the result.
|
|
||||||
* @param num_results how many rows we want in the result.
|
|
||||||
* @return the command.
|
|
||||||
*/
|
|
||||||
struct TALER_TESTING_Command
|
|
||||||
TALER_TESTING_cmd_bank_debits (const char *label,
|
|
||||||
const char *account_url,
|
|
||||||
const struct TALER_BANK_AuthenticationData *auth,
|
|
||||||
const char *start_row_reference,
|
|
||||||
long long num_results);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create transfer command.
|
|
||||||
*
|
|
||||||
* @param label command label.
|
|
||||||
* @param amount amount to transfer.
|
|
||||||
* @param account_base_url base URL of the account that implements this
|
|
||||||
* wire transer (which account gives money).
|
|
||||||
* @param auth authentication data to use
|
|
||||||
* @param payto_credit_account which account receives money.
|
|
||||||
* @param wtid wire transfer identifier to use
|
|
||||||
* @param exchange_base_url exchange URL to use
|
|
||||||
* @return the command.
|
|
||||||
*/
|
|
||||||
struct TALER_TESTING_Command
|
|
||||||
TALER_TESTING_cmd_transfer (const char *label,
|
|
||||||
const char *amount,
|
|
||||||
const char *account_base_url,
|
|
||||||
const struct TALER_BANK_AuthenticationData *auth,
|
|
||||||
const char *payto_credit_account,
|
|
||||||
const struct TALER_WireTransferIdentifierRawP *wtid,
|
|
||||||
const char *exchange_base_url);
|
|
||||||
|
|
||||||
|
|
||||||
/* ***** Commands ONLY for testing (/admin-API) **** */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create /admin/add-incoming command.
|
|
||||||
*
|
|
||||||
* @param label command label.
|
|
||||||
* @param amount amount to transfer.
|
|
||||||
* @param exchange_base_url base URL of the exchange account that receives this
|
|
||||||
* wire transer (which account receives money).
|
|
||||||
* @param payto_debit_account which account sends money.
|
|
||||||
* @param auth authentication data
|
|
||||||
* @return the command.
|
|
||||||
*/
|
|
||||||
struct TALER_TESTING_Command
|
|
||||||
TALER_TESTING_cmd_admin_add_incoming (const char *label,
|
|
||||||
const char *amount,
|
|
||||||
const char *exchange_base_url,
|
|
||||||
const struct
|
|
||||||
TALER_BANK_AuthenticationData *auth,
|
|
||||||
const char *payto_debit_account);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create "fakebank transfer" CMD, letting the caller specify
|
|
||||||
* a reference to a command that can offer a reserve private key.
|
|
||||||
* This private key will then be used to construct the subject line
|
|
||||||
* of the wire transfer.
|
|
||||||
*
|
|
||||||
* @param label command label.
|
|
||||||
* @param amount the amount to transfer.
|
|
||||||
* @param account_base_url base URL of the account that implements this
|
|
||||||
* wire transer (which account receives money).
|
|
||||||
* @param payto_debit_account which account sends money.
|
|
||||||
* @param auth authentication data
|
|
||||||
* @param ref reference to a command that can offer a reserve
|
|
||||||
* private key.
|
|
||||||
* @return the command.
|
|
||||||
*/
|
|
||||||
struct TALER_TESTING_Command
|
|
||||||
TALER_TESTING_cmd_admin_add_incoming_with_ref (const char *label,
|
|
||||||
const char *amount,
|
|
||||||
const char *account_base_url,
|
|
||||||
const struct
|
|
||||||
TALER_BANK_AuthenticationData *
|
|
||||||
auth,
|
|
||||||
const char *payto_debit_account,
|
|
||||||
const char *ref);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create "fakebank transfer" CMD, letting the caller specifying
|
|
||||||
* the merchant instance. This version is useful when a tip
|
|
||||||
* reserve should be topped up, in fact the interpreter will need
|
|
||||||
* the "tipping instance" in order to get the instance public key
|
|
||||||
* and make a wire transfer subject out of it.
|
|
||||||
*
|
|
||||||
* @param label command label.
|
|
||||||
* @param amount amount to transfer.
|
|
||||||
* @param account_base_url base URL of the account that implements this
|
|
||||||
* wire transer (which account receives money).
|
|
||||||
* @param payto_debit_account which account sends money.
|
|
||||||
* @param auth authentication data
|
|
||||||
* @param instance the instance that runs the tipping. Under this
|
|
||||||
* instance, the configuration file will provide the private
|
|
||||||
* key of the tipping reserve. This data will then used to
|
|
||||||
* construct the wire transfer subject line.
|
|
||||||
* @param config_filename configuration file to use.
|
|
||||||
* @return the command.
|
|
||||||
*/
|
|
||||||
struct TALER_TESTING_Command
|
|
||||||
TALER_TESTING_cmd_admin_add_incoming_with_instance (const char *label,
|
|
||||||
const char *amount,
|
|
||||||
const char *account_base_url,
|
|
||||||
const struct
|
|
||||||
TALER_BANK_AuthenticationData
|
|
||||||
*auth,
|
|
||||||
const char *
|
|
||||||
payto_debit_account,
|
|
||||||
const char *instance,
|
|
||||||
const char *config_filename);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modify a fakebank transfer command to enable retries when the
|
|
||||||
* reserve is not yet full or we get other transient errors from
|
|
||||||
* the fakebank.
|
|
||||||
*
|
|
||||||
* @param cmd a fakebank transfer command
|
|
||||||
* @return the command with retries enabled
|
|
||||||
*/
|
|
||||||
struct TALER_TESTING_Command
|
|
||||||
TALER_TESTING_cmd_admin_add_incoming_retry (struct TALER_TESTING_Command cmd);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -30,6 +30,8 @@
|
|||||||
#include "taler_exchange_service.h"
|
#include "taler_exchange_service.h"
|
||||||
#include <gnunet/gnunet_json_lib.h>
|
#include <gnunet/gnunet_json_lib.h>
|
||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_bank_service.h"
|
||||||
|
#include "taler_wire_lib.h"
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
|
|
||||||
|
|
||||||
@ -55,33 +57,46 @@
|
|||||||
TALER_TESTING_make_trait_uint64 (3, data)
|
TALER_TESTING_make_trait_uint64 (3, data)
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME: replace these!
|
||||||
#define TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT(cmd,out) \
|
#define TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT(cmd,out) \
|
||||||
TALER_TESTING_get_trait_string (cmd, 4, out)
|
TALER_TESTING_get_trait_string (cmd, 4, out)
|
||||||
|
|
||||||
|
// FIXME: replace these!
|
||||||
#define TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT(data) \
|
#define TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT(data) \
|
||||||
TALER_TESTING_make_trait_string (4, data)
|
TALER_TESTING_make_trait_string (4, data)
|
||||||
|
|
||||||
|
// FIXME: replace these!
|
||||||
#define TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT(cmd,out) \
|
#define TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT(cmd,out) \
|
||||||
TALER_TESTING_get_trait_string (cmd, 5, out)
|
TALER_TESTING_get_trait_string (cmd, 5, out)
|
||||||
|
|
||||||
|
// FIXME: replace these!
|
||||||
#define TALER_TESTING_MAKE_TRAIT_DEBIT_ACCOUNT(data) \
|
#define TALER_TESTING_MAKE_TRAIT_DEBIT_ACCOUNT(data) \
|
||||||
TALER_TESTING_make_trait_string (5, data)
|
TALER_TESTING_make_trait_string (5, data)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an x-taler-bank payto:// URL from a @a bank_url
|
||||||
|
* and an @a account_name.
|
||||||
|
*
|
||||||
|
* @param bank_url the bank URL
|
||||||
|
* @param account_name the account name
|
||||||
|
* @return payto:// URL
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
TALER_TESTING_make_xtalerbank_payto (const char *bank_url,
|
||||||
|
const char *account_name);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate and return a piece of wire-details. Combines
|
* Allocate and return a piece of wire-details. Combines
|
||||||
* the @a account_no and the @a bank_url to a
|
* a @a payto -URL and adds some salt to create the JSON.
|
||||||
* @a payto://-URL and adds some salt to create the JSON.
|
|
||||||
*
|
|
||||||
* @param account_no account number
|
|
||||||
* @param bank_url the bank_url
|
|
||||||
*
|
*
|
||||||
|
* @param payto payto://-URL to encapsulate
|
||||||
* @return JSON describing the account, including the
|
* @return JSON describing the account, including the
|
||||||
* payto://-URL of the account, must be manually decref'd
|
* payto://-URL of the account, must be manually decref'd
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_TESTING_make_wire_details (unsigned long long account_no,
|
TALER_TESTING_make_wire_details (const char *payto);
|
||||||
const char *bank_url);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,6 +111,28 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,
|
|||||||
const struct TALER_Amount *amount);
|
const struct TALER_Amount *amount);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration data for an exchange.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_ExchangeConfiguration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Exchange base URL as it appears in the configuration. Note
|
||||||
|
* that it might differ from the one where the exchange actually
|
||||||
|
* listens from.
|
||||||
|
*/
|
||||||
|
char *exchange_url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auditor base URL as it appears in the configuration. Note
|
||||||
|
* that it might differ from the one where the auditor actually
|
||||||
|
* listens from.
|
||||||
|
*/
|
||||||
|
char *auditor_url;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare launching an exchange. Checks that the configured
|
* Prepare launching an exchange. Checks that the configured
|
||||||
* port is available, runs taler-exchange-keyup,
|
* port is available, runs taler-exchange-keyup,
|
||||||
@ -103,19 +140,14 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,
|
|||||||
* launch the exchange process itself.
|
* launch the exchange process itself.
|
||||||
*
|
*
|
||||||
* @param config_filename configuration file to use
|
* @param config_filename configuration file to use
|
||||||
* @param auditor_base_url[out] will be set to the auditor base url,
|
* @param ec[out] will be set to the exchange configuration data
|
||||||
* if the config has any; otherwise it will be set to
|
|
||||||
* NULL.
|
|
||||||
* @param exchange_base_url[out] will be set to the exchange base url,
|
|
||||||
* if the config has any; otherwise it will be set to
|
|
||||||
* NULL.
|
|
||||||
* @return #GNUNET_OK on success, #GNUNET_NO if test should be
|
* @return #GNUNET_OK on success, #GNUNET_NO if test should be
|
||||||
* skipped, #GNUNET_SYSERR on test failure
|
* skipped, #GNUNET_SYSERR on test failure
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_prepare_exchange (const char *config_filename,
|
TALER_TESTING_prepare_exchange (const char *config_filename,
|
||||||
char **auditor_base_url,
|
struct TALER_TESTING_ExchangeConfiguration *ec);
|
||||||
char **exchange_base_url);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Canonical" cert_cb used when we are connecting to the
|
* "Canonical" cert_cb used when we are connecting to the
|
||||||
@ -245,24 +277,67 @@ TALER_TESTING_run_auditor_exchange (const char *config_filename,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test port in URL string for availability.
|
* Test port in URL string for availability.
|
||||||
|
*
|
||||||
|
* @param url URL to extract port from, 80 is default
|
||||||
|
* @return #GNUNET_OK if the port is free
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_url_port_free (const char *url);
|
TALER_TESTING_url_port_free (const char *url);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration data for a bank.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_BankConfiguration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bank base URL.
|
||||||
|
*/
|
||||||
|
char *bank_url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base URL of the exchange's bank account. Basically
|
||||||
|
* @e bank_url plus the exchange account.
|
||||||
|
*/
|
||||||
|
char *exchange_account_url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authentication data for the exchange user at the bank.
|
||||||
|
*/
|
||||||
|
struct TALER_BANK_AuthenticationData exchange_auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Payto URL of the exchange's account ("2")
|
||||||
|
*/
|
||||||
|
char *exchange_payto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Payto URL of a user account ("42")
|
||||||
|
*/
|
||||||
|
char *user42_payto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Payto URL of another user's account ("43")
|
||||||
|
*/
|
||||||
|
char *user43_payto;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare launching a fakebank. Check that the configuration
|
* Prepare launching a fakebank. Check that the configuration
|
||||||
* file has the right option, and that the port is avaiable.
|
* file has the right option, and that the port is avaiable.
|
||||||
* If everything is OK, return the configured URL of the fakebank.
|
* If everything is OK, return the configuration data of the fakebank.
|
||||||
*
|
*
|
||||||
* @param config_filename configuration file to use
|
* @param config_filename configuration file to use
|
||||||
* @param config_section which account to use
|
* @param config_section which account to use
|
||||||
* (must match x-taler-bank)
|
* (must match x-taler-bank)
|
||||||
* @return NULL on error, fakebank URL otherwise
|
* @param bc[out] set to the bank's configuration data
|
||||||
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
char *
|
int
|
||||||
TALER_TESTING_prepare_fakebank (const char *config_filename,
|
TALER_TESTING_prepare_fakebank (const char *config_filename,
|
||||||
const char *config_section);
|
const char *config_section,
|
||||||
|
struct TALER_TESTING_BankConfiguration *bc);
|
||||||
|
|
||||||
|
|
||||||
/* ******************* Generic interpreter logic ************ */
|
/* ******************* Generic interpreter logic ************ */
|
||||||
@ -707,9 +782,223 @@ TALER_TESTING_setup_with_auditor_and_exchange (TALER_TESTING_Main main_cb,
|
|||||||
void *main_cb_cls,
|
void *main_cb_cls,
|
||||||
const char *config_file);
|
const char *config_file);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the (Python) bank process. Assume the port
|
||||||
|
* is available and the database is clean. Use the "prepare
|
||||||
|
* bank" function to do such tasks.
|
||||||
|
*
|
||||||
|
* @param config_filename configuration filename.
|
||||||
|
* @param bank_url base URL of the bank, used by `wget' to check
|
||||||
|
* that the bank was started right.
|
||||||
|
*
|
||||||
|
* @return the process, or NULL if the process could not
|
||||||
|
* be started.
|
||||||
|
*/
|
||||||
|
struct GNUNET_OS_Process *
|
||||||
|
TALER_TESTING_run_bank (const char *config_filename,
|
||||||
|
const char *bank_url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the Fakebank by guessing / extracting the portnumber
|
||||||
|
* from the base URL.
|
||||||
|
*
|
||||||
|
* @param bank_url bank's base URL.
|
||||||
|
* @return the fakebank process handle, or NULL if any
|
||||||
|
* error occurs.
|
||||||
|
*/
|
||||||
|
struct TALER_FAKEBANK_Handle *
|
||||||
|
TALER_TESTING_run_fakebank (const char *bank_url);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the bank execution. Check if the port is available
|
||||||
|
* and reset database.
|
||||||
|
*
|
||||||
|
* @param config_filename configuration file name.
|
||||||
|
* @param bc[out] set to the bank's configuration data
|
||||||
|
* @return #GNUNET_OK on success
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_TESTING_prepare_bank (const char *config_filename,
|
||||||
|
struct TALER_TESTING_BankConfiguration *bc);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look for substring in a programs' name.
|
||||||
|
*
|
||||||
|
* @param prog program's name to look into
|
||||||
|
* @param marker chunk to find in @a prog
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_TESTING_has_in_name (const char *prog,
|
||||||
|
const char *marker);
|
||||||
|
|
||||||
|
|
||||||
/* ************** Specific interpreter commands ************ */
|
/* ************** Specific interpreter commands ************ */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a credit "history" CMD.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param account_url base URL of the account offering the "history"
|
||||||
|
* operation.
|
||||||
|
* @param auth login data to use
|
||||||
|
* @param start_row_reference reference to a command that can
|
||||||
|
* offer a row identifier, to be used as the starting row
|
||||||
|
* to accept in the result.
|
||||||
|
* @param num_results how many rows we want in the result,
|
||||||
|
* and ascending/descending call
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_bank_credits (const char *label,
|
||||||
|
const char *account_url,
|
||||||
|
const struct
|
||||||
|
TALER_BANK_AuthenticationData *auth,
|
||||||
|
const char *start_row_reference,
|
||||||
|
long long num_results);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a debit "history" CMD.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param account_url base URL of the account offering the "history"
|
||||||
|
* operation.
|
||||||
|
* @param auth authentication data
|
||||||
|
* @param start_row_reference reference to a command that can
|
||||||
|
* offer a row identifier, to be used as the starting row
|
||||||
|
* to accept in the result.
|
||||||
|
* @param num_results how many rows we want in the result.
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_bank_debits (const char *label,
|
||||||
|
const char *account_url,
|
||||||
|
const struct TALER_BANK_AuthenticationData *auth,
|
||||||
|
const char *start_row_reference,
|
||||||
|
long long num_results);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create transfer command.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param amount amount to transfer.
|
||||||
|
* @param account_base_url base URL of the account that implements this
|
||||||
|
* wire transer (which account gives money).
|
||||||
|
* @param auth authentication data to use
|
||||||
|
* @param payto_credit_account which account receives money.
|
||||||
|
* @param wtid wire transfer identifier to use
|
||||||
|
* @param exchange_base_url exchange URL to use
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_transfer (const char *label,
|
||||||
|
const char *amount,
|
||||||
|
const char *account_base_url,
|
||||||
|
const struct TALER_BANK_AuthenticationData *auth,
|
||||||
|
const char *payto_credit_account,
|
||||||
|
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||||
|
const char *exchange_base_url);
|
||||||
|
|
||||||
|
|
||||||
|
/* ***** Commands ONLY for testing (/admin-API) **** */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create /admin/add-incoming command.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param amount amount to transfer.
|
||||||
|
* @param exchange_base_url base URL of the exchange account that receives this
|
||||||
|
* wire transer (which account receives money).
|
||||||
|
* @param payto_debit_account which account sends money.
|
||||||
|
* @param auth authentication data
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_admin_add_incoming (const char *label,
|
||||||
|
const char *amount,
|
||||||
|
const char *exchange_base_url,
|
||||||
|
const struct
|
||||||
|
TALER_BANK_AuthenticationData *auth,
|
||||||
|
const char *payto_debit_account);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create "fakebank transfer" CMD, letting the caller specify
|
||||||
|
* a reference to a command that can offer a reserve private key.
|
||||||
|
* This private key will then be used to construct the subject line
|
||||||
|
* of the wire transfer.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param amount the amount to transfer.
|
||||||
|
* @param account_base_url base URL of the account that implements this
|
||||||
|
* wire transer (which account receives money).
|
||||||
|
* @param payto_debit_account which account sends money.
|
||||||
|
* @param auth authentication data
|
||||||
|
* @param ref reference to a command that can offer a reserve
|
||||||
|
* private key.
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_admin_add_incoming_with_ref (const char *label,
|
||||||
|
const char *amount,
|
||||||
|
const char *account_base_url,
|
||||||
|
const struct
|
||||||
|
TALER_BANK_AuthenticationData *
|
||||||
|
auth,
|
||||||
|
const char *payto_debit_account,
|
||||||
|
const char *ref);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create "fakebank transfer" CMD, letting the caller specifying
|
||||||
|
* the merchant instance. This version is useful when a tip
|
||||||
|
* reserve should be topped up, in fact the interpreter will need
|
||||||
|
* the "tipping instance" in order to get the instance public key
|
||||||
|
* and make a wire transfer subject out of it.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param amount amount to transfer.
|
||||||
|
* @param account_base_url base URL of the account that implements this
|
||||||
|
* wire transer (which account receives money).
|
||||||
|
* @param payto_debit_account which account sends money.
|
||||||
|
* @param auth authentication data
|
||||||
|
* @param instance the instance that runs the tipping. Under this
|
||||||
|
* instance, the configuration file will provide the private
|
||||||
|
* key of the tipping reserve. This data will then used to
|
||||||
|
* construct the wire transfer subject line.
|
||||||
|
* @param config_filename configuration file to use.
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_admin_add_incoming_with_instance (const char *label,
|
||||||
|
const char *amount,
|
||||||
|
const char *account_base_url,
|
||||||
|
const struct
|
||||||
|
TALER_BANK_AuthenticationData
|
||||||
|
*auth,
|
||||||
|
const char *
|
||||||
|
payto_debit_account,
|
||||||
|
const char *instance,
|
||||||
|
const char *config_filename);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify a fakebank transfer command to enable retries when the
|
||||||
|
* reserve is not yet full or we get other transient errors from
|
||||||
|
* the fakebank.
|
||||||
|
*
|
||||||
|
* @param cmd a fakebank transfer command
|
||||||
|
* @return the command with retries enabled
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command
|
||||||
|
TALER_TESTING_cmd_admin_add_incoming_retry (struct TALER_TESTING_Command cmd);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a "wirewatch" CMD.
|
* Make a "wirewatch" CMD.
|
||||||
*
|
*
|
||||||
@ -893,7 +1182,7 @@ TALER_TESTING_cmd_status (const char *label,
|
|||||||
* coins, this parameter selects which one in that array.
|
* coins, this parameter selects which one in that array.
|
||||||
* This value is currently ignored, as only one-coin
|
* This value is currently ignored, as only one-coin
|
||||||
* withdrawals are implemented.
|
* withdrawals are implemented.
|
||||||
* @param wire_details wire details associated with the "deposit"
|
* @param target_account_payto target account for the "deposit"
|
||||||
* request.
|
* request.
|
||||||
* @param contract_terms contract terms to be signed over by the
|
* @param contract_terms contract terms to be signed over by the
|
||||||
* coin.
|
* coin.
|
||||||
@ -907,7 +1196,7 @@ struct TALER_TESTING_Command
|
|||||||
TALER_TESTING_cmd_deposit (const char *label,
|
TALER_TESTING_cmd_deposit (const char *label,
|
||||||
const char *coin_reference,
|
const char *coin_reference,
|
||||||
unsigned int coin_index,
|
unsigned int coin_index,
|
||||||
json_t *wire_details,
|
const char *target_account_payto,
|
||||||
const char *contract_terms,
|
const char *contract_terms,
|
||||||
struct GNUNET_TIME_Relative refund_deadline,
|
struct GNUNET_TIME_Relative refund_deadline,
|
||||||
const char *amount,
|
const char *amount,
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
#include "taler_bank_service.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_testing_auditor_lib.h"
|
#include "taler_testing_auditor_lib.h"
|
||||||
|
|
||||||
@ -47,55 +46,14 @@
|
|||||||
"test_auditor_api_expire_reserve_now.conf"
|
"test_auditor_api_expire_reserve_now.conf"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL of the fakebank. Obtained from CONFIG_FILE's
|
* Exchange configuration data.
|
||||||
* "exchange-wire-test:BANK_URI" option.
|
|
||||||
*/
|
*/
|
||||||
static char *fakebank_url;
|
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auditor base URL as it appears in the configuration. Note
|
* Bank configuration data.
|
||||||
* that it might differ from the one where the exchange actually
|
|
||||||
* listens from.
|
|
||||||
*/
|
*/
|
||||||
static char *auditor_url;
|
static struct TALER_TESTING_BankConfiguration bc;
|
||||||
|
|
||||||
/**
|
|
||||||
* Exchange base URL as it appears in the configuration. Note
|
|
||||||
* that it might differ from the one where the exchange actually
|
|
||||||
* listens from.
|
|
||||||
*/
|
|
||||||
static char *exchange_url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* URL of the exchange's account at the bank. Obtained from CONFIG_FILE's
|
|
||||||
* "exchange-wire-test:BANK_URI" option plus the exchange account.
|
|
||||||
*/
|
|
||||||
static char *exchange_account_url; // FIXME: initialize!
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Account number of the exchange at the bank.
|
|
||||||
*/
|
|
||||||
#define EXCHANGE_ACCOUNT_NO "2" // FIXME: used?
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Payto URL of the user's account.
|
|
||||||
*/
|
|
||||||
static char *user_account_payto; // FIXME: initialize!
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Payto URL of the user's account.
|
|
||||||
*/
|
|
||||||
static char *user2_account_payto; // FIXME: initialize! (43!)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Payto URL of the exchange's account.
|
|
||||||
*/
|
|
||||||
static char *exchange_account_payto; // FIXME: initialize!
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Credentials for talking to the bank.
|
|
||||||
*/
|
|
||||||
static struct TALER_BANK_AuthenticationData auth; // FIXME: initialize!
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the taler-exchange-wirewatch command with
|
* Execute the taler-exchange-wirewatch command with
|
||||||
@ -123,10 +81,10 @@ static struct TALER_BANK_AuthenticationData auth; // FIXME: initialize!
|
|||||||
* @param amount amount to transfer, i.e. "EUR:1"
|
* @param amount amount to transfer, i.e. "EUR:1"
|
||||||
*/
|
*/
|
||||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||||
exchange_account_url, \
|
bc.exchange_account_url, \
|
||||||
&auth, \
|
&bc.exchange_auth, \
|
||||||
user_account_payto)
|
bc.user42_payto)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the taler-auditor.
|
* Run the taler-auditor.
|
||||||
@ -186,8 +144,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit ("deposit-simple",
|
TALER_TESTING_cmd_deposit ("deposit-simple",
|
||||||
"withdraw-coin-1",
|
"withdraw-coin-1",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
@ -221,8 +178,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
|
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
|
||||||
"refresh-withdraw-coin-1",
|
"refresh-withdraw-coin-1",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:1\"}]}",
|
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:1\"}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -246,8 +202,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
|
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
|
||||||
"refresh-reveal-1",
|
"refresh-reveal-1",
|
||||||
3,
|
3,
|
||||||
TALER_TESTING_make_wire_details (43,
|
bc.user43_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.1",
|
"EUR:0.1",
|
||||||
@ -268,78 +223,78 @@ run (void *cls,
|
|||||||
* Check all the transfers took place.
|
* Check all the transfers took place.
|
||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-499c", exchange_url,
|
("check_bank_transfer-499c", ec.exchange_url,
|
||||||
"EUR:4.98", exchange_account_payto, user_account_payto),
|
"EUR:4.98", bc.exchange_payto, bc.user42_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-99c1", exchange_url,
|
("check_bank_transfer-99c1", ec.exchange_url,
|
||||||
"EUR:0.98", exchange_account_payto, user_account_payto),
|
"EUR:0.98", bc.exchange_payto, bc.user42_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-99c", exchange_url,
|
("check_bank_transfer-99c", ec.exchange_url,
|
||||||
"EUR:0.08", exchange_account_payto, user2_account_payto),
|
"EUR:0.08", bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-aai-1", exchange_url,
|
("check_bank_transfer-aai-1", ec.exchange_url,
|
||||||
"EUR:5.01", user_account_payto, exchange_account_payto),
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-aai-2", exchange_url,
|
("check_bank_transfer-aai-2", ec.exchange_url,
|
||||||
"EUR:5.01", user_account_payto, exchange_account_payto),
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
||||||
|
|
||||||
/* The following transactions got originated within
|
/* The following transactions got originated within
|
||||||
* the "massive deposit confirms" batch. */
|
* the "massive deposit confirms" batch. */
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer",
|
("check-massive-transfer",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:10.10",
|
"EUR:10.10",
|
||||||
user_account_payto, exchange_account_payto),
|
bc.user42_payto, bc.exchange_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-1",
|
("check-massive-transfer-1",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-2",
|
("check-massive-transfer-2",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-3",
|
("check-massive-transfer-3",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-4",
|
("check-massive-transfer-4",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-5",
|
("check-massive-transfer-5",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-6",
|
("check-massive-transfer-6",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-7",
|
("check-massive-transfer-7",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-8",
|
("check-massive-transfer-8",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-9",
|
("check-massive-transfer-9",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check-massive-transfer-10",
|
("check-massive-transfer-10",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.98",
|
"EUR:0.98",
|
||||||
exchange_account_payto, user2_account_payto),
|
bc.exchange_payto, bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
@ -355,10 +310,10 @@ run (void *cls,
|
|||||||
CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"),
|
CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"),
|
||||||
/* "consume" reserve creation transfer. */
|
/* "consume" reserve creation transfer. */
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-unaggregated",
|
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-unaggregated",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:5.01",
|
"EUR:5.01",
|
||||||
user_account_payto,
|
bc.user42_payto,
|
||||||
exchange_account_payto),
|
bc.exchange_payto),
|
||||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
|
||||||
"create-reserve-unaggregated",
|
"create-reserve-unaggregated",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
@ -366,9 +321,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit ("deposit-unaggregated",
|
TALER_TESTING_cmd_deposit ("deposit-unaggregated",
|
||||||
"withdraw-coin-unaggregated",
|
"withdraw-coin-unaggregated",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_YEARS,
|
(GNUNET_TIME_UNIT_YEARS,
|
||||||
@ -404,8 +357,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit ("deposit-refund-1",
|
TALER_TESTING_cmd_deposit ("deposit-refund-1",
|
||||||
"withdraw-coin-r1",
|
"withdraw-coin-r1",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:5\"}]}",
|
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:5\"}]}",
|
||||||
GNUNET_TIME_UNIT_MINUTES,
|
GNUNET_TIME_UNIT_MINUTES,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
@ -423,8 +375,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit ("deposit-refund-2",
|
TALER_TESTING_cmd_deposit ("deposit-refund-2",
|
||||||
"withdraw-coin-r1",
|
"withdraw-coin-r1",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"more\",\"value\":\"EUR:5\"}]}",
|
"{\"items\":[{\"name\":\"more\",\"value\":\"EUR:5\"}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:4.99",
|
"EUR:4.99",
|
||||||
@ -510,8 +461,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit ("payback-deposit-partial",
|
TALER_TESTING_cmd_deposit ("payback-deposit-partial",
|
||||||
"payback-withdraw-coin-2a",
|
"payback-withdraw-coin-2a",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.5",
|
"EUR:0.5",
|
||||||
@ -581,9 +531,7 @@ run (void *cls,
|
|||||||
("massive-deposit-1",
|
("massive-deposit-1",
|
||||||
"massive-withdraw-1",
|
"massive-withdraw-1",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -592,9 +540,7 @@ run (void *cls,
|
|||||||
("massive-deposit-2",
|
("massive-deposit-2",
|
||||||
"massive-withdraw-2",
|
"massive-withdraw-2",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -603,9 +549,7 @@ run (void *cls,
|
|||||||
("massive-deposit-3",
|
("massive-deposit-3",
|
||||||
"massive-withdraw-3",
|
"massive-withdraw-3",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -614,9 +558,7 @@ run (void *cls,
|
|||||||
("massive-deposit-4",
|
("massive-deposit-4",
|
||||||
"massive-withdraw-4",
|
"massive-withdraw-4",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -625,9 +567,7 @@ run (void *cls,
|
|||||||
("massive-deposit-5",
|
("massive-deposit-5",
|
||||||
"massive-withdraw-5",
|
"massive-withdraw-5",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -636,9 +576,7 @@ run (void *cls,
|
|||||||
("massive-deposit-6",
|
("massive-deposit-6",
|
||||||
"massive-withdraw-6",
|
"massive-withdraw-6",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -647,9 +585,7 @@ run (void *cls,
|
|||||||
("massive-deposit-7",
|
("massive-deposit-7",
|
||||||
"massive-withdraw-7",
|
"massive-withdraw-7",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -658,9 +594,7 @@ run (void *cls,
|
|||||||
("massive-deposit-8",
|
("massive-deposit-8",
|
||||||
"massive-withdraw-8",
|
"massive-withdraw-8",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -669,9 +603,7 @@ run (void *cls,
|
|||||||
("massive-deposit-9",
|
("massive-deposit-9",
|
||||||
"massive-withdraw-9",
|
"massive-withdraw-9",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -680,9 +612,7 @@ run (void *cls,
|
|||||||
("massive-deposit-10",
|
("massive-deposit-10",
|
||||||
"massive-withdraw-10",
|
"massive-withdraw-10",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -727,7 +657,7 @@ run (void *cls,
|
|||||||
|
|
||||||
TALER_TESTING_run_with_fakebank (is,
|
TALER_TESTING_run_with_fakebank (is,
|
||||||
commands,
|
commands,
|
||||||
fakebank_url);
|
bc.bank_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -741,19 +671,18 @@ main (int argc,
|
|||||||
GNUNET_log_setup ("test-auditor-api",
|
GNUNET_log_setup ("test-auditor-api",
|
||||||
"INFO",
|
"INFO",
|
||||||
NULL);
|
NULL);
|
||||||
if (NULL == (fakebank_url
|
/* Check fakebank port is available and get configuration data. */
|
||||||
/* Check fakebank port is available and config cares
|
if (GNUNET_OK !=
|
||||||
* about bank url. */
|
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
||||||
= TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
"account-2",
|
||||||
"account-2")))
|
&bc))
|
||||||
return 77;
|
return 77;
|
||||||
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
||||||
/* @helpers. Run keyup, create tables, ... Note: it
|
/* @helpers. Run keyup, create tables, ... Note: it
|
||||||
* fetches the port number from config in order to see
|
* fetches the port number from config in order to see
|
||||||
* if it's available. */
|
* if it's available. */
|
||||||
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
||||||
&auditor_url,
|
&ec))
|
||||||
&exchange_url))
|
|
||||||
{
|
{
|
||||||
case GNUNET_SYSERR:
|
case GNUNET_SYSERR:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -32,36 +32,20 @@
|
|||||||
#include <gnunet/gnunet_curl_lib.h>
|
#include <gnunet/gnunet_curl_lib.h>
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME: rename config file to make it clear it is associated with a test!
|
||||||
#define CONFIG_FILE "bank.conf"
|
#define CONFIG_FILE "bank.conf"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fakebank URL.
|
* Bank configuration data.
|
||||||
*/
|
*/
|
||||||
static char *bank_url;
|
static struct TALER_TESTING_BankConfiguration bc;
|
||||||
|
|
||||||
/**
|
|
||||||
* Account URL.
|
|
||||||
*/
|
|
||||||
static char *account_url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* payto://-URL of another account.
|
|
||||||
*/
|
|
||||||
static char *payto_url;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle to the Py-bank daemon.
|
* Handle to the Py-bank daemon.
|
||||||
*/
|
*/
|
||||||
static struct GNUNET_OS_Process *bankd;
|
static struct GNUNET_OS_Process *bankd;
|
||||||
|
|
||||||
/**
|
|
||||||
* Authentication data to use.
|
|
||||||
*/
|
|
||||||
static struct TALER_BANK_AuthenticationData auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag indicating whether the test is running against the
|
* Flag indicating whether the test is running against the
|
||||||
* Fakebank. Set up at runtime.
|
* Fakebank. Set up at runtime.
|
||||||
@ -81,40 +65,40 @@ run (void *cls,
|
|||||||
struct TALER_WireTransferIdentifierRawP wtid;
|
struct TALER_WireTransferIdentifierRawP wtid;
|
||||||
struct TALER_TESTING_Command commands[] = {
|
struct TALER_TESTING_Command commands[] = {
|
||||||
TALER_TESTING_cmd_bank_credits ("history-0",
|
TALER_TESTING_cmd_bank_credits ("history-0",
|
||||||
account_url,
|
bc.exchange_account_url,
|
||||||
&auth,
|
&bc.exchange_auth,
|
||||||
NULL,
|
NULL,
|
||||||
1),
|
1),
|
||||||
TALER_TESTING_cmd_admin_add_incoming ("debit-1",
|
TALER_TESTING_cmd_admin_add_incoming ("debit-1",
|
||||||
"KUDOS:5.01",
|
"KUDOS:5.01",
|
||||||
account_url,
|
bc.exchange_account_url,
|
||||||
&auth,
|
&bc.exchange_auth,
|
||||||
payto_url),
|
bc.user42_payto),
|
||||||
TALER_TESTING_cmd_bank_credits ("history-1c",
|
TALER_TESTING_cmd_bank_credits ("history-1c",
|
||||||
account_url,
|
bc.exchange_account_url,
|
||||||
&auth,
|
&bc.exchange_auth,
|
||||||
NULL,
|
NULL,
|
||||||
5),
|
5),
|
||||||
TALER_TESTING_cmd_bank_debits ("history-1d",
|
TALER_TESTING_cmd_bank_debits ("history-1d",
|
||||||
account_url,
|
bc.exchange_account_url,
|
||||||
&auth,
|
&bc.exchange_auth,
|
||||||
NULL,
|
NULL,
|
||||||
5),
|
5),
|
||||||
TALER_TESTING_cmd_admin_add_incoming ("debit-2",
|
TALER_TESTING_cmd_admin_add_incoming ("debit-2",
|
||||||
"KUDOS:3.21",
|
"KUDOS:3.21",
|
||||||
account_url,
|
bc.exchange_account_url,
|
||||||
&auth,
|
&bc.exchange_auth,
|
||||||
payto_url),
|
bc.user42_payto),
|
||||||
TALER_TESTING_cmd_transfer ("credit-2",
|
TALER_TESTING_cmd_transfer ("credit-2",
|
||||||
"KUDOS:3.22",
|
"KUDOS:3.22",
|
||||||
account_url,
|
bc.exchange_account_url,
|
||||||
&auth,
|
&bc.exchange_auth,
|
||||||
payto_url,
|
bc.user42_payto,
|
||||||
&wtid,
|
&wtid,
|
||||||
"http://exchange.example.com/"),
|
"http://exchange.example.com/"),
|
||||||
TALER_TESTING_cmd_bank_debits ("history-2b",
|
TALER_TESTING_cmd_bank_debits ("history-2b",
|
||||||
account_url,
|
bc.exchange_account_url,
|
||||||
&auth,
|
&bc.exchange_auth,
|
||||||
NULL,
|
NULL,
|
||||||
5),
|
5),
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
@ -123,20 +107,11 @@ run (void *cls,
|
|||||||
memset (&wtid, 42, sizeof (wtid));
|
memset (&wtid, 42, sizeof (wtid));
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Bank serves at `%s'\n",
|
"Bank serves at `%s'\n",
|
||||||
bank_url);
|
bc.bank_url);
|
||||||
GNUNET_asprintf (&account_url,
|
|
||||||
"%s/%s",
|
|
||||||
bank_url,
|
|
||||||
"alice");
|
|
||||||
GNUNET_asprintf (&payto_url,
|
|
||||||
"payto://x-taler-bank/%s/%s",
|
|
||||||
bank_url,
|
|
||||||
"bob");
|
|
||||||
// FIXME: init 'auth'!
|
|
||||||
if (GNUNET_YES == with_fakebank)
|
if (GNUNET_YES == with_fakebank)
|
||||||
TALER_TESTING_run_with_fakebank (is,
|
TALER_TESTING_run_with_fakebank (is,
|
||||||
commands,
|
commands,
|
||||||
bank_url);
|
bc.bank_url);
|
||||||
else
|
else
|
||||||
TALER_TESTING_run (is,
|
TALER_TESTING_run (is,
|
||||||
commands);
|
commands);
|
||||||
@ -155,14 +130,15 @@ main (int argc,
|
|||||||
GNUNET_log_setup ("test-bank-api",
|
GNUNET_log_setup ("test-bank-api",
|
||||||
"DEBUG",
|
"DEBUG",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
with_fakebank = TALER_TESTING_has_in_name (argv[0],
|
with_fakebank = TALER_TESTING_has_in_name (argv[0],
|
||||||
"_with_fakebank");
|
"_with_fakebank");
|
||||||
if (GNUNET_YES == with_fakebank)
|
if (GNUNET_YES == with_fakebank)
|
||||||
{
|
{
|
||||||
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
|
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
|
||||||
if (NULL == (bank_url = TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
if (GNUNET_OK !=
|
||||||
"account-1")))
|
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
||||||
|
"account-1",
|
||||||
|
&bc))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return 77;
|
return 77;
|
||||||
@ -171,14 +147,16 @@ main (int argc,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
TALER_LOG_DEBUG ("Running against the Pybank.\n");
|
TALER_LOG_DEBUG ("Running against the Pybank.\n");
|
||||||
if (NULL == (bank_url = TALER_TESTING_prepare_bank (CONFIG_FILE)))
|
if (GNUNET_OK !=
|
||||||
|
TALER_TESTING_prepare_bank (CONFIG_FILE,
|
||||||
|
&bc))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return 77;
|
return 77;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == (bankd = TALER_TESTING_run_bank (CONFIG_FILE,
|
if (NULL == (bankd = TALER_TESTING_run_bank (CONFIG_FILE,
|
||||||
bank_url)))
|
bc.bank_url)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return 77;
|
return 77;
|
||||||
@ -197,9 +175,7 @@ main (int argc,
|
|||||||
SIGKILL);
|
SIGKILL);
|
||||||
GNUNET_OS_process_wait (bankd);
|
GNUNET_OS_process_wait (bankd);
|
||||||
GNUNET_OS_process_destroy (bankd);
|
GNUNET_OS_process_destroy (bankd);
|
||||||
GNUNET_free (bank_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include <taler/taler_twister_testing_lib.h>
|
#include <taler/taler_twister_testing_lib.h>
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
#include <taler/taler_twister_service.h>
|
#include <taler/taler_twister_service.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,6 +46,11 @@
|
|||||||
*/
|
*/
|
||||||
static int with_fakebank;
|
static int with_fakebank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bank configuration data.
|
||||||
|
*/
|
||||||
|
static struct TALER_TESTING_BankConfiguration bc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (real) Twister URL. Used at startup time to check if it runs.
|
* (real) Twister URL. Used at startup time to check if it runs.
|
||||||
*/
|
*/
|
||||||
@ -63,11 +67,6 @@ static char *twisted_account_url;
|
|||||||
*/
|
*/
|
||||||
static struct TALER_BANK_AuthenticationData auth;
|
static struct TALER_BANK_AuthenticationData auth;
|
||||||
|
|
||||||
/**
|
|
||||||
* URL of the bank.
|
|
||||||
*/
|
|
||||||
static char *bank_url;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Twister process.
|
* Twister process.
|
||||||
*/
|
*/
|
||||||
@ -112,7 +111,7 @@ run (void *cls,
|
|||||||
if (GNUNET_YES == with_fakebank)
|
if (GNUNET_YES == with_fakebank)
|
||||||
TALER_TESTING_run_with_fakebank (is,
|
TALER_TESTING_run_with_fakebank (is,
|
||||||
commands,
|
commands,
|
||||||
bank_url);
|
bc.bank_url);
|
||||||
else
|
else
|
||||||
TALER_TESTING_run (is,
|
TALER_TESTING_run (is,
|
||||||
commands);
|
commands);
|
||||||
@ -164,9 +163,10 @@ main (int argc,
|
|||||||
if (GNUNET_YES == with_fakebank)
|
if (GNUNET_YES == with_fakebank)
|
||||||
{
|
{
|
||||||
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
|
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
|
||||||
if (NULL == (bank_url = TALER_TESTING_prepare_fakebank
|
if (GNUNET_OK !=
|
||||||
(CONFIG_FILE,
|
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
||||||
"account-1")))
|
"account-1",
|
||||||
|
&bc))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (twister_url);
|
GNUNET_free (twister_url);
|
||||||
@ -176,8 +176,9 @@ main (int argc,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
TALER_LOG_DEBUG ("Running against the Pybank.\n");
|
TALER_LOG_DEBUG ("Running against the Pybank.\n");
|
||||||
if (NULL == (bank_url = TALER_TESTING_prepare_bank
|
if (GNUNET_OK !=
|
||||||
(CONFIG_FILE)))
|
TALER_TESTING_prepare_bank (CONFIG_FILE,
|
||||||
|
&bc))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (twister_url);
|
GNUNET_free (twister_url);
|
||||||
@ -185,11 +186,10 @@ main (int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == (bankd = TALER_TESTING_run_bank (CONFIG_FILE,
|
if (NULL == (bankd = TALER_TESTING_run_bank (CONFIG_FILE,
|
||||||
bank_url)))
|
bc.bank_url)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (twister_url);
|
GNUNET_free (twister_url);
|
||||||
GNUNET_free (bank_url);
|
|
||||||
return 77;
|
return 77;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,8 +210,6 @@ main (int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_free (twister_url);
|
GNUNET_free (twister_url);
|
||||||
GNUNET_free (bank_url);
|
|
||||||
|
|
||||||
if (GNUNET_OK == ret)
|
if (GNUNET_OK == ret)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2014--2019 Taler Systems SA
|
Copyright (C) 2014--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
|
||||||
@ -16,15 +16,13 @@
|
|||||||
License along with TALER; see the file COPYING. If not, see
|
License along with TALER; see the file COPYING. If not, see
|
||||||
<http://www.gnu.org/licenses/>
|
<http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file exchange/test_exchange_api.c
|
* @file lib/test_exchange_api.c
|
||||||
* @brief testcase to test exchange's HTTP API interface
|
* @brief testcase to test exchange's HTTP API interface
|
||||||
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
* @author Marcello Stanisci
|
* @author Marcello Stanisci
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "taler_util.h"
|
#include "taler_util.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
@ -35,7 +33,6 @@
|
|||||||
#include "taler_bank_service.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration file we use. One (big) configuration is used
|
* Configuration file we use. One (big) configuration is used
|
||||||
@ -46,56 +43,16 @@
|
|||||||
#define CONFIG_FILE_EXPIRE_RESERVE_NOW \
|
#define CONFIG_FILE_EXPIRE_RESERVE_NOW \
|
||||||
"test_exchange_api_expire_reserve_now.conf"
|
"test_exchange_api_expire_reserve_now.conf"
|
||||||
|
|
||||||
/**
|
|
||||||
* URL of the fakebank. Obtained from CONFIG_FILE's
|
|
||||||
* "exchange-wire-test:BANK_URI" option.
|
|
||||||
*/
|
|
||||||
static char *fakebank_url;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange base URL as it appears in the configuration. Note
|
* Exchange configuration data.
|
||||||
* that it might differ from the one where the exchange actually
|
|
||||||
* listens from.
|
|
||||||
*/
|
*/
|
||||||
static char *exchange_url;
|
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auditor base URL as it appears in the configuration. Note
|
* Bank configuration data.
|
||||||
* that it might differ from the one where the auditor actually
|
|
||||||
* listens from.
|
|
||||||
*/
|
*/
|
||||||
static char *auditor_url;
|
static struct TALER_TESTING_BankConfiguration bc;
|
||||||
|
|
||||||
/**
|
|
||||||
* URL of the exchange's account at the bank. Obtained from CONFIG_FILE's
|
|
||||||
* "exchange-wire-test:BANK_URI" option plus the exchange account.
|
|
||||||
*/
|
|
||||||
static char *exchange_account_url; // FIXME: initialize!
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Account number of the exchange at the bank.
|
|
||||||
*/
|
|
||||||
#define EXCHANGE_ACCOUNT_NO "2" // FIXME: used?
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Payto URL of the user's account.
|
|
||||||
*/
|
|
||||||
static char *user_account_payto; // FIXME: initialize!
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Payto URL of the user's account.
|
|
||||||
*/
|
|
||||||
static char *user2_account_payto; // FIXME: initialize! (43!)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Payto URL of the exchange's account.
|
|
||||||
*/
|
|
||||||
static char *exchange_account_payto; // FIXME: initialize!
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Credentials for talking to the bank.
|
|
||||||
*/
|
|
||||||
static struct TALER_BANK_AuthenticationData auth; // FIXME: initialize!
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,9 +82,9 @@ static struct TALER_BANK_AuthenticationData auth; // FIXME: initialize!
|
|||||||
*/
|
*/
|
||||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||||
exchange_account_url, \
|
bc.exchange_account_url, \
|
||||||
&auth, \
|
&bc.exchange_auth, \
|
||||||
user_account_payto)
|
bc.user42_payto)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main function that will tell the interpreter what commands to
|
* Main function that will tell the interpreter what commands to
|
||||||
@ -197,8 +154,7 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("deposit-simple", "withdraw-coin-1", 0,
|
("deposit-simple", "withdraw-coin-1", 0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK),
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK),
|
||||||
|
|
||||||
@ -215,8 +171,7 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("deposit-double-1", "withdraw-coin-1", 0,
|
("deposit-double-1", "withdraw-coin-1", 0,
|
||||||
TALER_TESTING_make_wire_details (43,
|
bc.user43_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_CONFLICT),
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_CONFLICT),
|
||||||
|
|
||||||
@ -230,8 +185,7 @@ run (void *cls,
|
|||||||
* how can a different id be generated?
|
* how can a different id be generated?
|
||||||
*/TALER_TESTING_cmd_deposit
|
*/TALER_TESTING_cmd_deposit
|
||||||
("deposit-double-1", "withdraw-coin-1", 0,
|
("deposit-double-1", "withdraw-coin-1", 0,
|
||||||
TALER_TESTING_make_wire_details (43,
|
bc.user43_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_CONFLICT),
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_CONFLICT),
|
||||||
|
|
||||||
@ -240,8 +194,7 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("deposit-double-2", "withdraw-coin-1", 0,
|
("deposit-double-2", "withdraw-coin-1", 0,
|
||||||
TALER_TESTING_make_wire_details (43,
|
bc.user43_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_CONFLICT),
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_CONFLICT),
|
||||||
|
|
||||||
@ -279,8 +232,7 @@ run (void *cls,
|
|||||||
*/TALER_TESTING_cmd_deposit
|
*/TALER_TESTING_cmd_deposit
|
||||||
("refresh-deposit-partial",
|
("refresh-deposit-partial",
|
||||||
"refresh-withdraw-coin-1", 0,
|
"refresh-withdraw-coin-1", 0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\
|
"{\"items\":[{\"name\":\"ice cream\",\
|
||||||
\"value\":\"EUR:1\"}]}",
|
\"value\":\"EUR:1\"}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
|
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
|
||||||
@ -321,8 +273,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("refresh-deposit-refreshed-1a",
|
("refresh-deposit-refreshed-1a",
|
||||||
"refresh-reveal-1-idempotency", 0,
|
"refresh-reveal-1-idempotency", 0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\
|
"{\"items\":[{\"name\":\"ice cream\",\
|
||||||
\"value\":3}]}",
|
\"value\":3}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
|
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
|
||||||
@ -333,8 +284,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("refresh-deposit-refreshed-1b",
|
("refresh-deposit-refreshed-1b",
|
||||||
"refresh-reveal-1", 3,
|
"refresh-reveal-1", 3,
|
||||||
TALER_TESTING_make_wire_details (43,
|
bc.user43_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\
|
"{\"items\":[{\"name\":\"ice cream\",\
|
||||||
\"value\":3}]}",
|
\"value\":3}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:0.1", MHD_HTTP_OK),
|
GNUNET_TIME_UNIT_ZERO, "EUR:0.1", MHD_HTTP_OK),
|
||||||
@ -390,32 +340,32 @@ run (void *cls,
|
|||||||
* Check all the transfers took place.
|
* Check all the transfers took place.
|
||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-499c", exchange_url,
|
("check_bank_transfer-499c", ec.exchange_url,
|
||||||
"EUR:4.98", exchange_account_payto, user_account_payto),
|
"EUR:4.98", bc.exchange_payto, bc.user42_payto),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-99c1", exchange_url,
|
("check_bank_transfer-99c1", ec.exchange_url,
|
||||||
"EUR:0.98", exchange_account_payto, user_account_payto),
|
"EUR:0.98", bc.exchange_payto, bc.user42_payto),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-99c2", exchange_url,
|
("check_bank_transfer-99c2", ec.exchange_url,
|
||||||
"EUR:0.98", exchange_account_payto, user_account_payto),
|
"EUR:0.98", bc.exchange_payto, bc.user42_payto),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-99c", exchange_url,
|
("check_bank_transfer-99c", ec.exchange_url,
|
||||||
"EUR:0.08", exchange_account_payto, user2_account_payto),
|
"EUR:0.08", bc.exchange_payto, bc.user43_payto),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-aai-1", exchange_url,
|
("check_bank_transfer-aai-1", ec.exchange_url,
|
||||||
"EUR:5.01", user_account_payto, exchange_account_payto),
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: the old test-suite had this "check bank transfer"
|
* NOTE: the old test-suite had this "check bank transfer"
|
||||||
* command with debit account == 424.
|
* command with debit account == 424.
|
||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-aai-2", exchange_url,
|
("check_bank_transfer-aai-2", ec.exchange_url,
|
||||||
"EUR:5.01", user_account_payto, exchange_account_payto),
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
||||||
|
|
||||||
@ -454,9 +404,9 @@ run (void *cls,
|
|||||||
/* "consume" reserve creation transfer. */
|
/* "consume" reserve creation transfer. */
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-unaggregated",
|
("check_bank_transfer-unaggregated",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:5.01",
|
"EUR:5.01",
|
||||||
user_account_payto, exchange_account_payto),
|
bc.user42_payto, bc.exchange_payto),
|
||||||
|
|
||||||
TALER_TESTING_cmd_withdraw_amount
|
TALER_TESTING_cmd_withdraw_amount
|
||||||
("withdraw-coin-unaggregated",
|
("withdraw-coin-unaggregated",
|
||||||
@ -468,9 +418,7 @@ run (void *cls,
|
|||||||
("deposit-unaggregated",
|
("deposit-unaggregated",
|
||||||
"withdraw-coin-unaggregated",
|
"withdraw-coin-unaggregated",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user43_payto,
|
||||||
(43,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_YEARS,
|
(GNUNET_TIME_UNIT_YEARS,
|
||||||
@ -513,8 +461,7 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("deposit-refund-1", "withdraw-coin-r1", 0,
|
("deposit-refund-1", "withdraw-coin-r1", 0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\","
|
"{\"items\":[{\"name\":\"ice cream\","
|
||||||
"\"value\":\"EUR:5\"}]}",
|
"\"value\":\"EUR:5\"}]}",
|
||||||
GNUNET_TIME_UNIT_MINUTES, "EUR:5", MHD_HTTP_OK),
|
GNUNET_TIME_UNIT_MINUTES, "EUR:5", MHD_HTTP_OK),
|
||||||
@ -533,8 +480,8 @@ run (void *cls,
|
|||||||
* fakebank and the second to actually check there are not
|
* fakebank and the second to actually check there are not
|
||||||
* other transfers around.
|
* other transfers around.
|
||||||
*/TALER_TESTING_cmd_check_bank_transfer
|
*/TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-pre-refund", exchange_url,
|
("check_bank_transfer-pre-refund", ec.exchange_url,
|
||||||
"EUR:5.01", user_account_payto, exchange_account_payto),
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_empty
|
TALER_TESTING_cmd_check_bank_empty
|
||||||
("check_bank_transfer-pre-refund"),
|
("check_bank_transfer-pre-refund"),
|
||||||
@ -558,8 +505,7 @@ run (void *cls,
|
|||||||
* 1 ct deposit fee) */
|
* 1 ct deposit fee) */
|
||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("deposit-refund-2", "withdraw-coin-r1", 0,
|
("deposit-refund-2", "withdraw-coin-r1", 0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"more ice cream\","
|
"{\"items\":[{\"name\":\"more ice cream\","
|
||||||
"\"value\":\"EUR:5\"}]}",
|
"\"value\":\"EUR:5\"}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:4.99", MHD_HTTP_OK),
|
GNUNET_TIME_UNIT_ZERO, "EUR:4.99", MHD_HTTP_OK),
|
||||||
@ -575,8 +521,8 @@ run (void *cls,
|
|||||||
* Check that deposit did run.
|
* Check that deposit did run.
|
||||||
*/
|
*/
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-pre-refund", exchange_url,
|
("check_bank_transfer-pre-refund", ec.exchange_url,
|
||||||
"EUR:4.97", exchange_account_payto, user_account_payto),
|
"EUR:4.97", bc.exchange_payto, bc.user42_payto),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run failing refund, as past deadline & aggregation.
|
* Run failing refund, as past deadline & aggregation.
|
||||||
@ -603,14 +549,13 @@ run (void *cls,
|
|||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-aai-3b", exchange_url,
|
("check_bank_transfer-aai-3b", ec.exchange_url,
|
||||||
"EUR:5.01", user_account_payto, exchange_account_payto),
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
||||||
|
|
||||||
|
|
||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("deposit-refund-1b", "withdraw-coin-rb", 0,
|
("deposit-refund-1b", "withdraw-coin-rb", 0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\","
|
"{\"items\":[{\"name\":\"ice cream\","
|
||||||
"\"value\":\"EUR:5\"}]}",
|
"\"value\":\"EUR:5\"}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK),
|
GNUNET_TIME_UNIT_ZERO, "EUR:5", MHD_HTTP_OK),
|
||||||
@ -723,17 +668,17 @@ run (void *cls,
|
|||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_short-lived_transfer",
|
("check_bank_short-lived_transfer",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:5.01",
|
"EUR:5.01",
|
||||||
user_account_payto,
|
bc.user42_payto,
|
||||||
exchange_account_payto),
|
bc.exchange_payto),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_short-lived_reimburse",
|
("check_bank_short-lived_reimburse",
|
||||||
exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
exchange_account_payto,
|
bc.exchange_payto,
|
||||||
user_account_payto),
|
bc.user42_payto),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per
|
* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per
|
||||||
@ -762,8 +707,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("payback-deposit-partial",
|
("payback-deposit-partial",
|
||||||
"payback-withdraw-coin-2a", 0,
|
"payback-withdraw-coin-2a", 0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:0.5", MHD_HTTP_OK),
|
GNUNET_TIME_UNIT_ZERO, "EUR:0.5", MHD_HTTP_OK),
|
||||||
|
|
||||||
@ -785,8 +729,7 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_deposit
|
TALER_TESTING_cmd_deposit
|
||||||
("payback-deposit-revoked",
|
("payback-deposit-revoked",
|
||||||
"payback-withdraw-coin-2b", 0,
|
"payback-withdraw-coin-2b", 0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_NOT_FOUND),
|
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_NOT_FOUND),
|
||||||
|
|
||||||
@ -800,9 +743,7 @@ run (void *cls,
|
|||||||
("payback-deposit-partial-after-payback",
|
("payback-deposit-partial-after-payback",
|
||||||
"payback-withdraw-coin-2a",
|
"payback-withdraw-coin-2a",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user42_payto,
|
||||||
(42,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.5",
|
"EUR:0.5",
|
||||||
@ -822,14 +763,14 @@ run (void *cls,
|
|||||||
|
|
||||||
/* check that we are empty before the rejection test */
|
/* check that we are empty before the rejection test */
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-pr1", exchange_url,
|
("check_bank_transfer-pr1", ec.exchange_url,
|
||||||
"EUR:5.01", user_account_payto, exchange_account_payto),
|
"EUR:5.01", bc.user42_payto, bc.exchange_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-pr2", exchange_url,
|
("check_bank_transfer-pr2", ec.exchange_url,
|
||||||
"EUR:2.02", user_account_payto, exchange_account_payto),
|
"EUR:2.02", bc.user42_payto, bc.exchange_payto),
|
||||||
TALER_TESTING_cmd_check_bank_transfer
|
TALER_TESTING_cmd_check_bank_transfer
|
||||||
("check_bank_transfer-pr3", exchange_url,
|
("check_bank_transfer-pr3", ec.exchange_url,
|
||||||
"EUR:1.01", user_account_payto, exchange_account_payto),
|
"EUR:1.01", bc.user42_payto, bc.exchange_payto),
|
||||||
TALER_TESTING_cmd_check_bank_empty
|
TALER_TESTING_cmd_check_bank_empty
|
||||||
("check-empty-again"),
|
("check-empty-again"),
|
||||||
|
|
||||||
@ -859,8 +800,7 @@ run (void *cls,
|
|||||||
*/TALER_TESTING_cmd_deposit
|
*/TALER_TESTING_cmd_deposit
|
||||||
("deposit-partial",
|
("deposit-partial",
|
||||||
"withdraw-coin-1", 0,
|
"withdraw-coin-1", 0,
|
||||||
TALER_TESTING_make_wire_details (42,
|
bc.user42_payto,
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\
|
"{\"items\":[{\"name\":\"ice cream\",\
|
||||||
\"value\":\"EUR:1\"}]}",
|
\"value\":\"EUR:1\"}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
|
GNUNET_TIME_UNIT_ZERO, "EUR:1", MHD_HTTP_OK),
|
||||||
@ -1008,7 +948,7 @@ run (void *cls,
|
|||||||
|
|
||||||
TALER_TESTING_run_with_fakebank (is,
|
TALER_TESTING_run_with_fakebank (is,
|
||||||
commands,
|
commands,
|
||||||
fakebank_url);
|
bc.bank_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1022,19 +962,18 @@ main (int argc,
|
|||||||
GNUNET_log_setup ("test-exchange-api",
|
GNUNET_log_setup ("test-exchange-api",
|
||||||
"INFO",
|
"INFO",
|
||||||
NULL);
|
NULL);
|
||||||
if (NULL == (fakebank_url
|
/* Check fakebank port is available and get config */
|
||||||
/* Check fakebank port is available and config cares
|
if (GNUNET_OK !=
|
||||||
* about bank url. */
|
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
||||||
= TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
"account-2",
|
||||||
"account-2")))
|
&bc))
|
||||||
return 77;
|
return 77;
|
||||||
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
||||||
/* @helpers. Run keyup, create tables, ... Note: it
|
/* @helpers. Run keyup, create tables, ... Note: it
|
||||||
* fetches the port number from config in order to see
|
* fetches the port number from config in order to see
|
||||||
* if it's available. */
|
* if it's available. */
|
||||||
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
||||||
&auditor_url,
|
&ec))
|
||||||
&exchange_url))
|
|
||||||
{
|
{
|
||||||
case GNUNET_SYSERR:
|
case GNUNET_SYSERR:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<http://www.gnu.org/licenses/>
|
<http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file exchange-lib/test_exchange_api_keys_cherry_picking.c
|
* @file lib/test_exchange_api_keys_cherry_picking.c
|
||||||
* @brief testcase to test exchange's /keys cherry picking ability
|
* @brief testcase to test exchange's /keys cherry picking ability
|
||||||
* @author Marcello Stanisci
|
* @author Marcello Stanisci
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
@ -84,14 +84,9 @@
|
|||||||
#define JAN2030 "2030-01-01"
|
#define JAN2030 "2030-01-01"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange base URL; mainly purpose is to make the compiler happy.
|
* Exchange configuration data.
|
||||||
*/
|
*/
|
||||||
static char *exchange_url;
|
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||||
|
|
||||||
/**
|
|
||||||
* Auditor base URL; mainly purpose is to make the compiler happy.
|
|
||||||
*/
|
|
||||||
static char *auditor_url;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -239,8 +234,7 @@ main (int argc,
|
|||||||
* fetches the port number from config in order to see
|
* fetches the port number from config in order to see
|
||||||
* if it's available. */
|
* if it's available. */
|
||||||
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
||||||
&auditor_url,
|
&ec))
|
||||||
&exchange_url))
|
|
||||||
{
|
{
|
||||||
case GNUNET_SYSERR:
|
case GNUNET_SYSERR:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -55,14 +55,9 @@
|
|||||||
"test_exchange_api_keys_cherry_picking_extended_2.conf"
|
"test_exchange_api_keys_cherry_picking_extended_2.conf"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange base URL; mainly purpose is to make the compiler happy.
|
* Exchange configuration data.
|
||||||
*/
|
*/
|
||||||
static char *exchange_url;
|
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||||
|
|
||||||
/**
|
|
||||||
* Auditor base URL; mainly purpose is to make the compiler happy.
|
|
||||||
*/
|
|
||||||
static char *auditor_url;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,8 +101,7 @@ main (int argc,
|
|||||||
* fetches the port number from config in order to see
|
* fetches the port number from config in order to see
|
||||||
* if it's available. */
|
* if it's available. */
|
||||||
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
||||||
&auditor_url,
|
&ec))
|
||||||
&exchange_url))
|
|
||||||
{
|
{
|
||||||
case GNUNET_SYSERR:
|
case GNUNET_SYSERR:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include "taler_bank_service.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
#include <taler/taler_twister_testing_lib.h>
|
#include <taler/taler_twister_testing_lib.h>
|
||||||
#include <taler/taler_twister_service.h>
|
#include <taler/taler_twister_service.h>
|
||||||
|
|
||||||
@ -49,47 +48,20 @@
|
|||||||
static char *twister_url;
|
static char *twister_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL of the fakebank. Obtained from CONFIG_FILE's
|
* Exchange configuration data.
|
||||||
* "exchange-wire-test:BANK_URI" option.
|
|
||||||
*/
|
*/
|
||||||
static char *fakebank_url;
|
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange base URL.
|
* Bank configuration data.
|
||||||
*/
|
*/
|
||||||
static char *exchange_url;
|
static struct TALER_TESTING_BankConfiguration bc;
|
||||||
|
|
||||||
/**
|
|
||||||
* Auditor URL, unused but needed to achieve compilation.
|
|
||||||
*/
|
|
||||||
static char *auditor_url;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Twister process.
|
* Twister process.
|
||||||
*/
|
*/
|
||||||
static struct GNUNET_OS_Process *twisterd;
|
static struct GNUNET_OS_Process *twisterd;
|
||||||
|
|
||||||
/**
|
|
||||||
* URL of the exchange's account at the bank. Obtained from CONFIG_FILE's
|
|
||||||
* "exchange-wire-test:BANK_URI" option plus the exchange account.
|
|
||||||
*/
|
|
||||||
static char *exchange_account_url; // FIXME: initialize!
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Account number of the exchange at the bank.
|
|
||||||
*/
|
|
||||||
#define EXCHANGE_ACCOUNT_NO "2" // FIXME: used?
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Payto URL of the user's account.
|
|
||||||
*/
|
|
||||||
static char *user_account_payto; // FIXME: initialize!
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Credentials for talking to the bank.
|
|
||||||
*/
|
|
||||||
static struct TALER_BANK_AuthenticationData auth; // FIXME: initialize!
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the taler-exchange-wirewatch command with
|
* Execute the taler-exchange-wirewatch command with
|
||||||
@ -119,9 +91,9 @@ static struct TALER_BANK_AuthenticationData auth; // FIXME: initialize!
|
|||||||
*/
|
*/
|
||||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||||
exchange_account_url, \
|
bc.exchange_account_url, \
|
||||||
&auth, \
|
&bc.exchange_auth, \
|
||||||
user_account_payto)
|
bc.user42_payto)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,9 +132,7 @@ run (void *cls,
|
|||||||
("refresh-deposit-partial",
|
("refresh-deposit-partial",
|
||||||
"refresh-withdraw-coin",
|
"refresh-withdraw-coin",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user42_payto,
|
||||||
(42,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\
|
"{\"items\":[{\"name\":\"ice cream\",\
|
||||||
\"value\":\"EUR:1\"}]}",
|
\"value\":\"EUR:1\"}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
@ -212,9 +182,7 @@ run (void *cls,
|
|||||||
("deposit-refund-1",
|
("deposit-refund-1",
|
||||||
"withdraw-coin-r1",
|
"withdraw-coin-r1",
|
||||||
0,
|
0,
|
||||||
TALER_TESTING_make_wire_details
|
bc.user42_payto,
|
||||||
(42,
|
|
||||||
fakebank_url),
|
|
||||||
"{\"items\":[{\"name\":\"ice cream\","
|
"{\"items\":[{\"name\":\"ice cream\","
|
||||||
"\"value\":\"EUR:5\"}]}",
|
"\"value\":\"EUR:5\"}]}",
|
||||||
GNUNET_TIME_UNIT_MINUTES,
|
GNUNET_TIME_UNIT_MINUTES,
|
||||||
@ -251,9 +219,7 @@ run (void *cls,
|
|||||||
("deposit-refund-to-fail",
|
("deposit-refund-to-fail",
|
||||||
"withdraw-coin-r1",
|
"withdraw-coin-r1",
|
||||||
0, /* coin index. */
|
0, /* coin index. */
|
||||||
TALER_TESTING_make_wire_details
|
bc.user42_payto,
|
||||||
(42,
|
|
||||||
fakebank_url),
|
|
||||||
/* This parameter will make any comparison about
|
/* This parameter will make any comparison about
|
||||||
h_contract_terms fail, when /refund will be handled.
|
h_contract_terms fail, when /refund will be handled.
|
||||||
So in other words, this is h_contract missmatch. */
|
So in other words, this is h_contract missmatch. */
|
||||||
@ -293,7 +259,7 @@ run (void *cls,
|
|||||||
|
|
||||||
TALER_TESTING_run_with_fakebank (is,
|
TALER_TESTING_run_with_fakebank (is,
|
||||||
commands,
|
commands,
|
||||||
fakebank_url);
|
bc.bank_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -322,9 +288,10 @@ main (int argc,
|
|||||||
GNUNET_log_setup ("test-exchange-api-twisted",
|
GNUNET_log_setup ("test-exchange-api-twisted",
|
||||||
"DEBUG", NULL);
|
"DEBUG", NULL);
|
||||||
|
|
||||||
if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank
|
if (GNUNET_OK !=
|
||||||
(CONFIG_FILE,
|
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
||||||
"account-2")))
|
"account-2",
|
||||||
|
&bc))
|
||||||
return 77;
|
return 77;
|
||||||
|
|
||||||
if (NULL == (twister_url = TALER_TESTING_prepare_twister
|
if (NULL == (twister_url = TALER_TESTING_prepare_twister
|
||||||
@ -334,8 +301,7 @@ main (int argc,
|
|||||||
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
||||||
|
|
||||||
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
||||||
&auditor_url,
|
&ec))
|
||||||
&exchange_url))
|
|
||||||
{
|
{
|
||||||
case GNUNET_SYSERR:
|
case GNUNET_SYSERR:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -345,8 +311,7 @@ main (int argc,
|
|||||||
|
|
||||||
case GNUNET_OK:
|
case GNUNET_OK:
|
||||||
|
|
||||||
if (NULL == (twisterd = TALER_TESTING_run_twister
|
if (NULL == (twisterd = TALER_TESTING_run_twister (CONFIG_FILE)))
|
||||||
(CONFIG_FILE)))
|
|
||||||
return 77;
|
return 77;
|
||||||
|
|
||||||
ret = TALER_TESTING_setup_with_exchange (&run,
|
ret = TALER_TESTING_setup_with_exchange (&run,
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <gnunet/gnunet_curl_lib.h>
|
#include <gnunet/gnunet_curl_lib.h>
|
||||||
#include "taler_exchange_service.h"
|
#include "taler_exchange_service.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_bank_service.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
|
@ -16,19 +16,16 @@
|
|||||||
License along with TALER; see the file COPYING. If not, see
|
License along with TALER; see the file COPYING. If not, see
|
||||||
<http://www.gnu.org/licenses/>
|
<http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file bank-lib/testing_api_cmd_history.c
|
* @file bank-lib/testing_api_cmd_history.c
|
||||||
* @brief command to check the /history API from the bank.
|
* @brief command to check the /history API from the bank.
|
||||||
* @author Marcello Stanisci
|
* @author Marcello Stanisci
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
#include <gnunet/gnunet_curl_lib.h>
|
#include <gnunet/gnunet_curl_lib.h>
|
||||||
#include "taler_exchange_service.h"
|
#include "taler_exchange_service.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_bank_service.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_testing_bank_lib.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -480,7 +480,7 @@ deposit_traits (void *cls,
|
|||||||
* coins, this parameter selects which one in that array.
|
* coins, this parameter selects which one in that array.
|
||||||
* This value is currently ignored, as only one-coin
|
* This value is currently ignored, as only one-coin
|
||||||
* withdrawals are implemented.
|
* withdrawals are implemented.
|
||||||
* @param wire_details wire details associated with the "deposit"
|
* @param target_account_payto target account for the "deposit"
|
||||||
* request.
|
* request.
|
||||||
* @param contract_terms contract terms to be signed over by the
|
* @param contract_terms contract terms to be signed over by the
|
||||||
* coin.
|
* coin.
|
||||||
@ -497,14 +497,16 @@ TALER_TESTING_cmd_deposit
|
|||||||
(const char *label,
|
(const char *label,
|
||||||
const char *coin_reference,
|
const char *coin_reference,
|
||||||
unsigned int coin_index,
|
unsigned int coin_index,
|
||||||
json_t *wire_details,
|
const char *target_account_payto,
|
||||||
const char *contract_terms,
|
const char *contract_terms,
|
||||||
struct GNUNET_TIME_Relative refund_deadline,
|
struct GNUNET_TIME_Relative refund_deadline,
|
||||||
const char *amount,
|
const char *amount,
|
||||||
unsigned int expected_response_code)
|
unsigned int expected_response_code)
|
||||||
{
|
{
|
||||||
struct DepositState *ds;
|
struct DepositState *ds;
|
||||||
|
json_t *wire_details;
|
||||||
|
|
||||||
|
wire_details = TALER_TESTING_make_wire_details (target_account_payto);
|
||||||
ds = GNUNET_new (struct DepositState);
|
ds = GNUNET_new (struct DepositState);
|
||||||
ds->coin_reference = coin_reference;
|
ds->coin_reference = coin_reference;
|
||||||
ds->coin_index = coin_index;
|
ds->coin_index = coin_index;
|
||||||
|
@ -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
|
||||||
@ -16,16 +16,14 @@
|
|||||||
License along with TALER; see the file COPYING. If not, see
|
License along with TALER; see the file COPYING. If not, see
|
||||||
<http://www.gnu.org/licenses/>
|
<http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file bank-lib/testing_api_helpers.c
|
* @file bank-lib/testing_api_helpers.c
|
||||||
* @brief convenience functions for bank-lib tests.
|
* @brief convenience functions for bank-lib tests.
|
||||||
* @author Marcello Stanisci
|
* @author Marcello Stanisci
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include "taler_testing_bank_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
|
|
||||||
|
|
||||||
@ -33,29 +31,6 @@
|
|||||||
do {GNUNET_break (0); return NULL; } while (0)
|
do {GNUNET_break (0); return NULL; } while (0)
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Keep each bank account credentials at index:
|
|
||||||
* bank account number - 1
|
|
||||||
*/
|
|
||||||
struct TALER_BANK_AuthenticationData AUTHS[] = {
|
|
||||||
|
|
||||||
/* Bank credentials */
|
|
||||||
{.method = TALER_BANK_AUTH_BASIC,
|
|
||||||
.details.basic.username = TALER_TESTING_BANK_USERNAME,
|
|
||||||
.details.basic.password = TALER_TESTING_BANK_PASSWORD},
|
|
||||||
|
|
||||||
/* Exchange credentials */
|
|
||||||
{.method = TALER_BANK_AUTH_BASIC,
|
|
||||||
.details.basic.username = TALER_TESTING_EXCHANGE_USERNAME,
|
|
||||||
.details.basic.password = TALER_TESTING_EXCHANGE_PASSWORD },
|
|
||||||
|
|
||||||
/* User credentials */
|
|
||||||
{.method = TALER_BANK_AUTH_BASIC,
|
|
||||||
.details.basic.username = TALER_TESTING_USER_USERNAME,
|
|
||||||
.details.basic.password = TALER_TESTING_USER_PASSWORD }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the Fakebank by guessing / extracting the portnumber
|
* Runs the Fakebank by guessing / extracting the portnumber
|
||||||
* from the base URL.
|
* from the base URL.
|
||||||
@ -244,19 +219,19 @@ TALER_TESTING_run_bank (const char *config_filename,
|
|||||||
* and reset database.
|
* and reset database.
|
||||||
*
|
*
|
||||||
* @param config_filename configuration file name.
|
* @param config_filename configuration file name.
|
||||||
*
|
* @param bc[out] set to the bank's configuration data
|
||||||
* @return the base url, or NULL upon errors. Must be freed
|
* @return the base url, or NULL upon errors. Must be freed
|
||||||
* by the caller.
|
* by the caller.
|
||||||
*/
|
*/
|
||||||
char *
|
int
|
||||||
TALER_TESTING_prepare_bank (const char *config_filename)
|
TALER_TESTING_prepare_bank (const char *config_filename,
|
||||||
|
struct TALER_TESTING_BankConfiguration *bc)
|
||||||
{
|
{
|
||||||
struct GNUNET_CONFIGURATION_Handle *cfg;
|
struct GNUNET_CONFIGURATION_Handle *cfg;
|
||||||
unsigned long long port;
|
unsigned long long port;
|
||||||
struct GNUNET_OS_Process *dbreset_proc;
|
struct GNUNET_OS_Process *dbreset_proc;
|
||||||
enum GNUNET_OS_ProcessStatusType type;
|
enum GNUNET_OS_ProcessStatusType type;
|
||||||
unsigned long code;
|
unsigned long code;
|
||||||
char *base_url;
|
|
||||||
char *database;
|
char *database;
|
||||||
|
|
||||||
cfg = GNUNET_CONFIGURATION_create ();
|
cfg = GNUNET_CONFIGURATION_create ();
|
||||||
@ -265,7 +240,8 @@ TALER_TESTING_prepare_bank (const char *config_filename)
|
|||||||
GNUNET_CONFIGURATION_load (cfg, config_filename))
|
GNUNET_CONFIGURATION_load (cfg, config_filename))
|
||||||
{
|
{
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
BANK_FAIL ();
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
@ -277,7 +253,8 @@ TALER_TESTING_prepare_bank (const char *config_filename)
|
|||||||
"bank",
|
"bank",
|
||||||
"DATABASE");
|
"DATABASE");
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
BANK_FAIL ();
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -291,17 +268,21 @@ TALER_TESTING_prepare_bank (const char *config_filename)
|
|||||||
"HTTP_PORT");
|
"HTTP_PORT");
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
GNUNET_free (database);
|
GNUNET_free (database);
|
||||||
BANK_FAIL ();
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
|
|
||||||
if (GNUNET_OK != GNUNET_NETWORK_test_port_free
|
if (GNUNET_OK !=
|
||||||
(IPPROTO_TCP, (uint16_t) port))
|
GNUNET_NETWORK_test_port_free (IPPROTO_TCP,
|
||||||
|
(uint16_t) port))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Required port %llu not available, skipping.\n",
|
"Required port %llu not available, skipping.\n",
|
||||||
port);
|
port);
|
||||||
BANK_FAIL ();
|
GNUNET_break (0);
|
||||||
|
GNUNET_free (database);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DB preparation */
|
/* DB preparation */
|
||||||
@ -321,7 +302,7 @@ TALER_TESTING_prepare_bank (const char *config_filename)
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Failed to flush the bank db.\n");
|
"Failed to flush the bank db.\n");
|
||||||
GNUNET_free (database);
|
GNUNET_free (database);
|
||||||
BANK_FAIL ();
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
GNUNET_free (database);
|
GNUNET_free (database);
|
||||||
|
|
||||||
@ -331,31 +312,161 @@ TALER_TESTING_prepare_bank (const char *config_filename)
|
|||||||
&code))
|
&code))
|
||||||
{
|
{
|
||||||
GNUNET_OS_process_destroy (dbreset_proc);
|
GNUNET_OS_process_destroy (dbreset_proc);
|
||||||
BANK_FAIL ();
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if ( (type == GNUNET_OS_PROCESS_EXITED) &&
|
if ( (type == GNUNET_OS_PROCESS_EXITED) &&
|
||||||
(0 != code) )
|
(0 != code) )
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Failed to setup database\n");
|
"Failed to setup database\n");
|
||||||
BANK_FAIL ();
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if ( (type != GNUNET_OS_PROCESS_EXITED) ||
|
if ( (type != GNUNET_OS_PROCESS_EXITED) ||
|
||||||
(0 != code) )
|
(0 != code) )
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Unexpected error running"
|
"Unexpected error running `taler-bank-manage django flush'!\n");
|
||||||
" `taler-bank-manage django flush..'!\n");
|
GNUNET_break (0);
|
||||||
BANK_FAIL ();
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_OS_process_destroy (dbreset_proc);
|
GNUNET_OS_process_destroy (dbreset_proc);
|
||||||
|
|
||||||
GNUNET_asprintf (&base_url,
|
GNUNET_asprintf (&bc->bank_url,
|
||||||
"http://localhost:%llu/",
|
"http://localhost:%llu/",
|
||||||
port);
|
port);
|
||||||
return base_url;
|
// FIXME: initialize rest of 'bc':
|
||||||
|
bc->exchange_account_url = NULL; // FIXME
|
||||||
|
bc->exchange_auth; // FIXME
|
||||||
|
bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "2");
|
||||||
|
bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
|
||||||
|
bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
|
||||||
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* end of testing_api_helpers.c */
|
/**
|
||||||
|
* Prepare launching a fakebank. Check that the configuration
|
||||||
|
* file has the right option, and that the port is available.
|
||||||
|
* If everything is OK, return the configuration data of the fakebank.
|
||||||
|
*
|
||||||
|
* @param config_filename configuration file to use
|
||||||
|
* @param config_section which account to use (must match x-taler-bank)
|
||||||
|
* @param bc[out] set to the bank's configuration data
|
||||||
|
* @return #GNUNET_OK on success
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_TESTING_prepare_fakebank (const char *config_filename,
|
||||||
|
const char *config_section,
|
||||||
|
struct TALER_TESTING_BankConfiguration *bc)
|
||||||
|
{
|
||||||
|
struct GNUNET_CONFIGURATION_Handle *cfg;
|
||||||
|
char *payto_url;
|
||||||
|
char *fakebank_url;
|
||||||
|
const char *start;
|
||||||
|
const char *end;
|
||||||
|
|
||||||
|
cfg = GNUNET_CONFIGURATION_create ();
|
||||||
|
if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
|
||||||
|
config_filename))
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
|
config_section,
|
||||||
|
"URL",
|
||||||
|
&payto_url))
|
||||||
|
{
|
||||||
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
||||||
|
config_section,
|
||||||
|
"URL");
|
||||||
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
|
if (0 != strncasecmp (payto_url,
|
||||||
|
"payto://x-taler-bank/",
|
||||||
|
strlen ("payto://x-taler-bank/")))
|
||||||
|
{
|
||||||
|
GNUNET_log_config_invalid
|
||||||
|
(GNUNET_ERROR_TYPE_WARNING,
|
||||||
|
config_section,
|
||||||
|
"URL",
|
||||||
|
"expected `x-taler-bank' payto://-URL");
|
||||||
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
|
GNUNET_free (payto_url);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
start = &payto_url [strlen ("payto://x-taler-bank/")];
|
||||||
|
end = strchr (start,
|
||||||
|
(unsigned char) '/');
|
||||||
|
if (NULL == end)
|
||||||
|
end = &start[strlen (start)];
|
||||||
|
fakebank_url = GNUNET_strndup (start,
|
||||||
|
end - start);
|
||||||
|
GNUNET_free (payto_url);
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_TESTING_url_port_free (fakebank_url))
|
||||||
|
{
|
||||||
|
GNUNET_free (fakebank_url);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
bc->bank_url = fakebank_url;
|
||||||
|
// FIXME: initialize rest of 'bc':
|
||||||
|
bc->exchange_account_url = NULL; // FIXME
|
||||||
|
bc->exchange_auth; // FIXME
|
||||||
|
bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "2");
|
||||||
|
bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
|
||||||
|
bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
|
||||||
|
return GNUNET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an x-taler-bank payto:// URL from a @a bank_url
|
||||||
|
* and an @a account_name.
|
||||||
|
*
|
||||||
|
* @param bank_url the bank URL
|
||||||
|
* @param account_name the account name
|
||||||
|
* @return payto:// URL
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
TALER_TESTING_make_xtalerbank_payto (const char *bank_url,
|
||||||
|
const char *account_name)
|
||||||
|
{
|
||||||
|
char *payto;
|
||||||
|
int ends_slash;
|
||||||
|
|
||||||
|
if (0 < strlen (bank_url))
|
||||||
|
ends_slash = '/' == bank_url[strlen (bank_url) - 1];
|
||||||
|
else
|
||||||
|
ends_slash = 0;
|
||||||
|
GNUNET_asprintf (&payto,
|
||||||
|
(ends_slash)
|
||||||
|
? "payto://x-taler-bank/%s%s"
|
||||||
|
: "payto://x-taler-bank/%s/%s",
|
||||||
|
bank_url,
|
||||||
|
account_name);
|
||||||
|
return payto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocate and return a piece of wire-details. Combines
|
||||||
|
* a @a payto -URL and adds some salt to create the JSON.
|
||||||
|
*
|
||||||
|
* @param payto payto://-URL to encapsulate
|
||||||
|
* @return JSON describing the account, including the
|
||||||
|
* payto://-URL of the account, must be manually decref'd
|
||||||
|
*/
|
||||||
|
json_t *
|
||||||
|
TALER_TESTING_make_wire_details (const char *payto)
|
||||||
|
{
|
||||||
|
return json_pack ("{s:s, s:s}",
|
||||||
|
"url", payto,
|
||||||
|
"salt",
|
||||||
|
"test-salt (must be constant for aggregation tests)");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* end of testing_api_helpers_bank.c */
|
||||||
|
@ -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
|
||||||
@ -339,15 +339,9 @@ TALER_TESTING_auditor_db_reset (const char *config_filename)
|
|||||||
struct SignInfo
|
struct SignInfo
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Set to the base URL of the exchange. To be free'd
|
* Members will be set to the exchange configuration.
|
||||||
* by the caller.
|
|
||||||
*/
|
*/
|
||||||
char *exchange_base_url;
|
struct TALER_TESTING_ExchangeConfiguration *ec;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to the auditor's base URL. To be free'd by the caller.
|
|
||||||
*/
|
|
||||||
char *auditor_base_url;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the configuration file to use.
|
* Name of the configuration file to use.
|
||||||
@ -379,17 +373,18 @@ sign_keys_for_exchange (void *cls,
|
|||||||
char *test_home_dir;
|
char *test_home_dir;
|
||||||
char *signed_keys_out;
|
char *signed_keys_out;
|
||||||
char *exchange_master_pub;
|
char *exchange_master_pub;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
"exchange",
|
"exchange",
|
||||||
"BASE_URL",
|
"BASE_URL",
|
||||||
&si->exchange_base_url))
|
&si->ec->exchange_url))
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
||||||
"exchange",
|
"exchange",
|
||||||
"BASE_URL");
|
"BASE_URL");
|
||||||
si->exchange_base_url = NULL;
|
si->ec->exchange_url = NULL;
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,14 +392,14 @@ sign_keys_for_exchange (void *cls,
|
|||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
"auditor",
|
"auditor",
|
||||||
"BASE_URL",
|
"BASE_URL",
|
||||||
&si->auditor_base_url))
|
&si->ec->auditor_url))
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
||||||
"auditor",
|
"auditor",
|
||||||
"BASE_URL");
|
"BASE_URL");
|
||||||
GNUNET_free (si->exchange_base_url);
|
GNUNET_free (si->ec->exchange_url);
|
||||||
si->exchange_base_url = NULL;
|
si->ec->exchange_url = NULL;
|
||||||
si->auditor_base_url = NULL;
|
si->ec->auditor_url = NULL;
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,11 +412,8 @@ sign_keys_for_exchange (void *cls,
|
|||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"paths",
|
"paths",
|
||||||
"TALER_TEST_HOME");
|
"TALER_TEST_HOME");
|
||||||
GNUNET_free (si->exchange_base_url);
|
ret = GNUNET_SYSERR;
|
||||||
GNUNET_free (si->auditor_base_url);
|
goto fail;
|
||||||
si->exchange_base_url = NULL;
|
|
||||||
si->auditor_base_url = NULL;
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_asprintf (&signed_keys_out,
|
GNUNET_asprintf (&signed_keys_out,
|
||||||
@ -438,42 +430,42 @@ sign_keys_for_exchange (void *cls,
|
|||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"exchange",
|
"exchange",
|
||||||
"MASTER_PUBLIC_KEY");
|
"MASTER_PUBLIC_KEY");
|
||||||
GNUNET_free (si->exchange_base_url);
|
|
||||||
GNUNET_free (si->auditor_base_url);
|
|
||||||
si->exchange_base_url = NULL;
|
|
||||||
si->auditor_base_url = NULL;
|
|
||||||
GNUNET_free (signed_keys_out);
|
GNUNET_free (signed_keys_out);
|
||||||
return GNUNET_SYSERR;
|
ret = GNUNET_SYSERR;
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_run_auditor_exchange (si->config_filename,
|
TALER_TESTING_run_auditor_exchange (si->config_filename,
|
||||||
exchange_master_pub,
|
exchange_master_pub,
|
||||||
si->exchange_base_url,
|
si->ec->exchange_url,
|
||||||
GNUNET_NO))
|
GNUNET_NO))
|
||||||
{
|
{
|
||||||
GNUNET_free (si->exchange_base_url);
|
GNUNET_free (signed_keys_out);
|
||||||
GNUNET_free (si->auditor_base_url);
|
ret = GNUNET_NO;
|
||||||
si->exchange_base_url = NULL;
|
goto fail;
|
||||||
si->auditor_base_url = NULL;
|
|
||||||
return GNUNET_NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_run_auditor_sign (si->config_filename,
|
TALER_TESTING_run_auditor_sign (si->config_filename,
|
||||||
exchange_master_pub,
|
exchange_master_pub,
|
||||||
si->auditor_base_url,
|
si->ec->auditor_url,
|
||||||
si->auditor_sign_input_filename,
|
si->auditor_sign_input_filename,
|
||||||
signed_keys_out))
|
signed_keys_out))
|
||||||
{
|
{
|
||||||
GNUNET_free (si->exchange_base_url);
|
GNUNET_free (signed_keys_out);
|
||||||
GNUNET_free (si->auditor_base_url);
|
GNUNET_free (exchange_master_pub);
|
||||||
si->exchange_base_url = NULL;
|
ret = GNUNET_NO;
|
||||||
si->auditor_base_url = NULL;
|
goto fail;
|
||||||
return GNUNET_NO;
|
|
||||||
}
|
}
|
||||||
GNUNET_free (signed_keys_out);
|
GNUNET_free (signed_keys_out);
|
||||||
GNUNET_free (exchange_master_pub);
|
GNUNET_free (exchange_master_pub);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
|
fail:
|
||||||
|
GNUNET_free (si->ec->exchange_url);
|
||||||
|
GNUNET_free (si->ec->auditor_url);
|
||||||
|
si->ec->exchange_url = NULL;
|
||||||
|
si->ec->auditor_url = NULL;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -484,24 +476,17 @@ sign_keys_for_exchange (void *cls,
|
|||||||
* launch the exchange process itself.
|
* launch the exchange process itself.
|
||||||
*
|
*
|
||||||
* @param config_filename configuration file to use
|
* @param config_filename configuration file to use
|
||||||
* @param auditor_base_url[out] will be set to the auditor base url,
|
* @param ec[out] will be set to the exchange configuration data
|
||||||
* if the config has any; otherwise it will be set to
|
|
||||||
* NULL.
|
|
||||||
* @param exchange_base_url[out] will be set to the exchange base url,
|
|
||||||
* if the config has any; otherwise it will be set to
|
|
||||||
* NULL.
|
|
||||||
* @return #GNUNET_OK on success, #GNUNET_NO if test should be
|
* @return #GNUNET_OK on success, #GNUNET_NO if test should be
|
||||||
* skipped, #GNUNET_SYSERR on test failure
|
* skipped, #GNUNET_SYSERR on test failure
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_prepare_exchange (const char *config_filename,
|
TALER_TESTING_prepare_exchange (const char *config_filename,
|
||||||
char **auditor_base_url,
|
struct TALER_TESTING_ExchangeConfiguration *ec)
|
||||||
char **exchange_base_url)
|
|
||||||
{
|
{
|
||||||
struct SignInfo si = {
|
struct SignInfo si = {
|
||||||
.config_filename = config_filename,
|
.config_filename = config_filename,
|
||||||
.exchange_base_url = NULL,
|
.ec = ec,
|
||||||
.auditor_base_url = NULL,
|
|
||||||
.auditor_sign_input_filename = "auditor.in"
|
.auditor_sign_input_filename = "auditor.in"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -520,8 +505,6 @@ TALER_TESTING_prepare_exchange (const char *config_filename,
|
|||||||
&sign_keys_for_exchange,
|
&sign_keys_for_exchange,
|
||||||
&si))
|
&si))
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
*exchange_base_url = si.exchange_base_url;
|
|
||||||
*auditor_base_url = si.auditor_base_url;
|
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,6 +929,9 @@ TALER_TESTING_setup_with_auditor_and_exchange (TALER_TESTING_Main main_cb,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test port in URL string for availability.
|
* Test port in URL string for availability.
|
||||||
|
*
|
||||||
|
* @param url URL to extract port from, 80 is default
|
||||||
|
* @return #GNUNET_OK if the port is free
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_url_port_free (const char *url)
|
TALER_TESTING_url_port_free (const char *url)
|
||||||
@ -972,109 +958,4 @@ TALER_TESTING_url_port_free (const char *url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocate and return a piece of wire-details. Combines
|
|
||||||
* the @a account_no and the @a bank_url to a
|
|
||||||
* @a payto://-URL and adds some salt to create the JSON.
|
|
||||||
*
|
|
||||||
* @param account_no account number
|
|
||||||
* @param bank_url the bank_url (FIXME/WARNING: shouldn't this be a _hostname_ ??)
|
|
||||||
* @return JSON describing the account, including the
|
|
||||||
* payto://-URL of the account, must be manually decref'd
|
|
||||||
*/
|
|
||||||
json_t *
|
|
||||||
TALER_TESTING_make_wire_details (unsigned long long account_no,
|
|
||||||
const char *bank_url)
|
|
||||||
{
|
|
||||||
char *payto;
|
|
||||||
json_t *ret;
|
|
||||||
int ends_slash;
|
|
||||||
|
|
||||||
if (0 < strlen (bank_url))
|
|
||||||
ends_slash = '/' == bank_url[strlen (bank_url) - 1];
|
|
||||||
else
|
|
||||||
ends_slash = 0;
|
|
||||||
|
|
||||||
GNUNET_asprintf (&payto,
|
|
||||||
(ends_slash)
|
|
||||||
? "payto://x-taler-bank/%s%llu"
|
|
||||||
: "payto://x-taler-bank/%s/%llu",
|
|
||||||
bank_url,
|
|
||||||
account_no);
|
|
||||||
ret = json_pack ("{s:s, s:s}",
|
|
||||||
"url", payto,
|
|
||||||
"salt",
|
|
||||||
"test-salt (must be constant for aggregation tests)");
|
|
||||||
GNUNET_free (payto);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare launching a fakebank. Check that the configuration
|
|
||||||
* file has the right option, and that the port is available.
|
|
||||||
* If everything is OK, return the configured URL of the fakebank.
|
|
||||||
*
|
|
||||||
* @param config_filename configuration file to use
|
|
||||||
* @param config_section which account to use (must match x-taler-bank)
|
|
||||||
* @return NULL on error, fakebank URL otherwise
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
TALER_TESTING_prepare_fakebank (const char *config_filename,
|
|
||||||
const char *config_section)
|
|
||||||
{
|
|
||||||
struct GNUNET_CONFIGURATION_Handle *cfg;
|
|
||||||
char *payto_url;
|
|
||||||
char *fakebank_url;
|
|
||||||
const char *start;
|
|
||||||
const char *end;
|
|
||||||
|
|
||||||
cfg = GNUNET_CONFIGURATION_create ();
|
|
||||||
if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
|
|
||||||
config_filename))
|
|
||||||
return NULL;
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
||||||
config_section,
|
|
||||||
"URL",
|
|
||||||
&payto_url))
|
|
||||||
{
|
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
|
||||||
config_section,
|
|
||||||
"URL");
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
|
||||||
if (0 != strncasecmp (payto_url,
|
|
||||||
"payto://x-taler-bank/",
|
|
||||||
strlen ("payto://x-taler-bank/")))
|
|
||||||
{
|
|
||||||
GNUNET_log_config_invalid
|
|
||||||
(GNUNET_ERROR_TYPE_WARNING,
|
|
||||||
config_section,
|
|
||||||
"URL",
|
|
||||||
"expected `x-taler-bank' payto://-URL");
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
|
||||||
GNUNET_free (payto_url);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
start = &payto_url [strlen ("payto://x-taler-bank/")];
|
|
||||||
end = strchr (start,
|
|
||||||
(unsigned char) '/');
|
|
||||||
if (NULL == end)
|
|
||||||
end = &start[strlen (start)];
|
|
||||||
fakebank_url = GNUNET_strndup (start,
|
|
||||||
end - start);
|
|
||||||
GNUNET_free (payto_url);
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_TESTING_url_port_free (fakebank_url))
|
|
||||||
{
|
|
||||||
GNUNET_free (fakebank_url);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return fakebank_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* end of testing_api_helpers.c */
|
/* end of testing_api_helpers.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user