major libtalertesting API refactoring, including no longer having taler-specific logic in the test engine core
This commit is contained in:
parent
015b08b048
commit
a2dde02b64
@ -17,7 +17,7 @@ AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv
|
||||
|
||||
# What is the Web site of the auditor (i.e. to file complaints about
|
||||
# a misbehaving exchange)?
|
||||
# BASE_URL = https://auditor.taler.net/
|
||||
BASE_URL = http://localhost:8083/
|
||||
|
||||
|
||||
# Network configuration for the normal API/service HTTP server
|
||||
|
@ -132,7 +132,7 @@ handle_mhd_completion_callback (void *cls,
|
||||
|
||||
|
||||
/**
|
||||
* Handle a "/version" request.
|
||||
* Handle a "/config" request.
|
||||
*
|
||||
* @param rh context of the handler
|
||||
* @param connection the MHD connection to handle
|
||||
@ -142,7 +142,7 @@ handle_mhd_completion_callback (void *cls,
|
||||
* @return MHD result code
|
||||
*/
|
||||
static MHD_RESULT
|
||||
handle_version (struct TAH_RequestHandler *rh,
|
||||
handle_config (struct TAH_RequestHandler *rh,
|
||||
struct MHD_Connection *connection,
|
||||
void **connection_cls,
|
||||
const char *upload_data,
|
||||
@ -207,9 +207,9 @@ handle_mhd_request (void *cls,
|
||||
{ "/exchanges", MHD_HTTP_METHOD_GET, "application/json",
|
||||
NULL, 0,
|
||||
&TAH_EXCHANGES_handler, MHD_HTTP_OK },
|
||||
{ "/version", MHD_HTTP_METHOD_GET, "application/json",
|
||||
{ "/config", MHD_HTTP_METHOD_GET, "application/json",
|
||||
NULL, 0,
|
||||
&handle_version, MHD_HTTP_OK },
|
||||
&handle_config, MHD_HTTP_OK },
|
||||
/* Landing page, for now tells humans to go away
|
||||
* (NOTE: ideally, the reverse proxy will respond with a nicer page) */
|
||||
{ "/", MHD_HTTP_METHOD_GET, "text/plain",
|
||||
|
@ -12,11 +12,9 @@ endif
|
||||
|
||||
bin_PROGRAMS = \
|
||||
taler-aggregator-benchmark \
|
||||
taler-bank-benchmark \
|
||||
taler-exchange-benchmark
|
||||
taler-bank-benchmark
|
||||
|
||||
bin_SCRIPTS = \
|
||||
taler-benchmark-setup.sh
|
||||
# taler-exchange-benchmark
|
||||
|
||||
|
||||
taler_aggregator_benchmark_SOURCES = \
|
||||
@ -75,5 +73,4 @@ EXTRA_DIST = \
|
||||
bank-benchmark-rsa.conf \
|
||||
coins-cs.conf \
|
||||
coins-rsa.conf \
|
||||
$(bin_SCRIPTS) \
|
||||
exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv
|
||||
|
@ -58,11 +58,11 @@ MAX_DEBT_BANK=EUR:1000000000000000.0
|
||||
DATABASE=bank-db.sqlite3
|
||||
|
||||
[libeufin-nexus]
|
||||
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
|
||||
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
|
||||
DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
|
||||
|
||||
[libeufin-sandbox]
|
||||
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
|
||||
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
|
||||
DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
|
||||
|
||||
[auditor]
|
||||
|
@ -322,11 +322,8 @@ launch_clients (void)
|
||||
if (1 == howmany_clients)
|
||||
{
|
||||
/* do everything in this process */
|
||||
result = TALER_TESTING_setup (&run,
|
||||
NULL,
|
||||
cfg,
|
||||
NULL,
|
||||
GNUNET_NO);
|
||||
result = TALER_TESTING_loop (&run,
|
||||
NULL);
|
||||
if (verbose)
|
||||
print_stats ();
|
||||
return result;
|
||||
@ -340,11 +337,8 @@ launch_clients (void)
|
||||
GNUNET_log_setup ("benchmark-worker",
|
||||
NULL == loglev ? "INFO" : loglev,
|
||||
logfile);
|
||||
result = TALER_TESTING_setup (&run,
|
||||
NULL,
|
||||
cfg,
|
||||
NULL,
|
||||
GNUNET_NO);
|
||||
result = TALER_TESTING_loop (&run,
|
||||
NULL);
|
||||
if (verbose)
|
||||
print_stats ();
|
||||
if (GNUNET_OK != result)
|
||||
|
@ -85,11 +85,6 @@ enum BenchmarkMode
|
||||
*/
|
||||
static const struct TALER_EXCHANGEDB_AccountInfo *exchange_bank_account;
|
||||
|
||||
/**
|
||||
* Configuration of our exchange.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Hold information about a user at the bank.
|
||||
*/
|
||||
@ -146,11 +141,6 @@ static unsigned int refresh_rate = 10;
|
||||
*/
|
||||
static unsigned int howmany_clients = 1;
|
||||
|
||||
/**
|
||||
* Bank configuration to use.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Log level used during the run.
|
||||
*/
|
||||
@ -474,45 +464,6 @@ print_stats (void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stop the fakebank.
|
||||
*
|
||||
* @param cls fakebank handle
|
||||
*/
|
||||
static void
|
||||
stop_fakebank (void *cls)
|
||||
{
|
||||
struct TALER_FAKEBANK_Handle *fakebank = cls;
|
||||
|
||||
TALER_FAKEBANK_stop (fakebank);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start the fakebank.
|
||||
*
|
||||
* @param cls NULL
|
||||
*/
|
||||
static void
|
||||
launch_fakebank (void *cls)
|
||||
{
|
||||
struct TALER_FAKEBANK_Handle *fakebank;
|
||||
|
||||
(void) cls;
|
||||
fakebank
|
||||
= TALER_TESTING_run_fakebank (
|
||||
exchange_bank_account->auth->wire_gateway_url,
|
||||
currency);
|
||||
if (NULL == fakebank)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return;
|
||||
}
|
||||
GNUNET_SCHEDULER_add_shutdown (&stop_fakebank,
|
||||
fakebank);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the benchmark in parallel in many (client) processes
|
||||
* and summarize result.
|
||||
@ -531,148 +482,6 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
|
||||
pid_t cpids[howmany_clients];
|
||||
pid_t fakebank = -1;
|
||||
int wstatus;
|
||||
struct GNUNET_OS_Process *bankd = NULL;
|
||||
struct GNUNET_OS_Process *auditord = NULL;
|
||||
struct GNUNET_OS_Process *exchanged = NULL;
|
||||
struct GNUNET_OS_Process *wirewatch = NULL;
|
||||
struct GNUNET_OS_Process *exchange_slave = NULL;
|
||||
struct GNUNET_DISK_PipeHandle *exchange_slave_pipe;
|
||||
|
||||
if ( (MODE_CLIENT == mode) ||
|
||||
(MODE_BOTH == mode) )
|
||||
{
|
||||
if (use_fakebank)
|
||||
{
|
||||
/* start fakebank */
|
||||
fakebank = fork ();
|
||||
if (0 == fakebank)
|
||||
{
|
||||
GNUNET_log_setup ("benchmark-fakebank",
|
||||
NULL == loglev ? "INFO" : loglev,
|
||||
logfile);
|
||||
GNUNET_SCHEDULER_run (&launch_fakebank,
|
||||
NULL);
|
||||
exit (0);
|
||||
}
|
||||
if (-1 == fakebank)
|
||||
{
|
||||
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
|
||||
"fork");
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* start bank */
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_bank (cfg_filename,
|
||||
GNUNET_NO,
|
||||
"exchange-account-test",
|
||||
&bc))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
bankd = TALER_TESTING_run_bank (cfg_filename,
|
||||
"http://localhost:8082/");
|
||||
if (NULL == bankd)
|
||||
return 77;
|
||||
}
|
||||
}
|
||||
|
||||
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
|
||||
{
|
||||
/* start exchange */
|
||||
exchanged = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
|
||||
NULL, NULL, NULL,
|
||||
"taler-exchange-httpd",
|
||||
"taler-exchange-httpd",
|
||||
"-c", config_file,
|
||||
"-C",
|
||||
NULL);
|
||||
if ( (NULL == exchanged) &&
|
||||
(MODE_BOTH == mode) )
|
||||
{
|
||||
if (-1 != fakebank)
|
||||
{
|
||||
kill (fakebank,
|
||||
SIGTERM);
|
||||
waitpid (fakebank,
|
||||
&wstatus,
|
||||
0);
|
||||
}
|
||||
if (NULL != bankd)
|
||||
{
|
||||
GNUNET_OS_process_kill (bankd,
|
||||
SIGTERM);
|
||||
GNUNET_OS_process_destroy (bankd);
|
||||
}
|
||||
return 77;
|
||||
}
|
||||
/* start auditor */
|
||||
auditord = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
|
||||
NULL, NULL, NULL,
|
||||
"taler-auditor-httpd",
|
||||
"taler-auditor-httpd",
|
||||
"-c", config_file,
|
||||
NULL);
|
||||
if (NULL == auditord)
|
||||
{
|
||||
GNUNET_OS_process_kill (exchanged,
|
||||
SIGTERM);
|
||||
if (MODE_BOTH == mode)
|
||||
{
|
||||
if (-1 != fakebank)
|
||||
{
|
||||
kill (fakebank,
|
||||
SIGTERM);
|
||||
waitpid (fakebank,
|
||||
&wstatus,
|
||||
0);
|
||||
}
|
||||
if (NULL != bankd)
|
||||
{
|
||||
GNUNET_OS_process_kill (bankd,
|
||||
SIGTERM);
|
||||
GNUNET_OS_process_destroy (bankd);
|
||||
}
|
||||
}
|
||||
GNUNET_OS_process_destroy (exchanged);
|
||||
return 77;
|
||||
}
|
||||
/* start exchange wirewatch */
|
||||
wirewatch = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
|
||||
NULL, NULL, NULL,
|
||||
"taler-exchange-wirewatch",
|
||||
"taler-exchange-wirewatch",
|
||||
"-c", config_file,
|
||||
NULL);
|
||||
if (NULL == wirewatch)
|
||||
{
|
||||
GNUNET_OS_process_kill (auditord,
|
||||
SIGTERM);
|
||||
GNUNET_OS_process_kill (exchanged,
|
||||
SIGTERM);
|
||||
if (MODE_BOTH == mode)
|
||||
{
|
||||
if (-1 != fakebank)
|
||||
{
|
||||
kill (fakebank,
|
||||
SIGTERM);
|
||||
waitpid (fakebank,
|
||||
&wstatus,
|
||||
0);
|
||||
}
|
||||
if (NULL != bankd)
|
||||
{
|
||||
GNUNET_OS_process_kill (bankd,
|
||||
SIGTERM);
|
||||
GNUNET_OS_process_destroy (bankd);
|
||||
}
|
||||
}
|
||||
GNUNET_OS_process_destroy (exchanged);
|
||||
return 77;
|
||||
}
|
||||
}
|
||||
|
||||
if (MODE_CLIENT == mode)
|
||||
{
|
||||
@ -710,58 +519,16 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to detect running exchange at `%s'\n",
|
||||
ec.exchange_url);
|
||||
GNUNET_OS_process_kill (exchanged,
|
||||
SIGTERM);
|
||||
if ( (MODE_BOTH == mode) || (MODE_CLIENT == mode))
|
||||
{
|
||||
if (-1 != fakebank)
|
||||
{
|
||||
kill (fakebank,
|
||||
SIGTERM);
|
||||
waitpid (fakebank,
|
||||
&wstatus,
|
||||
0);
|
||||
}
|
||||
if (NULL != bankd)
|
||||
{
|
||||
GNUNET_OS_process_kill (bankd,
|
||||
SIGTERM);
|
||||
GNUNET_OS_process_destroy (bankd);
|
||||
}
|
||||
}
|
||||
GNUNET_OS_process_wait (exchanged);
|
||||
GNUNET_OS_process_destroy (exchanged);
|
||||
if (NULL != wirewatch)
|
||||
{
|
||||
GNUNET_OS_process_kill (wirewatch,
|
||||
SIGTERM);
|
||||
GNUNET_OS_process_wait (wirewatch);
|
||||
GNUNET_OS_process_destroy (wirewatch);
|
||||
}
|
||||
if (NULL != auditord)
|
||||
{
|
||||
GNUNET_OS_process_kill (auditord,
|
||||
SIGTERM);
|
||||
GNUNET_OS_process_wait (auditord);
|
||||
GNUNET_OS_process_destroy (auditord);
|
||||
}
|
||||
return 77;
|
||||
}
|
||||
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
|
||||
{
|
||||
if (-1 != fakebank)
|
||||
sleep (1); /* make sure fakebank process is ready before continuing */
|
||||
|
||||
start_time = GNUNET_TIME_absolute_get ();
|
||||
result = GNUNET_OK;
|
||||
|
||||
if (1 == howmany_clients)
|
||||
{
|
||||
result = TALER_TESTING_setup (main_cb,
|
||||
main_cb_cls,
|
||||
cfg,
|
||||
exchanged,
|
||||
GNUNET_YES);
|
||||
result = TALER_TESTING_run (main_cb,
|
||||
main_cb_cls);
|
||||
print_stats ();
|
||||
}
|
||||
else
|
||||
@ -775,11 +542,8 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
|
||||
NULL == loglev ? "INFO" : loglev,
|
||||
logfile);
|
||||
|
||||
result = TALER_TESTING_setup (main_cb,
|
||||
main_cb_cls,
|
||||
cfg,
|
||||
exchanged,
|
||||
GNUNET_YES);
|
||||
result = TALER_TESTING_run (main_cb,
|
||||
main_cb_cls);
|
||||
print_stats ();
|
||||
if (GNUNET_OK != result)
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
@ -845,58 +609,6 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
|
||||
GNUNET_OS_process_destroy (exchange_slave);
|
||||
}
|
||||
|
||||
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
|
||||
{
|
||||
GNUNET_assert (NULL != wirewatch);
|
||||
GNUNET_assert (NULL != exchanged);
|
||||
GNUNET_assert (NULL != auditord);
|
||||
/* stop wirewatch */
|
||||
GNUNET_break (0 ==
|
||||
GNUNET_OS_process_kill (wirewatch,
|
||||
SIGTERM));
|
||||
GNUNET_break (GNUNET_OK ==
|
||||
GNUNET_OS_process_wait (wirewatch));
|
||||
GNUNET_OS_process_destroy (wirewatch);
|
||||
/* stop auditor */
|
||||
GNUNET_break (0 ==
|
||||
GNUNET_OS_process_kill (auditord,
|
||||
SIGTERM));
|
||||
GNUNET_break (GNUNET_OK ==
|
||||
GNUNET_OS_process_wait (auditord));
|
||||
GNUNET_OS_process_destroy (auditord);
|
||||
/* stop exchange */
|
||||
GNUNET_break (0 ==
|
||||
GNUNET_OS_process_kill (exchanged,
|
||||
SIGTERM));
|
||||
GNUNET_break (GNUNET_OK ==
|
||||
GNUNET_OS_process_wait (exchanged));
|
||||
GNUNET_OS_process_destroy (exchanged);
|
||||
}
|
||||
|
||||
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
|
||||
{
|
||||
/* stop fakebank */
|
||||
if (-1 != fakebank)
|
||||
{
|
||||
kill (fakebank,
|
||||
SIGTERM);
|
||||
waitpid (fakebank,
|
||||
&wstatus,
|
||||
0);
|
||||
if ( (! WIFEXITED (wstatus)) ||
|
||||
(0 != WEXITSTATUS (wstatus)) )
|
||||
{
|
||||
GNUNET_break (0);
|
||||
result = GNUNET_SYSERR;
|
||||
}
|
||||
}
|
||||
if (NULL != bankd)
|
||||
{
|
||||
GNUNET_OS_process_kill (bankd,
|
||||
SIGTERM);
|
||||
GNUNET_OS_process_destroy (bankd);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1066,39 +778,8 @@ main (int argc,
|
||||
GNUNET_free (cfg_filename);
|
||||
return BAD_CONFIG_FILE;
|
||||
}
|
||||
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
|
||||
{
|
||||
/* If we use the fakebank, we MUST reset the database as the fakebank
|
||||
will have forgotten everything... */
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_exchange (cfg_filename,
|
||||
(GNUNET_YES == use_fakebank)
|
||||
? GNUNET_YES
|
||||
: GNUNET_NO,
|
||||
&ec))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to prepare the exchange for launch\n");
|
||||
GNUNET_free (cfg_filename);
|
||||
return BAD_CONFIG_FILE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||
"exchange",
|
||||
"BASE_URL",
|
||||
&ec.exchange_url))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||
"exchange",
|
||||
"base_url");
|
||||
GNUNET_CONFIGURATION_destroy (cfg);
|
||||
GNUNET_free (cfg_filename);
|
||||
return BAD_CONFIG_FILE;
|
||||
}
|
||||
|
||||
{
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||
"benchmark-remote-exchange",
|
||||
|
@ -3,10 +3,10 @@
|
||||
[exchange-offline]
|
||||
|
||||
# Where do we store the offline master private key of the exchange?
|
||||
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange-offline/master.priv
|
||||
MASTER_PRIV_FILE = ${TALER_DATA_HOME}exchange-offline/master.priv
|
||||
|
||||
# Where do we store the TOFU key material?
|
||||
SECM_TOFU_FILE = ${TALER_DATA_HOME}/exchange-offline/secm_tofus.pub
|
||||
SECM_TOFU_FILE = ${TALER_DATA_HOME}exchange-offline/secm_tofus.pub
|
||||
|
||||
# Base32-encoded public key of the RSA helper.
|
||||
# SECM_DENOM_PUBKEY =
|
||||
|
@ -154,6 +154,7 @@ struct TALER_AUDITOR_HttpResponse
|
||||
* @param vi basic information about the auditor
|
||||
* @param compat protocol compatibility information
|
||||
*/
|
||||
// FIXME: bad API!
|
||||
typedef void
|
||||
(*TALER_AUDITOR_VersionCallback) (
|
||||
void *cls,
|
||||
|
@ -5873,7 +5873,7 @@ TALER_age_commitment_hash (
|
||||
enum GNUNET_GenericReturnValue
|
||||
TALER_age_restriction_commit (
|
||||
const struct TALER_AgeMask *mask,
|
||||
const uint8_t age,
|
||||
uint8_t age,
|
||||
const struct GNUNET_HashCode *seed,
|
||||
struct TALER_AgeCommitmentProof *comm_proof);
|
||||
|
||||
|
@ -623,15 +623,20 @@ enum TALER_EXCHANGE_CheckKeysFlags
|
||||
|
||||
/**
|
||||
* Check if our current response for /keys is valid, and if
|
||||
* not, trigger /keys download.
|
||||
* not, trigger /keys download. If @a cb is given, changes
|
||||
* the @a exchange callback for the /keys response.
|
||||
*
|
||||
* @param exchange exchange to check keys for
|
||||
* @param flags options controlling when to download what
|
||||
* @param cb function to call with the /keys response, can be NULL
|
||||
* @param cb_cls closure for @a cb
|
||||
* @return until when the existing response is current, 0 if we are re-downloading now
|
||||
*/
|
||||
struct GNUNET_TIME_Timestamp
|
||||
TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange,
|
||||
enum TALER_EXCHANGE_CheckKeysFlags flags);
|
||||
enum TALER_EXCHANGE_CheckKeysFlags flags,
|
||||
TALER_EXCHANGE_CertificationCallback cb,
|
||||
void *cb_cls);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -219,12 +219,12 @@ struct TALER_Extensions
|
||||
* Generic functions for extensions
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* @brief Loads the extensions as shared libraries, as specified in the given
|
||||
* TALER configuration.
|
||||
*
|
||||
* @param cfg Handle to the TALER configuration
|
||||
* @return GNUNET_OK on success, GNUNET_SYSERR if unknown extensions were found
|
||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR if unknown extensions were found
|
||||
* or any particular configuration couldn't be parsed.
|
||||
*/
|
||||
enum GNUNET_GenericReturnValue
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -102,7 +102,7 @@ struct TALER_AUDITOR_Handle
|
||||
void *version_cb_cls;
|
||||
|
||||
/**
|
||||
* Data for the request to get the /version of a auditor,
|
||||
* Data for the request to get the /config of a auditor,
|
||||
* NULL once we are past stage #MHS_INIT.
|
||||
*/
|
||||
struct GNUNET_CURL_Job *vr;
|
||||
@ -113,12 +113,12 @@ struct TALER_AUDITOR_Handle
|
||||
char *vr_url;
|
||||
|
||||
/**
|
||||
* Task for retrying /version request.
|
||||
* Task for retrying /config request.
|
||||
*/
|
||||
struct GNUNET_SCHEDULER_Task *retry_task;
|
||||
|
||||
/**
|
||||
* /version data of the auditor, only valid if
|
||||
* /config data of the auditor, only valid if
|
||||
* @e handshake_complete is past stage #MHS_VERSION.
|
||||
*/
|
||||
char *version;
|
||||
@ -129,7 +129,7 @@ struct TALER_AUDITOR_Handle
|
||||
struct TALER_AUDITOR_VersionInformation vi;
|
||||
|
||||
/**
|
||||
* Retry /version frequency.
|
||||
* Retry /config frequency.
|
||||
*/
|
||||
struct GNUNET_TIME_Relative retry_delay;
|
||||
|
||||
@ -141,10 +141,10 @@ struct TALER_AUDITOR_Handle
|
||||
};
|
||||
|
||||
|
||||
/* ***************** Internal /version fetching ************* */
|
||||
/* ***************** Internal /config fetching ************* */
|
||||
|
||||
/**
|
||||
* Decode the JSON in @a resp_obj from the /version response and store the data
|
||||
* Decode the JSON in @a resp_obj from the /config response and store the data
|
||||
* in the @a key_data.
|
||||
*
|
||||
* @param[in] resp_obj JSON object to parse
|
||||
@ -216,16 +216,16 @@ decode_version_json (const json_t *resp_obj,
|
||||
|
||||
|
||||
/**
|
||||
* Initiate download of /version from the auditor.
|
||||
* Initiate download of /config from the auditor.
|
||||
*
|
||||
* @param cls auditor where to download /version from
|
||||
* @param cls auditor where to download /config from
|
||||
*/
|
||||
static void
|
||||
request_version (void *cls);
|
||||
|
||||
|
||||
/**
|
||||
* Callback used when downloading the reply to a /version request
|
||||
* Callback used when downloading the reply to a /config request
|
||||
* is complete.
|
||||
*
|
||||
* @param cls the `struct TALER_AUDITOR_Handle`
|
||||
@ -267,7 +267,7 @@ version_completed_cb (void *cls,
|
||||
if (NULL == resp_obj)
|
||||
{
|
||||
GNUNET_break_op (0);
|
||||
TALER_LOG_WARNING ("NULL body for a 200-OK /version\n");
|
||||
TALER_LOG_WARNING ("NULL body for a 200-OK /config\n");
|
||||
hr.http_status = 0;
|
||||
hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
|
||||
break;
|
||||
@ -295,7 +295,7 @@ version_completed_cb (void *cls,
|
||||
if (MHD_HTTP_OK != response_code)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"/version failed for auditor %s: %u!\n",
|
||||
"/config failed for auditor %s: %u!\n",
|
||||
auditor->url,
|
||||
(unsigned int) response_code);
|
||||
auditor->state = MHS_FAILED;
|
||||
@ -309,7 +309,7 @@ version_completed_cb (void *cls,
|
||||
TALER_LOG_DEBUG ("Switching auditor state to 'version'\n");
|
||||
auditor->state = MHS_VERSION;
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Auditor %s is now READY!\n",
|
||||
"Auditor %s is ready!\n",
|
||||
auditor->url);
|
||||
/* notify application about the key information */
|
||||
auditor->version_cb (auditor->version_cb_cls,
|
||||
@ -320,9 +320,9 @@ version_completed_cb (void *cls,
|
||||
|
||||
|
||||
/**
|
||||
* Initiate download of /version from the auditor.
|
||||
* Initiate download of /config from the auditor.
|
||||
*
|
||||
* @param cls auditor where to download /version from
|
||||
* @param cls auditor where to download /config from
|
||||
*/
|
||||
static void
|
||||
request_version (void *cls)
|
||||
@ -406,7 +406,7 @@ TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx,
|
||||
auditor->ctx = ctx;
|
||||
auditor->url = GNUNET_strdup (url);
|
||||
auditor->vr_url = TALER_AUDITOR_path_to_url_ (auditor,
|
||||
"/version");
|
||||
"/config");
|
||||
if (NULL == auditor->vr_url)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
|
@ -1268,14 +1268,24 @@ TALER_EXCHANGE_set_last_denom (struct TALER_EXCHANGE_Handle *exchange,
|
||||
|
||||
struct GNUNET_TIME_Timestamp
|
||||
TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange,
|
||||
enum TALER_EXCHANGE_CheckKeysFlags flags)
|
||||
enum TALER_EXCHANGE_CheckKeysFlags flags,
|
||||
TALER_EXCHANGE_CertificationCallback cb,
|
||||
void *cb_cls)
|
||||
{
|
||||
bool force_download = 0 != (flags & TALER_EXCHANGE_CKF_FORCE_DOWNLOAD);
|
||||
bool pull_all_keys = 0 != (flags & TALER_EXCHANGE_CKF_PULL_ALL_KEYS);
|
||||
|
||||
if ( (NULL != cb) &&
|
||||
( (exchange->cert_cb != cb) ||
|
||||
(exchange->cert_cb_cls != cb_cls) ) )
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Changing target of exchange certification callback\n");
|
||||
exchange->cert_cb = cb;
|
||||
exchange->cert_cb_cls = cb_cls;
|
||||
}
|
||||
if (NULL != exchange->kr)
|
||||
return GNUNET_TIME_UNIT_ZERO_TS;
|
||||
|
||||
if (pull_all_keys)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
@ -2269,7 +2279,9 @@ const struct TALER_EXCHANGE_Keys *
|
||||
TALER_EXCHANGE_get_keys (struct TALER_EXCHANGE_Handle *exchange)
|
||||
{
|
||||
(void) TALER_EXCHANGE_check_keys_current (exchange,
|
||||
TALER_EXCHANGE_CKF_NONE);
|
||||
TALER_EXCHANGE_CKF_NONE,
|
||||
NULL,
|
||||
NULL);
|
||||
return &exchange->key_data;
|
||||
}
|
||||
|
||||
@ -2278,7 +2290,9 @@ json_t *
|
||||
TALER_EXCHANGE_get_keys_raw (struct TALER_EXCHANGE_Handle *exchange)
|
||||
{
|
||||
(void) TALER_EXCHANGE_check_keys_current (exchange,
|
||||
TALER_EXCHANGE_CKF_NONE);
|
||||
TALER_EXCHANGE_CKF_NONE,
|
||||
NULL,
|
||||
NULL);
|
||||
return json_deep_copy (exchange->key_data_raw);
|
||||
}
|
||||
|
||||
|
9
src/testing/.gitignore
vendored
9
src/testing/.gitignore
vendored
@ -46,3 +46,12 @@ test_exchange_api_twisted_cs
|
||||
test_exchange_api_twisted_rsa
|
||||
test_exchange_p2p_cs
|
||||
test_exchange_p2p_rsa
|
||||
*.edited
|
||||
tmp-last-response.*
|
||||
test_exchange_api_home/taler/auditor/
|
||||
test_exchange_api_home/taler/exchange-offline/secm_tofus.pub
|
||||
test_exchange_api_home/taler/exchange-secmod-cs/
|
||||
test_exchange_api_home/taler/exchange-secmod-eddsa/
|
||||
test_exchange_api_home/taler/exchange-secmod-rsa/
|
||||
test_exchange_api_keys_cherry_picking_home/taler/
|
||||
test_taler_exchange_httpd_home/taler/
|
||||
|
@ -13,6 +13,9 @@ endif
|
||||
clean-local:
|
||||
rm -rf report*
|
||||
|
||||
bin_SCRIPTS = \
|
||||
taler-unified-setup.sh
|
||||
|
||||
# Libraries
|
||||
|
||||
lib_LTLIBRARIES = \
|
||||
@ -54,11 +57,11 @@ libtalertesting_la_SOURCES = \
|
||||
testing_api_cmd_batch.c \
|
||||
testing_api_cmd_batch_deposit.c \
|
||||
testing_api_cmd_batch_withdraw.c \
|
||||
testing_api_cmd_change_auth.c \
|
||||
testing_api_cmd_check_aml_decision.c \
|
||||
testing_api_cmd_check_aml_decisions.c \
|
||||
testing_api_cmd_check_keys.c \
|
||||
testing_api_cmd_common.c \
|
||||
testing_api_cmd_connect_with_state.c \
|
||||
testing_api_cmd_contract_get.c \
|
||||
testing_api_cmd_deposit.c \
|
||||
testing_api_cmd_deposits_get.c \
|
||||
@ -70,6 +73,8 @@ libtalertesting_la_SOURCES = \
|
||||
testing_api_cmd_exec_transfer.c \
|
||||
testing_api_cmd_exec_wget.c \
|
||||
testing_api_cmd_exec_wirewatch.c \
|
||||
testing_api_cmd_get_auditor.c \
|
||||
testing_api_cmd_get_exchange.c \
|
||||
testing_api_cmd_insert_deposit.c \
|
||||
testing_api_cmd_kyc_check_get.c \
|
||||
testing_api_cmd_kyc_proof.c \
|
||||
@ -85,7 +90,6 @@ libtalertesting_la_SOURCES = \
|
||||
testing_api_cmd_purse_deposit.c \
|
||||
testing_api_cmd_purse_get.c \
|
||||
testing_api_cmd_purse_merge.c \
|
||||
testing_api_cmd_set_wire_fee.c \
|
||||
testing_api_cmd_recoup.c \
|
||||
testing_api_cmd_recoup_refresh.c \
|
||||
testing_api_cmd_refund.c \
|
||||
@ -101,9 +105,10 @@ libtalertesting_la_SOURCES = \
|
||||
testing_api_cmd_revoke.c \
|
||||
testing_api_cmd_revoke_denom_key.c \
|
||||
testing_api_cmd_revoke_sign_key.c \
|
||||
testing_api_cmd_rewind.c \
|
||||
testing_api_cmd_run_fakebank.c \
|
||||
testing_api_cmd_serialize_keys.c \
|
||||
testing_api_cmd_set_officer.c \
|
||||
testing_api_cmd_set_wire_fee.c \
|
||||
testing_api_cmd_signal.c \
|
||||
testing_api_cmd_sleep.c \
|
||||
testing_api_cmd_stat.c \
|
||||
@ -115,14 +120,15 @@ libtalertesting_la_SOURCES = \
|
||||
testing_api_cmd_wire_add.c \
|
||||
testing_api_cmd_wire_del.c \
|
||||
testing_api_cmd_withdraw.c \
|
||||
testing_api_helpers_auditor.c \
|
||||
testing_api_helpers_bank.c \
|
||||
testing_api_helpers_exchange.c \
|
||||
testing_api_loop.c \
|
||||
testing_api_misc.c \
|
||||
testing_api_traits.c
|
||||
|
||||
|
||||
libtalertesting_la_LIBADD = \
|
||||
$(top_builddir)/src/lib/libtalerauditor.la \
|
||||
$(top_builddir)/src/lib/libtalerexchange.la \
|
||||
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
|
||||
$(top_builddir)/src/json/libtalerjson.la \
|
||||
$(top_builddir)/src/mhd/libtalermhd.la \
|
||||
$(top_builddir)/src/util/libtalerutil.la \
|
||||
@ -141,15 +147,16 @@ libtalertesting_la_LIBADD = \
|
||||
|
||||
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
|
||||
|
||||
# removed for now, due to bug(s) in libeufin!
|
||||
noinst_PROGRAMS = \
|
||||
test_bank_api_with_nexus
|
||||
|
||||
.NOTPARALLEL:
|
||||
check_PROGRAMS = \
|
||||
test_auditor_api_cs \
|
||||
test_auditor_api_rsa \
|
||||
test_auditor_api_version_rsa \
|
||||
test_auditor_api_version_cs \
|
||||
test_auditor_api_version \
|
||||
test_bank_api_with_fakebank \
|
||||
test_bank_api_with_nexus \
|
||||
test_exchange_api_cs \
|
||||
test_exchange_api_rsa \
|
||||
test_exchange_api_keys_cherry_picking_cs \
|
||||
@ -212,22 +219,9 @@ test_auditor_api_rsa_LDADD = \
|
||||
$(XLIB)
|
||||
|
||||
|
||||
test_auditor_api_version_cs_SOURCES = \
|
||||
test_auditor_api_version_SOURCES = \
|
||||
test_auditor_api_version.c
|
||||
test_auditor_api_version_cs_LDADD = \
|
||||
libtalertesting.la \
|
||||
$(top_builddir)/src/lib/libtalerauditor.la \
|
||||
$(LIBGCRYPT_LIBS) \
|
||||
$(top_builddir)/src/util/libtalerutil.la \
|
||||
-lgnunettesting \
|
||||
-lgnunetcurl \
|
||||
-lgnunetutil \
|
||||
-ljansson \
|
||||
$(XLIB)
|
||||
|
||||
test_auditor_api_version_rsa_SOURCES = \
|
||||
test_auditor_api_version.c
|
||||
test_auditor_api_version_rsa_LDADD = \
|
||||
test_auditor_api_version_LDADD = \
|
||||
libtalertesting.la \
|
||||
$(top_builddir)/src/lib/libtalerauditor.la \
|
||||
$(LIBGCRYPT_LIBS) \
|
||||
@ -543,10 +537,14 @@ test_kyc_api_LDADD = \
|
||||
# Distribution
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(bin_SCRIPTS) \
|
||||
coins-cs.conf \
|
||||
coins-rsa.conf \
|
||||
test_auditor_api-cs.conf \
|
||||
test_auditor_api-rsa.conf \
|
||||
test_auditor_api_expire_reserve_now-cs.conf \
|
||||
test_auditor_api_expire_reserve_now-rsa.conf \
|
||||
test_bank_api.conf \
|
||||
test_bank_api_fakebank.conf \
|
||||
test_bank_api_fakebank_twisted.conf \
|
||||
test_bank_api_nexus.conf \
|
||||
|
118
src/testing/coins-cs.conf
Normal file
118
src/testing/coins-cs.conf
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
# Sections starting with "coin_" specify which denominations
|
||||
# the exchange should support (and their respective fee structure)
|
||||
[coin_eur_ct_1]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_ct_10]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_1]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_5]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_10]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
|
||||
[coin_eur_ct_1_age_restricted]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_ct_10_age_restricted]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_1_age_restricted]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_5_age_restricted]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_10_age_restricted]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
128
src/testing/coins-rsa.conf
Normal file
128
src/testing/coins-rsa.conf
Normal file
@ -0,0 +1,128 @@
|
||||
# This file is in the public domain.
|
||||
|
||||
# Sections starting with "coin_" specify which denominations
|
||||
# the exchange should support (and their respective fee structure)
|
||||
[coin_eur_ct_1]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_ct_10]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_1]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_5]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_10]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_ct_1_age_restricted]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
||||
|
||||
[coin_eur_ct_10_age_restricted]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
||||
|
||||
[coin_eur_1_age_restricted]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
||||
|
||||
[coin_eur_5_age_restricted]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
||||
|
||||
[coin_eur_10_age_restricted]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
@ -63,13 +63,15 @@ START_NEXUS=0
|
||||
START_SANDBOX=0
|
||||
START_TRANSFER=0
|
||||
START_WIREWATCH=0
|
||||
USE_ACCOUNT="exchange-account-1"
|
||||
USE_VALGRIND=""
|
||||
WIRE_DOMAIN="x-taler-bank"
|
||||
CONF_ORIG="~/.config/taler.conf"
|
||||
LOGLEVEL="DEBUG"
|
||||
DEFAULT_SLEEP="0.2"
|
||||
|
||||
# Parse command-line options
|
||||
while getopts ':abc:efghl:mnstvw' OPTION; do
|
||||
while getopts ':abc:d:efghl:mnr:stu:vw' OPTION; do
|
||||
case "$OPTION" in
|
||||
a)
|
||||
START_AUDITOR="1"
|
||||
@ -80,6 +82,9 @@ while getopts ':abc:efghl:mnstvw' OPTION; do
|
||||
c)
|
||||
CONF_ORIG="$OPTARG"
|
||||
;;
|
||||
c)
|
||||
WIRE_DOMAIN="$OPTARG"
|
||||
;;
|
||||
e)
|
||||
START_EXCHANGE="1"
|
||||
;;
|
||||
@ -91,14 +96,17 @@ while getopts ':abc:efghl:mnstvw' OPTION; do
|
||||
echo ' -a -- start auditor'
|
||||
echo ' -b -- start backup/sync'
|
||||
echo ' -c $CONF -- set configuration'
|
||||
echo ' -d $METHOD -- use wire method (default: x-taler-bank)'
|
||||
echo ' -e -- start exchange'
|
||||
echo ' -f -- start fakebank'
|
||||
echo ' -h -- print this help'
|
||||
echo ' -l $LOGLEVEL -- set log level'
|
||||
echo ' -m -- start merchant'
|
||||
echo ' -n -- start nexus'
|
||||
echo ' -r $MEX -- which exchange to use at the merchant (optional)'
|
||||
echo ' -s -- start sandbox'
|
||||
echo ' -t -- start transfer'
|
||||
echo ' -u $SECTION -- exchange account to use'
|
||||
echo ' -v -- use valgrind'
|
||||
echo ' -w -- start wirewatch'
|
||||
exit 0
|
||||
@ -115,12 +123,18 @@ while getopts ':abc:efghl:mnstvw' OPTION; do
|
||||
n)
|
||||
START_NEXUS="1"
|
||||
;;
|
||||
r)
|
||||
USE_MERCHANT_EXCHANGE="$OPTARG"
|
||||
;;
|
||||
s)
|
||||
START_SANDBOX="1"
|
||||
;;
|
||||
t)
|
||||
START_TRANSFER="1"
|
||||
;;
|
||||
u)
|
||||
USE_ACCOUNT="$OPTARG"
|
||||
;;
|
||||
v)
|
||||
USE_VALGRIND="valgrind --leak-check=yes"
|
||||
DEFAULT_SLEEP="2"
|
||||
@ -170,6 +184,12 @@ then
|
||||
echo " FOUND"
|
||||
fi
|
||||
|
||||
# FIXME-MS: when run twice using
|
||||
# taler-unified-setup.sh -c test_bank_api_nexus.conf -ns
|
||||
# libeufin fails with a 502 failure (sandbox happy, nexus dies) below.
|
||||
# Work-around is to delete the database every time. Very unclean. => needs a fix!
|
||||
rm -f *.sqlite3
|
||||
|
||||
EXCHANGE_URL=$(taler-config -c "$CONF" -s "EXCHANGE" -o "BASE_URL")
|
||||
CURRENCY=$(taler-config -c "$CONF" -s "TALER" -o "CURRENCY")
|
||||
|
||||
@ -249,7 +269,7 @@ then
|
||||
export LIBEUFIN_SANDBOX_USERNAME="exchange"
|
||||
export LIBEUFIN_SANDBOX_PASSWORD="x"
|
||||
EXCHANGE_PAYTO=$(libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri')
|
||||
taler-config -c "$CONF" -s exchange-account-1 -o "PAYTO_URI" -V "$EXCHANGE_PAYTO"
|
||||
taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "PAYTO_URI" -V "$EXCHANGE_PAYTO"
|
||||
echo " OK"
|
||||
|
||||
echo -n "Setting this exchange as the bank's default ..."
|
||||
@ -319,6 +339,7 @@ then
|
||||
export LIBEUFIN_NEXUS_USERNAME=exchange
|
||||
export LIBEUFIN_NEXUS_PASSWORD=x
|
||||
echo -n "Creating a EBICS connection at Nexus ..."
|
||||
# FIXME-MS: '||true' should be removed after we make 'new-ebics-connection' idempotent!
|
||||
libeufin-cli connections new-ebics-connection \
|
||||
--ebics-url "http://localhost:$SANDBOX_PORT/ebicsweb" \
|
||||
--host-id talerebics \
|
||||
@ -328,7 +349,7 @@ then
|
||||
echo "OK"
|
||||
|
||||
echo -n "Setup EBICS keying ..."
|
||||
libeufin-cli connections connect talerconn > /dev/null
|
||||
libeufin-cli connections connect talerconn
|
||||
echo "OK"
|
||||
echo -n "Download bank account name from Sandbox ..."
|
||||
libeufin-cli connections download-bank-accounts talerconn
|
||||
@ -383,7 +404,11 @@ then
|
||||
MASTER_PRIV_FILE=$(taler-config -f -c "${CONF}" -s "EXCHANGE-OFFLINE" -o "MASTER_PRIV_FILE")
|
||||
MASTER_PRIV_DIR=$(dirname "$MASTER_PRIV_FILE")
|
||||
mkdir -p "${MASTER_PRIV_DIR}"
|
||||
if [ ! -e "$MASTER_PRIV_FILE" ]
|
||||
then
|
||||
gnunet-ecc -g1 "$MASTER_PRIV_FILE" > /dev/null 2> /dev/null
|
||||
echo -n "."
|
||||
fi
|
||||
MASTER_PUB=$(gnunet-ecc -p "${MASTER_PRIV_FILE}")
|
||||
MPUB=$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)
|
||||
if [ "$MPUB" != "$MASTER_PUB" ]
|
||||
@ -391,7 +416,7 @@ then
|
||||
echo -n " patching master_pub ($MASTER_PUB)..."
|
||||
taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY -V "$MASTER_PUB"
|
||||
fi
|
||||
taler-exchange-dbinit -c "$CONF"
|
||||
taler-exchange-dbinit -c "$CONF" --reset
|
||||
$USE_VALGRIND taler-exchange-secmod-eddsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-eddsa.log &
|
||||
$USE_VALGRIND taler-exchange-secmod-rsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-rsa.log &
|
||||
$USE_VALGRIND taler-exchange-secmod-cs -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-cs.log &
|
||||
@ -427,16 +452,19 @@ fi
|
||||
if [ "1" = "$START_MERCHANT" ]
|
||||
then
|
||||
echo -n "Starting merchant ..."
|
||||
MEPUB=$(taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY)
|
||||
if [ ! -z "${USE_MERCHANT_EXCHANGE+x}" ]
|
||||
then
|
||||
MEPUB=$(taler-config -c "$CONF" -s "${USE_MERCHANT_EXCHANGE}" -o MASTER_KEY)
|
||||
MXPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
|
||||
if [ "$MEPUB" != "$MXPUB" ]
|
||||
then
|
||||
echo -n " patching master_pub ($MXPUB)..."
|
||||
taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY -V "$MXPUB"
|
||||
taler-config -c "$CONF" -s "${USE_MERCHANT_EXCHANGE}" -o MASTER_KEY -V "$MXPUB"
|
||||
fi
|
||||
fi
|
||||
MERCHANT_PORT=$(taler-config -c "$CONF" -s MERCHANT -o PORT)
|
||||
MERCHANT_URL="http://localhost:${MERCHANT_PORT}/"
|
||||
taler-merchant-dbinit -c "$CONF"
|
||||
taler-merchant-dbinit -c "$CONF" -L "$LOGLEVEL" --reset &> taler-merchant-dbinit.log
|
||||
$USE_VALGRIND taler-merchant-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-httpd.log &
|
||||
MERCHANT_HTTPD_PID=$!
|
||||
$USE_VALGRIND taler-merchant-webhook -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-webhook.log &
|
||||
@ -449,7 +477,7 @@ then
|
||||
echo -n "Starting sync ..."
|
||||
SYNC_PORT=$(taler-config -c "$CONF" -s SYNC -o PORT)
|
||||
SYNC_URL="http://localhost:${SYNC_PORT}/"
|
||||
sync-dbinit -c "$CONF"
|
||||
sync-dbinit -c "$CONF" --reset
|
||||
$USE_VALGRIND sync-httpd -c "$CONF" -L "$LOGLEVEL" 2> sync-httpd.log &
|
||||
echo " DONE"
|
||||
fi
|
||||
@ -458,14 +486,18 @@ fi
|
||||
if [ "1" = "$START_AUDITOR" ]
|
||||
then
|
||||
echo -n "Starting auditor ..."
|
||||
AUDITOR_URL="http://localhost:8083/"
|
||||
AUDITOR_URL=$(taler-config -c "$CONF" -s AUDITOR -o BASE_URL)
|
||||
AUDITOR_PRIV_FILE=$(taler-config -f -c "$CONF" -s AUDITOR -o AUDITOR_PRIV_FILE)
|
||||
AUDITOR_PRIV_DIR=$(dirname "$AUDITOR_PRIV_FILE")
|
||||
mkdir -p "$AUDITOR_PRIV_DIR"
|
||||
if [ ! -e "$AUDITOR_PRIV_FILE" ]
|
||||
then
|
||||
gnunet-ecc -g1 "$AUDITOR_PRIV_FILE" > /dev/null 2> /dev/null
|
||||
echo -n "."
|
||||
fi
|
||||
AUDITOR_PUB=$(gnunet-ecc -p "${AUDITOR_PRIV_FILE}")
|
||||
MAPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
|
||||
taler-auditor-dbinit -c "$CONF"
|
||||
taler-auditor-dbinit -c "$CONF" --reset
|
||||
taler-auditor-exchange -c "$CONF" -m "$MAPUB" -u "$EXCHANGE_URL"
|
||||
$USE_VALGRIND taler-auditor-httpd -L "$LOGLEVEL" -c "$CONF" 2> taler-auditor-httpd.log &
|
||||
echo " DONE"
|
||||
@ -503,20 +535,21 @@ echo -n "Waiting for Taler services ..."
|
||||
# Wait for all other taler services to be available
|
||||
for n in $(seq 1 20)
|
||||
do
|
||||
echo -n "."
|
||||
sleep "$DEFAULT_SLEEP"
|
||||
OK="0"
|
||||
if [ "1" = "$START_EXCHANGE" ]
|
||||
then
|
||||
echo -n "E"
|
||||
wget \
|
||||
--tries=1 \
|
||||
--timeout=1 \
|
||||
"http://localhost:8081/config" \
|
||||
"${EXCHANGE_URL}config" \
|
||||
-o /dev/null \
|
||||
-O /dev/null >/dev/null || continue
|
||||
fi
|
||||
if [ "1" = "$START_MERCHANT" ]
|
||||
then
|
||||
echo -n "M"
|
||||
wget \
|
||||
--tries=1 \
|
||||
--timeout=1 \
|
||||
@ -526,6 +559,7 @@ do
|
||||
fi
|
||||
if [ "1" = "$START_BACKUP" ]
|
||||
then
|
||||
echo -n "S"
|
||||
wget \
|
||||
--tries=1 \
|
||||
--timeout=1 \
|
||||
@ -535,6 +569,7 @@ do
|
||||
fi
|
||||
if [ "1" = "$START_AUDITOR" ]
|
||||
then
|
||||
echo -n "A"
|
||||
wget \
|
||||
--tries=1 \
|
||||
--timeout=1 \
|
||||
@ -584,23 +619,20 @@ then
|
||||
taler-exchange-offline -c "$CONF" \
|
||||
download \
|
||||
sign \
|
||||
wire-fee now iban "$CURRENCY:0.01" "$CURRENCY:0.01" \
|
||||
wire-fee now "$WIRE_DOMAIN" "$CURRENCY:0.01" "$CURRENCY:0.01" \
|
||||
global-fee now "$CURRENCY:0.01" "$CURRENCY:0.01" "$CURRENCY:0.01" 1h 1year 5 \
|
||||
upload &> taler-exchange-offline.log
|
||||
echo "OK"
|
||||
for ASEC in $(taler-config -c "$CONF" -S | grep -i "exchange-account-")
|
||||
do
|
||||
ENABLED=$(taler-config -c "$CONF" -s "$ASEC" -o "ENABLE_CREDIT")
|
||||
ENABLED=$(taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "ENABLE_CREDIT")
|
||||
if [ "YES" = "$ENABLED" ]
|
||||
then
|
||||
echo -n "Configuring bank account $ASEC ..."
|
||||
EXCHANGE_PAYTO_URI=$(taler-config -c "$CONF" -s "$ASEC" -o "PAYTO_URI")
|
||||
echo -n "Configuring bank account $USE_ACCOUNT ..."
|
||||
EXCHANGE_PAYTO_URI=$(taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "PAYTO_URI")
|
||||
taler-exchange-offline -c "$CONF" \
|
||||
enable-account "$EXCHANGE_PAYTO_URI" \
|
||||
upload &> "taler-exchange-offline-account-$ASEC.log"
|
||||
upload &> "taler-exchange-offline-account.log"
|
||||
echo " OK"
|
||||
fi
|
||||
done
|
||||
if [ "1" = "$START_AUDITOR" ]
|
||||
then
|
||||
echo -n "Enabling auditor ..."
|
@ -1,75 +1,43 @@
|
||||
# This file is in the public domain.
|
||||
|
||||
[PATHS]
|
||||
# Persistent data storage for the testcase
|
||||
TALER_TEST_HOME = test_taler_exchange_httpd_home/
|
||||
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
|
||||
|
||||
[taler-exchange-secmod-rsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
|
||||
[taler-exchange-secmod-eddsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
# Reduce from 12 weeks to ensure we have multiple
|
||||
DURATION = 14 days
|
||||
|
||||
[taler]
|
||||
# Currency supported by the exchange (can only be one)
|
||||
CURRENCY = EUR
|
||||
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||
|
||||
[exchange]
|
||||
AML_THRESHOLD = EUR:1000000
|
||||
|
||||
# The DB plugin to use
|
||||
DB = postgres
|
||||
|
||||
# HTTP port the exchange listens to
|
||||
PORT = 8081
|
||||
|
||||
# Master public key used to sign the exchange's various keys
|
||||
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||
|
||||
# Expected base URL of the exchange. Used in wire transfers for
|
||||
# the tracking API.
|
||||
BASE_URL = "http://localhost:8081/"
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://auditor.example.com/"
|
||||
PORT = 8083
|
||||
|
||||
[auditordb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[exchangedb]
|
||||
# After how long do we close idle reserves? The exchange
|
||||
# and the auditor must agree on this value. We currently
|
||||
# expect it to be globally defined for the whole system,
|
||||
# as there is no way for wallets to query this value. Thus,
|
||||
# it is only configurable for testing, and should be treated
|
||||
# as constant in production.
|
||||
IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
|
||||
|
||||
[exchangedb-postgres]
|
||||
|
||||
#The connection string the plugin has to use for connecting to the database
|
||||
CONFIG = postgres:///talercheck
|
||||
|
||||
[exchangedb]
|
||||
|
||||
# After how long do we close idle reserves? The exchange
|
||||
# and the auditor must agree on this value. We currently
|
||||
# expect it to be globally defined for the whole system,
|
||||
# as there is no way for wallets to query this value. Thus,
|
||||
# it is only configurable for testing, and should be treated
|
||||
# as constant in production.
|
||||
IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
|
||||
|
||||
# After how long do we forget about reserves? Should be above
|
||||
# the legal expiration timeframe of withdrawn coins.
|
||||
LEGAL_RESERVE_EXPIRATION_TIME = 7 years
|
||||
|
||||
[exchange-account-1]
|
||||
[exchangedb-postgres]
|
||||
CONFIG = postgres:///talercheck
|
||||
|
||||
[exchange-account-1]
|
||||
# What is the account URL?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
ENABLE_DEBIT = YES
|
||||
@ -81,7 +49,6 @@ WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = Exchange
|
||||
PASSWORD = x
|
||||
|
||||
|
||||
[bank]
|
||||
HTTP_PORT = 8082
|
||||
|
||||
|
@ -1,62 +1,41 @@
|
||||
# This file is in the public domain.
|
||||
|
||||
[PATHS]
|
||||
# Persistent data storage for the testcase
|
||||
TALER_TEST_HOME = test_taler_exchange_httpd_home/
|
||||
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
|
||||
|
||||
[taler-exchange-secmod-rsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
|
||||
[taler-exchange-secmod-eddsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
# Reduce from 12 weeks to ensure we have multiple
|
||||
DURATION = 14 days
|
||||
|
||||
[taler]
|
||||
# Currency supported by the exchange (can only be one)
|
||||
CURRENCY = EUR
|
||||
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||
|
||||
[exchange]
|
||||
AML_THRESHOLD = EUR:1000000
|
||||
|
||||
# The DB plugin to use
|
||||
DB = postgres
|
||||
|
||||
# HTTP port the exchange listens to
|
||||
PORT = 8081
|
||||
|
||||
# Master public key used to sign the exchange's various keys
|
||||
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||
|
||||
# Expected base URL of the exchange.
|
||||
BASE_URL = "http://localhost:8081/"
|
||||
|
||||
[exchangedb]
|
||||
# After how long do we close idle reserves? The exchange
|
||||
# and the auditor must agree on this value. We currently
|
||||
# expect it to be globally defined for the whole system,
|
||||
# as there is no way for wallets to query this value. Thus,
|
||||
# it is only configurable for testing, and should be treated
|
||||
# as constant in production.
|
||||
#
|
||||
# This is THE test that requires a short reserve expiration time!
|
||||
IDLE_RESERVE_EXPIRATION_TIME = 4 s
|
||||
|
||||
[exchangedb-postgres]
|
||||
#The connection string the plugin has to use for connecting to the database
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[auditordb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
|
||||
# HTTP port the auditor listens to
|
||||
PORT = 8083
|
||||
|
||||
[auditordb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[exchange-account-1]
|
||||
# What is the account URL?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
|
@ -1,141 +1,4 @@
|
||||
|
||||
# This file is in the public domain.
|
||||
#
|
||||
[PATHS]
|
||||
# Persistent data storage for the testcase
|
||||
TALER_TEST_HOME = test_exchange_api_home/
|
||||
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
|
||||
|
||||
[taler-exchange-secmod-cs]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
|
||||
[taler-exchange-secmod-eddsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
# Reduce from 12 weeks to ensure we have multiple
|
||||
DURATION = 14 days
|
||||
|
||||
|
||||
[taler]
|
||||
# Currency supported by the exchange (can only be one)
|
||||
CURRENCY = EUR
|
||||
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
|
||||
# HTTP port the auditor listens to
|
||||
PORT = 8083
|
||||
PUBLIC_KEY = XNYZPJJ6YPSQ4C6QPW120ACG9B5E5GBTTSYWXDMDB6G4X74TDBPG
|
||||
TINY_AMOUNT = EUR:0.01
|
||||
|
||||
[exchange]
|
||||
AML_THRESHOLD = EUR:1000000
|
||||
|
||||
# HTTP port the exchange listens to
|
||||
PORT = 8081
|
||||
|
||||
# Master public key used to sign the exchange's various keys
|
||||
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||
|
||||
# How to access our database
|
||||
DB = postgres
|
||||
|
||||
# Base URL of the exchange. Must be set to a URL where the
|
||||
# exchange (or the twister) is actually listening.
|
||||
BASE_URL = "http://localhost:8081/"
|
||||
|
||||
[exchangedb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[auditordb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
# Sections starting with "exchange-account-" configure the bank accounts
|
||||
# of the exchange. The "URL" specifies the account in
|
||||
# payto://-format.
|
||||
[exchange-account-1]
|
||||
# What is the URL of our account?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
|
||||
|
||||
[exchange-accountcredentials-1]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
|
||||
|
||||
[bank]
|
||||
HTTP_PORT = 8082
|
||||
|
||||
# ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-account-2]
|
||||
# What is the bank account (with the "Taler Bank" demo system)?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
ENABLE_DEBIT = YES
|
||||
ENABLE_CREDIT = YES
|
||||
|
||||
# Authentication information for basic authentication
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
|
||||
WIRE_GATEWAY_AUTH_METHOD = "basic"
|
||||
USERNAME = user
|
||||
PASSWORD = pass
|
||||
|
||||
|
||||
|
||||
|
||||
# Sections starting with "coin_" specify which denominations
|
||||
# the exchange should support (and their respective fee structure)
|
||||
[coin_eur_ct_1]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_ct_10]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_1]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_5]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_10]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
@INLINE@ coins-cs.conf
|
||||
@INLINE@ test_exchange_api.conf
|
||||
|
@ -1,147 +1,4 @@
|
||||
|
||||
# This file is in the public domain.
|
||||
#
|
||||
[PATHS]
|
||||
# Persistent data storage for the testcase
|
||||
TALER_TEST_HOME = test_exchange_api_home/
|
||||
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
|
||||
|
||||
[taler-exchange-secmod-rsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
|
||||
[taler-exchange-secmod-eddsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
# Reduce from 12 weeks to ensure we have multiple
|
||||
DURATION = 14 days
|
||||
|
||||
|
||||
[taler]
|
||||
# Currency supported by the exchange (can only be one)
|
||||
CURRENCY = EUR
|
||||
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
|
||||
# HTTP port the auditor listens to
|
||||
PORT = 8083
|
||||
PUBLIC_KEY = XNYZPJJ6YPSQ4C6QPW120ACG9B5E5GBTTSYWXDMDB6G4X74TDBPG
|
||||
|
||||
TINY_AMOUNT = EUR:0.01
|
||||
|
||||
[exchange]
|
||||
AML_THRESHOLD = EUR:1000000
|
||||
|
||||
# HTTP port the exchange listens to
|
||||
PORT = 8081
|
||||
|
||||
# Master public key used to sign the exchange's various keys
|
||||
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||
|
||||
# How to access our database
|
||||
DB = postgres
|
||||
|
||||
# Base URL of the exchange. Must be set to a URL where the
|
||||
# exchange (or the twister) is actually listening.
|
||||
BASE_URL = "http://localhost:8081/"
|
||||
|
||||
[exchangedb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[auditordb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
# Sections starting with "exchange-account-" configure the bank accounts
|
||||
# of the exchange. The "URL" specifies the account in
|
||||
# payto://-format.
|
||||
[exchange-account-1]
|
||||
# What is the URL of our account?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
|
||||
|
||||
[exchange-accountcredentials-1]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
|
||||
|
||||
[bank]
|
||||
HTTP_PORT = 8082
|
||||
|
||||
# ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-account-2]
|
||||
# What is the bank account (with the "Taler Bank" demo system)?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
ENABLE_DEBIT = YES
|
||||
ENABLE_CREDIT = YES
|
||||
|
||||
# Authentication information for basic authentication
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
|
||||
WIRE_GATEWAY_AUTH_METHOD = "basic"
|
||||
USERNAME = user
|
||||
PASSWORD = pass
|
||||
|
||||
|
||||
|
||||
|
||||
# Sections starting with "coin_" specify which denominations
|
||||
# the exchange should support (and their respective fee structure)
|
||||
[coin_eur_ct_1]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_ct_10]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_1]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_5]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_10]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
@INLINE@ coins-rsa.conf
|
||||
@INLINE@ test_exchange_api.conf
|
||||
|
@ -45,14 +45,9 @@ static char *config_file;
|
||||
static char *config_file_expire_reserve_now;
|
||||
|
||||
/**
|
||||
* Exchange configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* Execute the taler-exchange-wirewatch command with
|
||||
@ -83,8 +78,8 @@ static struct TALER_TESTING_BankConfiguration bc;
|
||||
*/
|
||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||
&bc.exchange_auth, \
|
||||
bc.user42_payto)
|
||||
&cred.ba, \
|
||||
cred.user42_payto)
|
||||
|
||||
/**
|
||||
* Run the taler-auditor.
|
||||
@ -116,7 +111,7 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer
|
||||
("check-create-reserve-1",
|
||||
"EUR:5.01", bc.user42_payto, bc.exchange_payto,
|
||||
"EUR:5.01", cred.user42_payto, cred.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous transfer.
|
||||
@ -140,7 +135,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-simple",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -157,7 +152,7 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer
|
||||
("check-refresh-create-reserve-1",
|
||||
"EUR:5.01", bc.user42_payto, bc.exchange_payto,
|
||||
"EUR:5.01", cred.user42_payto, cred.exchange_payto,
|
||||
"refresh-create-reserve-1"),
|
||||
/**
|
||||
* Make previous command effective.
|
||||
@ -178,7 +173,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
|
||||
"refresh-withdraw-coin-1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -203,7 +198,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
|
||||
"refresh-reveal-1",
|
||||
3,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.1",
|
||||
@ -225,75 +220,75 @@ run (void *cls,
|
||||
*/
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check_bank_transfer-499c",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:4.98",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check_bank_transfer-99c1",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check_bank_transfer-99c",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.08",
|
||||
bc.exchange_payto,
|
||||
bc.user43_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
|
||||
/* The following transactions got originated within
|
||||
* the "massive deposit confirms" batch. */
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check-massive-transfer-1",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-2",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-3",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-4",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-5",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-6",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-7",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-8",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-9",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-10",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
@ -311,8 +306,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check_bank_transfer-unaggregated",
|
||||
"EUR:5.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-unaggregated"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
|
||||
"create-reserve-unaggregated",
|
||||
@ -322,7 +317,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-unaggregated",
|
||||
"withdraw-coin-unaggregated",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_relative_multiply
|
||||
(GNUNET_TIME_UNIT_YEARS,
|
||||
@ -359,7 +354,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-1",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
"EUR:5",
|
||||
@ -376,7 +371,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-2",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:4.99",
|
||||
@ -466,7 +461,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("recoup-deposit-partial",
|
||||
"recoup-withdraw-coin-2a",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.5",
|
||||
@ -493,7 +488,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-massive-transfer",
|
||||
"EUR:10.10",
|
||||
bc.user42_payto, bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"massive-reserve"),
|
||||
CMD_EXEC_WIREWATCH ("massive-wirewatch"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-1",
|
||||
@ -550,7 +546,7 @@ run (void *cls,
|
||||
"massive-deposit-1",
|
||||
"massive-withdraw-1",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -559,7 +555,7 @@ run (void *cls,
|
||||
("massive-deposit-2",
|
||||
"massive-withdraw-2",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -568,7 +564,7 @@ run (void *cls,
|
||||
("massive-deposit-3",
|
||||
"massive-withdraw-3",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -577,7 +573,7 @@ run (void *cls,
|
||||
("massive-deposit-4",
|
||||
"massive-withdraw-4",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -586,7 +582,7 @@ run (void *cls,
|
||||
("massive-deposit-5",
|
||||
"massive-withdraw-5",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -595,7 +591,7 @@ run (void *cls,
|
||||
("massive-deposit-6",
|
||||
"massive-withdraw-6",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -604,7 +600,7 @@ run (void *cls,
|
||||
("massive-deposit-7",
|
||||
"massive-withdraw-7",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -613,7 +609,7 @@ run (void *cls,
|
||||
("massive-deposit-8",
|
||||
"massive-withdraw-8",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -622,7 +618,7 @@ run (void *cls,
|
||||
("massive-deposit-9",
|
||||
"massive-withdraw-9",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -631,13 +627,12 @@ run (void *cls,
|
||||
"massive-deposit-10",
|
||||
"massive-withdraw-10",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
MHD_HTTP_OK),
|
||||
TALER_TESTING_cmd_deposit_confirmation ("deposit-confirmation",
|
||||
is->auditor,
|
||||
"massive-deposit-10",
|
||||
0,
|
||||
"EUR:0.99",
|
||||
@ -648,21 +643,22 @@ run (void *cls,
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-2"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_file,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01"),
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_wire_add ("add-wire-account",
|
||||
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
2),
|
||||
"-u", "exchange-account-2",
|
||||
"-ae",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
TALER_TESTING_cmd_get_auditor ("get-auditor",
|
||||
cred.cfg,
|
||||
true),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
|
||||
TALER_TESTING_cmd_exec_auditor_offline ("auditor-offline",
|
||||
config_file),
|
||||
CMD_RUN_AUDITOR ("virgin-auditor"),
|
||||
@ -690,9 +686,8 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
}
|
||||
|
||||
|
||||
@ -700,15 +695,9 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
(void) argc;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup (argv[0],
|
||||
"INFO",
|
||||
NULL);
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
@ -719,41 +708,15 @@ main (int argc,
|
||||
"test_auditor_api_expire_reserve_now-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (cipher);
|
||||
/* Check fakebank port is available and get configuration data. */
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (config_file,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
return 77;
|
||||
TALER_TESTING_cleanup_files (config_file);
|
||||
/* @helpers. Run keyup, create tables, ... Note: it
|
||||
* fetches the port number from config in order to see
|
||||
* if it's available. */
|
||||
switch (TALER_TESTING_prepare_exchange (config_file,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
case GNUNET_NO:
|
||||
return 78;
|
||||
case GNUNET_OK:
|
||||
if (GNUNET_OK !=
|
||||
/* Set up event loop and reschedule context, plus
|
||||
* start/stop the exchange. It calls TALER_TESTING_setup
|
||||
* which creates the 'is' object.
|
||||
*/
|
||||
TALER_TESTING_auditor_setup (&run,
|
||||
NULL,
|
||||
config_file))
|
||||
return 2;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014-2018 Taler Systems SA
|
||||
Copyright (C) 2014-2023 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
|
||||
@ -39,7 +39,7 @@
|
||||
* Configuration file we use. One (big) configuration is used
|
||||
* for the various components for this test.
|
||||
*/
|
||||
#define CONFIG_FILE "test_auditor_api.conf"
|
||||
#define CONFIG_FILE "test_auditor_api-rsa.conf"
|
||||
|
||||
static struct TALER_AUDITOR_Handle *ah;
|
||||
|
||||
@ -51,6 +51,7 @@ static int global_ret;
|
||||
|
||||
static struct GNUNET_SCHEDULER_Task *tt;
|
||||
|
||||
|
||||
static void
|
||||
do_shutdown (void *cls)
|
||||
{
|
||||
@ -148,15 +149,16 @@ main (int argc,
|
||||
"taler-auditor-httpd",
|
||||
"taler-auditor-httpd",
|
||||
"-c", CONFIG_FILE,
|
||||
"-L", "INFO",
|
||||
NULL);
|
||||
if (NULL == proc)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to run `taler-auditor-httpd`,"
|
||||
" is your PATH correct?\n");
|
||||
"Failed to run `taler-auditor-httpd`, is your PATH correct?\n");
|
||||
return 77;
|
||||
}
|
||||
if (0 != TALER_TESTING_wait_auditor_ready ("http://localhost:8083/"))
|
||||
global_ret = TALER_TESTING_wait_httpd_ready ("http://localhost:8083/");
|
||||
if (0 != global_ret)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to launch `taler-auditor-httpd`\n");
|
||||
@ -166,7 +168,8 @@ main (int argc,
|
||||
GNUNET_SCHEDULER_run (&run,
|
||||
NULL);
|
||||
}
|
||||
GNUNET_OS_process_kill (proc, SIGTERM);
|
||||
GNUNET_OS_process_kill (proc,
|
||||
SIGTERM);
|
||||
GNUNET_OS_process_wait (proc);
|
||||
GNUNET_OS_process_destroy (proc);
|
||||
return global_ret;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "taler_testing_lib.h"
|
||||
|
||||
#define CONFIG_FILE_FAKEBANK "test_bank_api_fakebank.conf"
|
||||
|
||||
#define CONFIG_FILE_NEXUS "test_bank_api_nexus.conf"
|
||||
|
||||
|
||||
@ -41,28 +42,19 @@
|
||||
* Configuration file. It changes based on
|
||||
* whether Nexus or Fakebank are used.
|
||||
*/
|
||||
const char *cfgfile;
|
||||
static const char *cfgfile;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* Flag indicating whether the test is running against the
|
||||
* Fakebank. Set up at runtime.
|
||||
* Which bank is the test running against?
|
||||
* Set up at runtime.
|
||||
*/
|
||||
static int with_fakebank;
|
||||
static enum TALER_TESTING_BankSystem bs;
|
||||
|
||||
/**
|
||||
* Handles to the libeufin services.
|
||||
*/
|
||||
static struct TALER_TESTING_LibeufinServices libeufin_services;
|
||||
|
||||
/**
|
||||
* Needed to shutdown differently.
|
||||
*/
|
||||
static int with_libeufin;
|
||||
|
||||
/**
|
||||
* Main function that will tell the interpreter what commands to
|
||||
@ -75,20 +67,36 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_WireTransferIdentifierRawP wtid;
|
||||
const char *ssoptions;
|
||||
|
||||
(void) cls;
|
||||
memset (&wtid, 42, sizeof (wtid));
|
||||
switch (bs)
|
||||
{
|
||||
case TALER_TESTING_BS_FAKEBANK:
|
||||
ssoptions = "-f";
|
||||
break;
|
||||
case TALER_TESTING_BS_IBAN:
|
||||
ssoptions = "-ns";
|
||||
break;
|
||||
}
|
||||
memset (&wtid,
|
||||
42,
|
||||
sizeof (wtid));
|
||||
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
cfgfile,
|
||||
ssoptions,
|
||||
NULL),
|
||||
TALER_TESTING_cmd_bank_credits ("history-0",
|
||||
&bc.exchange_auth,
|
||||
&cred.ba,
|
||||
NULL,
|
||||
1),
|
||||
TALER_TESTING_cmd_admin_add_incoming ("credit-1",
|
||||
"KUDOS:5.01",
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto),
|
||||
"EUR:5.01",
|
||||
&cred.ba,
|
||||
cred.user42_payto),
|
||||
/**
|
||||
* This CMD doesn't care about the HTTP response code; that's
|
||||
* because Fakebank and euFin behaves differently when a reserve
|
||||
@ -96,9 +104,9 @@ run (void *cls,
|
||||
* with 200 but it bounces the payment back to the customer.
|
||||
*/
|
||||
TALER_TESTING_cmd_admin_add_incoming_with_ref ("credit-1-fail",
|
||||
"KUDOS:2.01",
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto,
|
||||
"EUR:2.01",
|
||||
&cred.ba,
|
||||
cred.user42_payto,
|
||||
"credit-1",
|
||||
-1),
|
||||
TALER_TESTING_cmd_sleep ("Waiting 4s for 'credit-1' to settle",
|
||||
@ -108,28 +116,28 @@ run (void *cls,
|
||||
* reserve public key didn't make it to the exchange.
|
||||
*/
|
||||
TALER_TESTING_cmd_bank_credits ("history-1c",
|
||||
&bc.exchange_auth,
|
||||
&cred.ba,
|
||||
NULL,
|
||||
5),
|
||||
TALER_TESTING_cmd_bank_debits ("history-1d",
|
||||
&bc.exchange_auth,
|
||||
&cred.ba,
|
||||
NULL,
|
||||
5),
|
||||
TALER_TESTING_cmd_admin_add_incoming ("credit-2",
|
||||
"KUDOS:3.21",
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto),
|
||||
"EUR:3.21",
|
||||
&cred.ba,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_transfer ("debit-1",
|
||||
"KUDOS:3.22",
|
||||
&bc.exchange_auth,
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto,
|
||||
"EUR:3.22",
|
||||
&cred.ba,
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto,
|
||||
&wtid,
|
||||
"http://exchange.example.com/"),
|
||||
|
||||
TALER_TESTING_cmd_sleep ("Waiting 5s for 'debit-1' to settle",
|
||||
5),
|
||||
with_libeufin
|
||||
(bs == TALER_TESTING_BS_IBAN)
|
||||
? TALER_TESTING_cmd_nexus_fetch_transactions (
|
||||
"fetch-transactions-at-nexus",
|
||||
"exchange", /* from taler-nexus-prepare */
|
||||
@ -139,7 +147,7 @@ run (void *cls,
|
||||
: TALER_TESTING_cmd_sleep ("nop",
|
||||
0),
|
||||
TALER_TESTING_cmd_bank_debits ("history-2b",
|
||||
&bc.exchange_auth,
|
||||
&cred.ba,
|
||||
NULL,
|
||||
5),
|
||||
TALER_TESTING_cmd_end ()
|
||||
@ -147,116 +155,44 @@ run (void *cls,
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Bank serves at `%s'\n",
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
if (GNUNET_YES == with_fakebank)
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
else
|
||||
cred.ba.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs #TALER_TESTING_setup() using the configuration.
|
||||
*
|
||||
* @param cls unused
|
||||
* @param cfg configuration to use
|
||||
* @return status code
|
||||
*/
|
||||
static int
|
||||
setup_with_cfg (void *cls,
|
||||
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||
{
|
||||
(void) cls;
|
||||
return TALER_TESTING_setup (&run,
|
||||
NULL,
|
||||
cfg,
|
||||
NULL,
|
||||
GNUNET_NO);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
int rv;
|
||||
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup ("test-bank-api",
|
||||
"INFO",
|
||||
NULL);
|
||||
|
||||
with_fakebank = TALER_TESTING_has_in_name (argv[0],
|
||||
"_with_fakebank");
|
||||
if (GNUNET_YES == with_fakebank)
|
||||
if (TALER_TESTING_has_in_name (argv[0],
|
||||
"_with_fakebank"))
|
||||
{
|
||||
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
|
||||
bs = TALER_TESTING_BS_FAKEBANK;
|
||||
cfgfile = CONFIG_FILE_FAKEBANK;
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (CONFIG_FILE_FAKEBANK,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return 77;
|
||||
}
|
||||
}
|
||||
else if (GNUNET_YES == TALER_TESTING_has_in_name (argv[0],
|
||||
else if (TALER_TESTING_has_in_name (argv[0],
|
||||
"_with_nexus"))
|
||||
{
|
||||
TALER_LOG_DEBUG ("Running with Nexus.\n");
|
||||
with_libeufin = GNUNET_YES;
|
||||
bs = TALER_TESTING_BS_IBAN;
|
||||
cfgfile = CONFIG_FILE_NEXUS;
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_libeufin (CONFIG_FILE_NEXUS,
|
||||
GNUNET_YES,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no bank service was specified. */
|
||||
GNUNET_break (0);
|
||||
return 77;
|
||||
}
|
||||
libeufin_services = TALER_TESTING_run_libeufin (&bc);
|
||||
if ( (NULL == libeufin_services.nexus) ||
|
||||
(NULL == libeufin_services.sandbox) )
|
||||
return 77;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no bank service was ever invoked. */
|
||||
return 77;
|
||||
}
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_parse_and_run (cfgfile,
|
||||
&setup_with_cfg,
|
||||
NULL))
|
||||
rv = 1;
|
||||
else
|
||||
rv = 0;
|
||||
|
||||
if (with_libeufin)
|
||||
{
|
||||
GNUNET_OS_process_kill (libeufin_services.nexus,
|
||||
SIGKILL);
|
||||
GNUNET_OS_process_wait (libeufin_services.nexus);
|
||||
GNUNET_OS_process_destroy (libeufin_services.nexus);
|
||||
|
||||
GNUNET_OS_process_kill (libeufin_services.sandbox,
|
||||
SIGKILL);
|
||||
GNUNET_OS_process_wait (libeufin_services.sandbox);
|
||||
GNUNET_OS_process_destroy (libeufin_services.sandbox);
|
||||
}
|
||||
|
||||
return rv;
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
cfgfile,
|
||||
"exchange-account-2",
|
||||
bs,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
13
src/testing/test_bank_api.conf
Normal file
13
src/testing/test_bank_api.conf
Normal file
@ -0,0 +1,13 @@
|
||||
# This file is in the public domain
|
||||
|
||||
[PATHS]
|
||||
TALER_TEST_HOME = test_exchange_api_home/
|
||||
|
||||
[taler]
|
||||
currency = EUR
|
||||
|
||||
[bank]
|
||||
# not (!) used by the nexus, only by the helper
|
||||
# check to make sure the port is free for Nexus.
|
||||
SERVE = http
|
||||
HTTP_PORT = 8082
|
@ -1,21 +1,14 @@
|
||||
# This file is in the public domain.
|
||||
@INLINE@ test_bank_api.conf
|
||||
|
||||
[taler]
|
||||
currency = KUDOS
|
||||
[exchange-account-1]
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost:8082/1?receiver-name=1"
|
||||
|
||||
[exchange-account-2]
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost:8082/2?receiver-name=2"
|
||||
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8081/2/"
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = Exchange
|
||||
PASSWORD = x
|
||||
|
||||
[bank]
|
||||
SERVE = http
|
||||
HTTP_PORT = 8081
|
||||
DATABASE = postgres:///talercheck
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
|
@ -1,12 +1,15 @@
|
||||
# This file is in the public domain.
|
||||
|
||||
@INLINE@ test_bank_api_fakebank.conf
|
||||
|
||||
[twister]
|
||||
|
||||
# HTTP listen port for twister
|
||||
HTTP_PORT = 8888
|
||||
SERVE = tcp
|
||||
|
||||
# HTTP Destination for twister. The test-Webserver needs
|
||||
# to listen on the port used here. Note: no trailing '/'!
|
||||
DESTINATION_BASE_URL = "http://localhost:8081"
|
||||
DESTINATION_BASE_URL = "http://localhost:8082"
|
||||
|
||||
# Control port for TCP
|
||||
# PORT = 8889
|
||||
@ -18,20 +21,3 @@ ACCEPT_FROM6 = ::1;
|
||||
UNIXPATH = /tmp/taler-service-twister.sock
|
||||
UNIX_MATCH_UID = NO
|
||||
UNIX_MATCH_GID = YES
|
||||
|
||||
[taler]
|
||||
currency = KUDOS
|
||||
|
||||
[bank]
|
||||
serve = http
|
||||
http_port = 8081
|
||||
database = postgres:///talercheck
|
||||
|
||||
[exchange-account-1]
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost:8081/1?receiver-name=1"
|
||||
|
||||
[exchange-account-2]
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost:8081/2?receiver-name=2"
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
|
@ -1,21 +1,19 @@
|
||||
# This file is in the public domain.
|
||||
|
||||
[taler]
|
||||
currency = TESTKUDOS
|
||||
@INLINE@ test_bank_api.conf
|
||||
|
||||
[exchange-account-2]
|
||||
PAYTO_URI = payto://iban/BIC/ES9121000418450200051332?receiver-name=Exchange
|
||||
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = http://localhost:5001/facades/my-facade/taler-wire-gateway/
|
||||
WIRE_GATEWAY_URL = http://localhost:8082/facades/test-facade/taler-wire-gateway/
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = exchange
|
||||
PASSWORD = x
|
||||
|
||||
[bank]
|
||||
# not (!) used by the nexus, only by the helper
|
||||
# check to make sure the port is free for Nexus.
|
||||
HTTP_PORT = 5001
|
||||
[libeufin-nexus]
|
||||
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
|
||||
DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
[libeufin-sandbox]
|
||||
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
|
||||
DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014-2018 Taler Systems SA
|
||||
Copyright (C) 2014-2023 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
|
||||
@ -17,7 +17,7 @@
|
||||
<http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file testing/test_bank_api_with_fakebank_twisted.c
|
||||
* @file testing/test_bank_api_twisted.c
|
||||
* @author Marcello Stanisci
|
||||
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
||||
* @author Christian Grothoff
|
||||
@ -42,14 +42,20 @@
|
||||
#define CONFIG_FILE_FAKEBANK "test_bank_api_fakebank_twisted.conf"
|
||||
|
||||
/**
|
||||
* True when the test runs against Fakebank.
|
||||
* Configuration file we use.
|
||||
*/
|
||||
static int with_fakebank;
|
||||
static const char *cfgfile;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* Which bank is the test running against?
|
||||
* Set up at runtime.
|
||||
*/
|
||||
static enum TALER_TESTING_BankSystem bs;
|
||||
|
||||
/**
|
||||
* (real) Twister URL. Used at startup time to check if it runs.
|
||||
@ -61,11 +67,6 @@ static char *twister_url;
|
||||
*/
|
||||
static struct GNUNET_OS_Process *twisterd;
|
||||
|
||||
/**
|
||||
* Python bank process handle.
|
||||
*/
|
||||
static struct GNUNET_OS_Process *bankd;
|
||||
|
||||
|
||||
/**
|
||||
* Main function that will tell
|
||||
@ -78,156 +79,118 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_WireTransferIdentifierRawP wtid;
|
||||
/* Route our commands through twister. */
|
||||
/* Authentication data to route our commands through twister. */
|
||||
struct TALER_BANK_AuthenticationData exchange_auth_twisted;
|
||||
const char *systype = NULL;
|
||||
|
||||
(void) cls;
|
||||
memset (&wtid,
|
||||
0x5a,
|
||||
sizeof (wtid));
|
||||
GNUNET_memcpy (&exchange_auth_twisted,
|
||||
&bc.exchange_auth,
|
||||
&cred.ba,
|
||||
sizeof (struct TALER_BANK_AuthenticationData));
|
||||
if (with_fakebank)
|
||||
exchange_auth_twisted.wire_gateway_url =
|
||||
"http://localhost:8888/2/";
|
||||
else
|
||||
exchange_auth_twisted.wire_gateway_url =
|
||||
"http://localhost:8888/taler-wire-gateway/Exchange/";
|
||||
switch (bs)
|
||||
{
|
||||
case TALER_TESTING_BS_FAKEBANK:
|
||||
exchange_auth_twisted.wire_gateway_url
|
||||
= "http://localhost:8888/2/";
|
||||
systype = "-f";
|
||||
break;
|
||||
case TALER_TESTING_BS_IBAN:
|
||||
exchange_auth_twisted.wire_gateway_url
|
||||
= "http://localhost:8888/taler-wire-gateway/Exchange/";
|
||||
systype = "-ns";
|
||||
break;
|
||||
}
|
||||
GNUNET_assert (NULL != systype);
|
||||
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
cfgfile,
|
||||
systype,
|
||||
NULL),
|
||||
/* Test retrying transfer after failure. */
|
||||
TALER_TESTING_cmd_malform_response ("malform-transfer",
|
||||
CONFIG_FILE_FAKEBANK),
|
||||
cfgfile),
|
||||
TALER_TESTING_cmd_transfer_retry (
|
||||
TALER_TESTING_cmd_transfer ("debit-1",
|
||||
"KUDOS:3.22",
|
||||
"EUR:3.22",
|
||||
&exchange_auth_twisted,
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto,
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto,
|
||||
&wtid,
|
||||
"http://exchange.example.com/")),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
|
||||
if (GNUNET_YES == with_fakebank)
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
else
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Kill, wait, and destroy convenience function.
|
||||
*
|
||||
* @param process process to purge.
|
||||
* @param[in] process process to purge.
|
||||
*/
|
||||
static void
|
||||
purge_process (struct GNUNET_OS_Process *process)
|
||||
{
|
||||
GNUNET_OS_process_kill (process, SIGINT);
|
||||
GNUNET_OS_process_kill (process,
|
||||
SIGINT);
|
||||
GNUNET_OS_process_wait (process);
|
||||
GNUNET_OS_process_destroy (process);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs #TALER_TESTING_setup() using the configuration.
|
||||
*
|
||||
* @param cls unused
|
||||
* @param cfg configuration to use
|
||||
* @return status code
|
||||
*/
|
||||
static int
|
||||
setup_with_cfg (void *cls,
|
||||
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||
{
|
||||
(void) cls;
|
||||
return TALER_TESTING_setup (&run,
|
||||
NULL,
|
||||
cfg,
|
||||
NULL,
|
||||
GNUNET_NO);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
int ret;
|
||||
const char *cfgfilename;
|
||||
|
||||
(void) argc;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup ("test-bank-api-with-(fake)bank-twisted",
|
||||
if (TALER_TESTING_has_in_name (argv[0],
|
||||
"_with_fakebank"))
|
||||
{
|
||||
bs = TALER_TESTING_BS_FAKEBANK;
|
||||
cfgfile = CONFIG_FILE_FAKEBANK;
|
||||
}
|
||||
else if (TALER_TESTING_has_in_name (argv[0],
|
||||
"_with_nexus"))
|
||||
{
|
||||
GNUNET_assert (0); /* FIXME: test with nexus not yet implemented */
|
||||
bs = TALER_TESTING_BS_IBAN;
|
||||
/* cfgfile = CONFIG_FILE_NEXUS; */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no bank service was specified. */
|
||||
GNUNET_break (0);
|
||||
return 77;
|
||||
}
|
||||
|
||||
/* FIXME: introduce commands for twister! */
|
||||
twister_url = TALER_TWISTER_prepare_twister (cfgfile);
|
||||
if (NULL == twister_url)
|
||||
return 77;
|
||||
twisterd = TALER_TWISTER_run_twister (cfgfile);
|
||||
if (NULL == twisterd)
|
||||
return 77;
|
||||
ret = TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
NULL);
|
||||
|
||||
with_fakebank = TALER_TESTING_has_in_name (argv[0],
|
||||
"_with_fakebank");
|
||||
|
||||
if (with_fakebank)
|
||||
cfgfilename = CONFIG_FILE_FAKEBANK;
|
||||
else
|
||||
GNUNET_assert (0);
|
||||
if (NULL == (twister_url = TALER_TWISTER_prepare_twister (
|
||||
cfgfilename)))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return 77;
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"twister_url is %s\n",
|
||||
twister_url);
|
||||
if (NULL == (twisterd = TALER_TWISTER_run_twister (cfgfilename)))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
GNUNET_free (twister_url);
|
||||
return 77;
|
||||
}
|
||||
if (GNUNET_YES == with_fakebank)
|
||||
{
|
||||
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (cfgfilename,
|
||||
cfgfile,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
GNUNET_free (twister_url);
|
||||
return 77;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GNUNET_assert (0);
|
||||
}
|
||||
|
||||
sleep (5);
|
||||
ret = GNUNET_CONFIGURATION_parse_and_run (cfgfilename,
|
||||
&setup_with_cfg,
|
||||
bs,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
purge_process (twisterd);
|
||||
|
||||
if (GNUNET_NO == with_fakebank)
|
||||
{
|
||||
GNUNET_OS_process_kill (bankd,
|
||||
SIGKILL);
|
||||
GNUNET_OS_process_wait (bankd);
|
||||
GNUNET_OS_process_destroy (bankd);
|
||||
}
|
||||
|
||||
GNUNET_free (twister_url);
|
||||
if (GNUNET_OK == ret)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,120 +1,4 @@
|
||||
# This file is in the public domain.
|
||||
#
|
||||
@INLINE@ coins-cs.conf
|
||||
@INLINE@ test_exchange_api.conf
|
||||
|
||||
# Sections starting with "coin_" specify which denominations
|
||||
# the exchange should support (and their respective fee structure)
|
||||
[coin_eur_ct_1]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_ct_10]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_1]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_5]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_10]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_ct_1_age_restricted]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_ct_10_age_restricted]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_1_age_restricted]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_5_age_restricted]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_10_age_restricted]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
age_restricted = YES
|
||||
CIPHER = CS
|
||||
|
@ -1,130 +1,4 @@
|
||||
# This file is in the public domain.
|
||||
#
|
||||
@INLINE@ test_exchange_api.conf
|
||||
|
||||
# Sections starting with "coin_" specify which denominations
|
||||
# the exchange should support (and their respective fee structure)
|
||||
[coin_eur_ct_1]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_ct_10]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_1]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_5]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_10]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_ct_1_age_restricted]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
||||
|
||||
[coin_eur_ct_10_age_restricted]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
||||
|
||||
[coin_eur_1_age_restricted]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
||||
|
||||
[coin_eur_5_age_restricted]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
||||
|
||||
[coin_eur_10_age_restricted]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
rsa_keysize = 1024
|
||||
age_restricted = YES
|
||||
CIPHER = RSA
|
||||
@INLINE@ coins-rsa.conf
|
||||
|
@ -49,14 +49,9 @@ static char *config_file;
|
||||
static char *config_file_expire_reserve_now;
|
||||
|
||||
/**
|
||||
* Exchange configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* Some tests behave differently when using CS as we cannot
|
||||
@ -97,8 +92,8 @@ static bool uses_cs;
|
||||
*/
|
||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||
&bc.exchange_auth, \
|
||||
bc.user42_payto)
|
||||
&cred.ba, \
|
||||
cred.user42_payto)
|
||||
|
||||
/**
|
||||
* Main function that will tell the interpreter what commands to
|
||||
@ -142,8 +137,8 @@ run (void *cls,
|
||||
MHD_HTTP_OK),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
|
||||
"EUR:6.02",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -201,7 +196,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-simple",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -219,7 +214,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-reused-coin-key-failure",
|
||||
"withdraw-coin-1x",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -232,7 +227,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-double-1",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -246,7 +241,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-double-1",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -257,7 +252,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-double-2",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -282,8 +277,8 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("ck-refresh-create-reserve-1",
|
||||
"EUR:5.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"refresh-create-reserve-1"),
|
||||
/**
|
||||
* Make previous command effective.
|
||||
@ -304,7 +299,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
|
||||
"refresh-withdraw-coin-1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -341,7 +336,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1a",
|
||||
"refresh-reveal-1-idempotency",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -352,7 +347,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
|
||||
"refresh-reveal-1",
|
||||
3,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.1",
|
||||
@ -390,8 +385,8 @@ run (void *cls,
|
||||
"EUR:6.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age",
|
||||
"EUR:6.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-age"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -417,7 +412,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-simple-age",
|
||||
"withdraw-coin-age-1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:4.99",
|
||||
@ -464,53 +459,53 @@ run (void *cls,
|
||||
* Check all the transfers took place.
|
||||
*/
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:4.98",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c2",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:4.97",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c2",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c3",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c4",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.08",
|
||||
bc.exchange_payto,
|
||||
bc.user43_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c2",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.08",
|
||||
bc.exchange_payto,
|
||||
bc.user43_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
/* In case of CS, one transaction above succeeded that
|
||||
failed for RSA, hence we need to check for an extra transfer here */
|
||||
uses_cs
|
||||
? TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-98c",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.98",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto)
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto)
|
||||
: TALER_TESTING_cmd_sleep ("dummy",
|
||||
0),
|
||||
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
||||
@ -544,8 +539,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-create-reserve-unaggregated",
|
||||
"EUR:5.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-unaggregated"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
|
||||
@ -556,7 +551,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-unaggregated",
|
||||
"withdraw-coin-unaggregated",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_relative_multiply (
|
||||
GNUNET_TIME_UNIT_YEARS,
|
||||
@ -578,8 +573,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"ck-refresh-create-reserve-age-1",
|
||||
"EUR:6.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"refresh-create-reserve-age-1"),
|
||||
/**
|
||||
* Make previous command effective.
|
||||
@ -600,7 +595,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age",
|
||||
"refresh-withdraw-coin-age-1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -637,7 +632,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1a",
|
||||
"refresh-reveal-age-1-idempotency",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -648,7 +643,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1b",
|
||||
"refresh-reveal-age-1",
|
||||
3,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.1",
|
||||
@ -680,8 +675,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-create-reserve-aggtest",
|
||||
"EUR:5.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-aggtest"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-aggtest"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aggtest",
|
||||
@ -692,7 +687,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-aggtest-1",
|
||||
"withdraw-coin-aggtest",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:2",
|
||||
@ -700,7 +695,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit_with_ref ("deposit-aggtest-2",
|
||||
"withdraw-coin-aggtest",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:2",
|
||||
@ -708,10 +703,10 @@ run (void *cls,
|
||||
"deposit-aggtest-1"),
|
||||
CMD_EXEC_AGGREGATOR ("aggregation-aggtest"),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check-bank-transfer-aggtest",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:3.97",
|
||||
bc.exchange_payto,
|
||||
bc.user43_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("check-bank-empty-aggtest"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
@ -725,8 +720,8 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-r1",
|
||||
"EUR:5.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-r1"),
|
||||
/**
|
||||
* Run wire-watch to trigger the reserve creation.
|
||||
@ -745,7 +740,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-1",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
"EUR:5",
|
||||
@ -779,7 +774,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-insufficient-refund",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:4\"}]}",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
"EUR:4",
|
||||
@ -796,7 +791,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-2",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:4.99",
|
||||
@ -810,10 +805,10 @@ run (void *cls,
|
||||
* Check that deposit did run.
|
||||
*/
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:4.97",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
/**
|
||||
* Run failing refund, as past deadline & aggregation.
|
||||
*/
|
||||
@ -830,8 +825,8 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-rb",
|
||||
"EUR:5.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-rb"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-rb"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb",
|
||||
@ -842,7 +837,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-1b",
|
||||
"withdraw-coin-rb",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -876,8 +871,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"recoup-create-reserve-1-check",
|
||||
"EUR:15.02",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"recoup-create-reserve-1"),
|
||||
/**
|
||||
* Run wire-watch to trigger the reserve creation.
|
||||
@ -1006,8 +1001,8 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-short-lived-reserve",
|
||||
"EUR:5.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"short-lived-reserve"),
|
||||
TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation",
|
||||
config_file_expire_reserve_now),
|
||||
@ -1029,10 +1024,10 @@ run (void *cls,
|
||||
0, /* age restriction off */
|
||||
MHD_HTTP_CONFLICT),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_reimburse",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:5",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
/* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per
|
||||
* config, then withdraw two coin, partially spend one, and
|
||||
* then have the rest paid back. Check deposit of other coin
|
||||
@ -1042,8 +1037,8 @@ run (void *cls,
|
||||
"EUR:2.02"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2",
|
||||
"EUR:2.02",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"recoup-create-reserve-2"),
|
||||
/* Make previous command effective. */
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-5"),
|
||||
@ -1062,7 +1057,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("recoup-deposit-partial",
|
||||
"recoup-withdraw-coin-2a",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.5",
|
||||
@ -1090,7 +1085,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("recoup-deposit-revoked",
|
||||
"recoup-withdraw-coin-2b",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -1102,7 +1097,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("recoup-deposit-partial-after-recoup",
|
||||
"recoup-withdraw-coin-2a",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.5",
|
||||
@ -1113,8 +1108,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-recoup-create-reserve-3",
|
||||
"EUR:1.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"recoup-create-reserve-3"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-6"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-3-revoked",
|
||||
@ -1144,8 +1139,8 @@ run (void *cls,
|
||||
MHD_HTTP_OK),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1",
|
||||
"EUR:6.03",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-batch-reserve-1"),
|
||||
/*
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -1184,7 +1179,7 @@ run (void *cls,
|
||||
* Spend the coins.
|
||||
*/
|
||||
TALER_TESTING_cmd_batch_deposit ("batch-deposit-1",
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
MHD_HTTP_OK,
|
||||
@ -1232,33 +1227,18 @@ run (void *cls,
|
||||
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
/* setup exchange */
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_extensions ("offline-sign-extensions",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_wire_add ("add-wire-account",
|
||||
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_global_fees (
|
||||
"offline-sign-global-fees",
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-2"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_file,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01",
|
||||
"EUR:0.01",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
GNUNET_TIME_UNIT_DAYS,
|
||||
1),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||
config_file,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01"),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
1),
|
||||
"-e",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
|
||||
TALER_TESTING_cmd_batch ("wire",
|
||||
wire),
|
||||
TALER_TESTING_cmd_batch ("withdraw",
|
||||
@ -1291,9 +1271,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1302,19 +1281,14 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
(void) argc;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup (argv[0],
|
||||
"INFO",
|
||||
NULL);
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
uses_cs = (0 == strcmp (cipher, "cs"));
|
||||
uses_cs = (0 == strcmp (cipher,
|
||||
"cs"));
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_exchange_api-%s.conf",
|
||||
cipher);
|
||||
@ -1322,42 +1296,15 @@ main (int argc,
|
||||
"test_exchange_api_expire_reserve_now-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (cipher);
|
||||
|
||||
/* Check fakebank port is available and get config */
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (config_file,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
return 77;
|
||||
TALER_TESTING_cleanup_files (config_file);
|
||||
/* @helpers. Run keyup, create tables, ... Note: it
|
||||
* fetches the port number from config in order to see
|
||||
* if it's available. */
|
||||
switch (TALER_TESTING_prepare_exchange (config_file,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
case GNUNET_NO:
|
||||
return 78;
|
||||
case GNUNET_OK:
|
||||
if (GNUNET_OK !=
|
||||
/* Set up event loop and reschedule context, plus
|
||||
* start/stop the exchange. It calls TALER_TESTING_setup
|
||||
* which creates the 'is' object.
|
||||
*/
|
||||
TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
config_file))
|
||||
return 2;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,30 +2,64 @@
|
||||
#
|
||||
|
||||
[PATHS]
|
||||
# Persistent data storage for the testcase
|
||||
TALER_TEST_HOME = test_exchange_api_home/
|
||||
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
|
||||
|
||||
[taler-exchange-secmod-rsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
|
||||
[taler-exchange-secmod-eddsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
# Reduce from 12 weeks to ensure we have multiple
|
||||
DURATION = 14 days
|
||||
|
||||
[taler]
|
||||
# Currency supported by the exchange (can only be one)
|
||||
CURRENCY = EUR
|
||||
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
|
||||
# HTTP port the auditor listens to
|
||||
PORT = 8083
|
||||
PUBLIC_KEY = SA7JVMCW3MMN7SYAWJ9AB0BGJDX6MP3PNN2JWQ3T8233MDSQC7Z0
|
||||
TINY_AMOUNT = EUR:0.01
|
||||
|
||||
[auditordb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[bank]
|
||||
HTTP_PORT = 8082
|
||||
|
||||
[exchange]
|
||||
TERMS_ETAG = 0
|
||||
PRIVACY_ETAG = 0
|
||||
AML_THRESHOLD = EUR:1000000
|
||||
PORT = 8081
|
||||
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||
DB = postgres
|
||||
BASE_URL = "http://localhost:8081/"
|
||||
EXPIRE_SHARD_SIZE = 300 ms
|
||||
EXPIRE_IDLE_SLEEP_INTERVAL = 1 s
|
||||
|
||||
[exchangedb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[taler-exchange-secmod-rsa]
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
|
||||
[taler-exchange-secmod-eddsa]
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
DURATION = 14 days
|
||||
|
||||
|
||||
[exchange-account-1]
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
|
||||
ENABLE_DEBIT = YES
|
||||
ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-accountcredentials-1]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
|
||||
|
||||
[exchange-account-2]
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
ENABLE_DEBIT = YES
|
||||
ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = Exchange
|
||||
PASSWORD = x
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
|
||||
|
||||
|
||||
[kyc-provider-test-oauth2]
|
||||
@ -48,68 +82,6 @@ REQUIRED_CHECKS = DUMMY
|
||||
THRESHOLD = EUR:0
|
||||
TIMEFRAME = 1d
|
||||
|
||||
[exchange]
|
||||
|
||||
TERMS_ETAG = 0
|
||||
PRIVACY_ETAG = 0
|
||||
|
||||
AML_THRESHOLD = EUR:1000000
|
||||
|
||||
# HTTP port the exchange listens to
|
||||
PORT = 8081
|
||||
|
||||
# Master public key used to sign the exchange's various keys
|
||||
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||
|
||||
# How to access our database
|
||||
DB = postgres
|
||||
|
||||
# Base URL of the exchange. Must be set to a URL where the
|
||||
# exchange (or the twister) is actually listening.
|
||||
BASE_URL = "http://localhost:8081/"
|
||||
|
||||
# How big is an individual shard to be processed
|
||||
# by taler-exchange-expire (in time). It may take
|
||||
# this much time for an expired purse to be really
|
||||
# cleaned up and the coins refunded.
|
||||
EXPIRE_SHARD_SIZE = 300 ms
|
||||
|
||||
EXPIRE_IDLE_SLEEP_INTERVAL = 1 s
|
||||
|
||||
[exchangedb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[auditordb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
# Sections starting with "exchange-account-" configure the bank accounts
|
||||
# of the exchange. The "URL" specifies the account in
|
||||
# payto://-format.
|
||||
[exchange-account-1]
|
||||
# What is the URL of our account?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
|
||||
# ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-accountcredentials-1]
|
||||
WIRE_GATEWAY_URL = "http://localhost:9081/42/"
|
||||
|
||||
[exchange-account-2]
|
||||
# What is the bank account (with the "Taler Bank" demo system)?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
ENABLE_DEBIT = YES
|
||||
ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = Exchange
|
||||
PASSWORD = x
|
||||
WIRE_GATEWAY_URL = "http://localhost:9081/2/"
|
||||
|
||||
[bank]
|
||||
HTTP_PORT = 9081
|
||||
|
||||
# Enabled extensions
|
||||
[exchange-extension-age_restriction]
|
||||
ENABLED = YES
|
||||
# default age groups:
|
||||
#AGE_GROUPS = "8:10:12:14:16:18:21"
|
||||
|
@ -0,0 +1 @@
|
||||
p<EFBFBD>^<5E>-<2D>33<33><33>XX<>!<04>\0q<30><71><EFBFBD><EFBFBD><18>mU<6D>_<EFBFBD><5F>
|
@ -43,9 +43,9 @@ lished
|
||||
static char *config_file;
|
||||
|
||||
/**
|
||||
* Exchange configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
|
||||
/**
|
||||
@ -59,27 +59,19 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_wire_add ("add-wire-account",
|
||||
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_file,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01"),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("initial-/keys",
|
||||
1),
|
||||
"-e",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("initial-/keys"),
|
||||
TALER_TESTING_cmd_sleep ("sleep",
|
||||
6 /* seconds */),
|
||||
TALER_TESTING_cmd_check_keys ("check-keys-1",
|
||||
2 /* generation */),
|
||||
TALER_TESTING_cmd_check_keys ("check-keys-1"),
|
||||
TALER_TESTING_cmd_check_keys_with_last_denom ("check-keys-2",
|
||||
3 /* generation */,
|
||||
"check-keys-1"),
|
||||
TALER_TESTING_cmd_serialize_keys ("serialize-keys"),
|
||||
TALER_TESTING_cmd_connect_with_state ("reconnect-with-state",
|
||||
@ -88,8 +80,7 @@ run (void *cls,
|
||||
* Make sure we have the same keys situation as
|
||||
* it was before the serialization.
|
||||
*/
|
||||
TALER_TESTING_cmd_check_keys ("check-keys-after-deserialization",
|
||||
4),
|
||||
TALER_TESTING_cmd_check_keys ("check-keys-after-deserialization"),
|
||||
/**
|
||||
* Use one of the deserialized keys.
|
||||
*/
|
||||
@ -109,51 +100,26 @@ run (void *cls,
|
||||
int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
(void) argc;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup (argv[0],
|
||||
"INFO",
|
||||
NULL);
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_exchange_api_keys_cherry_picking-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (cipher);
|
||||
TALER_TESTING_cleanup_files (config_file);
|
||||
/* @helpers. Run keyup, create tables, ... Note: it
|
||||
* fetches the port number from config in order to see
|
||||
* if it's available. */
|
||||
switch (TALER_TESTING_prepare_exchange (config_file,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
case GNUNET_NO:
|
||||
return 77;
|
||||
case GNUNET_OK:
|
||||
if (GNUNET_OK !=
|
||||
/* Set up event loop and reschedule context, plus
|
||||
* start/stop the exchange. It calls TALER_TESTING_setup
|
||||
* which creates the 'is' object.
|
||||
*/
|
||||
TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
config_file))
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,48 +3,21 @@
|
||||
[PATHS]
|
||||
# Persistent data storage for the testcase
|
||||
TALER_TEST_HOME = test_exchange_api_keys_cherry_picking_home/
|
||||
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
|
||||
|
||||
# Persistent data storage
|
||||
TALER_DATA_HOME = $TALER_HOME/.local/share/taler/
|
||||
|
||||
# Configuration files
|
||||
TALER_CONFIG_HOME = $TALER_HOME/.config/taler/
|
||||
|
||||
# Cached data, no big deal if lost
|
||||
TALER_CACHE_HOME = $TALER_HOME/.cache/taler/
|
||||
|
||||
[taler]
|
||||
# Currency supported by the exchange (can only be one)
|
||||
CURRENCY = EUR
|
||||
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||
|
||||
[taler-exchange-secmod-eddsa]
|
||||
OVERLAP_DURATION = 1 s
|
||||
DURATION = 30 s
|
||||
LOOKAHEAD_SIGN = 20 s
|
||||
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
|
||||
# HTTP port the auditor listens to
|
||||
PORT = 8083
|
||||
|
||||
[exchange]
|
||||
|
||||
AML_THRESHOLD = EUR:1000000
|
||||
|
||||
# HTTP port the exchange listens to
|
||||
PORT = 8081
|
||||
|
||||
# Master public key used to sign the exchange's various keys
|
||||
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||
|
||||
# How to access our database
|
||||
DB = postgres
|
||||
|
||||
# Base URL of the exchange. Must be set to a URL where the
|
||||
# exchange (or the twister) is actually listening.
|
||||
BASE_URL = "http://localhost:8081/"
|
||||
|
||||
[exchangedb-postgres]
|
||||
@ -55,6 +28,8 @@ CONFIG = "postgres:///talercheck"
|
||||
|
||||
[exchange-account-1]
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
|
||||
ENABLE_DEBIT = YES
|
||||
ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-accountcredentials-1]
|
||||
WIRE_GATEWAY_URL = "http://localhost:9082/42/"
|
||||
@ -66,11 +41,9 @@ ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = "http://localhost:9082/2/"
|
||||
|
||||
# Authentication information for basic authentication
|
||||
TALER_BANK_AUTH_METHOD = "basic"
|
||||
USERNAME = user
|
||||
PASSWORD = pass
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = Exchange
|
||||
PASSWORD = x
|
||||
|
||||
[bank]
|
||||
HTTP_PORT=8082
|
||||
|
@ -44,9 +44,9 @@
|
||||
static char *config_file;
|
||||
|
||||
/**
|
||||
* Exchange configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
|
||||
/**
|
||||
@ -60,22 +60,21 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_wire_add ("add-wire-account",
|
||||
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
1),
|
||||
TALER_TESTING_cmd_check_keys ("first-download",
|
||||
1),
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-2"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_file,
|
||||
"-e",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
|
||||
TALER_TESTING_cmd_check_keys ("first-download"),
|
||||
/* Causes GET /keys?last_denom_issue=0 */
|
||||
TALER_TESTING_cmd_check_keys_with_last_denom ("second-download",
|
||||
1,
|
||||
"zero"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
@ -89,51 +88,26 @@ run (void *cls,
|
||||
int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
(void) argc;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup (argv[0],
|
||||
"INFO",
|
||||
NULL);
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_exchange_api_keys_cherry_picking-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (cipher);
|
||||
TALER_TESTING_cleanup_files (config_file);
|
||||
/* @helpers. Run keyup, create tables, ... Note: it
|
||||
* fetches the port number from config in order to see
|
||||
* if it's available. */
|
||||
switch (TALER_TESTING_prepare_exchange (config_file,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
case GNUNET_NO:
|
||||
return 77;
|
||||
case GNUNET_OK:
|
||||
if (GNUNET_OK !=
|
||||
/* Set up event loop and reschedule context, plus
|
||||
* start/stop the exchange. It calls TALER_TESTING_setup
|
||||
* which creates the 'is' object.
|
||||
*/
|
||||
TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
config_file))
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014--2020 Taler Systems SA
|
||||
Copyright (C) 2014--2023 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
|
||||
@ -42,14 +42,9 @@
|
||||
static char *config_file;
|
||||
|
||||
/**
|
||||
* Exchange configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
|
||||
/**
|
||||
@ -63,6 +58,18 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command revocation[] = {
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-2"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_file,
|
||||
"-e",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
#if 0
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
@ -72,20 +79,20 @@ run (void *cls,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
1),
|
||||
#endif
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
|
||||
/**
|
||||
* Fill reserve with EUR:10.02, as withdraw fee is 1 ct per
|
||||
* config.
|
||||
*/
|
||||
TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1",
|
||||
"EUR:10.02",
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto),
|
||||
&cred.ba,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
|
||||
"EUR:10.02",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
/**
|
||||
* Run wire-watch to trigger the reserve creation.
|
||||
@ -109,7 +116,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-partial",
|
||||
"withdraw-revocation-coin-1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -118,7 +125,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-full",
|
||||
"withdraw-revocation-coin-2",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -241,66 +248,34 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
revocation,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
revocation);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
(void) argc;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup (argv[0],
|
||||
"INFO",
|
||||
NULL);
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_exchange_api-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (cipher);
|
||||
/* Check fakebank port is available and get config */
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (config_file,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
return 77;
|
||||
TALER_TESTING_cleanup_files (config_file);
|
||||
/* @helpers. Run keyup, create tables, ... Note: it
|
||||
* fetches the port number from config in order to see
|
||||
* if it's available. */
|
||||
switch (TALER_TESTING_prepare_exchange (config_file,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
case GNUNET_NO:
|
||||
return 77;
|
||||
case GNUNET_OK:
|
||||
if (GNUNET_OK !=
|
||||
/* Set up event loop and reschedule context, plus
|
||||
* start/stop the exchange. It calls TALER_TESTING_setup
|
||||
* which creates the 'is' object.
|
||||
*/
|
||||
TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
config_file))
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,21 +43,16 @@
|
||||
*/
|
||||
static char *config_file;
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* (real) Twister URL. Used at startup time to check if it runs.
|
||||
*/
|
||||
static char *twister_url;
|
||||
|
||||
/**
|
||||
* Exchange configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Twister process.
|
||||
*/
|
||||
@ -92,8 +87,8 @@ CMD_TRANSFER_TO_EXCHANGE (const char *label,
|
||||
{
|
||||
return TALER_TESTING_cmd_admin_add_incoming (label,
|
||||
amount,
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto);
|
||||
&cred.ba,
|
||||
cred.user42_payto);
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +127,7 @@ run (void *cls,
|
||||
"refresh-deposit-partial",
|
||||
"refresh-withdraw-coin",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -178,7 +173,7 @@ run (void *cls,
|
||||
"deposit-refund-1",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
"EUR:5",
|
||||
@ -201,7 +196,7 @@ run (void *cls,
|
||||
"deposit-refund-to-fail",
|
||||
"withdraw-coin-r1",
|
||||
0, /* coin index. */
|
||||
bc.user42_payto,
|
||||
cred.user42_payto,
|
||||
/* This parameter will make any comparison about
|
||||
h_contract_terms fail, when /refund will be handled.
|
||||
So in other words, this is h_contract mismatch. */
|
||||
@ -251,17 +246,17 @@ run (void *cls,
|
||||
#endif
|
||||
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
TALER_TESTING_cmd_wire_add (
|
||||
"add-wire-account",
|
||||
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys (
|
||||
"offline-sign-future-keys",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys (
|
||||
"refetch /keys",
|
||||
1),
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-2"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_file,
|
||||
"-e",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
TALER_TESTING_cmd_batch (
|
||||
"refresh-reveal-409-conflict",
|
||||
refresh_409_conflict),
|
||||
@ -276,16 +271,15 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Kill, wait, and destroy convenience function.
|
||||
*
|
||||
* @param process process to purge.
|
||||
* @param[in] process process to purge.
|
||||
*/
|
||||
static void
|
||||
purge_process (struct GNUNET_OS_Process *process)
|
||||
@ -301,57 +295,37 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
char *cipher;
|
||||
int ret;
|
||||
|
||||
(void) argc;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup (argv[0],
|
||||
"INFO",
|
||||
NULL);
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_exchange_api_twisted-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (cipher);
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (config_file,
|
||||
}
|
||||
/* FIXME: introduce commands for twister! */
|
||||
twister_url = TALER_TWISTER_prepare_twister (config_file);
|
||||
if (NULL == twister_url)
|
||||
return 77;
|
||||
twisterd = TALER_TWISTER_run_twister (config_file);
|
||||
if (NULL == twisterd)
|
||||
return 77;
|
||||
ret = TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
return 77;
|
||||
if (NULL == (twister_url = TALER_TWISTER_prepare_twister
|
||||
(config_file)))
|
||||
return 77;
|
||||
TALER_TESTING_cleanup_files (config_file);
|
||||
switch (TALER_TESTING_prepare_exchange (config_file,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
case GNUNET_NO:
|
||||
return 77;
|
||||
case GNUNET_OK:
|
||||
if (NULL == (twisterd = TALER_TWISTER_run_twister (config_file)))
|
||||
return 77;
|
||||
ret = TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
config_file);
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
purge_process (twisterd);
|
||||
GNUNET_free (twister_url);
|
||||
|
||||
if (GNUNET_OK != ret)
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2020-2022 Taler Systems SA
|
||||
Copyright (C) 2020-2023 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
|
||||
@ -35,16 +35,10 @@
|
||||
*/
|
||||
static char *config_file;
|
||||
|
||||
|
||||
/**
|
||||
* Exchange configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
|
||||
/**
|
||||
@ -58,10 +52,20 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
/* this currently fails, because the
|
||||
auditor is already added by the test setup logic */
|
||||
TALER_TESTING_cmd_auditor_del ("del-auditor-NOT-FOUND",
|
||||
MHD_HTTP_NOT_FOUND,
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_file,
|
||||
"-u", "exchange-account-2",
|
||||
"-ae",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
TALER_TESTING_cmd_get_auditor ("get-auditor",
|
||||
cred.cfg,
|
||||
true),
|
||||
TALER_TESTING_cmd_auditor_del ("del-auditor-FROM-SETUP",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-BAD-SIG",
|
||||
MHD_HTTP_FORBIDDEN,
|
||||
@ -141,72 +145,39 @@ run (void *cls,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
1),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
(void) argc;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup (argv[0],
|
||||
"INFO",
|
||||
NULL);
|
||||
/* Check fakebank port is available and get config */
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_exchange_api-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (cipher);
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (config_file,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
return 77;
|
||||
TALER_TESTING_cleanup_files (config_file);
|
||||
/* @helpers. Create tables, ... Note: it
|
||||
* fetches the port number from config in order to see
|
||||
* if it's available. */
|
||||
switch (TALER_TESTING_prepare_exchange (config_file,
|
||||
GNUNET_YES, /* reset DB? */
|
||||
&ec))
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
case GNUNET_NO:
|
||||
return 77;
|
||||
case GNUNET_OK:
|
||||
if (GNUNET_OK !=
|
||||
/* Set up event loop and reschedule context, plus
|
||||
* start/stop the exchange. It calls TALER_TESTING_setup
|
||||
* which creates the 'is' object.
|
||||
*/
|
||||
TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
config_file))
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,14 +42,9 @@
|
||||
static char *config_file;
|
||||
|
||||
/**
|
||||
* Exchange configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* Some tests behave differently when using CS as we cannot
|
||||
@ -90,8 +85,8 @@ static bool uses_cs;
|
||||
*/
|
||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||
&bc.exchange_auth, \
|
||||
bc.user42_payto)
|
||||
&cred.ba, \
|
||||
cred.user42_payto)
|
||||
|
||||
/**
|
||||
* Main function that will tell the interpreter what commands to
|
||||
@ -122,13 +117,13 @@ run (void *cls,
|
||||
MHD_HTTP_OK),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
|
||||
"EUR:5.04",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-2",
|
||||
"EUR:5.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-2"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -380,15 +375,15 @@ run (void *cls,
|
||||
"EUR:1.04"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-100",
|
||||
"EUR:1.04",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-100"),
|
||||
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-101",
|
||||
"EUR:1.04"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-101",
|
||||
"EUR:1.04",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-101"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-100"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-100",
|
||||
@ -500,32 +495,18 @@ run (void *cls,
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
/* setup exchange */
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_extensions ("offline-sign-extensions",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_wire_add ("add-wire-account",
|
||||
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-wire-fees",
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-2"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_file,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01"),
|
||||
TALER_TESTING_cmd_exec_offline_sign_global_fees ("offline-sign-global-fees",
|
||||
config_file,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01",
|
||||
"EUR:0.01",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
GNUNET_TIME_UNIT_DAYS,
|
||||
1),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||
config_file),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
1),
|
||||
"-e",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
|
||||
TALER_TESTING_cmd_batch ("withdraw",
|
||||
withdraw),
|
||||
TALER_TESTING_cmd_batch ("push",
|
||||
@ -541,9 +522,8 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
}
|
||||
|
||||
|
||||
@ -551,15 +531,9 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
(void) argc;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup (argv[0],
|
||||
"INFO",
|
||||
NULL);
|
||||
{
|
||||
char *cipher;
|
||||
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
@ -568,42 +542,15 @@ main (int argc,
|
||||
"test_exchange_api-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (cipher);
|
||||
|
||||
/* Check fakebank port is available and get config */
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (config_file,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
return 77;
|
||||
TALER_TESTING_cleanup_files (config_file);
|
||||
/* @helpers. Run keyup, create tables, ... Note: it
|
||||
* fetches the port number from config in order to see
|
||||
* if it's available. */
|
||||
switch (TALER_TESTING_prepare_exchange (config_file,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
case GNUNET_NO:
|
||||
return 78;
|
||||
case GNUNET_OK:
|
||||
if (GNUNET_OK !=
|
||||
/* Set up event loop and reschedule context, plus
|
||||
* start/stop the exchange. It calls TALER_TESTING_setup
|
||||
* which creates the 'is' object.
|
||||
*/
|
||||
TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
config_file))
|
||||
return 2;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,14 +41,10 @@
|
||||
#define CONFIG_FILE "test_kyc_api.conf"
|
||||
|
||||
/**
|
||||
* Exchange configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Execute the taler-exchange-wirewatch command with
|
||||
@ -79,8 +75,8 @@ static struct TALER_TESTING_BankConfiguration bc;
|
||||
*/
|
||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||
&bc.exchange_auth, \
|
||||
bc.user42_payto)
|
||||
&cred.ba, \
|
||||
cred.user42_payto)
|
||||
|
||||
/**
|
||||
* Main function that will tell the interpreter what commands to
|
||||
@ -98,8 +94,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-create-reserve-1",
|
||||
"EUR:15.02",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-no-kyc",
|
||||
@ -150,7 +146,7 @@ run (void *cls,
|
||||
"deposit-simple",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
bc.user43_payto,
|
||||
cred.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -196,10 +192,10 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-after-kyc"),
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check_bank_transfer-499c",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:4.98",
|
||||
bc.exchange_payto,
|
||||
bc.user43_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
@ -255,13 +251,13 @@ run (void *cls,
|
||||
MHD_HTTP_OK),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-1",
|
||||
"EUR:5.04",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"p2p_create-reserve-1"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-2",
|
||||
"EUR:5.01",
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
"p2p_create-reserve-2"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -518,29 +514,18 @@ run (void *cls,
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-2"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
CONFIG_FILE,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01"),
|
||||
TALER_TESTING_cmd_exec_offline_sign_global_fees ("offline-sign-global-fees",
|
||||
CONFIG_FILE,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01",
|
||||
"EUR:0.01",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
GNUNET_TIME_UNIT_DAYS,
|
||||
1),
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_wire_add ("add-wire-account",
|
||||
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||
CONFIG_FILE),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
2),
|
||||
"-e",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
|
||||
TALER_TESTING_cmd_batch ("withdraw",
|
||||
withdraw),
|
||||
TALER_TESTING_cmd_batch ("spend",
|
||||
@ -563,9 +548,8 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
}
|
||||
|
||||
|
||||
@ -574,48 +558,14 @@ main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup ("test-kyc-api",
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
NULL);
|
||||
/* Check fakebank port is available and get configuration data. */
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
||||
CONFIG_FILE,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
return 77;
|
||||
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
||||
/* @helpers. Run keyup, create tables, ... Note: it
|
||||
* fetches the port number from config in order to see
|
||||
* if it's available. */
|
||||
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
case GNUNET_NO:
|
||||
return 77;
|
||||
case GNUNET_OK:
|
||||
if (GNUNET_OK !=
|
||||
/* Set up event loop and reschedule context, plus
|
||||
* start/stop the exchange. It calls TALER_TESTING_setup
|
||||
* which creates the 'is' object.
|
||||
*/
|
||||
TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
CONFIG_FILE))
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,51 +1,7 @@
|
||||
|
||||
# This file is in the public domain.
|
||||
#
|
||||
[PATHS]
|
||||
# Persistent data storage for the testcase
|
||||
TALER_TEST_HOME = test_exchange_api_home/
|
||||
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
|
||||
|
||||
[taler-exchange-secmod-rsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
|
||||
[taler-exchange-secmod-eddsa]
|
||||
# Reduce from 1 year to speed up test
|
||||
LOOKAHEAD_SIGN = 24 days
|
||||
# Reduce from 12 weeks to ensure we have multiple
|
||||
DURATION = 14 days
|
||||
|
||||
|
||||
[taler]
|
||||
# Currency supported by the exchange (can only be one)
|
||||
CURRENCY = EUR
|
||||
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
|
||||
# HTTP port the auditor listens to
|
||||
PORT = 8083
|
||||
|
||||
TINY_AMOUNT = EUR:0.01
|
||||
|
||||
[exchange]
|
||||
AML_THRESHOLD = EUR:1000000
|
||||
|
||||
# HTTP port the exchange listens to
|
||||
PORT = 8081
|
||||
|
||||
# Master public key used to sign the exchange's various keys
|
||||
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||
|
||||
# How to access our database
|
||||
DB = postgres
|
||||
|
||||
# Base URL of the exchange. Must be set to a URL where the
|
||||
# exchange (or the twister) is actually listening.
|
||||
BASE_URL = "http://localhost:8081/"
|
||||
|
||||
@INLINE@ coins-rsa.conf
|
||||
@INLINE@ test_exchange_api.conf
|
||||
|
||||
[kyc-provider-test-oauth2]
|
||||
COST = 0
|
||||
@ -83,157 +39,3 @@ OPERATION_TYPE = MERGE
|
||||
REQUIRED_CHECKS = DUMMY
|
||||
THRESHOLD = EUR:0
|
||||
TIMEFRAME = 1d
|
||||
|
||||
[exchangedb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
[auditordb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
|
||||
# Sections starting with "exchange-account-" configure the bank accounts
|
||||
# of the exchange. The "URL" specifies the account in
|
||||
# payto://-format.
|
||||
[exchange-account-1]
|
||||
# What is the URL of our account?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
|
||||
|
||||
[exchange-accountcredentials-1]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
|
||||
|
||||
[bank]
|
||||
HTTP_PORT = 8082
|
||||
|
||||
# ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-account-2]
|
||||
# What is the bank account (with the "Taler Bank" demo system)?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
ENABLE_DEBIT = YES
|
||||
ENABLE_CREDIT = YES
|
||||
|
||||
# Authentication information for basic authentication
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
|
||||
WIRE_GATEWAY_AUTH_METHOD = "basic"
|
||||
USERNAME = user
|
||||
PASSWORD = pass
|
||||
|
||||
|
||||
|
||||
|
||||
# Sections starting with "coin_" specify which denominations
|
||||
# the exchange should support (and their respective fee structure)
|
||||
[coin_eur_ct_1]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_ct_2]
|
||||
value = EUR:0.01
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.00
|
||||
fee_deposit = EUR:0.00
|
||||
fee_refresh = EUR:0.01
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_ct_10]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_ct_11]
|
||||
value = EUR:0.10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_1]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_2]
|
||||
value = EUR:1
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_5]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_6]
|
||||
value = EUR:5
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
||||
|
||||
[coin_eur_10]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = RSA
|
||||
rsa_keysize = 1024
|
||||
|
||||
[coin_eur_11]
|
||||
value = EUR:10
|
||||
duration_withdraw = 7 days
|
||||
duration_spend = 2 years
|
||||
duration_legal = 3 years
|
||||
fee_withdraw = EUR:0.01
|
||||
fee_deposit = EUR:0.01
|
||||
fee_refresh = EUR:0.03
|
||||
fee_refund = EUR:0.01
|
||||
CIPHER = CS
|
@ -31,24 +31,9 @@
|
||||
|
||||
|
||||
/**
|
||||
* Helper structure to keep exchange configuration values.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Contains plugin.
|
||||
*/
|
||||
static struct TALER_TESTING_DatabaseConnection dbc;
|
||||
|
||||
/**
|
||||
* Return value from main().
|
||||
*/
|
||||
static int result;
|
||||
struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* Name of the configuration file to use.
|
||||
@ -70,24 +55,6 @@ static char *config_filename;
|
||||
TALER_TESTING_cmd_exec_transfer (label "-transfer", cfg_fn)
|
||||
|
||||
|
||||
/**
|
||||
* Function run on shutdown to unload the DB plugin.
|
||||
*
|
||||
* @param cls NULL
|
||||
*/
|
||||
static void
|
||||
unload_db (void *cls)
|
||||
{
|
||||
(void) cls;
|
||||
if (NULL != dbc.plugin)
|
||||
{
|
||||
dbc.plugin->drop_tables (dbc.plugin->cls);
|
||||
TALER_EXCHANGEDB_plugin_unload (dbc.plugin);
|
||||
dbc.plugin = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Collects all the tests.
|
||||
*/
|
||||
@ -96,11 +63,13 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command all[] = {
|
||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-1"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_filename,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01"),
|
||||
// check no aggregation happens on a empty database
|
||||
"-e",
|
||||
NULL),
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty-db",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),
|
||||
@ -108,7 +77,7 @@ run (void *cls,
|
||||
/* check aggregation happens on the simplest case:
|
||||
one deposit into the database. */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-1",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -119,15 +88,15 @@ run (void *cls,
|
||||
config_filename),
|
||||
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.89",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-1"),
|
||||
|
||||
/* check aggregation accumulates well. */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-2a",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -136,7 +105,7 @@ run (void *cls,
|
||||
"EUR:0.1"),
|
||||
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-2b",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -148,15 +117,15 @@ run (void *cls,
|
||||
config_filename),
|
||||
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-2",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:1.79",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-2"),
|
||||
|
||||
/* check that different merchants stem different aggregations. */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-3a",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
"4",
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -164,7 +133,7 @@ run (void *cls,
|
||||
"EUR:1",
|
||||
"EUR:0.1"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-3b",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
"5",
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -172,7 +141,7 @@ run (void *cls,
|
||||
"EUR:1",
|
||||
"EUR:0.1"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-3c",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"alice",
|
||||
"4",
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -183,25 +152,25 @@ run (void *cls,
|
||||
config_filename),
|
||||
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3a",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.89",
|
||||
bc.exchange_payto,
|
||||
cred.exchange_payto,
|
||||
"payto://x-taler-bank/localhost/4?receiver-name=4"),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.89",
|
||||
bc.exchange_payto,
|
||||
cred.exchange_payto,
|
||||
"payto://x-taler-bank/localhost/4?receiver-name=4"),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.89",
|
||||
bc.exchange_payto,
|
||||
cred.exchange_payto,
|
||||
"payto://x-taler-bank/localhost/5?receiver-name=5"),
|
||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-3"),
|
||||
|
||||
/* checking that aggregator waits for the deadline. */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-4a",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -211,7 +180,7 @@ run (void *cls,
|
||||
"EUR:0.2",
|
||||
"EUR:0.1"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-4b",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -230,14 +199,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-4-delayed",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-4",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.19",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
|
||||
// test picking all deposits at earliest deadline
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-5a",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -248,7 +217,7 @@ run (void *cls,
|
||||
"EUR:0.1"),
|
||||
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-5b",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -267,13 +236,13 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-5-delayed",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-5",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.19",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
/* Test NEVER running 'tiny' unless they make up minimum unit */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6a",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -285,7 +254,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-6a-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6b",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -293,7 +262,7 @@ run (void *cls,
|
||||
"EUR:0.102",
|
||||
"EUR:0.1"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6c",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -305,7 +274,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-6c-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6d",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -317,7 +286,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-6d-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6e",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -327,14 +296,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-6e",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-6",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.01",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
|
||||
/* Test profiteering if wire deadline is short */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-7a",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -346,7 +315,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-7a-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-7b",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -356,14 +325,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-profit",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.01",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
|
||||
/* Now check profit was actually taken */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-7c",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -373,14 +342,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-loss",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.01",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
|
||||
/* Test that aggregation would happen fully if wire deadline is long */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-8a",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -394,7 +363,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-8a-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-8b",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -410,7 +379,7 @@ run (void *cls,
|
||||
|
||||
/* now trigger aggregate with large transaction and short deadline */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-8c",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -420,14 +389,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-8",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-8",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.03",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
|
||||
/* Test aggregation with fees and rounding profits. */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-9a",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -441,7 +410,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-9a-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-9b",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -457,7 +426,7 @@ run (void *cls,
|
||||
|
||||
/* now trigger aggregate with large transaction and short deadline */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-9c",
|
||||
&dbc,
|
||||
cred.cfg,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -468,49 +437,15 @@ run (void *cls,
|
||||
config_filename),
|
||||
/* 0.009 + 0.009 + 0.022 - 0.001 - 0.002 - 0.008 = 0.029 => 0.02 */
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-9",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:0.01",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
all,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare database and launch the test.
|
||||
*
|
||||
* @param cls unused
|
||||
* @param is interpreter to use
|
||||
*/
|
||||
static void
|
||||
prepare_database (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
dbc.plugin = TALER_EXCHANGEDB_plugin_load (is->cfg);
|
||||
if (NULL == dbc.plugin)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
result = 77;
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
dbc.plugin->preflight (dbc.plugin->cls))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
result = 77;
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_SCHEDULER_add_shutdown (&unload_db,
|
||||
NULL);
|
||||
run (NULL,
|
||||
is);
|
||||
TALER_TESTING_run (is,
|
||||
all);
|
||||
}
|
||||
|
||||
|
||||
@ -519,7 +454,6 @@ main (int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
const char *plugin_name;
|
||||
char *testname;
|
||||
|
||||
if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
|
||||
{
|
||||
@ -527,52 +461,17 @@ main (int argc,
|
||||
return -1;
|
||||
}
|
||||
plugin_name++;
|
||||
(void) GNUNET_asprintf (&testname,
|
||||
"test-taler-exchange-aggregator-%s",
|
||||
plugin_name);
|
||||
(void) GNUNET_asprintf (&config_filename,
|
||||
"%s.conf",
|
||||
testname);
|
||||
|
||||
GNUNET_log_setup ("test_taler_exchange_aggregator",
|
||||
"test-taler-exchange-aggregator-%s.conf",
|
||||
plugin_name);
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
NULL);
|
||||
|
||||
/* these might get in the way */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
|
||||
TALER_TESTING_cleanup_files (config_filename);
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_exchange (config_filename,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
TALER_LOG_WARNING ("Could not prepare the exchange.\n");
|
||||
return 77;
|
||||
}
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (config_filename,
|
||||
config_filename,
|
||||
"exchange-account-1",
|
||||
&bc))
|
||||
{
|
||||
TALER_LOG_WARNING ("Could not prepare the fakebank\n");
|
||||
return 77;
|
||||
}
|
||||
result = GNUNET_OK;
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_setup_with_exchange (&prepare_database,
|
||||
NULL,
|
||||
config_filename))
|
||||
{
|
||||
TALER_LOG_WARNING ("Could not prepare database for tests.\n");
|
||||
return result;
|
||||
}
|
||||
GNUNET_free (config_filename);
|
||||
GNUNET_free (testname);
|
||||
return GNUNET_OK == result ? 0 : 1;
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,14 +34,9 @@
|
||||
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
* Our credentials.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Helper structure to keep exchange configuration values.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* Name of the configuration file to use.
|
||||
@ -66,8 +61,8 @@ transfer_to_exchange (const char *label,
|
||||
{
|
||||
return TALER_TESTING_cmd_admin_add_incoming (label,
|
||||
amount,
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto);
|
||||
&cred.ba,
|
||||
cred.user42_payto);
|
||||
}
|
||||
|
||||
|
||||
@ -82,21 +77,19 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command all[] = {
|
||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-1"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_filename,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01"),
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_wire_add ("add-wire-account",
|
||||
"payto://x-taler-bank/localhost/2?receiver-name=2",
|
||||
MHD_HTTP_NO_CONTENT,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
1),
|
||||
"-e",
|
||||
"-u", "exchange-account-1",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_get_exchange ("get-exchange",
|
||||
cred.cfg,
|
||||
true,
|
||||
true),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
|
||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty"),
|
||||
TALER_TESTING_cmd_exec_wirewatch ("run-wirewatch-on-empty",
|
||||
@ -111,8 +104,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"clear-good-transfer-to-the-exchange",
|
||||
"EUR:5",
|
||||
bc.user42_payto, // debit
|
||||
bc.exchange_payto, // credit
|
||||
cred.user42_payto, // debit
|
||||
cred.exchange_payto, // credit
|
||||
"run-transfer-good-to-exchange"),
|
||||
|
||||
TALER_TESTING_cmd_exec_closer ("run-closer-non-expired-reserve",
|
||||
@ -135,88 +128,47 @@ run (void *cls,
|
||||
|
||||
CMD_EXEC_AGGREGATOR ("run-closer-on-expired-reserve"),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
|
||||
ec.exchange_url,
|
||||
cred.exchange_url,
|
||||
"EUR:4.99",
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-2"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
all,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
all);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
const char *plugin_name;
|
||||
|
||||
(void) argc;
|
||||
/* these might get in the way */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup ("test_taler_exchange_wirewatch",
|
||||
"INFO",
|
||||
NULL);
|
||||
|
||||
if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
|
||||
plugin_name = strrchr (argv[0], (int) '-');
|
||||
if (NULL == plugin_name)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return -1;
|
||||
}
|
||||
plugin_name++;
|
||||
{
|
||||
char *testname;
|
||||
|
||||
GNUNET_asprintf (&testname,
|
||||
"test-taler-exchange-wirewatch-%s",
|
||||
plugin_name);
|
||||
GNUNET_asprintf (&config_filename,
|
||||
"%s.conf",
|
||||
testname);
|
||||
GNUNET_free (testname);
|
||||
"test-taler-exchange-wirewatch-%s.conf",
|
||||
plugin_name);
|
||||
}
|
||||
/* check database is working */
|
||||
{
|
||||
struct GNUNET_PQ_Context *conn;
|
||||
struct GNUNET_PQ_ExecuteStatement es[] = {
|
||||
GNUNET_PQ_EXECUTE_STATEMENT_END
|
||||
};
|
||||
|
||||
conn = GNUNET_PQ_connect ("postgres:///talercheck",
|
||||
NULL,
|
||||
es,
|
||||
NULL);
|
||||
if (NULL == conn)
|
||||
return 77;
|
||||
GNUNET_PQ_disconnect (conn);
|
||||
}
|
||||
|
||||
TALER_TESTING_cleanup_files (config_filename);
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_exchange (config_filename,
|
||||
GNUNET_YES,
|
||||
&ec))
|
||||
{
|
||||
TALER_LOG_INFO ("Could not prepare the exchange\n");
|
||||
return 77;
|
||||
}
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (config_filename,
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_filename,
|
||||
"exchange-account-1",
|
||||
&bc))
|
||||
return 77;
|
||||
|
||||
return (GNUNET_OK ==
|
||||
TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
config_filename)) ? 0 : 1;
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
/**
|
||||
* @file testing/testing_api_cmd_auditor_add.c
|
||||
* @brief command for testing /auditor_add.
|
||||
* @brief command for testing auditor_add
|
||||
* @author Christian Grothoff
|
||||
*/
|
||||
#include "platform.h"
|
||||
@ -75,16 +75,8 @@ auditor_add_cb (
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -106,10 +98,43 @@ auditor_add_run (void *cls,
|
||||
struct AuditorAddState *ds = cls;
|
||||
struct GNUNET_TIME_Timestamp now;
|
||||
struct TALER_MasterSignatureP master_sig;
|
||||
const struct TALER_AuditorPublicKeyP *auditor_pub;
|
||||
const struct TALER_TESTING_Command *auditor_cmd;
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
const char *exchange_url;
|
||||
const char *auditor_url;
|
||||
|
||||
(void) cmd;
|
||||
now = GNUNET_TIME_timestamp_get ();
|
||||
ds->is = is;
|
||||
|
||||
auditor_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"auditor");
|
||||
if (NULL == auditor_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_auditor_pub (auditor_cmd,
|
||||
&auditor_pub));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_auditor_url (auditor_cmd,
|
||||
&auditor_url));
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
|
||||
|
||||
if (ds->bad_sig)
|
||||
{
|
||||
memset (&master_sig,
|
||||
@ -118,17 +143,22 @@ auditor_add_run (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
TALER_exchange_offline_auditor_add_sign (&is->auditor_pub,
|
||||
is->auditor_url,
|
||||
const struct TALER_MasterPrivateKeyP *master_priv;
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_master_priv (exchange_cmd,
|
||||
&master_priv));
|
||||
TALER_exchange_offline_auditor_add_sign (auditor_pub,
|
||||
auditor_url,
|
||||
now,
|
||||
&is->master_priv,
|
||||
master_priv,
|
||||
&master_sig);
|
||||
}
|
||||
ds->dh = TALER_EXCHANGE_management_enable_auditor (
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
&is->auditor_pub,
|
||||
is->auditor_url,
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
auditor_pub,
|
||||
auditor_url,
|
||||
"test-case auditor", /* human-readable auditor name */
|
||||
now,
|
||||
&master_sig,
|
||||
@ -158,9 +188,7 @@ auditor_add_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_management_enable_auditor_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -80,16 +80,8 @@ denom_sig_add_cb (
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -112,6 +104,11 @@ auditor_add_run (void *cls,
|
||||
struct TALER_AuditorSignatureP auditor_sig;
|
||||
struct TALER_DenominationHashP h_denom_pub;
|
||||
const struct TALER_EXCHANGE_DenomPublicKey *dk;
|
||||
const struct TALER_AuditorPublicKeyP *auditor_pub;
|
||||
const struct TALER_TESTING_Command *auditor_cmd;
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
const char *exchange_url;
|
||||
const char *auditor_url;
|
||||
|
||||
(void) cmd;
|
||||
/* Get denom pub from trait */
|
||||
@ -120,7 +117,6 @@ auditor_add_run (void *cls,
|
||||
|
||||
denom_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||
ds->denom_ref);
|
||||
|
||||
if (NULL == denom_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
@ -133,6 +129,31 @@ auditor_add_run (void *cls,
|
||||
&dk));
|
||||
}
|
||||
ds->is = is;
|
||||
auditor_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"auditor");
|
||||
if (NULL == auditor_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_auditor_pub (auditor_cmd,
|
||||
&auditor_pub));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_auditor_url (auditor_cmd,
|
||||
&auditor_url));
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
if (ds->bad_sig)
|
||||
{
|
||||
memset (&auditor_sig,
|
||||
@ -141,28 +162,33 @@ auditor_add_run (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
struct TALER_MasterPublicKeyP master_pub;
|
||||
const struct TALER_MasterPublicKeyP *master_pub;
|
||||
const struct TALER_AuditorPrivateKeyP *auditor_priv;
|
||||
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&is->master_priv.eddsa_priv,
|
||||
&master_pub.eddsa_pub);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_master_pub (exchange_cmd,
|
||||
&master_pub));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_auditor_priv (auditor_cmd,
|
||||
&auditor_priv));
|
||||
TALER_auditor_denom_validity_sign (
|
||||
is->auditor_url,
|
||||
auditor_url,
|
||||
&dk->h_key,
|
||||
&master_pub,
|
||||
master_pub,
|
||||
dk->valid_from,
|
||||
dk->withdraw_valid_until,
|
||||
dk->expire_deposit,
|
||||
dk->expire_legal,
|
||||
&dk->value,
|
||||
&dk->fees,
|
||||
&is->auditor_priv,
|
||||
auditor_priv,
|
||||
&auditor_sig);
|
||||
}
|
||||
ds->dh = TALER_EXCHANGE_add_auditor_denomination (
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
&h_denom_pub,
|
||||
&is->auditor_pub,
|
||||
auditor_pub,
|
||||
&auditor_sig,
|
||||
&denom_sig_add_cb,
|
||||
ds);
|
||||
@ -190,9 +216,7 @@ auditor_add_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_add_auditor_denomination_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -76,16 +76,8 @@ auditor_del_cb (
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -107,10 +99,36 @@ auditor_del_run (void *cls,
|
||||
struct AuditorDelState *ds = cls;
|
||||
struct TALER_MasterSignatureP master_sig;
|
||||
struct GNUNET_TIME_Timestamp now;
|
||||
const struct TALER_AuditorPublicKeyP *auditor_pub;
|
||||
const struct TALER_TESTING_Command *auditor_cmd;
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
const char *exchange_url;
|
||||
|
||||
(void) cmd;
|
||||
now = GNUNET_TIME_timestamp_get ();
|
||||
ds->is = is;
|
||||
auditor_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"auditor");
|
||||
if (NULL == auditor_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_auditor_pub (auditor_cmd,
|
||||
&auditor_pub));
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
if (ds->bad_sig)
|
||||
{
|
||||
memset (&master_sig,
|
||||
@ -119,15 +137,20 @@ auditor_del_run (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
TALER_exchange_offline_auditor_del_sign (&is->auditor_pub,
|
||||
const struct TALER_MasterPrivateKeyP *master_priv;
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_master_priv (exchange_cmd,
|
||||
&master_priv));
|
||||
TALER_exchange_offline_auditor_del_sign (auditor_pub,
|
||||
now,
|
||||
&is->master_priv,
|
||||
master_priv,
|
||||
&master_sig);
|
||||
}
|
||||
ds->dh = TALER_EXCHANGE_management_disable_auditor (
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
&is->auditor_pub,
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
auditor_pub,
|
||||
now,
|
||||
&master_sig,
|
||||
&auditor_del_cb,
|
||||
@ -156,9 +179,7 @@ auditor_del_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_management_disable_auditor_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -68,11 +68,6 @@ struct DepositConfirmationState
|
||||
*/
|
||||
struct TALER_AUDITOR_DepositConfirmationHandle *dc;
|
||||
|
||||
/**
|
||||
* Auditor connection.
|
||||
*/
|
||||
struct TALER_AUDITOR_Handle *auditor;
|
||||
|
||||
/**
|
||||
* Interpreter state.
|
||||
*/
|
||||
@ -125,8 +120,7 @@ do_retry (void *cls)
|
||||
struct DepositConfirmationState *dcs = cls;
|
||||
|
||||
dcs->retry_task = NULL;
|
||||
dcs->is->commands[dcs->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
TALER_TESTING_touch_cmd (dcs->is);
|
||||
deposit_confirmation_run (dcs,
|
||||
NULL,
|
||||
dcs->is);
|
||||
@ -166,21 +160,15 @@ deposit_confirmation_cb (void *cls,
|
||||
else
|
||||
dcs->backoff = GNUNET_TIME_randomized_backoff (dcs->backoff,
|
||||
MAX_BACKOFF);
|
||||
dcs->is->commands[dcs->is->ip].num_tries++;
|
||||
TALER_TESTING_inc_tries (dcs->is);
|
||||
dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff,
|
||||
&do_retry,
|
||||
dcs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
dcs->is->commands[dcs->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply, stderr, 0);
|
||||
TALER_TESTING_interpreter_fail (dcs->is);
|
||||
TALER_TESTING_unexpected_status (dcs->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (dcs->is);
|
||||
@ -220,10 +208,31 @@ deposit_confirmation_run (void *cls,
|
||||
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
|
||||
const struct TALER_EXCHANGE_Keys *keys;
|
||||
const struct TALER_EXCHANGE_SigningPublicKey *spk;
|
||||
struct TALER_AUDITOR_Handle *auditor;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
dcs->is = is;
|
||||
GNUNET_assert (NULL != dcs->deposit_reference);
|
||||
{
|
||||
const struct TALER_TESTING_Command *auditor_cmd;
|
||||
|
||||
auditor_cmd
|
||||
= TALER_TESTING_interpreter_get_command (is,
|
||||
"auditor");
|
||||
if (NULL == auditor_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_auditor (auditor_cmd,
|
||||
&auditor));
|
||||
}
|
||||
deposit_cmd
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
dcs->deposit_reference);
|
||||
@ -251,7 +260,7 @@ deposit_confirmation_run (void *cls,
|
||||
dcs->coin_index,
|
||||
&wire_deadline));
|
||||
GNUNET_assert (NULL != exchange_timestamp);
|
||||
keys = TALER_EXCHANGE_get_keys (dcs->is->exchange);
|
||||
keys = TALER_EXCHANGE_get_keys (exchange);
|
||||
GNUNET_assert (NULL != keys);
|
||||
spk = TALER_EXCHANGE_get_signing_key_info (keys,
|
||||
exchange_pub);
|
||||
@ -308,7 +317,7 @@ deposit_confirmation_run (void *cls,
|
||||
if (GNUNET_TIME_absolute_is_zero (refund_deadline.abs_time))
|
||||
refund_deadline = timestamp;
|
||||
}
|
||||
dcs->dc = TALER_AUDITOR_deposit_confirmation (dcs->auditor,
|
||||
dcs->dc = TALER_AUDITOR_deposit_confirmation (auditor,
|
||||
&h_wire,
|
||||
&no_h_policy,
|
||||
&h_contract_terms,
|
||||
@ -353,9 +362,7 @@ deposit_confirmation_cleanup (void *cls,
|
||||
|
||||
if (NULL != dcs->dc)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
dcs->is->ip,
|
||||
TALER_TESTING_command_incomplete (dcs->is,
|
||||
cmd->label);
|
||||
TALER_AUDITOR_deposit_confirmation_cancel (dcs->dc);
|
||||
dcs->dc = NULL;
|
||||
@ -371,7 +378,6 @@ deposit_confirmation_cleanup (void *cls,
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_deposit_confirmation (const char *label,
|
||||
struct TALER_AUDITOR_Handle *auditor,
|
||||
const char *deposit_reference,
|
||||
unsigned int coin_index,
|
||||
const char *amount_without_fee,
|
||||
@ -380,7 +386,6 @@ TALER_TESTING_cmd_deposit_confirmation (const char *label,
|
||||
struct DepositConfirmationState *dcs;
|
||||
|
||||
dcs = GNUNET_new (struct DepositConfirmationState);
|
||||
dcs->auditor = auditor;
|
||||
dcs->deposit_reference = deposit_reference;
|
||||
dcs->coin_index = coin_index;
|
||||
dcs->amount_without_fee = amount_without_fee;
|
||||
|
@ -53,11 +53,6 @@ struct ExchangesState
|
||||
*/
|
||||
struct TALER_AUDITOR_ListExchangesHandle *leh;
|
||||
|
||||
/**
|
||||
* Auditor connection.
|
||||
*/
|
||||
struct TALER_AUDITOR_Handle *auditor;
|
||||
|
||||
/**
|
||||
* Interpreter state.
|
||||
*/
|
||||
@ -115,8 +110,7 @@ do_retry (void *cls)
|
||||
struct ExchangesState *es = cls;
|
||||
|
||||
es->retry_task = NULL;
|
||||
es->is->commands[es->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
TALER_TESTING_touch_cmd (es->is);
|
||||
exchanges_run (es,
|
||||
NULL,
|
||||
es->is);
|
||||
@ -159,24 +153,15 @@ exchanges_cb (void *cls,
|
||||
else
|
||||
es->backoff = GNUNET_TIME_randomized_backoff (es->backoff,
|
||||
MAX_BACKOFF);
|
||||
es->is->commands[es->is->ip].num_tries++;
|
||||
TALER_TESTING_inc_tries (es->is);
|
||||
es->retry_task = GNUNET_SCHEDULER_add_delayed (es->backoff,
|
||||
&do_retry,
|
||||
es);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
(int) hr->ec,
|
||||
es->is->commands[es->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (es->is);
|
||||
TALER_TESTING_unexpected_status (es->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
if (NULL != es->exchange_url)
|
||||
@ -217,11 +202,24 @@ exchanges_run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct ExchangesState *es = cls;
|
||||
const struct TALER_TESTING_Command *auditor_cmd;
|
||||
struct TALER_AUDITOR_Handle *auditor;
|
||||
|
||||
(void) cmd;
|
||||
auditor_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"auditor");
|
||||
if (NULL == auditor_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_auditor (auditor_cmd,
|
||||
&auditor));
|
||||
|
||||
es->is = is;
|
||||
es->leh = TALER_AUDITOR_list_exchanges
|
||||
(is->auditor,
|
||||
es->leh = TALER_AUDITOR_list_exchanges (auditor,
|
||||
&exchanges_cb,
|
||||
es);
|
||||
|
||||
@ -250,9 +248,7 @@ exchanges_cleanup (void *cls,
|
||||
|
||||
if (NULL != es->leh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
es->is->ip,
|
||||
TALER_TESTING_command_incomplete (es->is,
|
||||
cmd->label);
|
||||
TALER_AUDITOR_list_exchanges_cancel (es->leh);
|
||||
es->leh = NULL;
|
||||
@ -275,7 +271,7 @@ exchanges_cleanup (void *cls,
|
||||
* @param index index number of the traits to be returned.
|
||||
* @return #GNUNET_OK on success
|
||||
*/
|
||||
static int
|
||||
static enum GNUNET_GenericReturnValue
|
||||
exchanges_traits (void *cls,
|
||||
const void **ret,
|
||||
const char *trait,
|
||||
@ -301,13 +297,11 @@ exchanges_traits (void *cls,
|
||||
*/
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_exchanges (const char *label,
|
||||
struct TALER_AUDITOR_Handle *auditor,
|
||||
unsigned int expected_response_code)
|
||||
{
|
||||
struct ExchangesState *es;
|
||||
|
||||
es = GNUNET_new (struct ExchangesState);
|
||||
es->auditor = auditor;
|
||||
es->expected_response_code = expected_response_code;
|
||||
|
||||
{
|
||||
|
@ -180,8 +180,7 @@ do_retry (void *cls)
|
||||
struct AdminAddIncomingState *fts = cls;
|
||||
|
||||
fts->retry_task = NULL;
|
||||
fts->is->commands[fts->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
TALER_TESTING_touch_cmd (fts->is);
|
||||
admin_add_incoming_run (fts,
|
||||
NULL,
|
||||
fts->is);
|
||||
@ -279,7 +278,7 @@ confirmation_cb (void *cls,
|
||||
else
|
||||
fts->backoff = GNUNET_TIME_randomized_backoff (fts->backoff,
|
||||
MAX_BACKOFF);
|
||||
fts->is->commands[fts->is->ip].num_tries++;
|
||||
TALER_TESTING_inc_tries (fts->is);
|
||||
fts->retry_task = GNUNET_SCHEDULER_add_delayed (
|
||||
fts->backoff,
|
||||
&do_retry,
|
||||
@ -314,6 +313,7 @@ admin_add_incoming_run (void *cls,
|
||||
bool have_public = false;
|
||||
|
||||
(void) cmd;
|
||||
fts->is = is;
|
||||
/* Use reserve public key as subject */
|
||||
if (NULL != fts->reserve_reference)
|
||||
{
|
||||
@ -364,7 +364,6 @@ admin_add_incoming_run (void *cls,
|
||||
fts->reserve_history.amount = fts->amount;
|
||||
fts->reserve_history.details.in_details.sender_url
|
||||
= (char *) fts->payto_debit_account; /* remember to NOT free this one... */
|
||||
fts->is = is;
|
||||
fts->aih
|
||||
= TALER_BANK_admin_add_incoming (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
@ -398,8 +397,7 @@ admin_add_incoming_cleanup (void *cls,
|
||||
|
||||
if (NULL != fts->aih)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %s did not complete\n",
|
||||
TALER_TESTING_command_incomplete (fts->is,
|
||||
cmd->label);
|
||||
TALER_BANK_admin_add_incoming_cancel (fts->aih);
|
||||
fts->aih = NULL;
|
||||
@ -439,12 +437,12 @@ admin_add_incoming_traits (void *cls,
|
||||
{
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
|
||||
TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account),
|
||||
TALER_TESTING_make_trait_payto_uri (&fts->payto_debit_account),
|
||||
TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account),
|
||||
TALER_TESTING_make_trait_payto_uri (fts->payto_debit_account),
|
||||
/* Used as a marker, content does not matter */
|
||||
TALER_TESTING_make_trait_credit_payto_uri (&void_uri),
|
||||
TALER_TESTING_make_trait_credit_payto_uri (void_uri),
|
||||
TALER_TESTING_make_trait_exchange_bank_account_url (
|
||||
&fts->exchange_credit_url),
|
||||
fts->exchange_credit_url),
|
||||
TALER_TESTING_make_trait_amount (&fts->amount),
|
||||
TALER_TESTING_make_trait_timestamp (0,
|
||||
&fts->timestamp),
|
||||
@ -464,13 +462,14 @@ admin_add_incoming_traits (void *cls,
|
||||
{
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
|
||||
TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account),
|
||||
TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account),
|
||||
/* Used as a marker, content does not matter */
|
||||
TALER_TESTING_make_trait_credit_payto_uri (&void_uri),
|
||||
TALER_TESTING_make_trait_credit_payto_uri (void_uri),
|
||||
TALER_TESTING_make_trait_exchange_bank_account_url (
|
||||
&fts->exchange_credit_url),
|
||||
fts->exchange_credit_url),
|
||||
TALER_TESTING_make_trait_amount (&fts->amount),
|
||||
TALER_TESTING_make_trait_timestamp (0, &fts->timestamp),
|
||||
TALER_TESTING_make_trait_timestamp (0,
|
||||
&fts->timestamp),
|
||||
TALER_TESTING_make_trait_reserve_pub (&fts->reserve_pub),
|
||||
TALER_TESTING_make_trait_reserve_history (0,
|
||||
&fts->reserve_history),
|
||||
|
@ -82,8 +82,30 @@ check_bank_admin_transfer_run (void *cls,
|
||||
const char *credit_payto;
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||
const struct TALER_TESTING_Command *cmd_ref;
|
||||
struct TALER_FAKEBANK_Handle *fakebank;
|
||||
|
||||
(void) cmd;
|
||||
{
|
||||
const struct TALER_TESTING_Command *fakebank_cmd;
|
||||
|
||||
fakebank_cmd
|
||||
= TALER_TESTING_interpreter_get_command (is,
|
||||
"fakebank");
|
||||
if (NULL == fakebank_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_fakebank (fakebank_cmd,
|
||||
&fakebank))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
}
|
||||
cmd_ref
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
bcs->reserve_pub_ref);
|
||||
@ -109,9 +131,9 @@ check_bank_admin_transfer_run (void *cls,
|
||||
&amount))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to parse amount `%s' at %u\n",
|
||||
"Failed to parse amount `%s' at %s\n",
|
||||
bcs->amount,
|
||||
is->ip);
|
||||
TALER_TESTING_interpreter_get_current_label (is));
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
@ -122,7 +144,7 @@ check_bank_admin_transfer_run (void *cls,
|
||||
debit_payto,
|
||||
debit_account);
|
||||
if (GNUNET_OK !=
|
||||
TALER_FAKEBANK_check_credit (is->fakebank,
|
||||
TALER_FAKEBANK_check_credit (fakebank,
|
||||
&amount,
|
||||
debit_account,
|
||||
credit_account,
|
||||
|
@ -91,26 +91,48 @@ check_bank_transfer_run (void *cls,
|
||||
struct TALER_Amount amount;
|
||||
char *debit_account;
|
||||
char *credit_account;
|
||||
const char **exchange_base_url;
|
||||
const char **debit_payto;
|
||||
const char **credit_payto;
|
||||
const char *exchange_base_url;
|
||||
const char *debit_payto;
|
||||
const char *credit_payto;
|
||||
struct TALER_FAKEBANK_Handle *fakebank;
|
||||
|
||||
(void) cmd;
|
||||
{
|
||||
const struct TALER_TESTING_Command *fakebank_cmd;
|
||||
|
||||
fakebank_cmd
|
||||
= TALER_TESTING_interpreter_get_command (is,
|
||||
"fakebank");
|
||||
if (NULL == fakebank_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_fakebank (fakebank_cmd,
|
||||
&fakebank))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (NULL == bcs->deposit_reference)
|
||||
{
|
||||
TALER_LOG_INFO ("Deposit reference NOT given\n");
|
||||
debit_payto = &bcs->debit_payto;
|
||||
credit_payto = &bcs->credit_payto;
|
||||
exchange_base_url = &bcs->exchange_base_url;
|
||||
debit_payto = bcs->debit_payto;
|
||||
credit_payto = bcs->credit_payto;
|
||||
exchange_base_url = bcs->exchange_base_url;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_string_to_amount (bcs->amount,
|
||||
&amount))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to parse amount `%s' at %u\n",
|
||||
"Failed to parse amount `%s' at %s\n",
|
||||
bcs->amount,
|
||||
is->ip);
|
||||
TALER_TESTING_interpreter_get_current_label (is));
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
@ -145,27 +167,22 @@ check_bank_transfer_run (void *cls,
|
||||
TALER_TESTING_FAIL (is);
|
||||
amount = *amount_ptr;
|
||||
}
|
||||
|
||||
|
||||
debit_account = TALER_xtalerbank_account_from_payto (*debit_payto);
|
||||
credit_account = TALER_xtalerbank_account_from_payto (*credit_payto);
|
||||
|
||||
debit_account = TALER_xtalerbank_account_from_payto (debit_payto);
|
||||
credit_account = TALER_xtalerbank_account_from_payto (credit_payto);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"converted debit_payto (%s) to debit_account (%s)\n",
|
||||
*debit_payto,
|
||||
debit_payto,
|
||||
debit_account);
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"converted credit_payto (%s) to credit_account (%s)\n",
|
||||
*credit_payto,
|
||||
credit_payto,
|
||||
credit_account);
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_FAKEBANK_check_debit (is->fakebank,
|
||||
TALER_FAKEBANK_check_debit (fakebank,
|
||||
&amount,
|
||||
debit_account,
|
||||
credit_account,
|
||||
*exchange_base_url,
|
||||
exchange_base_url,
|
||||
&bcs->wtid))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
@ -217,7 +234,7 @@ check_bank_transfer_traits (void *cls,
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_wtid (wtid_ptr),
|
||||
TALER_TESTING_make_trait_exchange_url (
|
||||
&bcs->exchange_base_url),
|
||||
bcs->exchange_base_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
|
@ -58,9 +58,33 @@ check_bank_empty_run (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_FAKEBANK_Handle *fakebank;
|
||||
|
||||
(void) cls;
|
||||
(void) cmd;
|
||||
if (GNUNET_OK != TALER_FAKEBANK_check_empty (is->fakebank))
|
||||
{
|
||||
const struct TALER_TESTING_Command *fakebank_cmd;
|
||||
|
||||
fakebank_cmd
|
||||
= TALER_TESTING_interpreter_get_command (is,
|
||||
"fakebank");
|
||||
if (NULL == fakebank_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_fakebank (fakebank_cmd,
|
||||
&fakebank))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
TALER_FAKEBANK_check_empty (fakebank))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
|
@ -82,6 +82,11 @@ struct HistoryState
|
||||
*/
|
||||
struct TALER_BANK_CreditHistoryHandle *hh;
|
||||
|
||||
/**
|
||||
* The interpreter.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
|
||||
/**
|
||||
* Authentication data for the operation.
|
||||
*/
|
||||
@ -144,90 +149,64 @@ print_expected (struct History *h,
|
||||
|
||||
|
||||
/**
|
||||
* This function constructs the list of history elements that
|
||||
* interest the account number of the caller. It has two main
|
||||
* loops: the first to figure out how many history elements have
|
||||
* to be allocated, and the second to actually populate every
|
||||
* element.
|
||||
*
|
||||
* @param is interpreter state (supposedly having the
|
||||
* current CMD pointing at a "history" CMD).
|
||||
* @param[out] rh history array to initialize.
|
||||
* @return number of entries in @a rh.
|
||||
* Closure for command_cb().
|
||||
*/
|
||||
static unsigned int
|
||||
build_history (struct TALER_TESTING_Interpreter *is,
|
||||
struct History **rh)
|
||||
struct IteratorContext
|
||||
{
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
unsigned int total;
|
||||
unsigned int pos;
|
||||
struct History *h;
|
||||
const struct TALER_TESTING_Command *add_incoming_cmd;
|
||||
int inc;
|
||||
unsigned int start;
|
||||
unsigned int end;
|
||||
|
||||
int ok;
|
||||
const uint64_t *row_id_start = NULL;
|
||||
|
||||
if (NULL != hs->start_row_reference)
|
||||
{
|
||||
TALER_LOG_INFO ("`%s': start row given via reference `%s'\n",
|
||||
TALER_TESTING_interpreter_get_current_label (is),
|
||||
hs->start_row_reference);
|
||||
add_incoming_cmd
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
hs->start_row_reference);
|
||||
GNUNET_assert (NULL != add_incoming_cmd);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_row (add_incoming_cmd,
|
||||
&row_id_start));
|
||||
}
|
||||
|
||||
GNUNET_assert (0 != hs->num_results);
|
||||
if (0 == is->ip)
|
||||
{
|
||||
TALER_LOG_DEBUG ("Checking history at FIRST transaction (EMPTY)\n");
|
||||
*rh = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hs->num_results > 0)
|
||||
{
|
||||
inc = 1; /* _inc_rement */
|
||||
start = 0;
|
||||
end = is->ip - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
inc = -1;
|
||||
start = is->ip - 1;
|
||||
end = 0;
|
||||
}
|
||||
/**
|
||||
* ok equals GNUNET_YES whenever a starting row_id
|
||||
* was provided AND was found among the CMDs, OR no
|
||||
* starting row was given in the first place.
|
||||
* Array of history items to return.
|
||||
*/
|
||||
ok = GNUNET_NO;
|
||||
if (NULL == row_id_start)
|
||||
ok = GNUNET_YES;
|
||||
h = NULL;
|
||||
total = 0;
|
||||
GNUNET_array_grow (h,
|
||||
total,
|
||||
4);
|
||||
pos = 0;
|
||||
for (unsigned int off = start; off != end + inc; off += inc)
|
||||
struct History *h;
|
||||
|
||||
/**
|
||||
* Set to the row ID from where on we should actually process history items,
|
||||
* or NULL if we should process all of them.
|
||||
*/
|
||||
const uint64_t *row_id_start;
|
||||
|
||||
/**
|
||||
* History state we are working on.
|
||||
*/
|
||||
struct HistoryState *hs;
|
||||
|
||||
/**
|
||||
* Current length of the @e h array.
|
||||
*/
|
||||
unsigned int total;
|
||||
|
||||
/**
|
||||
* Current write position in @e h array.
|
||||
*/
|
||||
unsigned int pos;
|
||||
|
||||
/**
|
||||
* Ok equals True whenever a starting row_id was provided AND was found
|
||||
* among the CMDs, OR no starting row was given in the first place.
|
||||
*/
|
||||
bool ok;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper function of build_history() that expands
|
||||
* the history for each relevant command encountered.
|
||||
*
|
||||
* @param[in,out] cls our `struct IteratorContext`
|
||||
* @param cmd a command to process
|
||||
*/
|
||||
static void
|
||||
command_cb (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
const struct TALER_TESTING_Command *cmd = &is->commands[off];
|
||||
struct IteratorContext *ic = cls;
|
||||
struct HistoryState *hs = ic->hs;
|
||||
const uint64_t *row_id;
|
||||
const char **credit_account;
|
||||
const char **debit_account;
|
||||
const char *credit_account;
|
||||
const char *debit_account;
|
||||
const struct TALER_Amount *amount;
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||
const char **exchange_credit_url;
|
||||
const char *exchange_credit_url;
|
||||
|
||||
/**
|
||||
* The following command allows us to skip over those CMDs
|
||||
@ -253,60 +232,111 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
TALER_TESTING_get_trait_exchange_bank_account_url (
|
||||
cmd,
|
||||
&exchange_credit_url)) )
|
||||
continue; // Not an interesting event
|
||||
return; // Not an interesting event
|
||||
|
||||
/**
|
||||
* Is the interesting event a match with regard to
|
||||
* the row_id value? If yes, store this condition
|
||||
* to the state and analyze the next CMDs.
|
||||
*/
|
||||
if ( (NULL != row_id_start) &&
|
||||
(*row_id_start == *row_id) &&
|
||||
(GNUNET_NO == ok) )
|
||||
if ( (NULL != ic->row_id_start) &&
|
||||
(*(ic->row_id_start) == *row_id) &&
|
||||
(! ic->ok) )
|
||||
{
|
||||
ok = GNUNET_YES;
|
||||
continue;
|
||||
ic->ok = true;
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* The interesting event didn't match the wanted
|
||||
* row_id value, analyze the next CMDs. Note: this
|
||||
* branch is relevant only when row_id WAS given.
|
||||
*/
|
||||
if (GNUNET_NO == ok)
|
||||
continue;
|
||||
if (! ic->ok)
|
||||
return;
|
||||
if (0 != strcasecmp (hs->account_url,
|
||||
*exchange_credit_url))
|
||||
continue; // Account mismatch
|
||||
if (total >= GNUNET_MAX (hs->num_results,
|
||||
exchange_credit_url))
|
||||
return; // Account mismatch
|
||||
if (ic->total >= GNUNET_MAX (hs->num_results,
|
||||
-hs->num_results) )
|
||||
{
|
||||
TALER_LOG_DEBUG ("Hit history limit\n");
|
||||
break;
|
||||
return;
|
||||
}
|
||||
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
|
||||
*debit_account,
|
||||
*credit_account,
|
||||
debit_account,
|
||||
credit_account,
|
||||
hs->account_url);
|
||||
/* found matching record, make sure we have room */
|
||||
if (pos == total)
|
||||
GNUNET_array_grow (h,
|
||||
total,
|
||||
pos * 2);
|
||||
h[pos].url = GNUNET_strdup (*debit_account);
|
||||
h[pos].details.debit_account_uri = h[pos].url;
|
||||
h[pos].details.amount = *amount;
|
||||
h[pos].row_id = *row_id;
|
||||
h[pos].details.reserve_pub = *reserve_pub;
|
||||
h[pos].details.credit_account_uri = *exchange_credit_url;
|
||||
pos++;
|
||||
if (ic->pos == ic->total)
|
||||
GNUNET_array_grow (ic->h,
|
||||
ic->total,
|
||||
ic->pos * 2);
|
||||
ic->h[ic->pos].url = GNUNET_strdup (debit_account);
|
||||
ic->h[ic->pos].details.debit_account_uri = ic->h[ic->pos].url;
|
||||
ic->h[ic->pos].details.amount = *amount;
|
||||
ic->h[ic->pos].row_id = *row_id;
|
||||
ic->h[ic->pos].details.reserve_pub = *reserve_pub;
|
||||
ic->h[ic->pos].details.credit_account_uri = exchange_credit_url;
|
||||
ic->pos++;
|
||||
}
|
||||
GNUNET_assert (GNUNET_YES == ok);
|
||||
GNUNET_array_grow (h,
|
||||
total,
|
||||
pos);
|
||||
if (0 == pos)
|
||||
|
||||
|
||||
/**
|
||||
* This function constructs the list of history elements that
|
||||
* interest the account number of the caller. It has two main
|
||||
* loops: the first to figure out how many history elements have
|
||||
* to be allocated, and the second to actually populate every
|
||||
* element.
|
||||
*
|
||||
* @param is interpreter state (supposedly having the
|
||||
* current CMD pointing at a "history" CMD).
|
||||
* @param[out] rh history array to initialize.
|
||||
* @return number of entries in @a rh.
|
||||
*/
|
||||
static unsigned int
|
||||
build_history (struct HistoryState *hs,
|
||||
struct History **rh)
|
||||
{
|
||||
struct TALER_TESTING_Interpreter *is = hs->is;
|
||||
struct IteratorContext ic = {
|
||||
.hs = hs
|
||||
};
|
||||
|
||||
if (NULL != hs->start_row_reference)
|
||||
{
|
||||
const struct TALER_TESTING_Command *add_incoming_cmd;
|
||||
|
||||
TALER_LOG_INFO ("`%s': start row given via reference `%s'\n",
|
||||
TALER_TESTING_interpreter_get_current_label (is),
|
||||
hs->start_row_reference);
|
||||
add_incoming_cmd
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
hs->start_row_reference);
|
||||
GNUNET_assert (NULL != add_incoming_cmd);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_row (add_incoming_cmd,
|
||||
&ic.row_id_start));
|
||||
}
|
||||
|
||||
ic.ok = false;
|
||||
if (NULL == ic.row_id_start)
|
||||
ic.ok = true;
|
||||
GNUNET_array_grow (ic.h,
|
||||
ic.total,
|
||||
4);
|
||||
GNUNET_assert (0 != hs->num_results);
|
||||
TALER_TESTING_iterate (is,
|
||||
hs->num_results > 0,
|
||||
&command_cb,
|
||||
&ic);
|
||||
GNUNET_assert (ic.ok);
|
||||
GNUNET_array_grow (ic.h,
|
||||
ic.total,
|
||||
ic.pos);
|
||||
if (0 == ic.pos)
|
||||
TALER_LOG_DEBUG ("Empty credit history computed\n");
|
||||
*rh = h;
|
||||
return total;
|
||||
*rh = ic.h;
|
||||
return ic.pos;
|
||||
}
|
||||
|
||||
|
||||
@ -376,8 +406,8 @@ static void
|
||||
history_cb (void *cls,
|
||||
const struct TALER_BANK_CreditHistoryResponse *chr)
|
||||
{
|
||||
struct TALER_TESTING_Interpreter *is = cls;
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
struct HistoryState *hs = cls;
|
||||
struct TALER_TESTING_Interpreter *is = hs->is;
|
||||
|
||||
hs->hh = NULL;
|
||||
switch (chr->http_status)
|
||||
@ -470,6 +500,7 @@ history_run (void *cls,
|
||||
const uint64_t *row_ptr;
|
||||
|
||||
(void) cmd;
|
||||
hs->is = is;
|
||||
/* Get row_id from trait. */
|
||||
if (NULL != hs->start_row_reference)
|
||||
{
|
||||
@ -490,15 +521,16 @@ history_run (void *cls,
|
||||
TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
|
||||
(unsigned long long) row_id);
|
||||
}
|
||||
hs->total = build_history (is,
|
||||
hs->total = build_history (hs,
|
||||
&hs->h);
|
||||
hs->hh = TALER_BANK_credit_history (is->ctx,
|
||||
hs->hh = TALER_BANK_credit_history (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
&hs->auth,
|
||||
row_id,
|
||||
hs->num_results,
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
&history_cb,
|
||||
is);
|
||||
hs);
|
||||
GNUNET_assert (NULL != hs->hh);
|
||||
}
|
||||
|
||||
@ -519,7 +551,8 @@ history_cleanup (void *cls,
|
||||
(void) cmd;
|
||||
if (NULL != hs->hh)
|
||||
{
|
||||
TALER_LOG_WARNING ("/history/incoming did not complete\n");
|
||||
TALER_TESTING_command_incomplete (hs->is,
|
||||
cmd->label);
|
||||
TALER_BANK_credit_history_cancel (hs->hh);
|
||||
}
|
||||
GNUNET_free (hs->account_url);
|
||||
|
@ -91,6 +91,11 @@ struct HistoryState
|
||||
*/
|
||||
struct TALER_BANK_DebitHistoryHandle *hh;
|
||||
|
||||
/**
|
||||
* Our interpreter.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
|
||||
/**
|
||||
* Expected number of results (= rows).
|
||||
*/
|
||||
@ -147,93 +152,65 @@ print_expected (struct History *h,
|
||||
|
||||
|
||||
/**
|
||||
* This function constructs the list of history elements that
|
||||
* interest the account number of the caller. It has two main
|
||||
* loops: the first to figure out how many history elements have
|
||||
* to be allocated, and the second to actually populate every
|
||||
* element.
|
||||
*
|
||||
* @param is interpreter state (supposedly having the
|
||||
* current CMD pointing at a "history" CMD).
|
||||
* @param[out] rh history array to initialize.
|
||||
* @return number of entries in @a rh.
|
||||
* Closure for command_cb().
|
||||
*/
|
||||
static unsigned int
|
||||
build_history (struct TALER_TESTING_Interpreter *is,
|
||||
struct History **rh)
|
||||
struct IteratorContext
|
||||
{
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
unsigned int total;
|
||||
unsigned int pos;
|
||||
/**
|
||||
* Array of history items to return.
|
||||
*/
|
||||
struct History *h;
|
||||
const struct TALER_TESTING_Command *add_incoming_cmd;
|
||||
int inc;
|
||||
int start;
|
||||
int end;
|
||||
/* #GNUNET_YES whenever either no 'start' value was given for the history
|
||||
* query, or the given value is found in the list of all the CMDs. */
|
||||
int ok;
|
||||
const uint64_t *row_id_start = NULL;
|
||||
|
||||
if (NULL != hs->start_row_reference)
|
||||
{
|
||||
TALER_LOG_INFO
|
||||
("`%s': start row given via reference `%s'\n",
|
||||
TALER_TESTING_interpreter_get_current_label (is),
|
||||
hs->start_row_reference);
|
||||
add_incoming_cmd = TALER_TESTING_interpreter_lookup_command (
|
||||
is,
|
||||
hs->start_row_reference);
|
||||
GNUNET_assert (NULL != add_incoming_cmd);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_row (add_incoming_cmd,
|
||||
&row_id_start));
|
||||
}
|
||||
/**
|
||||
* Set to the row ID from where on we should actually process history items,
|
||||
* or NULL if we should process all of them.
|
||||
*/
|
||||
const uint64_t *row_id_start;
|
||||
|
||||
GNUNET_assert (0 != hs->num_results);
|
||||
if (0 == is->ip)
|
||||
{
|
||||
TALER_LOG_DEBUG ("Checking history at first CMD..\n");
|
||||
*rh = NULL;
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* History state we are working on.
|
||||
*/
|
||||
struct HistoryState *hs;
|
||||
|
||||
/* AKA 'delta' */
|
||||
if (hs->num_results > 0)
|
||||
{
|
||||
inc = 1; /* _inc_rement: go forwards */
|
||||
start = 0;
|
||||
end = is->ip;
|
||||
}
|
||||
else
|
||||
{
|
||||
inc = -1; /* decrement: we go backwards */
|
||||
start = is->ip - 1;
|
||||
end = -1; /* range is exclusive, do look at 0! */
|
||||
}
|
||||
/**
|
||||
* Current length of the @e h array.
|
||||
*/
|
||||
unsigned int total;
|
||||
|
||||
ok = GNUNET_NO;
|
||||
if (NULL == row_id_start)
|
||||
ok = GNUNET_YES;
|
||||
h = NULL;
|
||||
total = 0;
|
||||
GNUNET_array_grow (h,
|
||||
total,
|
||||
4);
|
||||
pos = 0;
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Checking commands %u to %u for debit history\n",
|
||||
start,
|
||||
end);
|
||||
for (int off = start; off != end; off += inc)
|
||||
/**
|
||||
* Current write position in @e h array.
|
||||
*/
|
||||
unsigned int pos;
|
||||
|
||||
/**
|
||||
* Ok equals True whenever a starting row_id was provided AND was found
|
||||
* among the CMDs, OR no starting row was given in the first place.
|
||||
*/
|
||||
bool ok;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper function of build_history() that expands
|
||||
* the history for each relevant command encountered.
|
||||
*
|
||||
* @param[in,out] cls our `struct IteratorContext`
|
||||
* @param cmd a command to process
|
||||
*/
|
||||
static void
|
||||
command_cb (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
const struct TALER_TESTING_Command *cmd = &is->commands[off];
|
||||
struct IteratorContext *ic = cls;
|
||||
struct HistoryState *hs = ic->hs;
|
||||
|
||||
const uint64_t *row_id;
|
||||
const char **debit_account;
|
||||
const char **credit_account;
|
||||
const char *debit_account;
|
||||
const char *credit_account;
|
||||
const struct TALER_Amount *amount;
|
||||
const struct TALER_WireTransferIdentifierRawP *wtid;
|
||||
const char **exchange_base_url;
|
||||
const char *exchange_base_url;
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Checking if command %s is relevant for debit history\n",
|
||||
@ -256,55 +233,105 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_exchange_url (cmd,
|
||||
&exchange_base_url)) )
|
||||
continue; /* not an event we care about */
|
||||
return; /* not an event we care about */
|
||||
/* Seek "/history/outgoing" starting row. */
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Command %s is relevant for debit history!\n",
|
||||
cmd->label);
|
||||
if ( (NULL != row_id_start) &&
|
||||
(*row_id_start == *row_id) &&
|
||||
(GNUNET_NO == ok) )
|
||||
if ( (NULL != ic->row_id_start) &&
|
||||
(*(ic->row_id_start) == *row_id) &&
|
||||
(! ic->ok) )
|
||||
{
|
||||
/* Until here, nothing counted. */
|
||||
ok = GNUNET_YES;
|
||||
continue;
|
||||
ic->ok = true;
|
||||
return;
|
||||
}
|
||||
/* when 'start' was _not_ given, then ok == GNUNET_YES */
|
||||
if (GNUNET_NO == ok)
|
||||
continue; /* skip until we find the marker */
|
||||
if (total >= GNUNET_MAX (hs->num_results,
|
||||
if (! ic->ok)
|
||||
return; /* skip until we find the marker */
|
||||
if (ic->total >= GNUNET_MAX (hs->num_results,
|
||||
-hs->num_results) )
|
||||
{
|
||||
TALER_LOG_DEBUG ("Hit history limit\n");
|
||||
break;
|
||||
return;
|
||||
}
|
||||
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
|
||||
*debit_account,
|
||||
*credit_account,
|
||||
debit_account,
|
||||
credit_account,
|
||||
hs->account_url);
|
||||
/* found matching record, make sure we have room */
|
||||
if (pos == total)
|
||||
GNUNET_array_grow (h,
|
||||
total,
|
||||
pos * 2);
|
||||
h[pos].c_url = GNUNET_strdup (*credit_account);
|
||||
h[pos].d_url = GNUNET_strdup (*debit_account);
|
||||
h[pos].details.credit_account_uri = h[pos].c_url;
|
||||
h[pos].details.debit_account_uri = h[pos].d_url;
|
||||
h[pos].details.amount = *amount;
|
||||
h[pos].row_id = *row_id;
|
||||
h[pos].details.wtid = *wtid;
|
||||
h[pos].details.exchange_base_url = *exchange_base_url;
|
||||
pos++;
|
||||
if (ic->pos == ic->total)
|
||||
GNUNET_array_grow (ic->h,
|
||||
ic->total,
|
||||
ic->pos * 2);
|
||||
ic->h[ic->pos].c_url = GNUNET_strdup (credit_account);
|
||||
ic->h[ic->pos].d_url = GNUNET_strdup (debit_account);
|
||||
ic->h[ic->pos].details.credit_account_uri = ic->h[ic->pos].c_url;
|
||||
ic->h[ic->pos].details.debit_account_uri = ic->h[ic->pos].d_url;
|
||||
ic->h[ic->pos].details.amount = *amount;
|
||||
ic->h[ic->pos].row_id = *row_id;
|
||||
ic->h[ic->pos].details.wtid = *wtid;
|
||||
ic->h[ic->pos].details.exchange_base_url = exchange_base_url;
|
||||
ic->pos++;
|
||||
}
|
||||
GNUNET_assert (GNUNET_YES == ok);
|
||||
GNUNET_array_grow (h,
|
||||
total,
|
||||
pos);
|
||||
if (0 == pos)
|
||||
TALER_LOG_DEBUG ("Empty debit history computed\n");
|
||||
*rh = h;
|
||||
return total;
|
||||
|
||||
|
||||
/**
|
||||
* This function constructs the list of history elements that
|
||||
* interest the account number of the caller. It has two main
|
||||
* loops: the first to figure out how many history elements have
|
||||
* to be allocated, and the second to actually populate every
|
||||
* element.
|
||||
*
|
||||
* @param hs history state command context
|
||||
* @param[out] rh history array to initialize.
|
||||
* @return number of entries in @a rh.
|
||||
*/
|
||||
static unsigned int
|
||||
build_history (struct HistoryState *hs,
|
||||
struct History **rh)
|
||||
{
|
||||
struct TALER_TESTING_Interpreter *is = hs->is;
|
||||
struct IteratorContext ic = {
|
||||
.hs = hs
|
||||
};
|
||||
|
||||
if (NULL != hs->start_row_reference)
|
||||
{
|
||||
const struct TALER_TESTING_Command *add_incoming_cmd;
|
||||
|
||||
TALER_LOG_INFO (
|
||||
"`%s': start row given via reference `%s'\n",
|
||||
TALER_TESTING_interpreter_get_current_label (is),
|
||||
hs->start_row_reference);
|
||||
add_incoming_cmd = TALER_TESTING_interpreter_lookup_command (
|
||||
is,
|
||||
hs->start_row_reference);
|
||||
GNUNET_assert (NULL != add_incoming_cmd);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_row (add_incoming_cmd,
|
||||
&ic.row_id_start));
|
||||
}
|
||||
|
||||
ic.ok = false;
|
||||
if (NULL == ic.row_id_start)
|
||||
ic.ok = true;
|
||||
GNUNET_array_grow (ic.h,
|
||||
ic.total,
|
||||
4);
|
||||
GNUNET_assert (0 != hs->num_results);
|
||||
TALER_TESTING_iterate (is,
|
||||
hs->num_results > 0,
|
||||
&command_cb,
|
||||
&ic);
|
||||
GNUNET_assert (ic.ok);
|
||||
GNUNET_array_grow (ic.h,
|
||||
ic.total,
|
||||
ic.pos);
|
||||
if (0 == ic.pos)
|
||||
TALER_LOG_DEBUG ("Empty credit history computed\n");
|
||||
*rh = ic.h;
|
||||
return ic.pos;
|
||||
}
|
||||
|
||||
|
||||
@ -368,8 +395,8 @@ static void
|
||||
history_cb (void *cls,
|
||||
const struct TALER_BANK_DebitHistoryResponse *dhr)
|
||||
{
|
||||
struct TALER_TESTING_Interpreter *is = cls;
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
struct HistoryState *hs = cls;
|
||||
struct TALER_TESTING_Interpreter *is = hs->is;
|
||||
|
||||
hs->hh = NULL;
|
||||
switch (dhr->http_status)
|
||||
@ -462,6 +489,7 @@ history_run (void *cls,
|
||||
const uint64_t *row_ptr;
|
||||
|
||||
(void) cmd;
|
||||
hs->is = is;
|
||||
/* Get row_id from trait. */
|
||||
if (NULL != hs->start_row_reference)
|
||||
{
|
||||
@ -482,14 +510,16 @@ history_run (void *cls,
|
||||
TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
|
||||
(unsigned long long) row_id);
|
||||
}
|
||||
hs->total = build_history (is, &hs->h);
|
||||
hs->hh = TALER_BANK_debit_history (is->ctx,
|
||||
hs->total = build_history (hs,
|
||||
&hs->h);
|
||||
hs->hh = TALER_BANK_debit_history (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
&hs->auth,
|
||||
row_id,
|
||||
hs->num_results,
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
&history_cb,
|
||||
is);
|
||||
hs);
|
||||
GNUNET_assert (NULL != hs->hh);
|
||||
}
|
||||
|
||||
@ -510,7 +540,8 @@ history_cleanup (void *cls,
|
||||
(void) cmd;
|
||||
if (NULL != hs->hh)
|
||||
{
|
||||
TALER_LOG_WARNING ("/history/outgoing did not complete\n");
|
||||
TALER_TESTING_command_incomplete (hs->is,
|
||||
cmd->label);
|
||||
TALER_BANK_debit_history_cancel (hs->hh);
|
||||
}
|
||||
for (unsigned int off = 0; off<hs->total; off++)
|
||||
|
@ -149,8 +149,7 @@ do_retry (void *cls)
|
||||
struct TransferState *fts = cls;
|
||||
|
||||
fts->retry_task = NULL;
|
||||
fts->is->commands[fts->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
TALER_TESTING_touch_cmd (fts->is);
|
||||
transfer_run (fts,
|
||||
NULL,
|
||||
fts->is);
|
||||
@ -191,7 +190,7 @@ confirmation_cb (void *cls,
|
||||
fts->backoff = GNUNET_TIME_UNIT_ZERO;
|
||||
else
|
||||
fts->backoff = EXCHANGE_LIB_BACKOFF (fts->backoff);
|
||||
fts->is->commands[fts->is->ip].num_tries++;
|
||||
TALER_TESTING_inc_tries (fts->is);
|
||||
fts->retry_task
|
||||
= GNUNET_SCHEDULER_add_delayed (fts->backoff,
|
||||
&do_retry,
|
||||
@ -199,12 +198,8 @@ confirmation_cb (void *cls,
|
||||
return;
|
||||
}
|
||||
}
|
||||
GNUNET_break (0);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Bank returned HTTP status %u/%d\n",
|
||||
tr->http_status,
|
||||
(int) tr->ec);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
TALER_TESTING_unexpected_status (is,
|
||||
tr->http_status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -276,8 +271,7 @@ transfer_cleanup (void *cls,
|
||||
|
||||
if (NULL != fts->weh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %s did not complete\n",
|
||||
TALER_TESTING_command_incomplete (fts->is,
|
||||
cmd->label);
|
||||
TALER_BANK_transfer_cancel (fts->weh);
|
||||
fts->weh = NULL;
|
||||
@ -311,12 +305,12 @@ transfer_traits (void *cls,
|
||||
struct TransferState *fts = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_exchange_url (
|
||||
(const char **) &fts->exchange_base_url),
|
||||
fts->exchange_base_url),
|
||||
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
|
||||
TALER_TESTING_make_trait_credit_payto_uri (
|
||||
(const char **) &fts->payto_credit_account),
|
||||
fts->payto_credit_account),
|
||||
TALER_TESTING_make_trait_debit_payto_uri (
|
||||
(const char **) &fts->payto_debit_account),
|
||||
fts->payto_debit_account),
|
||||
TALER_TESTING_make_trait_amount (&fts->amount),
|
||||
TALER_TESTING_make_trait_timestamp (0, &fts->timestamp),
|
||||
TALER_TESTING_make_trait_wtid (&fts->wtid),
|
||||
|
@ -37,6 +37,11 @@ struct BatchState
|
||||
*/
|
||||
struct TALER_TESTING_Command *batch;
|
||||
|
||||
/**
|
||||
* My command (the batch command).
|
||||
*/
|
||||
const struct TALER_TESTING_Command *cmd;
|
||||
|
||||
/**
|
||||
* Internal command pointer.
|
||||
*/
|
||||
@ -58,6 +63,7 @@ batch_run (void *cls,
|
||||
{
|
||||
struct BatchState *bs = cls;
|
||||
|
||||
bs->cmd = cmd;
|
||||
if (NULL != bs->batch[bs->batch_ip].label)
|
||||
TALER_LOG_INFO ("Running batched command: %s\n",
|
||||
bs->batch[bs->batch_ip].label);
|
||||
@ -167,19 +173,33 @@ TALER_TESTING_cmd_batch (const char *label,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is)
|
||||
bool
|
||||
TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is,
|
||||
void *cls)
|
||||
{
|
||||
struct BatchState *bs = is->commands[is->ip].cls;
|
||||
struct BatchState *bs = cls;
|
||||
struct TALER_TESTING_Command *bcmd = &bs->batch[bs->batch_ip];
|
||||
|
||||
if (NULL == bs->batch[bs->batch_ip].label)
|
||||
if (NULL == bcmd->label)
|
||||
{
|
||||
is->commands[is->ip].finish_time = GNUNET_TIME_absolute_get ();
|
||||
is->ip++;
|
||||
return;
|
||||
/* This batch is done */
|
||||
return true;
|
||||
}
|
||||
bs->batch[bs->batch_ip].finish_time = GNUNET_TIME_absolute_get ();
|
||||
if (TALER_TESTING_cmd_is_batch (bcmd))
|
||||
{
|
||||
if (TALER_TESTING_cmd_batch_next (is,
|
||||
bcmd->cls))
|
||||
{
|
||||
/* sub-batch is done */
|
||||
bcmd->finish_time = GNUNET_TIME_absolute_get ();
|
||||
bs->batch_ip++;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* Simple command is done */
|
||||
bcmd->finish_time = GNUNET_TIME_absolute_get ();
|
||||
bs->batch_ip++;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,16 +198,8 @@ batch_deposit_cb (void *cls,
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != dr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
dr->hr.http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (dr->hr.reply,
|
||||
stderr,
|
||||
JSON_INDENT (2));
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
dr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
if (MHD_HTTP_OK == dr->hr.http_status)
|
||||
@ -259,8 +251,12 @@ batch_deposit_run (void *cls,
|
||||
&wire_salt),
|
||||
GNUNET_JSON_spec_end ()
|
||||
};
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
memset (cdds,
|
||||
0,
|
||||
sizeof (cdds));
|
||||
@ -387,7 +383,7 @@ batch_deposit_run (void *cls,
|
||||
.refund_deadline = ds->refund_deadline
|
||||
};
|
||||
|
||||
ds->dh = TALER_EXCHANGE_batch_deposit (is->exchange,
|
||||
ds->dh = TALER_EXCHANGE_batch_deposit (exchange,
|
||||
&dcd,
|
||||
ds->num_coins,
|
||||
cdds,
|
||||
@ -422,9 +418,7 @@ batch_deposit_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_batch_deposit_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -189,18 +189,8 @@ reserve_batch_withdraw_cb (void *cls,
|
||||
ws->wsh = NULL;
|
||||
if (ws->expected_response_code != wr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
wr->hr.http_status,
|
||||
(int) wr->hr.ec,
|
||||
TALER_TESTING_interpreter_get_current_label (is),
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (wr->hr.reply,
|
||||
stderr,
|
||||
0);
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
TALER_TESTING_unexpected_status (is,
|
||||
wr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
switch (wr->hr.http_status)
|
||||
@ -263,8 +253,12 @@ batch_withdraw_run (void *cls,
|
||||
const struct TALER_TESTING_Command *create_reserve;
|
||||
const struct TALER_EXCHANGE_DenomPublicKey *dpk;
|
||||
struct TALER_EXCHANGE_WithdrawCoinInput wcis[ws->num_coins];
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ws->is = is;
|
||||
create_reserve
|
||||
= TALER_TESTING_interpreter_lookup_command (
|
||||
@ -287,7 +281,7 @@ batch_withdraw_run (void *cls,
|
||||
}
|
||||
if (NULL == ws->exchange_url)
|
||||
ws->exchange_url
|
||||
= GNUNET_strdup (TALER_EXCHANGE_get_base_url (is->exchange));
|
||||
= GNUNET_strdup (TALER_EXCHANGE_get_base_url (exchange));
|
||||
ws->reserve_priv = *rp;
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&ws->reserve_priv.eddsa_priv,
|
||||
&ws->reserve_pub.eddsa_pub);
|
||||
@ -301,7 +295,7 @@ batch_withdraw_run (void *cls,
|
||||
struct TALER_EXCHANGE_WithdrawCoinInput *wci = &wcis[i];
|
||||
|
||||
TALER_planchet_master_setup_random (&cs->ps);
|
||||
dpk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (is->exchange),
|
||||
dpk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (exchange),
|
||||
&cs->amount,
|
||||
ws->age > 0);
|
||||
if (NULL == dpk)
|
||||
@ -327,7 +321,7 @@ batch_withdraw_run (void *cls,
|
||||
wci->ps = &cs->ps;
|
||||
wci->ach = cs->h_age_commitment;
|
||||
}
|
||||
ws->wsh = TALER_EXCHANGE_batch_withdraw (is->exchange,
|
||||
ws->wsh = TALER_EXCHANGE_batch_withdraw (exchange,
|
||||
rp,
|
||||
wcis,
|
||||
ws->num_coins,
|
||||
@ -357,8 +351,7 @@ batch_withdraw_cleanup (void *cls,
|
||||
|
||||
if (NULL != ws->wsh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %s did not complete\n",
|
||||
TALER_TESTING_command_incomplete (ws->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_batch_withdraw_cancel (ws->wsh);
|
||||
ws->wsh = NULL;
|
||||
@ -427,12 +420,9 @@ batch_withdraw_traits (void *cls,
|
||||
TALER_TESTING_make_trait_amounts (index,
|
||||
&cs->amount),
|
||||
TALER_TESTING_make_trait_legi_requirement_row (&ws->requirement_row),
|
||||
TALER_TESTING_make_trait_h_payto (
|
||||
&ws->h_payto),
|
||||
TALER_TESTING_make_trait_payto_uri (
|
||||
(const char **) &ws->reserve_payto_uri),
|
||||
TALER_TESTING_make_trait_exchange_url (
|
||||
(const char **) &ws->exchange_url),
|
||||
TALER_TESTING_make_trait_h_payto (&ws->h_payto),
|
||||
TALER_TESTING_make_trait_payto_uri (ws->reserve_payto_uri),
|
||||
TALER_TESTING_make_trait_exchange_url (ws->exchange_url),
|
||||
TALER_TESTING_make_trait_age_commitment_proof (index,
|
||||
cs->age_commitment_proof),
|
||||
TALER_TESTING_make_trait_h_age_commitment (index,
|
||||
|
@ -1,153 +0,0 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
(C) 2021 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 testing/testing_api_cmd_change_auth.c
|
||||
* @brief command(s) to change CURL context authorization header
|
||||
* @author Christian Grothoff
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include "taler_json_lib.h"
|
||||
#include <gnunet/gnunet_curl_lib.h>
|
||||
#include "taler_testing_lib.h"
|
||||
|
||||
|
||||
/**
|
||||
* State for a "authchange" CMD.
|
||||
*/
|
||||
struct AuthchangeState
|
||||
{
|
||||
|
||||
/**
|
||||
* What is the new authorization token to send?
|
||||
*/
|
||||
const char *auth_token;
|
||||
|
||||
/**
|
||||
* Old context, clean up on termination.
|
||||
*/
|
||||
struct GNUNET_CURL_Context *old_ctx;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Run the command.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command to execute.
|
||||
* @param is the interpreter state.
|
||||
*/
|
||||
static void
|
||||
authchange_run (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct AuthchangeState *ss = cls;
|
||||
|
||||
(void) cmd;
|
||||
ss->old_ctx = is->ctx;
|
||||
if (NULL != is->rc)
|
||||
{
|
||||
GNUNET_CURL_gnunet_rc_destroy (is->rc);
|
||||
is->rc = NULL;
|
||||
}
|
||||
is->ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
|
||||
&is->rc);
|
||||
GNUNET_CURL_enable_async_scope_header (is->ctx,
|
||||
"Taler-Correlation-Id");
|
||||
GNUNET_assert (NULL != is->ctx);
|
||||
is->rc = GNUNET_CURL_gnunet_rc_create (is->ctx);
|
||||
if (NULL != ss->auth_token)
|
||||
{
|
||||
char *authorization;
|
||||
|
||||
GNUNET_asprintf (&authorization,
|
||||
"%s: %s",
|
||||
MHD_HTTP_HEADER_AUTHORIZATION,
|
||||
ss->auth_token);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
GNUNET_CURL_append_header (is->ctx,
|
||||
authorization));
|
||||
GNUNET_free (authorization);
|
||||
}
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call GNUNET_CURL_fini(). Done as a separate task to
|
||||
* ensure that all of the command's cleanups have been
|
||||
* executed first. See #7151.
|
||||
*
|
||||
* @param cls a `struct GNUNET_CURL_Context *` to clean up.
|
||||
*/
|
||||
static void
|
||||
deferred_cleanup_cb (void *cls)
|
||||
{
|
||||
struct GNUNET_CURL_Context *ctx = cls;
|
||||
|
||||
GNUNET_CURL_fini (ctx);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup the state from a "authchange" CMD.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command which is being cleaned up.
|
||||
*/
|
||||
static void
|
||||
authchange_cleanup (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct AuthchangeState *ss = cls;
|
||||
|
||||
(void) cmd;
|
||||
if (NULL != ss->old_ctx)
|
||||
{
|
||||
(void) GNUNET_SCHEDULER_add_now (&deferred_cleanup_cb,
|
||||
ss->old_ctx);
|
||||
ss->old_ctx = NULL;
|
||||
}
|
||||
GNUNET_free (ss);
|
||||
}
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_set_authorization (const char *label,
|
||||
const char *auth_token)
|
||||
{
|
||||
struct AuthchangeState *ss;
|
||||
|
||||
ss = GNUNET_new (struct AuthchangeState);
|
||||
ss->auth_token = auth_token;
|
||||
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = ss,
|
||||
.label = label,
|
||||
.run = &authchange_run,
|
||||
.cleanup = &authchange_cleanup
|
||||
};
|
||||
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* end of testing_api_cmd_change_auth.c */
|
@ -79,22 +79,14 @@ check_aml_decision_cb (void *cls,
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_http_status != adr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
adr->hr.http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (adr->hr.reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
adr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
if (MHD_HTTP_OK == adr->hr.http_status)
|
||||
{
|
||||
const struct TALER_TESTING_Command *ref;
|
||||
const char **justification;
|
||||
const char *justification;
|
||||
enum TALER_AmlDecisionState *new_state;
|
||||
const struct TALER_Amount *amount;
|
||||
const struct TALER_EXCHANGE_AmlDecisionDetail *oldest = NULL;
|
||||
@ -138,7 +130,7 @@ check_aml_decision_cb (void *cls,
|
||||
}
|
||||
if ( (oldest->new_state != *new_state) ||
|
||||
(0 != strcmp (oldest->justification,
|
||||
*justification) ) )
|
||||
justification) ) )
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
@ -165,9 +157,26 @@ check_aml_decision_run (void *cls,
|
||||
const struct TALER_PaytoHashP *h_payto;
|
||||
const struct TALER_AmlOfficerPrivateKeyP *officer_priv;
|
||||
const struct TALER_TESTING_Command *ref;
|
||||
const char *exchange_url;
|
||||
|
||||
(void) cmd;
|
||||
ds->is = is;
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
}
|
||||
|
||||
ref = TALER_TESTING_interpreter_lookup_command (is,
|
||||
ds->ref_operation);
|
||||
if (NULL == ref)
|
||||
@ -191,8 +200,8 @@ check_aml_decision_run (void *cls,
|
||||
TALER_TESTING_get_trait_officer_priv (ref,
|
||||
&officer_priv));
|
||||
ds->dh = TALER_EXCHANGE_lookup_aml_decision (
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
h_payto,
|
||||
officer_priv,
|
||||
true, /* history */
|
||||
@ -222,9 +231,7 @@ check_aml_decision_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_lookup_aml_decision_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -79,16 +79,8 @@ check_aml_decisions_cb (void *cls,
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_http_status != adr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
adr->hr.http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (adr->hr.reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
adr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -110,9 +102,25 @@ check_aml_decisions_run (void *cls,
|
||||
struct AmlCheckState *ds = cls;
|
||||
const struct TALER_AmlOfficerPrivateKeyP *officer_priv;
|
||||
const struct TALER_TESTING_Command *ref;
|
||||
const char *exchange_url;
|
||||
|
||||
(void) cmd;
|
||||
ds->is = is;
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
}
|
||||
ref = TALER_TESTING_interpreter_lookup_command (is,
|
||||
ds->ref_officer);
|
||||
if (NULL == ref)
|
||||
@ -125,8 +133,8 @@ check_aml_decisions_run (void *cls,
|
||||
TALER_TESTING_get_trait_officer_priv (ref,
|
||||
&officer_priv));
|
||||
ds->dh = TALER_EXCHANGE_lookup_aml_decisions (
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
INT64_MAX,
|
||||
-1, /* return last one for testing */
|
||||
ds->filter,
|
||||
@ -157,9 +165,7 @@ check_aml_decisions_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_lookup_aml_decisions_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -33,17 +33,10 @@
|
||||
*/
|
||||
struct CheckKeysState
|
||||
{
|
||||
/**
|
||||
* This number will instruct the CMD interpreter to
|
||||
* make sure that /keys was downloaded `generation` times
|
||||
* _before_ running the very CMD logic.
|
||||
*/
|
||||
unsigned int generation;
|
||||
|
||||
/**
|
||||
* If this value is true, then the "cherry
|
||||
* picking" facility is turned off; whole /keys is
|
||||
* downloaded.
|
||||
* If this value is true, then the "cherry picking" facility is turned off;
|
||||
* whole /keys is downloaded.
|
||||
*/
|
||||
bool pull_all_keys;
|
||||
|
||||
@ -52,6 +45,11 @@ struct CheckKeysState
|
||||
*/
|
||||
const char *last_denom_date_ref;
|
||||
|
||||
/**
|
||||
* Our interpreter state.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
|
||||
/**
|
||||
* Last denomination date we received when doing this request.
|
||||
*/
|
||||
@ -59,6 +57,30 @@ struct CheckKeysState
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function called with information about who is auditing
|
||||
* a particular exchange and what keys the exchange is using.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param kr response from /keys
|
||||
*/
|
||||
static void
|
||||
keys_cb (void *cls,
|
||||
const struct TALER_EXCHANGE_KeysResponse *kr)
|
||||
{
|
||||
struct CheckKeysState *cks = cls;
|
||||
|
||||
if (MHD_HTTP_OK != kr->hr.http_status)
|
||||
{
|
||||
TALER_TESTING_unexpected_status (cks->is,
|
||||
kr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
cks->my_denom_date = kr->details.ok.keys->last_denom_issue_date;
|
||||
TALER_TESTING_interpreter_next (cks->is);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the "check keys" command.
|
||||
*
|
||||
@ -72,17 +94,14 @@ check_keys_run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct CheckKeysState *cks = cls;
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"cmd `%s' (ip: %u), key generation: %d\n",
|
||||
cmd->label,
|
||||
is->ip,
|
||||
is->key_generation);
|
||||
if (is->key_generation < cks->generation)
|
||||
{
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
struct GNUNET_TIME_Timestamp rdate;
|
||||
|
||||
is->working = GNUNET_NO;
|
||||
(void) cmd;
|
||||
cks->is = is;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Triggering GET /keys, cmd `%s'\n",
|
||||
cmd->label);
|
||||
@ -92,7 +111,7 @@ check_keys_run (void *cls,
|
||||
cks->last_denom_date_ref))
|
||||
{
|
||||
TALER_LOG_DEBUG ("Forcing last_denom_date URL argument set to zero\n");
|
||||
TALER_EXCHANGE_set_last_denom (is->exchange,
|
||||
TALER_EXCHANGE_set_last_denom (exchange,
|
||||
GNUNET_TIME_UNIT_ZERO_TS);
|
||||
}
|
||||
else
|
||||
@ -119,33 +138,20 @@ check_keys_run (void *cls,
|
||||
}
|
||||
|
||||
TALER_LOG_DEBUG ("Forcing last_denom_date URL argument\n");
|
||||
TALER_EXCHANGE_set_last_denom (is->exchange,
|
||||
TALER_EXCHANGE_set_last_denom (exchange,
|
||||
*last_denom_date);
|
||||
}
|
||||
}
|
||||
|
||||
rdate = TALER_EXCHANGE_check_keys_current (
|
||||
is->exchange,
|
||||
exchange,
|
||||
cks->pull_all_keys
|
||||
? TALER_EXCHANGE_CKF_FORCE_ALL_NOW
|
||||
: TALER_EXCHANGE_CKF_FORCE_DOWNLOAD);
|
||||
: TALER_EXCHANGE_CKF_FORCE_DOWNLOAD,
|
||||
&keys_cb,
|
||||
cks);
|
||||
/* Redownload /keys. */
|
||||
GNUNET_break (GNUNET_TIME_absolute_is_zero (rdate.abs_time));
|
||||
return;
|
||||
}
|
||||
{
|
||||
const struct TALER_EXCHANGE_Keys *keys;
|
||||
|
||||
keys = TALER_EXCHANGE_get_keys (is->exchange);
|
||||
if (NULL == keys)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
cks->my_denom_date = keys->last_denom_issue_date;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
}
|
||||
|
||||
|
||||
@ -176,7 +182,7 @@ check_keys_cleanup (void *cls,
|
||||
* @param index index number of the object to offer.
|
||||
* @return #GNUNET_OK on success
|
||||
*/
|
||||
static int
|
||||
static enum GNUNET_GenericReturnValue
|
||||
check_keys_traits (void *cls,
|
||||
const void **ret,
|
||||
const char *trait,
|
||||
@ -184,7 +190,6 @@ check_keys_traits (void *cls,
|
||||
{
|
||||
struct CheckKeysState *cks = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
/* history entry MUST be first due to response code logic below! */
|
||||
TALER_TESTING_make_trait_timestamp (0,
|
||||
&cks->my_denom_date),
|
||||
TALER_TESTING_trait_end ()
|
||||
@ -198,13 +203,11 @@ check_keys_traits (void *cls,
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_check_keys (const char *label,
|
||||
unsigned int generation)
|
||||
TALER_TESTING_cmd_check_keys (const char *label)
|
||||
{
|
||||
struct CheckKeysState *cks;
|
||||
|
||||
cks = GNUNET_new (struct CheckKeysState);
|
||||
cks->generation = generation;
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = cks,
|
||||
@ -220,12 +223,10 @@ TALER_TESTING_cmd_check_keys (const char *label,
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label,
|
||||
unsigned int generation)
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label)
|
||||
{
|
||||
struct TALER_TESTING_Command cmd
|
||||
= TALER_TESTING_cmd_check_keys (label,
|
||||
generation);
|
||||
= TALER_TESTING_cmd_check_keys (label);
|
||||
struct CheckKeysState *cks = cmd.cls;
|
||||
|
||||
cks->pull_all_keys = true;
|
||||
@ -236,13 +237,12 @@ TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label,
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_check_keys_with_last_denom (
|
||||
const char *label,
|
||||
unsigned int generation,
|
||||
const char *last_denom_date_ref)
|
||||
{
|
||||
struct TALER_TESTING_Command cmd
|
||||
= TALER_TESTING_cmd_check_keys (label,
|
||||
generation);
|
||||
= TALER_TESTING_cmd_check_keys (label);
|
||||
struct CheckKeysState *cks = cmd.cls;
|
||||
|
||||
cks->last_denom_date_ref = last_denom_date_ref;
|
||||
return cmd;
|
||||
}
|
||||
|
191
src/testing/testing_api_cmd_connect_with_state.c
Normal file
191
src/testing/testing_api_cmd_connect_with_state.c
Normal file
@ -0,0 +1,191 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
(C) 2018-2023 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 testing/testing_api_cmd_connect_with_state.c
|
||||
* @brief Lets tests use the keys deserialization API.
|
||||
* @author Marcello Stanisci
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include <jansson.h>
|
||||
#include "taler_testing_lib.h"
|
||||
|
||||
|
||||
/**
|
||||
* Internal state for a connect-with-state CMD.
|
||||
*/
|
||||
struct ConnectWithStateState
|
||||
{
|
||||
|
||||
/**
|
||||
* Reference to a CMD that offers a serialized key-state
|
||||
* that will be used in the reconnection.
|
||||
*/
|
||||
const char *state_reference;
|
||||
|
||||
/**
|
||||
* Interpreter state.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
|
||||
/**
|
||||
* New exchange handle.
|
||||
*/
|
||||
struct TALER_EXCHANGE_Handle *exchange;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
cert_cb (void *cls,
|
||||
const struct TALER_EXCHANGE_KeysResponse *kr)
|
||||
{
|
||||
struct ConnectWithStateState *cwss = cls;
|
||||
struct TALER_TESTING_Interpreter *is = cwss->is;
|
||||
const struct TALER_EXCHANGE_HttpResponse *hr = &kr->hr;
|
||||
|
||||
switch (hr->http_status)
|
||||
{
|
||||
case MHD_HTTP_OK:
|
||||
/* dealt with below */
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Got failure response %u/%d for /keys!\n",
|
||||
hr->http_status,
|
||||
(int) hr->ec);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||
"Got %d DK from /keys\n",
|
||||
kr->details.ok.keys->num_denom_keys);
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the command.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command to execute.
|
||||
* @param is the interpreter state.
|
||||
*/
|
||||
static void
|
||||
connect_with_state_run (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct ConnectWithStateState *cwss = cls;
|
||||
const struct TALER_TESTING_Command *state_cmd;
|
||||
const json_t *serialized_keys;
|
||||
const char *exchange_url;
|
||||
|
||||
cwss->is = is;
|
||||
state_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||
cwss->state_reference);
|
||||
if (NULL == state_cmd)
|
||||
{
|
||||
/* Command providing serialized keys not found. */
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_keys (state_cmd,
|
||||
&serialized_keys));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (state_cmd,
|
||||
&exchange_url));
|
||||
cwss->exchange
|
||||
= TALER_EXCHANGE_connect (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
&cert_cb,
|
||||
cwss,
|
||||
TALER_EXCHANGE_OPTION_DATA,
|
||||
serialized_keys,
|
||||
TALER_EXCHANGE_OPTION_END);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Offer exchange connection as trait.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param[out] ret result.
|
||||
* @param trait name of the trait.
|
||||
* @param index index number of the object to offer.
|
||||
* @return #GNUNET_OK on success.
|
||||
*/
|
||||
static enum GNUNET_GenericReturnValue
|
||||
connect_with_state_traits (void *cls,
|
||||
const void **ret,
|
||||
const char *trait,
|
||||
unsigned int index)
|
||||
{
|
||||
struct ConnectWithStateState *cwss = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_exchange (cwss->exchange),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
return TALER_TESTING_get_trait (traits,
|
||||
ret,
|
||||
trait,
|
||||
index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup the state of a "connect with state" CMD. Just
|
||||
* a placeholder to avoid jumping on an invalid address.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command which is being cleaned up.
|
||||
*/
|
||||
static void
|
||||
connect_with_state_cleanup (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct ConnectWithStateState *cwss = cls;
|
||||
|
||||
GNUNET_free (cwss);
|
||||
}
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_connect_with_state (const char *label,
|
||||
const char *state_reference)
|
||||
{
|
||||
struct ConnectWithStateState *cwss;
|
||||
|
||||
cwss = GNUNET_new (struct ConnectWithStateState);
|
||||
cwss->state_reference = state_reference;
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = cwss,
|
||||
.label = label,
|
||||
.run = connect_with_state_run,
|
||||
.cleanup = connect_with_state_cleanup,
|
||||
.traits = connect_with_state_traits
|
||||
};
|
||||
|
||||
return cmd;
|
||||
}
|
||||
}
|
@ -101,16 +101,8 @@ get_cb (void *cls,
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != dr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
dr->hr.http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (dr->hr.reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
dr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
ref = TALER_TESTING_interpreter_lookup_command (ds->is,
|
||||
@ -198,8 +190,12 @@ get_run (void *cls,
|
||||
struct ContractGetState *ds = cls;
|
||||
const struct TALER_ContractDiffiePrivateP *contract_priv;
|
||||
const struct TALER_TESTING_Command *ref;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ds->is = is;
|
||||
ref = TALER_TESTING_interpreter_lookup_command (ds->is,
|
||||
ds->contract_ref);
|
||||
@ -214,7 +210,7 @@ get_run (void *cls,
|
||||
}
|
||||
ds->contract_priv = *contract_priv;
|
||||
ds->dh = TALER_EXCHANGE_contract_get (
|
||||
is->exchange,
|
||||
exchange,
|
||||
contract_priv,
|
||||
&get_cb,
|
||||
ds);
|
||||
@ -244,9 +240,7 @@ get_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_contract_get_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -199,8 +199,7 @@ do_retry (void *cls)
|
||||
struct DepositState *ds = cls;
|
||||
|
||||
ds->retry_task = NULL;
|
||||
ds->is->commands[ds->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
TALER_TESTING_touch_cmd (ds->is);
|
||||
deposit_run (ds,
|
||||
NULL,
|
||||
ds->is);
|
||||
@ -240,7 +239,7 @@ deposit_cb (void *cls,
|
||||
else
|
||||
ds->backoff = GNUNET_TIME_randomized_backoff (ds->backoff,
|
||||
MAX_BACKOFF);
|
||||
ds->is->commands[ds->is->ip].num_tries++;
|
||||
TALER_TESTING_inc_tries (ds->is);
|
||||
GNUNET_assert (NULL == ds->retry_task);
|
||||
ds->retry_task
|
||||
= GNUNET_SCHEDULER_add_delayed (ds->backoff,
|
||||
@ -249,16 +248,8 @@ deposit_cb (void *cls,
|
||||
return;
|
||||
}
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
dr->hr.http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (dr->hr.reply,
|
||||
stderr,
|
||||
JSON_INDENT (2));
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
dr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
if (MHD_HTTP_OK == dr->hr.http_status)
|
||||
@ -305,8 +296,12 @@ deposit_run (void *cls,
|
||||
&wire_salt),
|
||||
GNUNET_JSON_spec_end ()
|
||||
};
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ds->is = is;
|
||||
if (NULL != ds->deposit_reference)
|
||||
{
|
||||
@ -474,7 +469,7 @@ deposit_run (void *cls,
|
||||
.refund_deadline = ds->refund_deadline
|
||||
};
|
||||
|
||||
ds->dh = TALER_EXCHANGE_deposit (is->exchange,
|
||||
ds->dh = TALER_EXCHANGE_deposit (exchange,
|
||||
&dcd,
|
||||
&cdd,
|
||||
&deposit_cb,
|
||||
@ -508,9 +503,7 @@ deposit_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_deposit_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -39,6 +39,11 @@ struct TrackTransactionState
|
||||
*/
|
||||
const char *bank_transfer_reference;
|
||||
|
||||
/**
|
||||
* Our command.
|
||||
*/
|
||||
const struct TALER_TESTING_Command *cmd;
|
||||
|
||||
/**
|
||||
* The WTID associated by the transaction being tracked.
|
||||
*/
|
||||
@ -107,22 +112,12 @@ deposit_wtid_cb (void *cls,
|
||||
{
|
||||
struct TrackTransactionState *tts = cls;
|
||||
struct TALER_TESTING_Interpreter *is = tts->is;
|
||||
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
|
||||
|
||||
tts->tth = NULL;
|
||||
if (tts->expected_response_code != dr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
dr->hr.http_status,
|
||||
(int) dr->hr.ec,
|
||||
cmd->label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (dr->hr.reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
TALER_TESTING_unexpected_status (is,
|
||||
dr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
switch (dr->hr.http_status)
|
||||
@ -203,8 +198,12 @@ track_transaction_run (void *cls,
|
||||
struct TALER_MerchantWireHashP h_wire_details;
|
||||
struct TALER_PrivateContractHashP h_contract_terms;
|
||||
const struct TALER_MerchantPrivateKeyP *merchant_priv;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
tts->cmd = cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
tts->is = is;
|
||||
transaction_cmd
|
||||
= TALER_TESTING_interpreter_lookup_command (tts->is,
|
||||
@ -276,7 +275,7 @@ track_transaction_run (void *cls,
|
||||
return;
|
||||
}
|
||||
|
||||
tts->tth = TALER_EXCHANGE_deposits_get (is->exchange,
|
||||
tts->tth = TALER_EXCHANGE_deposits_get (exchange,
|
||||
merchant_priv,
|
||||
&h_wire_details,
|
||||
&h_contract_terms,
|
||||
@ -303,9 +302,7 @@ track_transaction_cleanup (void *cls,
|
||||
|
||||
if (NULL != tts->tth)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
tts->is->ip,
|
||||
TALER_TESTING_command_incomplete (tts->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_deposits_get_cancel (tts->tth);
|
||||
tts->tth = NULL;
|
||||
@ -335,10 +332,8 @@ track_transaction_traits (void *cls,
|
||||
TALER_TESTING_make_trait_wtid (&tts->wtid),
|
||||
TALER_TESTING_make_trait_legi_requirement_row (
|
||||
&tts->requirement_row),
|
||||
TALER_TESTING_make_trait_h_payto (
|
||||
&tts->h_payto),
|
||||
TALER_TESTING_make_trait_payto_uri (
|
||||
(const char **) &tts->merchant_payto_uri),
|
||||
TALER_TESTING_make_trait_h_payto (&tts->h_payto),
|
||||
TALER_TESTING_make_trait_payto_uri (tts->merchant_payto_uri),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
|
280
src/testing/testing_api_cmd_get_auditor.c
Normal file
280
src/testing/testing_api_cmd_get_auditor.c
Normal file
@ -0,0 +1,280 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
(C) 2023 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 testing/testing_api_cmd_get_auditor.c
|
||||
* @brief Command to get an auditor handle
|
||||
* @author Christian Grothoff
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include "taler_json_lib.h"
|
||||
#include <gnunet/gnunet_curl_lib.h>
|
||||
#include "taler_testing_lib.h"
|
||||
|
||||
|
||||
/**
|
||||
* State for a "get auditor" CMD.
|
||||
*/
|
||||
struct GetAuditorState
|
||||
{
|
||||
|
||||
/**
|
||||
* Private key of the auditor.
|
||||
*/
|
||||
struct TALER_AuditorPrivateKeyP auditor_priv;
|
||||
|
||||
/**
|
||||
* Public key of the auditor.
|
||||
*/
|
||||
struct TALER_AuditorPublicKeyP auditor_pub;
|
||||
|
||||
/**
|
||||
* Our interpreter state.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
|
||||
/**
|
||||
* Auditor handle we produced.
|
||||
*/
|
||||
struct TALER_AUDITOR_Handle *auditor;
|
||||
|
||||
/**
|
||||
* URL of the auditor.
|
||||
*/
|
||||
char *auditor_url;
|
||||
|
||||
/**
|
||||
* Filename of the master private key of the auditor.
|
||||
*/
|
||||
char *priv_file;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function called with information about the auditor.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param hr HTTP response data
|
||||
* @param vi basic information about the auditor
|
||||
* @param compat protocol compatibility information
|
||||
*/
|
||||
static void
|
||||
version_cb (
|
||||
void *cls,
|
||||
const struct TALER_AUDITOR_HttpResponse *hr,
|
||||
const struct TALER_AUDITOR_VersionInformation *vi,
|
||||
enum TALER_AUDITOR_VersionCompatibility compat)
|
||||
{
|
||||
struct GetAuditorState *gas = cls;
|
||||
|
||||
if (MHD_HTTP_OK != hr->http_status)
|
||||
{
|
||||
TALER_TESTING_unexpected_status (gas->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (gas->is);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the "get_auditor" command.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command currently being executed.
|
||||
* @param is the interpreter state.
|
||||
*/
|
||||
static void
|
||||
get_auditor_run (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct GetAuditorState *gas = cls;
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == gas->auditor_url)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
if (NULL != gas->priv_file)
|
||||
{
|
||||
if (GNUNET_SYSERR ==
|
||||
GNUNET_CRYPTO_eddsa_key_from_file (gas->priv_file,
|
||||
GNUNET_YES,
|
||||
&gas->auditor_priv.eddsa_priv))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&gas->auditor_priv.eddsa_priv,
|
||||
&gas->auditor_pub.eddsa_pub);
|
||||
}
|
||||
gas->is = is;
|
||||
gas->auditor
|
||||
= TALER_AUDITOR_connect (TALER_TESTING_interpreter_get_context (is),
|
||||
gas->auditor_url,
|
||||
&version_cb,
|
||||
gas);
|
||||
if (NULL == gas->auditor)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup the state.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command which is being cleaned up.
|
||||
*/
|
||||
static void
|
||||
get_auditor_cleanup (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct GetAuditorState *gas = cls;
|
||||
|
||||
if (NULL != gas->auditor)
|
||||
{
|
||||
TALER_AUDITOR_disconnect (gas->auditor);
|
||||
gas->auditor = NULL;
|
||||
}
|
||||
GNUNET_free (gas->priv_file);
|
||||
GNUNET_free (gas->auditor_url);
|
||||
GNUNET_free (gas);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Offer internal data to a "get_auditor" CMD state to other commands.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param[out] ret result (could be anything)
|
||||
* @param trait name of the trait
|
||||
* @param index index number of the object to offer.
|
||||
* @return #GNUNET_OK on success
|
||||
*/
|
||||
static enum GNUNET_GenericReturnValue
|
||||
get_auditor_traits (void *cls,
|
||||
const void **ret,
|
||||
const char *trait,
|
||||
unsigned int index)
|
||||
{
|
||||
struct GetAuditorState *gas = cls;
|
||||
unsigned int off = (NULL == gas->priv_file) ? 2 : 0;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_auditor_priv (&gas->auditor_priv),
|
||||
TALER_TESTING_make_trait_auditor_pub (&gas->auditor_pub),
|
||||
TALER_TESTING_make_trait_auditor (gas->auditor),
|
||||
TALER_TESTING_make_trait_auditor_url (gas->auditor_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
return TALER_TESTING_get_trait (&traits[off],
|
||||
ret,
|
||||
trait,
|
||||
index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the base URL of the auditor from @a cfg.
|
||||
*
|
||||
* @param cfg configuration to evaluate
|
||||
* @return base URL of the auditor according to @a cfg
|
||||
*/
|
||||
static char *
|
||||
get_auditor_base_url (
|
||||
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||
{
|
||||
char *auditor_url;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||
"auditor",
|
||||
"BASE_URL",
|
||||
&auditor_url))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||
"auditor",
|
||||
"BASE_URL");
|
||||
return NULL;
|
||||
}
|
||||
return auditor_url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the file name of the master private key file of the auditor from @a
|
||||
* cfg.
|
||||
*
|
||||
* @param cfg configuration to evaluate
|
||||
* @return base URL of the auditor according to @a cfg
|
||||
*/
|
||||
static char *
|
||||
get_auditor_priv_file (
|
||||
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||
{
|
||||
char *fn;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_filename (cfg,
|
||||
"auditor",
|
||||
"AUDITOR_PRIV_FILE",
|
||||
&fn))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||
"auditor",
|
||||
"AUDITOR_PRIV_FILE");
|
||||
return NULL;
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_get_auditor (
|
||||
const char *label,
|
||||
const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
bool load_auditor_keys)
|
||||
{
|
||||
struct GetAuditorState *gas;
|
||||
|
||||
gas = GNUNET_new (struct GetAuditorState);
|
||||
gas->auditor_url = get_auditor_base_url (cfg);
|
||||
if (load_auditor_keys)
|
||||
gas->priv_file = get_auditor_priv_file (cfg);
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = gas,
|
||||
.label = label,
|
||||
.run = &get_auditor_run,
|
||||
.cleanup = &get_auditor_cleanup,
|
||||
.traits = &get_auditor_traits,
|
||||
.name = "auditor"
|
||||
};
|
||||
|
||||
return cmd;
|
||||
}
|
||||
}
|
308
src/testing/testing_api_cmd_get_exchange.c
Normal file
308
src/testing/testing_api_cmd_get_exchange.c
Normal file
@ -0,0 +1,308 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
(C) 2023 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 testing/testing_api_cmd_get_exchange.c
|
||||
* @brief Command to get an exchange handle
|
||||
* @author Christian Grothoff
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include "taler_json_lib.h"
|
||||
#include <gnunet/gnunet_curl_lib.h>
|
||||
#include "taler_testing_lib.h"
|
||||
|
||||
|
||||
/**
|
||||
* State for a "get exchange" CMD.
|
||||
*/
|
||||
struct GetExchangeState
|
||||
{
|
||||
|
||||
/**
|
||||
* Master private key of the exchange.
|
||||
*/
|
||||
struct TALER_MasterPrivateKeyP master_priv;
|
||||
|
||||
/**
|
||||
* Our interpreter state.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
|
||||
/**
|
||||
* Exchange handle we produced.
|
||||
*/
|
||||
struct TALER_EXCHANGE_Handle *exchange;
|
||||
|
||||
/**
|
||||
* URL of the exchange.
|
||||
*/
|
||||
char *exchange_url;
|
||||
|
||||
/**
|
||||
* Filename of the master private key of the exchange.
|
||||
*/
|
||||
char *master_priv_file;
|
||||
|
||||
/**
|
||||
* Are we waiting for /keys before continuing?
|
||||
*/
|
||||
bool wait_for_keys;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
cert_cb (void *cls,
|
||||
const struct TALER_EXCHANGE_KeysResponse *kr)
|
||||
{
|
||||
struct GetExchangeState *ges = cls;
|
||||
const struct TALER_EXCHANGE_HttpResponse *hr = &kr->hr;
|
||||
struct TALER_TESTING_Interpreter *is = ges->is;
|
||||
|
||||
switch (hr->http_status)
|
||||
{
|
||||
case MHD_HTTP_OK:
|
||||
if (ges->wait_for_keys)
|
||||
{
|
||||
ges->wait_for_keys = false;
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
TALER_EXCHANGE_disconnect (ges->exchange);
|
||||
ges->exchange = NULL;
|
||||
if (ges->wait_for_keys)
|
||||
{
|
||||
ges->wait_for_keys = false;
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the "get_exchange" command.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command currently being executed.
|
||||
* @param is the interpreter state.
|
||||
*/
|
||||
static void
|
||||
get_exchange_run (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct GetExchangeState *ges = cls;
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == ges->exchange_url)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
if (NULL != ges->master_priv_file)
|
||||
{
|
||||
if (GNUNET_SYSERR ==
|
||||
GNUNET_CRYPTO_eddsa_key_from_file (ges->master_priv_file,
|
||||
GNUNET_YES,
|
||||
&ges->master_priv.eddsa_priv))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ges->is = is;
|
||||
ges->exchange
|
||||
= TALER_EXCHANGE_connect (TALER_TESTING_interpreter_get_context (is),
|
||||
ges->exchange_url,
|
||||
&cert_cb,
|
||||
ges,
|
||||
TALER_EXCHANGE_OPTION_END);
|
||||
if (NULL == ges->exchange)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
if (! ges->wait_for_keys)
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup the state.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command which is being cleaned up.
|
||||
*/
|
||||
static void
|
||||
get_exchange_cleanup (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct GetExchangeState *ges = cls;
|
||||
|
||||
if (NULL != ges->exchange)
|
||||
{
|
||||
TALER_EXCHANGE_disconnect (ges->exchange);
|
||||
ges->exchange = NULL;
|
||||
}
|
||||
GNUNET_free (ges->master_priv_file);
|
||||
GNUNET_free (ges->exchange_url);
|
||||
GNUNET_free (ges);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Offer internal data to a "get_exchange" CMD state to other commands.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param[out] ret result (could be anything)
|
||||
* @param trait name of the trait
|
||||
* @param index index number of the object to offer.
|
||||
* @return #GNUNET_OK on success
|
||||
*/
|
||||
static enum GNUNET_GenericReturnValue
|
||||
get_exchange_traits (void *cls,
|
||||
const void **ret,
|
||||
const char *trait,
|
||||
unsigned int index)
|
||||
{
|
||||
struct GetExchangeState *ges = cls;
|
||||
unsigned int off = (NULL == ges->master_priv_file) ? 1 : 0;
|
||||
const struct TALER_EXCHANGE_Keys *keys
|
||||
= TALER_EXCHANGE_get_keys (ges->exchange);
|
||||
|
||||
if (NULL != keys)
|
||||
{
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_master_priv (&ges->master_priv),
|
||||
TALER_TESTING_make_trait_master_pub (&keys->master_pub),
|
||||
TALER_TESTING_make_trait_exchange (ges->exchange),
|
||||
TALER_TESTING_make_trait_exchange_url (ges->exchange_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
return TALER_TESTING_get_trait (&traits[off],
|
||||
ret,
|
||||
trait,
|
||||
index);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_master_priv (&ges->master_priv),
|
||||
TALER_TESTING_make_trait_exchange (ges->exchange),
|
||||
TALER_TESTING_make_trait_exchange_url (ges->exchange_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
return TALER_TESTING_get_trait (&traits[off],
|
||||
ret,
|
||||
trait,
|
||||
index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the base URL of the exchange from @a cfg.
|
||||
*
|
||||
* @param cfg configuration to evaluate
|
||||
* @return base URL of the exchange according to @a cfg
|
||||
*/
|
||||
static char *
|
||||
get_exchange_base_url (
|
||||
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||
{
|
||||
char *exchange_url;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||
"exchange",
|
||||
"BASE_URL",
|
||||
&exchange_url))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||
"exchange",
|
||||
"BASE_URL");
|
||||
return NULL;
|
||||
}
|
||||
return exchange_url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the file name of the master private key file of the exchange from @a
|
||||
* cfg.
|
||||
*
|
||||
* @param cfg configuration to evaluate
|
||||
* @return base URL of the exchange according to @a cfg
|
||||
*/
|
||||
static char *
|
||||
get_exchange_master_priv_file (
|
||||
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||
{
|
||||
char *fn;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_filename (cfg,
|
||||
"exchange-offline",
|
||||
"MASTER_PRIV_FILE",
|
||||
&fn))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||
"exchange-offline",
|
||||
"MASTER_PRIV_FILE");
|
||||
return NULL;
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_get_exchange (
|
||||
const char *label,
|
||||
const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
bool wait_for_keys,
|
||||
bool load_private_key)
|
||||
{
|
||||
struct GetExchangeState *ges;
|
||||
|
||||
ges = GNUNET_new (struct GetExchangeState);
|
||||
ges->exchange_url = get_exchange_base_url (cfg);
|
||||
if (load_private_key)
|
||||
ges->master_priv_file = get_exchange_master_priv_file (cfg);
|
||||
ges->wait_for_keys = wait_for_keys;
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = ges,
|
||||
.label = label,
|
||||
.run = &get_exchange_run,
|
||||
.cleanup = &get_exchange_cleanup,
|
||||
.traits = &get_exchange_traits,
|
||||
.name = "exchange"
|
||||
};
|
||||
|
||||
return cmd;
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@
|
||||
#include "taler_signatures.h"
|
||||
#include "taler_testing_lib.h"
|
||||
#include "taler_exchangedb_plugin.h"
|
||||
#include "taler_exchangedb_lib.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -37,9 +38,9 @@
|
||||
struct InsertDepositState
|
||||
{
|
||||
/**
|
||||
* Configuration file used by the command.
|
||||
* Database connection we use.
|
||||
*/
|
||||
const struct TALER_TESTING_DatabaseConnection *dbc;
|
||||
struct TALER_EXCHANGEDB_Plugin *plugin;
|
||||
|
||||
/**
|
||||
* Human-readable name of the shop.
|
||||
@ -71,6 +72,11 @@ struct InsertDepositState
|
||||
* Deposit fee.
|
||||
*/
|
||||
const char *deposit_fee;
|
||||
|
||||
/**
|
||||
* Do we used a cached @e plugin?
|
||||
*/
|
||||
bool cached;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -133,6 +139,19 @@ insert_deposit_run (void *cls,
|
||||
struct TALER_DenominationPrivateKey denom_priv;
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == ids->plugin)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
ids->plugin->preflight (ids->plugin->cls))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
// prepare and store issue first.
|
||||
fake_issue (&issue);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
@ -144,14 +163,14 @@ insert_deposit_run (void *cls,
|
||||
&issue.denom_hash);
|
||||
|
||||
if ( (GNUNET_OK !=
|
||||
ids->dbc->plugin->start (ids->dbc->plugin->cls,
|
||||
ids->plugin->start (ids->plugin->cls,
|
||||
"talertestinglib: denomination insertion")) ||
|
||||
(GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||
ids->dbc->plugin->insert_denomination_info (ids->dbc->plugin->cls,
|
||||
ids->plugin->insert_denomination_info (ids->plugin->cls,
|
||||
&dpk,
|
||||
&issue)) ||
|
||||
(GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||
ids->dbc->plugin->commit (ids->dbc->plugin->cls)) )
|
||||
ids->plugin->commit (ids->plugin->cls)) )
|
||||
{
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
TALER_denom_pub_free (&dpk);
|
||||
@ -248,23 +267,23 @@ insert_deposit_run (void *cls,
|
||||
struct TALER_AgeCommitmentHash agh;
|
||||
|
||||
if ( (GNUNET_OK !=
|
||||
ids->dbc->plugin->start (ids->dbc->plugin->cls,
|
||||
ids->plugin->start (ids->plugin->cls,
|
||||
"libtalertesting: insert deposit")) ||
|
||||
(0 >
|
||||
ids->dbc->plugin->ensure_coin_known (ids->dbc->plugin->cls,
|
||||
ids->plugin->ensure_coin_known (ids->plugin->cls,
|
||||
&deposit.coin,
|
||||
&known_coin_id,
|
||||
&dph,
|
||||
&agh)) ||
|
||||
(GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||
ids->dbc->plugin->insert_deposit (ids->dbc->plugin->cls,
|
||||
ids->plugin->insert_deposit (ids->plugin->cls,
|
||||
ids->exchange_timestamp,
|
||||
&deposit)) ||
|
||||
(GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||
ids->dbc->plugin->commit (ids->dbc->plugin->cls)) )
|
||||
ids->plugin->commit (ids->plugin->cls)) )
|
||||
{
|
||||
GNUNET_break (0);
|
||||
ids->dbc->plugin->rollback (ids->dbc->plugin->cls);
|
||||
ids->plugin->rollback (ids->plugin->cls);
|
||||
GNUNET_free (deposit.receiver_wire_account);
|
||||
TALER_denom_pub_free (&dpk);
|
||||
TALER_denom_priv_free (&denom_priv);
|
||||
@ -295,6 +314,14 @@ insert_deposit_cleanup (void *cls,
|
||||
struct InsertDepositState *ids = cls;
|
||||
|
||||
(void) cmd;
|
||||
if ( (NULL != ids->plugin) &&
|
||||
(! ids->cached) )
|
||||
{
|
||||
// FIXME: historically, we also did:
|
||||
// ids->plugin->drop_tables (ids->plugin->cls);
|
||||
TALER_EXCHANGEDB_plugin_unload (ids->plugin);
|
||||
ids->plugin = NULL;
|
||||
}
|
||||
GNUNET_free (ids);
|
||||
}
|
||||
|
||||
@ -302,7 +329,7 @@ insert_deposit_cleanup (void *cls,
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_insert_deposit (
|
||||
const char *label,
|
||||
const struct TALER_TESTING_DatabaseConnection *dbc,
|
||||
const struct GNUNET_CONFIGURATION_Handle *db_cfg,
|
||||
const char *merchant_name,
|
||||
const char *merchant_account,
|
||||
struct GNUNET_TIME_Timestamp exchange_timestamp,
|
||||
@ -310,10 +337,22 @@ TALER_TESTING_cmd_insert_deposit (
|
||||
const char *amount_with_fee,
|
||||
const char *deposit_fee)
|
||||
{
|
||||
static struct TALER_EXCHANGEDB_Plugin *pluginc;
|
||||
static const struct GNUNET_CONFIGURATION_Handle *db_cfgc;
|
||||
struct InsertDepositState *ids;
|
||||
|
||||
ids = GNUNET_new (struct InsertDepositState);
|
||||
ids->dbc = dbc;
|
||||
if (db_cfgc == db_cfg)
|
||||
{
|
||||
ids->plugin = pluginc;
|
||||
ids->cached = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ids->plugin = TALER_EXCHANGEDB_plugin_load (db_cfg);
|
||||
pluginc = ids->plugin;
|
||||
db_cfgc = db_cfg;
|
||||
}
|
||||
ids->merchant_name = merchant_name;
|
||||
ids->merchant_account = merchant_account;
|
||||
ids->exchange_timestamp = exchange_timestamp;
|
||||
|
@ -73,19 +73,12 @@ check_kyc_cb (void *cls,
|
||||
{
|
||||
struct KycCheckGetState *kcg = cls;
|
||||
struct TALER_TESTING_Interpreter *is = kcg->is;
|
||||
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
|
||||
|
||||
kcg->kwh = NULL;
|
||||
if (kcg->expected_response_code != ks->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
ks->http_status,
|
||||
(int) ks->ec,
|
||||
cmd->label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
TALER_TESTING_unexpected_status (is,
|
||||
ks->http_status);
|
||||
return;
|
||||
}
|
||||
switch (ks->http_status)
|
||||
@ -121,8 +114,12 @@ check_kyc_run (void *cls,
|
||||
const struct TALER_TESTING_Command *res_cmd;
|
||||
const uint64_t *requirement_row;
|
||||
const struct TALER_PaytoHashP *h_payto;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
kcg->is = is;
|
||||
res_cmd = TALER_TESTING_interpreter_lookup_command (kcg->is,
|
||||
kcg->
|
||||
@ -155,7 +152,7 @@ check_kyc_run (void *cls,
|
||||
TALER_TESTING_interpreter_fail (kcg->is);
|
||||
return;
|
||||
}
|
||||
kcg->kwh = TALER_EXCHANGE_kyc_check (is->exchange,
|
||||
kcg->kwh = TALER_EXCHANGE_kyc_check (exchange,
|
||||
*requirement_row,
|
||||
h_payto,
|
||||
TALER_KYCLOGIC_KYC_UT_INDIVIDUAL,
|
||||
@ -181,9 +178,7 @@ check_kyc_cleanup (void *cls,
|
||||
|
||||
if (NULL != kcg->kwh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
kcg->is->ip,
|
||||
TALER_TESTING_command_incomplete (kcg->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_kyc_check_cancel (kcg->kwh);
|
||||
kcg->kwh = NULL;
|
||||
@ -210,8 +205,7 @@ check_kyc_traits (void *cls,
|
||||
{
|
||||
struct KycCheckGetState *kcg = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_kyc_url (
|
||||
(const char **) &kcg->kyc_url),
|
||||
TALER_TESTING_make_trait_kyc_url (kcg->kyc_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
|
@ -83,18 +83,12 @@ proof_kyc_cb (void *cls,
|
||||
{
|
||||
struct KycProofGetState *kcg = cls;
|
||||
struct TALER_TESTING_Interpreter *is = kcg->is;
|
||||
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
|
||||
|
||||
kcg->kph = NULL;
|
||||
if (kcg->expected_response_code != kpr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
kpr->http_status,
|
||||
cmd->label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
TALER_TESTING_unexpected_status (is,
|
||||
kpr->http_status);
|
||||
return;
|
||||
}
|
||||
switch (kpr->http_status)
|
||||
@ -133,8 +127,12 @@ proof_kyc_run (void *cls,
|
||||
const struct TALER_TESTING_Command *res_cmd;
|
||||
const struct TALER_PaytoHashP *h_payto;
|
||||
char *uargs;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
kps->is = is;
|
||||
res_cmd = TALER_TESTING_interpreter_lookup_command (
|
||||
kps->is,
|
||||
@ -159,7 +157,7 @@ proof_kyc_run (void *cls,
|
||||
GNUNET_asprintf (&uargs,
|
||||
"&code=%s",
|
||||
kps->code);
|
||||
kps->kph = TALER_EXCHANGE_kyc_proof (is->exchange,
|
||||
kps->kph = TALER_EXCHANGE_kyc_proof (exchange,
|
||||
h_payto,
|
||||
kps->logic,
|
||||
uargs,
|
||||
@ -185,9 +183,7 @@ proof_kyc_cleanup (void *cls,
|
||||
|
||||
if (NULL != kps->kph)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
kps->is->ip,
|
||||
TALER_TESTING_command_incomplete (kps->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_kyc_proof_cancel (kps->kph);
|
||||
kps->kph = NULL;
|
||||
@ -214,8 +210,7 @@ proof_kyc_traits (void *cls,
|
||||
{
|
||||
struct KycProofGetState *kps = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_web_url (
|
||||
(const char **) &kps->redirect_url),
|
||||
TALER_TESTING_make_trait_web_url (kps->redirect_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
|
@ -48,6 +48,11 @@ struct KycWalletGetState
|
||||
*/
|
||||
char *reserve_payto_uri;
|
||||
|
||||
/**
|
||||
* Our command.
|
||||
*/
|
||||
const struct TALER_TESTING_Command *cmd;
|
||||
|
||||
/**
|
||||
* Command to get a reserve private key from.
|
||||
*/
|
||||
@ -99,20 +104,12 @@ wallet_kyc_cb (void *cls,
|
||||
{
|
||||
struct KycWalletGetState *kwg = cls;
|
||||
struct TALER_TESTING_Interpreter *is = kwg->is;
|
||||
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
|
||||
|
||||
kwg->kwh = NULL;
|
||||
if (kwg->expected_response_code != wkr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d (wanted %u) to command %s in %s:%u\n",
|
||||
wkr->http_status,
|
||||
(int) wkr->ec,
|
||||
kwg->expected_response_code,
|
||||
cmd->label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
TALER_TESTING_unexpected_status (is,
|
||||
wkr->http_status);
|
||||
return;
|
||||
}
|
||||
switch (wkr->http_status)
|
||||
@ -150,8 +147,12 @@ wallet_kyc_run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct KycWalletGetState *kwg = cls;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
kwg->cmd = cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
kwg->is = is;
|
||||
if (NULL != kwg->reserve_reference)
|
||||
{
|
||||
@ -184,9 +185,9 @@ wallet_kyc_run (void *cls,
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&kwg->reserve_priv.eddsa_priv,
|
||||
&kwg->reserve_pub.eddsa_pub);
|
||||
kwg->reserve_payto_uri
|
||||
= TALER_reserve_make_payto (TALER_EXCHANGE_get_base_url (is->exchange),
|
||||
= TALER_reserve_make_payto (TALER_EXCHANGE_get_base_url (exchange),
|
||||
&kwg->reserve_pub);
|
||||
kwg->kwh = TALER_EXCHANGE_kyc_wallet (is->exchange,
|
||||
kwg->kwh = TALER_EXCHANGE_kyc_wallet (exchange,
|
||||
&kwg->reserve_priv,
|
||||
&kwg->balance,
|
||||
&wallet_kyc_cb,
|
||||
@ -210,9 +211,7 @@ wallet_kyc_cleanup (void *cls,
|
||||
|
||||
if (NULL != kwg->kwh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
kwg->is->ip,
|
||||
TALER_TESTING_command_incomplete (kwg->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_kyc_wallet_cancel (kwg->kwh);
|
||||
kwg->kwh = NULL;
|
||||
@ -243,8 +242,7 @@ wallet_kyc_traits (void *cls,
|
||||
TALER_TESTING_make_trait_reserve_pub (&kwg->reserve_pub),
|
||||
TALER_TESTING_make_trait_legi_requirement_row (&kwg->requirement_row),
|
||||
TALER_TESTING_make_trait_h_payto (&kwg->h_payto),
|
||||
TALER_TESTING_make_trait_payto_uri (
|
||||
(const char **) &kwg->reserve_payto_uri),
|
||||
TALER_TESTING_make_trait_payto_uri (kwg->reserve_payto_uri),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
|
@ -162,16 +162,8 @@ deposit_cb (void *cls,
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != dr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
dr->hr.http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (dr->hr.reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
dr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
if (MHD_HTTP_OK == dr->hr.http_status)
|
||||
@ -197,8 +189,12 @@ deposit_run (void *cls,
|
||||
{
|
||||
struct PurseCreateDepositState *ds = cls;
|
||||
struct TALER_EXCHANGE_PurseDeposit deposits[ds->num_coin_references];
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ds->is = is;
|
||||
for (unsigned int i = 0; i<ds->num_coin_references; i++)
|
||||
{
|
||||
@ -263,7 +259,7 @@ deposit_run (void *cls,
|
||||
"pay_deadline",
|
||||
GNUNET_JSON_from_timestamp (ds->purse_expiration)));
|
||||
ds->dh = TALER_EXCHANGE_purse_create_with_deposit (
|
||||
is->exchange,
|
||||
exchange,
|
||||
&ds->purse_priv,
|
||||
&ds->merge_priv,
|
||||
&ds->contract_priv,
|
||||
@ -299,9 +295,7 @@ deposit_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_purse_create_with_deposit_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -74,16 +74,8 @@ purse_delete_cb (void *cls,
|
||||
pds->pdh = NULL;
|
||||
if (pds->expected_response_code != pdr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
pdr->hr.http_status,
|
||||
pds->is->commands[pds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (pdr->hr.reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (pds->is);
|
||||
TALER_TESTING_unexpected_status (pds->is,
|
||||
pdr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (pds->is);
|
||||
@ -105,8 +97,12 @@ purse_delete_run (void *cls,
|
||||
struct PurseDeleteState *pds = cls;
|
||||
const struct TALER_PurseContractPrivateKeyP *purse_priv;
|
||||
const struct TALER_TESTING_Command *ref;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ref = TALER_TESTING_interpreter_lookup_command (is,
|
||||
pds->purse_cmd);
|
||||
if (NULL == ref)
|
||||
@ -125,7 +121,7 @@ purse_delete_run (void *cls,
|
||||
}
|
||||
pds->is = is;
|
||||
pds->pdh = TALER_EXCHANGE_purse_delete (
|
||||
is->exchange,
|
||||
exchange,
|
||||
purse_priv,
|
||||
&purse_delete_cb,
|
||||
pds);
|
||||
@ -153,9 +149,7 @@ purse_delete_cleanup (void *cls,
|
||||
|
||||
if (NULL != pds->pdh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
pds->is->ip,
|
||||
TALER_TESTING_command_incomplete (pds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_purse_delete_cancel (pds->pdh);
|
||||
pds->pdh = NULL;
|
||||
|
@ -133,20 +133,15 @@ deposit_cb (void *cls,
|
||||
const struct TALER_EXCHANGE_PurseDepositResponse *dr)
|
||||
{
|
||||
struct PurseDepositState *ds = cls;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (ds->is);
|
||||
|
||||
ds->dh = NULL;
|
||||
GNUNET_assert (NULL != exchange);
|
||||
if (ds->expected_response_code != dr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
dr->hr.http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (dr->hr.reply,
|
||||
stderr,
|
||||
JSON_INDENT (2));
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
dr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
if (MHD_HTTP_OK == dr->hr.http_status)
|
||||
@ -205,7 +200,7 @@ deposit_cb (void *cls,
|
||||
const struct TALER_EXCHANGE_Keys *keys;
|
||||
const struct TALER_EXCHANGE_GlobalFee *gf;
|
||||
|
||||
keys = TALER_EXCHANGE_get_keys (ds->is->exchange);
|
||||
keys = TALER_EXCHANGE_get_keys (exchange);
|
||||
GNUNET_assert (NULL != keys);
|
||||
gf = TALER_EXCHANGE_get_global_fee (keys,
|
||||
*merge_timestamp);
|
||||
@ -264,10 +259,13 @@ deposit_run (void *cls,
|
||||
struct TALER_EXCHANGE_PurseDeposit deposits[ds->num_coin_references];
|
||||
const struct TALER_PurseContractPublicKeyP *purse_pub;
|
||||
const struct TALER_TESTING_Command *purse_cmd;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
(void) cmd;
|
||||
ds->is = is;
|
||||
|
||||
purse_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||
ds->purse_ref);
|
||||
GNUNET_assert (NULL != purse_cmd);
|
||||
@ -323,7 +321,7 @@ deposit_run (void *cls,
|
||||
}
|
||||
|
||||
ds->dh = TALER_EXCHANGE_purse_deposit (
|
||||
is->exchange,
|
||||
exchange,
|
||||
NULL, /* FIXME #7271: WADs support: purse exchange URL */
|
||||
&ds->purse_pub,
|
||||
ds->min_age,
|
||||
@ -357,9 +355,7 @@ deposit_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_purse_deposit_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -183,7 +183,11 @@ status_run (void *cls,
|
||||
{
|
||||
struct StatusState *ss = cls;
|
||||
const struct TALER_TESTING_Command *create_purse;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ss->is = is;
|
||||
create_purse
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -198,7 +202,7 @@ status_run (void *cls,
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
ss->pgh = TALER_EXCHANGE_purse_get (is->exchange,
|
||||
ss->pgh = TALER_EXCHANGE_purse_get (exchange,
|
||||
ss->purse_pub,
|
||||
ss->timeout,
|
||||
ss->wait_for_merge,
|
||||
@ -227,9 +231,7 @@ status_cleanup (void *cls,
|
||||
|
||||
if (NULL != ss->pgh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ss->is->ip,
|
||||
TALER_TESTING_command_incomplete (ss->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_purse_get_cancel (ss->pgh);
|
||||
ss->pgh = NULL;
|
||||
|
@ -177,16 +177,8 @@ merge_cb (void *cls,
|
||||
|
||||
if (ds->expected_response_code != dr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
dr->hr.http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (dr->hr.reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
dr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -209,8 +201,12 @@ merge_run (void *cls,
|
||||
const struct TALER_PurseMergePrivateKeyP *merge_priv;
|
||||
const json_t *ct;
|
||||
const struct TALER_TESTING_Command *ref;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ds->is = is;
|
||||
ref = TALER_TESTING_interpreter_lookup_command (ds->is,
|
||||
ds->merge_ref);
|
||||
@ -302,8 +298,21 @@ merge_run (void *cls,
|
||||
&ds->reserve_pub.eddsa_pub);
|
||||
{
|
||||
char *payto_uri;
|
||||
const char *exchange_url;
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
|
||||
payto_uri = TALER_reserve_make_payto (is->exchange_url,
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
payto_uri = TALER_reserve_make_payto (exchange_url,
|
||||
&ds->reserve_pub);
|
||||
TALER_payto_hash (payto_uri,
|
||||
&ds->h_payto);
|
||||
@ -313,7 +322,7 @@ merge_run (void *cls,
|
||||
&ds->merge_pub.eddsa_pub);
|
||||
ds->merge_timestamp = GNUNET_TIME_timestamp_get ();
|
||||
ds->dh = TALER_EXCHANGE_account_merge (
|
||||
is->exchange,
|
||||
exchange,
|
||||
NULL, /* no wad */
|
||||
&ds->reserve_priv,
|
||||
&ds->purse_pub,
|
||||
@ -351,9 +360,7 @@ merge_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_account_merge_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -82,7 +82,6 @@ recoup_cb (void *cls,
|
||||
struct RecoupState *ps = cls;
|
||||
const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr;
|
||||
struct TALER_TESTING_Interpreter *is = ps->is;
|
||||
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
|
||||
const struct TALER_TESTING_Command *reserve_cmd;
|
||||
char *cref;
|
||||
unsigned int idx;
|
||||
@ -90,18 +89,8 @@ recoup_cb (void *cls,
|
||||
ps->ph = NULL;
|
||||
if (ps->expected_response_code != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
(int) hr->ec,
|
||||
cmd->label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
fprintf (stderr, "\n");
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
TALER_TESTING_unexpected_status (is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -193,7 +182,11 @@ recoup_run (void *cls,
|
||||
char *cref;
|
||||
unsigned int idx;
|
||||
const struct TALER_ExchangeWithdrawValues *ewv;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ps->is = is;
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_parse_coin_reference (
|
||||
@ -266,7 +259,7 @@ recoup_run (void *cls,
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Trying to recoup denomination '%s'\n",
|
||||
TALER_B2S (&denom_pub->h_key));
|
||||
ps->ph = TALER_EXCHANGE_recoup (is->exchange,
|
||||
ps->ph = TALER_EXCHANGE_recoup (exchange,
|
||||
denom_pub,
|
||||
coin_sig,
|
||||
ewv,
|
||||
|
@ -82,25 +82,14 @@ recoup_refresh_cb (void *cls,
|
||||
struct RecoupRefreshState *rrs = cls;
|
||||
const struct TALER_EXCHANGE_HttpResponse *hr = &rrr->hr;
|
||||
struct TALER_TESTING_Interpreter *is = rrs->is;
|
||||
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
|
||||
char *cref;
|
||||
unsigned int idx;
|
||||
|
||||
rrs->ph = NULL;
|
||||
if (rrs->expected_response_code != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
(int) hr->ec,
|
||||
cmd->label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
fprintf (stderr, "\n");
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
TALER_TESTING_unexpected_status (is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -195,7 +184,11 @@ recoup_refresh_run (void *cls,
|
||||
const struct TALER_ExchangeWithdrawValues *ewv;
|
||||
char *cref;
|
||||
unsigned int idx;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
rrs->is = is;
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_parse_coin_reference (
|
||||
@ -280,7 +273,7 @@ recoup_refresh_run (void *cls,
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Trying to recoup_refresh denomination '%s'\n",
|
||||
TALER_B2S (&denom_pub->h_key));
|
||||
rrs->ph = TALER_EXCHANGE_recoup_refresh (is->exchange,
|
||||
rrs->ph = TALER_EXCHANGE_recoup_refresh (exchange,
|
||||
denom_pub,
|
||||
coin_sig,
|
||||
ewv,
|
||||
|
@ -102,6 +102,11 @@ struct RefreshMeltState
|
||||
*/
|
||||
struct TALER_EXCHANGE_RefreshData refresh_data;
|
||||
|
||||
/**
|
||||
* Our command.
|
||||
*/
|
||||
const struct TALER_TESTING_Command *cmd;
|
||||
|
||||
/**
|
||||
* Reference to a previous melt command.
|
||||
*/
|
||||
@ -209,6 +214,11 @@ struct RefreshRevealState
|
||||
*/
|
||||
struct TALER_EXCHANGE_RefreshesRevealHandle *rrh;
|
||||
|
||||
/**
|
||||
* Our command.
|
||||
*/
|
||||
const struct TALER_TESTING_Command *cmd;
|
||||
|
||||
/**
|
||||
* Convenience struct to keep in one place all the
|
||||
* data related to one fresh coin, set by the reveal callback
|
||||
@ -272,6 +282,11 @@ struct RefreshLinkState
|
||||
*/
|
||||
const char *reveal_reference;
|
||||
|
||||
/**
|
||||
* Our command.
|
||||
*/
|
||||
const struct TALER_TESTING_Command *cmd;
|
||||
|
||||
/**
|
||||
* Handle to the ongoing operation.
|
||||
*/
|
||||
@ -334,8 +349,7 @@ do_reveal_retry (void *cls)
|
||||
struct RefreshRevealState *rrs = cls;
|
||||
|
||||
rrs->retry_task = NULL;
|
||||
rrs->is->commands[rrs->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
TALER_TESTING_touch_cmd (rrs->is);
|
||||
refresh_reveal_run (rrs,
|
||||
NULL,
|
||||
rrs->is);
|
||||
@ -357,8 +371,12 @@ reveal_cb (void *cls,
|
||||
struct RefreshRevealState *rrs = cls;
|
||||
const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr;
|
||||
const struct TALER_TESTING_Command *melt_cmd;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (rrs->is);
|
||||
|
||||
rrs->rrh = NULL;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
if (rrs->expected_response_code != hr->http_status)
|
||||
{
|
||||
if (0 != rrs->do_retry)
|
||||
@ -380,24 +398,15 @@ reveal_cb (void *cls,
|
||||
MAX_BACKOFF);
|
||||
rrs->total_backoff = GNUNET_TIME_relative_add (rrs->total_backoff,
|
||||
rrs->backoff);
|
||||
rrs->is->commands[rrs->is->ip].num_tries++;
|
||||
TALER_TESTING_inc_tries (rrs->is);
|
||||
rrs->retry_task = GNUNET_SCHEDULER_add_delayed (rrs->backoff,
|
||||
&do_reveal_retry,
|
||||
rrs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
(int) hr->ec,
|
||||
rrs->is->commands[rrs->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (rrs->is);
|
||||
TALER_TESTING_unexpected_status (rrs->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
melt_cmd = TALER_TESTING_interpreter_lookup_command (rrs->is,
|
||||
@ -444,9 +453,9 @@ reveal_cb (void *cls,
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Total reveal backoff for %s was %s\n",
|
||||
rrs->is->commands[rrs->is->ip].label,
|
||||
rrs->cmd->label,
|
||||
GNUNET_STRINGS_relative_time_to_string (rrs->total_backoff,
|
||||
GNUNET_YES));
|
||||
true));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -487,7 +496,12 @@ refresh_reveal_run (void *cls,
|
||||
struct RefreshRevealState *rrs = cls;
|
||||
struct RefreshMeltState *rms;
|
||||
const struct TALER_TESTING_Command *melt_cmd;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
rrs->cmd = cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
rrs->is = is;
|
||||
melt_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||
rrs->melt_reference);
|
||||
@ -504,7 +518,7 @@ refresh_reveal_run (void *cls,
|
||||
|
||||
for (unsigned int i = 0; i<rms->num_fresh_coins; i++)
|
||||
alg_values[i] = rms->mbds[i].alg_value;
|
||||
rrs->rrh = TALER_EXCHANGE_refreshes_reveal (is->exchange,
|
||||
rrs->rrh = TALER_EXCHANGE_refreshes_reveal (exchange,
|
||||
&rms->rms,
|
||||
&rms->refresh_data,
|
||||
rms->num_fresh_coins,
|
||||
@ -538,9 +552,7 @@ refresh_reveal_cleanup (void *cls,
|
||||
(void) cmd;
|
||||
if (NULL != rrs->rrh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
rrs->is->ip,
|
||||
TALER_TESTING_command_incomplete (rrs->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_refreshes_reveal_cancel (rrs->rrh);
|
||||
rrs->rrh = NULL;
|
||||
@ -585,8 +597,7 @@ do_link_retry (void *cls)
|
||||
struct RefreshLinkState *rls = cls;
|
||||
|
||||
rls->retry_task = NULL;
|
||||
rls->is->commands[rls->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
TALER_TESTING_touch_cmd (rls->is);
|
||||
refresh_link_run (rls,
|
||||
NULL,
|
||||
rls->is);
|
||||
@ -608,7 +619,6 @@ link_cb (void *cls,
|
||||
struct RefreshLinkState *rls = cls;
|
||||
const struct TALER_EXCHANGE_HttpResponse *hr = &lr->hr;
|
||||
const struct TALER_TESTING_Command *reveal_cmd;
|
||||
struct TALER_TESTING_Command *link_cmd = &rls->is->commands[rls->is->ip];
|
||||
unsigned int found;
|
||||
const unsigned int *num_fresh_coins;
|
||||
|
||||
@ -634,24 +644,15 @@ link_cb (void *cls,
|
||||
MAX_BACKOFF);
|
||||
rls->total_backoff = GNUNET_TIME_relative_add (rls->total_backoff,
|
||||
rls->backoff);
|
||||
rls->is->commands[rls->is->ip].num_tries++;
|
||||
TALER_TESTING_inc_tries (rls->is);
|
||||
rls->retry_task = GNUNET_SCHEDULER_add_delayed (rls->backoff,
|
||||
&do_link_retry,
|
||||
rls);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
(int) hr->ec,
|
||||
link_cmd->label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (rls->is);
|
||||
TALER_TESTING_unexpected_status (rls->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
|
||||
@ -749,9 +750,9 @@ link_cb (void *cls,
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Total link backoff for %s was %s\n",
|
||||
rls->is->commands[rls->is->ip].label,
|
||||
rls->cmd->label,
|
||||
GNUNET_STRINGS_relative_time_to_string (rls->total_backoff,
|
||||
GNUNET_YES));
|
||||
true));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -782,8 +783,12 @@ refresh_link_run (void *cls,
|
||||
const struct TALER_TESTING_Command *reveal_cmd;
|
||||
const struct TALER_TESTING_Command *melt_cmd;
|
||||
const struct TALER_TESTING_Command *coin_cmd;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
rls->cmd = cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
rls->is = is;
|
||||
reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
|
||||
rls->reveal_reference);
|
||||
@ -827,7 +832,7 @@ refresh_link_run (void *cls,
|
||||
}
|
||||
|
||||
/* finally, use private key from withdraw sign command */
|
||||
rls->rlh = TALER_EXCHANGE_link (is->exchange,
|
||||
rls->rlh = TALER_EXCHANGE_link (exchange,
|
||||
coin_priv,
|
||||
rms->refresh_data.melt_age_commitment_proof,
|
||||
&link_cb,
|
||||
@ -857,10 +862,7 @@ refresh_link_cleanup (void *cls,
|
||||
|
||||
if (NULL != rls->rlh)
|
||||
{
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
rls->is->ip,
|
||||
TALER_TESTING_command_incomplete (rls->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_link_cancel (rls->rlh);
|
||||
rls->rlh = NULL;
|
||||
@ -885,8 +887,7 @@ do_melt_retry (void *cls)
|
||||
struct RefreshMeltState *rms = cls;
|
||||
|
||||
rms->retry_task = NULL;
|
||||
rms->is->commands[rms->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
TALER_TESTING_touch_cmd (rms->is);
|
||||
melt_run (rms,
|
||||
NULL,
|
||||
rms->is);
|
||||
@ -907,8 +908,12 @@ melt_cb (void *cls,
|
||||
{
|
||||
struct RefreshMeltState *rms = cls;
|
||||
const struct TALER_EXCHANGE_HttpResponse *hr = &mr->hr;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (rms->is);
|
||||
|
||||
rms->rmh = NULL;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
if (rms->expected_response_code != hr->http_status)
|
||||
{
|
||||
if (0 != rms->do_retry)
|
||||
@ -930,24 +935,15 @@ melt_cb (void *cls,
|
||||
MAX_BACKOFF);
|
||||
rms->total_backoff = GNUNET_TIME_relative_add (rms->total_backoff,
|
||||
rms->backoff);
|
||||
rms->is->commands[rms->is->ip].num_tries++;
|
||||
TALER_TESTING_inc_tries (rms->is);
|
||||
rms->retry_task = GNUNET_SCHEDULER_add_delayed (rms->backoff,
|
||||
&do_melt_retry,
|
||||
rms);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
(int) hr->ec,
|
||||
rms->is->commands[rms->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (rms->is);
|
||||
TALER_TESTING_unexpected_status (rms->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
if (MHD_HTTP_OK == hr->http_status)
|
||||
@ -969,15 +965,15 @@ melt_cb (void *cls,
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Total melt backoff for %s was %s\n",
|
||||
rms->is->commands[rms->is->ip].label,
|
||||
rms->cmd->label,
|
||||
GNUNET_STRINGS_relative_time_to_string (rms->total_backoff,
|
||||
GNUNET_YES));
|
||||
true));
|
||||
}
|
||||
if (rms->double_melt)
|
||||
{
|
||||
TALER_LOG_DEBUG ("Doubling the melt (%s)\n",
|
||||
rms->is->commands[rms->is->ip].label);
|
||||
rms->rmh = TALER_EXCHANGE_melt (rms->is->exchange,
|
||||
rms->cmd->label);
|
||||
rms->rmh = TALER_EXCHANGE_melt (exchange,
|
||||
&rms->rms,
|
||||
&rms->refresh_data,
|
||||
&melt_cb,
|
||||
@ -1008,8 +1004,12 @@ melt_run (void *cls,
|
||||
NULL
|
||||
};
|
||||
const char **melt_fresh_amounts;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
rms->cmd = cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
if (NULL == (melt_fresh_amounts = rms->melt_fresh_amounts))
|
||||
melt_fresh_amounts = default_melt_fresh_amounts;
|
||||
rms->is = is;
|
||||
@ -1113,7 +1113,7 @@ melt_run (void *cls,
|
||||
TALER_TESTING_interpreter_fail (rms->is);
|
||||
return;
|
||||
}
|
||||
fresh_pk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (is->exchange),
|
||||
fresh_pk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (exchange),
|
||||
&fresh_amount,
|
||||
age_restricted);
|
||||
if (NULL == fresh_pk)
|
||||
@ -1149,7 +1149,7 @@ melt_run (void *cls,
|
||||
GNUNET_assert (age_restricted ==
|
||||
(NULL != age_commitment_proof));
|
||||
|
||||
rms->rmh = TALER_EXCHANGE_melt (is->exchange,
|
||||
rms->rmh = TALER_EXCHANGE_melt (exchange,
|
||||
&rms->rms,
|
||||
&rms->refresh_data,
|
||||
&melt_cb,
|
||||
@ -1181,10 +1181,8 @@ melt_cleanup (void *cls,
|
||||
(void) cmd;
|
||||
if (NULL != rms->rmh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
rms->is->ip,
|
||||
rms->is->commands[rms->is->ip].label);
|
||||
TALER_TESTING_command_incomplete (rms->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_melt_cancel (rms->rmh);
|
||||
rms->rmh = NULL;
|
||||
}
|
||||
|
@ -83,23 +83,12 @@ refund_cb (void *cls,
|
||||
{
|
||||
struct RefundState *rs = cls;
|
||||
const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr;
|
||||
struct TALER_TESTING_Command *refund_cmd;
|
||||
|
||||
refund_cmd = &rs->is->commands[rs->is->ip];
|
||||
rs->rh = NULL;
|
||||
if (rs->expected_response_code != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
hr->ec,
|
||||
refund_cmd->label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (rs->is);
|
||||
TALER_TESTING_unexpected_status (rs->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (rs->is);
|
||||
@ -127,17 +116,17 @@ refund_run (void *cls,
|
||||
const struct TALER_MerchantPrivateKeyP *merchant_priv;
|
||||
const struct TALER_TESTING_Command *coin_cmd;
|
||||
|
||||
rs->exchange = is->exchange;
|
||||
rs->exchange = TALER_TESTING_get_exchange (is);
|
||||
if (NULL == rs->exchange)
|
||||
return;
|
||||
rs->is = is;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_string_to_amount (rs->refund_amount,
|
||||
&refund_amount))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to parse amount `%s' at %u/%s\n",
|
||||
"Failed to parse amount `%s' at %s\n",
|
||||
rs->refund_amount,
|
||||
is->ip,
|
||||
cmd->label);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
@ -210,9 +199,7 @@ refund_cleanup (void *cls,
|
||||
|
||||
if (NULL != rs->rh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
rs->is->ip,
|
||||
TALER_TESTING_command_incomplete (rs->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_refund_cancel (rs->rh);
|
||||
rs->rh = NULL;
|
||||
|
@ -152,7 +152,11 @@ attest_run (void *cls,
|
||||
{
|
||||
struct AttestState *ss = cls;
|
||||
const struct TALER_TESTING_Command *create_reserve;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ss->is = is;
|
||||
create_reserve
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -175,7 +179,7 @@ attest_run (void *cls,
|
||||
}
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
|
||||
&ss->reserve_pub.eddsa_pub);
|
||||
ss->rsh = TALER_EXCHANGE_reserves_attest (is->exchange,
|
||||
ss->rsh = TALER_EXCHANGE_reserves_attest (exchange,
|
||||
ss->reserve_priv,
|
||||
ss->attrs_len,
|
||||
ss->attrs,
|
||||
@ -199,9 +203,7 @@ attest_cleanup (void *cls,
|
||||
|
||||
if (NULL != ss->rsh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ss->is->ip,
|
||||
TALER_TESTING_command_incomplete (ss->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_reserves_attest_cancel (ss->rsh);
|
||||
ss->rsh = NULL;
|
||||
|
@ -142,7 +142,11 @@ close_run (void *cls,
|
||||
{
|
||||
struct CloseState *ss = cls;
|
||||
const struct TALER_TESTING_Command *create_reserve;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ss->is = is;
|
||||
create_reserve
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -165,7 +169,7 @@ close_run (void *cls,
|
||||
}
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
|
||||
&ss->reserve_pub.eddsa_pub);
|
||||
ss->rsh = TALER_EXCHANGE_reserves_close (is->exchange,
|
||||
ss->rsh = TALER_EXCHANGE_reserves_close (exchange,
|
||||
ss->reserve_priv,
|
||||
ss->target_account,
|
||||
&reserve_close_cb,
|
||||
@ -188,9 +192,7 @@ close_cleanup (void *cls,
|
||||
|
||||
if (NULL != ss->rsh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ss->is->ip,
|
||||
TALER_TESTING_command_incomplete (ss->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_reserves_close_cancel (ss->rsh);
|
||||
ss->rsh = NULL;
|
||||
|
@ -178,7 +178,11 @@ status_run (void *cls,
|
||||
{
|
||||
struct StatusState *ss = cls;
|
||||
const struct TALER_TESTING_Command *create_reserve;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ss->is = is;
|
||||
create_reserve
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -193,7 +197,7 @@ status_run (void *cls,
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
ss->rsh = TALER_EXCHANGE_reserves_get (is->exchange,
|
||||
ss->rsh = TALER_EXCHANGE_reserves_get (exchange,
|
||||
ss->reserve_pubp,
|
||||
ss->timeout,
|
||||
&reserve_status_cb,
|
||||
@ -221,9 +225,7 @@ status_cleanup (void *cls,
|
||||
|
||||
if (NULL != ss->rsh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ss->is->ip,
|
||||
TALER_TESTING_command_incomplete (ss->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_reserves_get_cancel (ss->rsh);
|
||||
ss->rsh = NULL;
|
||||
|
@ -125,7 +125,11 @@ get_attestable_run (void *cls,
|
||||
const struct TALER_TESTING_Command *ref_reserve;
|
||||
const struct TALER_ReservePrivateKeyP *reserve_priv;
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ss->is = is;
|
||||
ref_reserve
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -158,7 +162,7 @@ get_attestable_run (void *cls,
|
||||
}
|
||||
ss->reserve_pub = *reserve_pub;
|
||||
}
|
||||
ss->rgah = TALER_EXCHANGE_reserves_get_attestable (is->exchange,
|
||||
ss->rgah = TALER_EXCHANGE_reserves_get_attestable (exchange,
|
||||
&ss->reserve_pub,
|
||||
&reserve_get_attestable_cb,
|
||||
ss);
|
||||
@ -180,9 +184,7 @@ get_attestable_cleanup (void *cls,
|
||||
|
||||
if (NULL != ss->rgah)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ss->is->ip,
|
||||
TALER_TESTING_command_incomplete (ss->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_reserves_get_attestable_cancel (ss->rgah);
|
||||
ss->rgah = NULL;
|
||||
|
@ -79,24 +79,55 @@ struct HistoryState
|
||||
|
||||
|
||||
/**
|
||||
* Check if @a cmd changed the reserve, if so, find the
|
||||
* entry in @a history and set the respective index in @a found
|
||||
* to #GNUNET_YES. If the entry is not found, return #GNUNET_SYSERR.
|
||||
*
|
||||
* @param reserve_pub public key of the reserve for which we have the @a history
|
||||
* @param cmd command to analyze for impact on history
|
||||
* @param history_length number of entries in @a history and @a found
|
||||
* @param history history to check
|
||||
* @param[in,out] found array to update
|
||||
* @return #GNUNET_OK if @a cmd action on reserve was found in @a history
|
||||
* Closure for analysis_cb().
|
||||
*/
|
||||
static enum GNUNET_GenericReturnValue
|
||||
analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
unsigned int history_length,
|
||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *history,
|
||||
bool *found)
|
||||
struct AnalysisContext
|
||||
{
|
||||
/**
|
||||
* Reserve public key we are looking at.
|
||||
*/
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||
|
||||
/**
|
||||
* Length of the @e history array.
|
||||
*/
|
||||
unsigned int history_length;
|
||||
|
||||
/**
|
||||
* Array of history items to match.
|
||||
*/
|
||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *history;
|
||||
|
||||
/**
|
||||
* Array of @e history_length of matched entries.
|
||||
*/
|
||||
bool *found;
|
||||
|
||||
/**
|
||||
* Set to true if an entry could not be found.
|
||||
*/
|
||||
bool failure;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Check if @a cmd changed the reserve, if so, find the
|
||||
* entry in our history and set the respective index in found
|
||||
* to true. If the entry is not found, set failure.
|
||||
*
|
||||
* @param cls our `struct AnalysisContext *`
|
||||
* @param cmd command to analyze for impact on history
|
||||
*/
|
||||
static void
|
||||
analyze_command (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct AnalysisContext *ac = cls;
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub = ac->reserve_pub;
|
||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *history = ac->history;
|
||||
unsigned int history_length = ac->history_length;
|
||||
bool *found = ac->found;
|
||||
|
||||
if (TALER_TESTING_cmd_is_batch (cmd))
|
||||
{
|
||||
struct TALER_TESTING_Command *cur;
|
||||
@ -108,28 +139,26 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
&bcmd))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
ac->failure = true;
|
||||
return;
|
||||
}
|
||||
for (unsigned int i = 0; NULL != (*bcmd)[i].label; i++)
|
||||
{
|
||||
struct TALER_TESTING_Command *step = &(*bcmd)[i];
|
||||
|
||||
if (GNUNET_OK !=
|
||||
analyze_command (reserve_pub,
|
||||
step,
|
||||
history_length,
|
||||
history,
|
||||
found))
|
||||
analyze_command (ac,
|
||||
step);
|
||||
if (ac->failure)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Entry for batch step `%s' missing in history\n",
|
||||
step->label);
|
||||
return GNUNET_SYSERR;
|
||||
return;
|
||||
}
|
||||
if (step == cur)
|
||||
break; /* if *we* are in a batch, make sure not to analyze commands past 'now' */
|
||||
}
|
||||
return GNUNET_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
@ -138,11 +167,11 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_reserve_pub (cmd,
|
||||
&rp))
|
||||
return GNUNET_OK; /* command does nothing for reserves */
|
||||
return; /* command does nothing for reserves */
|
||||
if (0 !=
|
||||
GNUNET_memcmp (rp,
|
||||
reserve_pub))
|
||||
return GNUNET_OK; /* command affects some _other_ reserve */
|
||||
return; /* command affects some _other_ reserve */
|
||||
for (unsigned int j = 0; true; j++)
|
||||
{
|
||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
|
||||
@ -156,9 +185,9 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
/* NOTE: only for debugging... */
|
||||
if (0 == j)
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||
"Command `%s' has the reserve_pub trait, but does not reserve history trait\n",
|
||||
"Command `%s' has the reserve_pub, but lacks reserve history trait\n",
|
||||
cmd->label);
|
||||
return GNUNET_OK; /* command does nothing for reserves */
|
||||
return; /* command does nothing for reserves */
|
||||
}
|
||||
for (unsigned int i = 0; i<history_length; i++)
|
||||
{
|
||||
@ -179,7 +208,8 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
"Command `%s' reserve history entry #%u not found\n",
|
||||
cmd->label,
|
||||
j);
|
||||
return GNUNET_SYSERR;
|
||||
ac->failure = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -200,15 +230,19 @@ reserve_history_cb (void *cls,
|
||||
struct HistoryState *ss = cls;
|
||||
struct TALER_TESTING_Interpreter *is = ss->is;
|
||||
struct TALER_Amount eb;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
ss->rsh = NULL;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
if (MHD_HTTP_OK == rs->hr.http_status)
|
||||
{
|
||||
const struct TALER_EXCHANGE_Keys *keys;
|
||||
const struct TALER_EXCHANGE_GlobalFee *gf;
|
||||
|
||||
ss->reserve_history.type = TALER_EXCHANGE_RTT_HISTORY;
|
||||
keys = TALER_EXCHANGE_get_keys (ss->is->exchange);
|
||||
keys = TALER_EXCHANGE_get_keys (exchange);
|
||||
GNUNET_assert (NULL != keys);
|
||||
gf = TALER_EXCHANGE_get_global_fee (keys,
|
||||
rs->ts);
|
||||
@ -254,34 +288,32 @@ reserve_history_cb (void *cls,
|
||||
}
|
||||
{
|
||||
bool found[rs->details.ok.history_len];
|
||||
struct AnalysisContext ac = {
|
||||
.reserve_pub = &ss->reserve_pub,
|
||||
.history = rs->details.ok.history,
|
||||
.history_length = rs->details.ok.history_len,
|
||||
.found = found
|
||||
};
|
||||
|
||||
memset (found,
|
||||
0,
|
||||
sizeof (found));
|
||||
for (unsigned int i = 0; i<= (unsigned int) is->ip; i++)
|
||||
TALER_TESTING_iterate (is,
|
||||
true,
|
||||
&analyze_command,
|
||||
&ac);
|
||||
if (ac.failure)
|
||||
{
|
||||
struct TALER_TESTING_Command *cmd = &is->commands[i];
|
||||
|
||||
if (GNUNET_OK !=
|
||||
analyze_command (&ss->reserve_pub,
|
||||
cmd,
|
||||
rs->details.ok.history_len,
|
||||
rs->details.ok.history,
|
||||
found))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Entry for command `%s' missing in history\n",
|
||||
cmd->label);
|
||||
json_dumpf (rs->hr.reply,
|
||||
stderr,
|
||||
JSON_INDENT (2));
|
||||
TALER_TESTING_interpreter_fail (ss->is);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; i<rs->details.ok.history_len; i++)
|
||||
if (! found[i])
|
||||
{
|
||||
if (found[i])
|
||||
continue;
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"History entry at index %u of type %d not justified by command history\n",
|
||||
i,
|
||||
@ -311,7 +343,11 @@ history_run (void *cls,
|
||||
{
|
||||
struct HistoryState *ss = cls;
|
||||
const struct TALER_TESTING_Command *create_reserve;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ss->is = is;
|
||||
create_reserve
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -333,7 +369,7 @@ history_run (void *cls,
|
||||
}
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
|
||||
&ss->reserve_pub.eddsa_pub);
|
||||
ss->rsh = TALER_EXCHANGE_reserves_history (is->exchange,
|
||||
ss->rsh = TALER_EXCHANGE_reserves_history (exchange,
|
||||
ss->reserve_priv,
|
||||
&reserve_history_cb,
|
||||
ss);
|
||||
@ -388,9 +424,7 @@ history_cleanup (void *cls,
|
||||
|
||||
if (NULL != ss->rsh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ss->is->ip,
|
||||
TALER_TESTING_command_incomplete (ss->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_reserves_history_cancel (ss->rsh);
|
||||
ss->rsh = NULL;
|
||||
|
@ -165,7 +165,11 @@ open_run (void *cls,
|
||||
struct OpenState *ss = cls;
|
||||
const struct TALER_TESTING_Command *create_reserve;
|
||||
struct TALER_EXCHANGE_PurseDeposit cp[GNUNET_NZL (ss->cpl)];
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ss->is = is;
|
||||
create_reserve
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -252,7 +256,7 @@ open_run (void *cls,
|
||||
cpi->h_denom_pub = denom_pub->h_key;
|
||||
}
|
||||
ss->rsh = TALER_EXCHANGE_reserves_open (
|
||||
is->exchange,
|
||||
exchange,
|
||||
ss->reserve_priv,
|
||||
&ss->reserve_pay,
|
||||
ss->cpl,
|
||||
@ -279,9 +283,7 @@ open_cleanup (void *cls,
|
||||
|
||||
if (NULL != ss->rsh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ss->is->ip,
|
||||
TALER_TESTING_command_incomplete (ss->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_reserves_open_cancel (ss->rsh);
|
||||
ss->rsh = NULL;
|
||||
|
@ -153,16 +153,8 @@ purse_cb (void *cls,
|
||||
ds->reserve_sig = *dr->reserve_sig;
|
||||
if (ds->expected_response_code != dr->hr.http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
dr->hr.http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (dr->hr.reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
dr->hr.http_status);
|
||||
return;
|
||||
}
|
||||
switch (dr->hr.http_status)
|
||||
@ -192,8 +184,12 @@ purse_run (void *cls,
|
||||
struct ReservePurseState *ds = cls;
|
||||
const struct TALER_ReservePrivateKeyP *reserve_priv;
|
||||
const struct TALER_TESTING_Command *ref;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ds->is = is;
|
||||
ref = TALER_TESTING_interpreter_lookup_command (ds->is,
|
||||
ds->reserve_ref);
|
||||
@ -221,8 +217,21 @@ purse_run (void *cls,
|
||||
|
||||
{
|
||||
char *payto_uri;
|
||||
const char *exchange_url;
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
|
||||
payto_uri = TALER_reserve_make_payto (is->exchange_url,
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
payto_uri = TALER_reserve_make_payto (exchange_url,
|
||||
&ds->reserve_pub);
|
||||
TALER_payto_hash (payto_uri,
|
||||
&ds->h_payto);
|
||||
@ -236,7 +245,7 @@ purse_run (void *cls,
|
||||
GNUNET_JSON_from_timestamp (ds->purse_expiration)));
|
||||
ds->merge_timestamp = GNUNET_TIME_timestamp_get ();
|
||||
ds->dh = TALER_EXCHANGE_purse_create_with_merge (
|
||||
is->exchange,
|
||||
exchange,
|
||||
&ds->reserve_priv,
|
||||
&ds->purse_priv,
|
||||
&ds->merge_priv,
|
||||
@ -273,9 +282,7 @@ purse_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_purse_create_with_merge_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
@ -69,26 +69,56 @@ struct StatusState
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
};
|
||||
|
||||
/**
|
||||
* Closure for analysis_cb().
|
||||
*/
|
||||
struct AnalysisContext
|
||||
{
|
||||
/**
|
||||
* Reserve public key we are looking at.
|
||||
*/
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||
|
||||
/**
|
||||
* Length of the @e history array.
|
||||
*/
|
||||
unsigned int history_length;
|
||||
|
||||
/**
|
||||
* Array of history items to match.
|
||||
*/
|
||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *history;
|
||||
|
||||
/**
|
||||
* Array of @e history_length of matched entries.
|
||||
*/
|
||||
bool *found;
|
||||
|
||||
/**
|
||||
* Set to true if an entry could not be found.
|
||||
*/
|
||||
bool failure;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Check if @a cmd changed the reserve, if so, find the
|
||||
* entry in @a history and set the respective index in @a found
|
||||
* to #GNUNET_YES. If the entry is not found, return #GNUNET_SYSERR.
|
||||
* entry in our history and set the respective index in found
|
||||
* to true. If the entry is not found, set failure.
|
||||
*
|
||||
* @param reserve_pub public key of the reserve for which we have the @a history
|
||||
* @param cls our `struct AnalysisContext *`
|
||||
* @param cmd command to analyze for impact on history
|
||||
* @param history_length number of entries in @a history and @a found
|
||||
* @param history history to check
|
||||
* @param[in,out] found array to update
|
||||
* @return #GNUNET_OK if @a cmd action on reserve was found in @a history
|
||||
*/
|
||||
static enum GNUNET_GenericReturnValue
|
||||
analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
unsigned int history_length,
|
||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *history,
|
||||
bool *found)
|
||||
static void
|
||||
analyze_command (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct AnalysisContext *ac = cls;
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub = ac->reserve_pub;
|
||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *history = ac->history;
|
||||
unsigned int history_length = ac->history_length;
|
||||
bool *found = ac->found;
|
||||
|
||||
if (TALER_TESTING_cmd_is_batch (cmd))
|
||||
{
|
||||
struct TALER_TESTING_Command *cur;
|
||||
@ -100,7 +130,8 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
&bcmd))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return GNUNET_SYSERR;
|
||||
ac->failure = true;
|
||||
return;
|
||||
}
|
||||
for (unsigned int i = 0; NULL != (*bcmd)[i].label; i++)
|
||||
{
|
||||
@ -108,33 +139,30 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
|
||||
if (step == cur)
|
||||
break; /* if *we* are in a batch, make sure not to analyze commands past 'now' */
|
||||
if (GNUNET_OK !=
|
||||
analyze_command (reserve_pub,
|
||||
step,
|
||||
history_length,
|
||||
history,
|
||||
found))
|
||||
analyze_command (ac,
|
||||
step);
|
||||
if (ac->failure)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Entry for batch step `%s' missing in history\n",
|
||||
step->label);
|
||||
return GNUNET_SYSERR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
return GNUNET_OK;
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
const struct TALER_ReservePublicKeyP *rp;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_reserve_pub (cmd,
|
||||
&rp))
|
||||
return GNUNET_OK; /* command does nothing for reserves */
|
||||
return; /* command does nothing for reserves */
|
||||
if (0 !=
|
||||
GNUNET_memcmp (rp,
|
||||
reserve_pub))
|
||||
return GNUNET_OK; /* command affects some _other_ reserve */
|
||||
return; /* command affects some _other_ reserve */
|
||||
for (unsigned int j = 0; true; j++)
|
||||
{
|
||||
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
|
||||
@ -149,7 +177,7 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||
"Command `%s' has the reserve_pub trait, but does not reserve history trait\n",
|
||||
cmd->label);
|
||||
return GNUNET_OK; /* command does nothing for reserves */
|
||||
return; /* command does nothing for reserves */
|
||||
}
|
||||
for (unsigned int i = 0; i<history_length; i++)
|
||||
{
|
||||
@ -170,7 +198,8 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
"Command `%s' reserve history entry #%u not found\n",
|
||||
cmd->label,
|
||||
j);
|
||||
return GNUNET_SYSERR;
|
||||
ac->failure = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -230,34 +259,32 @@ reserve_status_cb (void *cls,
|
||||
}
|
||||
{
|
||||
bool found[rs->details.ok.history_len];
|
||||
struct AnalysisContext ac = {
|
||||
.reserve_pub = &ss->reserve_pub,
|
||||
.history = rs->details.ok.history,
|
||||
.history_length = rs->details.ok.history_len,
|
||||
.found = found
|
||||
};
|
||||
|
||||
memset (found,
|
||||
0,
|
||||
sizeof (found));
|
||||
for (unsigned int i = 0; i<= (unsigned int) is->ip; i++)
|
||||
TALER_TESTING_iterate (is,
|
||||
true,
|
||||
&analyze_command,
|
||||
&ac);
|
||||
if (ac.failure)
|
||||
{
|
||||
struct TALER_TESTING_Command *cmd = &is->commands[i];
|
||||
|
||||
if (GNUNET_OK !=
|
||||
analyze_command (&ss->reserve_pub,
|
||||
cmd,
|
||||
rs->details.ok.history_len,
|
||||
rs->details.ok.history,
|
||||
found))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Entry for command `%s' missing in history\n",
|
||||
cmd->label);
|
||||
json_dumpf (rs->hr.reply,
|
||||
stderr,
|
||||
JSON_INDENT (2));
|
||||
TALER_TESTING_interpreter_fail (ss->is);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; i<rs->details.ok.history_len; i++)
|
||||
if (! found[i])
|
||||
{
|
||||
if (found[i])
|
||||
continue;
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"History entry at index %u of type %d not justified by command status\n",
|
||||
i,
|
||||
@ -287,7 +314,11 @@ status_run (void *cls,
|
||||
{
|
||||
struct StatusState *ss = cls;
|
||||
const struct TALER_TESTING_Command *create_reserve;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ss->is = is;
|
||||
create_reserve
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -310,7 +341,7 @@ status_run (void *cls,
|
||||
}
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
|
||||
&ss->reserve_pub.eddsa_pub);
|
||||
ss->rsh = TALER_EXCHANGE_reserves_status (is->exchange,
|
||||
ss->rsh = TALER_EXCHANGE_reserves_status (exchange,
|
||||
ss->reserve_priv,
|
||||
&reserve_status_cb,
|
||||
ss);
|
||||
@ -332,9 +363,7 @@ status_cleanup (void *cls,
|
||||
|
||||
if (NULL != ss->rsh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ss->is->ip,
|
||||
TALER_TESTING_command_incomplete (ss->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_reserves_status_cancel (ss->rsh);
|
||||
ss->rsh = NULL;
|
||||
|
@ -78,16 +78,8 @@ success_cb (
|
||||
rs->kh = NULL;
|
||||
if (rs->expected_response_code != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
rs->is->commands[rs->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (rs->is);
|
||||
TALER_TESTING_unexpected_status (rs->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (rs->is);
|
||||
@ -159,7 +151,23 @@ revoke_run (void *cls,
|
||||
const struct TALER_TESTING_Command *coin_cmd;
|
||||
const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
|
||||
struct TALER_MasterSignatureP master_sig;
|
||||
const char *exchange_url;
|
||||
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
}
|
||||
rs->is = is;
|
||||
/* Get denom pub from trait */
|
||||
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -186,13 +194,27 @@ revoke_run (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
const struct TALER_MasterPrivateKeyP *master_priv;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_master_priv (exchange_cmd,
|
||||
&master_priv));
|
||||
TALER_exchange_offline_denomination_revoke_sign (&denom_pub->h_key,
|
||||
&is->master_priv,
|
||||
master_priv,
|
||||
&master_sig);
|
||||
}
|
||||
rs->kh = TALER_EXCHANGE_management_revoke_denomination_key (
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
&denom_pub->h_key,
|
||||
&master_sig,
|
||||
&success_cb,
|
||||
|
@ -78,16 +78,8 @@ success_cb (
|
||||
rs->kh = NULL;
|
||||
if (rs->expected_response_code != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
rs->is->commands[rs->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (rs->is);
|
||||
TALER_TESTING_unexpected_status (rs->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (rs->is);
|
||||
@ -159,7 +151,23 @@ revoke_run (void *cls,
|
||||
const struct TALER_TESTING_Command *coin_cmd;
|
||||
const struct TALER_ExchangePublicKeyP *exchange_pub;
|
||||
struct TALER_MasterSignatureP master_sig;
|
||||
const char *exchange_url;
|
||||
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
}
|
||||
rs->is = is;
|
||||
/* Get sign pub from trait */
|
||||
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||
@ -186,13 +194,27 @@ revoke_run (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
const struct TALER_MasterPrivateKeyP *master_priv;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_master_priv (exchange_cmd,
|
||||
&master_priv));
|
||||
TALER_exchange_offline_signkey_revoke_sign (exchange_pub,
|
||||
&is->master_priv,
|
||||
master_priv,
|
||||
&master_sig);
|
||||
}
|
||||
rs->kh = TALER_EXCHANGE_management_revoke_signing_key (
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
exchange_pub,
|
||||
&master_sig,
|
||||
&success_cb,
|
||||
|
@ -1,197 +0,0 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014-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 testing/testing_api_cmd_rewind.c
|
||||
* @brief command to rewind the instruction pointer.
|
||||
* @author Marcello Stanisci
|
||||
* @author Christian Grothoff
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include "taler_exchange_service.h"
|
||||
#include "taler_testing_lib.h"
|
||||
|
||||
|
||||
/**
|
||||
* State for a "rewind" CMD.
|
||||
*/
|
||||
struct RewindIpState
|
||||
{
|
||||
/**
|
||||
* Instruction pointer to set into the interpreter.
|
||||
*/
|
||||
const char *target_label;
|
||||
|
||||
/**
|
||||
* How many times this set should take place. However, this value lives at
|
||||
* the calling process, and this CMD is only in charge of checking and
|
||||
* decremeting it.
|
||||
*/
|
||||
unsigned int counter;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Seek for the @a target command in @a batch (and rewind to it
|
||||
* if successful).
|
||||
*
|
||||
* @param is the interpreter state (for failures)
|
||||
* @param cmd batch to search for @a target
|
||||
* @param target command to search for
|
||||
* @return #GNUNET_OK on success, #GNUNET_NO if target was not found,
|
||||
* #GNUNET_SYSERR if target is in the future and we failed
|
||||
*/
|
||||
static enum GNUNET_GenericReturnValue
|
||||
seek_batch (struct TALER_TESTING_Interpreter *is,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
const struct TALER_TESTING_Command *target)
|
||||
{
|
||||
unsigned int new_ip;
|
||||
struct TALER_TESTING_Command **batch;
|
||||
struct TALER_TESTING_Command *current;
|
||||
struct TALER_TESTING_Command *icmd;
|
||||
struct TALER_TESTING_Command *match;
|
||||
|
||||
current = TALER_TESTING_cmd_batch_get_current (cmd);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_batch_cmds (cmd,
|
||||
&batch));
|
||||
match = NULL;
|
||||
for (new_ip = 0;
|
||||
NULL != (icmd = &(*batch)[new_ip]);
|
||||
new_ip++)
|
||||
{
|
||||
if (current == target)
|
||||
current = NULL;
|
||||
if (icmd == target)
|
||||
{
|
||||
match = icmd;
|
||||
break;
|
||||
}
|
||||
if (TALER_TESTING_cmd_is_batch (icmd))
|
||||
{
|
||||
int ret = seek_batch (is,
|
||||
icmd,
|
||||
target);
|
||||
if (GNUNET_SYSERR == ret)
|
||||
return GNUNET_SYSERR; /* failure! */
|
||||
if (GNUNET_OK == ret)
|
||||
{
|
||||
match = icmd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NULL == current)
|
||||
{
|
||||
/* refuse to jump forward */
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
if (NULL == match)
|
||||
return GNUNET_NO; /* not found */
|
||||
TALER_TESTING_cmd_batch_set_current (cmd,
|
||||
new_ip);
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the "rewind" CMD.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd command being executed now.
|
||||
* @param is the interpreter state.
|
||||
*/
|
||||
static void
|
||||
rewind_ip_run (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct RewindIpState *ris = cls;
|
||||
const struct TALER_TESTING_Command *target;
|
||||
unsigned int new_ip;
|
||||
|
||||
(void) cmd;
|
||||
if (0 == ris->counter)
|
||||
{
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
return;
|
||||
}
|
||||
target
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
ris->target_label);
|
||||
if (NULL == target)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
ris->counter--;
|
||||
for (new_ip = 0;
|
||||
NULL != is->commands[new_ip].label;
|
||||
new_ip++)
|
||||
{
|
||||
const struct TALER_TESTING_Command *cmd = &is->commands[new_ip];
|
||||
|
||||
if (cmd == target)
|
||||
break;
|
||||
if (TALER_TESTING_cmd_is_batch (cmd))
|
||||
{
|
||||
int ret = seek_batch (is,
|
||||
cmd,
|
||||
target);
|
||||
if (GNUNET_SYSERR == ret)
|
||||
return; /* failure! */
|
||||
if (GNUNET_OK == ret)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (new_ip > (unsigned int) is->ip)
|
||||
{
|
||||
/* refuse to jump forward */
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
is->ip = new_ip - 1; /* -1 because the next function will advance by one */
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
}
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_rewind_ip (const char *label,
|
||||
const char *target_label,
|
||||
unsigned int counter)
|
||||
{
|
||||
struct RewindIpState *ris;
|
||||
|
||||
ris = GNUNET_new (struct RewindIpState);
|
||||
ris->target_label = target_label;
|
||||
ris->counter = counter;
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = ris,
|
||||
.label = label,
|
||||
.run = &rewind_ip_run
|
||||
};
|
||||
|
||||
return cmd;
|
||||
}
|
||||
}
|
211
src/testing/testing_api_cmd_run_fakebank.c
Normal file
211
src/testing/testing_api_cmd_run_fakebank.c
Normal file
@ -0,0 +1,211 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
(C) 2023 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 testing/testing_api_cmd_run_fakebank.c
|
||||
* @brief Command to run fakebank in-process
|
||||
* @author Christian Grothoff
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include "taler_json_lib.h"
|
||||
#include <gnunet/gnunet_curl_lib.h>
|
||||
#include "taler_testing_lib.h"
|
||||
|
||||
/**
|
||||
* State for a "run fakebank" CMD.
|
||||
*/
|
||||
struct RunFakebankState
|
||||
{
|
||||
|
||||
/**
|
||||
* Our interpreter state.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
|
||||
/**
|
||||
* Handle to the fakebank we are running.
|
||||
*/
|
||||
struct TALER_FAKEBANK_Handle *fakebank;
|
||||
|
||||
/**
|
||||
* URL of the bank.
|
||||
*/
|
||||
char *bank_url;
|
||||
|
||||
/**
|
||||
* Currency to use.
|
||||
*/
|
||||
char *currency;
|
||||
|
||||
/**
|
||||
* Data for access control.
|
||||
*/
|
||||
struct TALER_BANK_AuthenticationData ba;
|
||||
|
||||
/**
|
||||
* Port to use.
|
||||
*/
|
||||
uint16_t port;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Run the "get_exchange" command.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command currently being executed.
|
||||
* @param is the interpreter state.
|
||||
*/
|
||||
static void
|
||||
run_fakebank_run (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct RunFakebankState *rfs = cls;
|
||||
|
||||
(void) cmd;
|
||||
rfs->fakebank = TALER_FAKEBANK_start (rfs->port,
|
||||
rfs->currency);
|
||||
if (NULL == rfs->fakebank)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup the state.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command which is being cleaned up.
|
||||
*/
|
||||
static void
|
||||
run_fakebank_cleanup (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct RunFakebankState *rfs = cls;
|
||||
|
||||
if (NULL != rfs->fakebank)
|
||||
{
|
||||
TALER_FAKEBANK_stop (rfs->fakebank);
|
||||
rfs->fakebank = NULL;
|
||||
}
|
||||
GNUNET_free (rfs->ba.wire_gateway_url);
|
||||
GNUNET_free (rfs->bank_url);
|
||||
GNUNET_free (rfs);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Offer internal data to a "run_fakebank" CMD state to other commands.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param[out] ret result (could be anything)
|
||||
* @param trait name of the trait
|
||||
* @param index index number of the object to offer.
|
||||
* @return #GNUNET_OK on success
|
||||
*/
|
||||
static enum GNUNET_GenericReturnValue
|
||||
run_fakebank_traits (void *cls,
|
||||
const void **ret,
|
||||
const char *trait,
|
||||
unsigned int index)
|
||||
{
|
||||
struct RunFakebankState *rfs = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_bank_auth_data (&rfs->ba),
|
||||
TALER_TESTING_make_trait_fakebank (rfs->fakebank),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
return TALER_TESTING_get_trait (traits,
|
||||
ret,
|
||||
trait,
|
||||
index);
|
||||
}
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_run_fakebank (
|
||||
const char *label,
|
||||
const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
const char *exchange_account_section)
|
||||
{
|
||||
struct RunFakebankState *rfs;
|
||||
unsigned long long fakebank_port;
|
||||
char *exchange_payto_uri;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_number (cfg,
|
||||
"BANK",
|
||||
"HTTP_PORT",
|
||||
&fakebank_port))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||
"BANK",
|
||||
"HTTP_PORT");
|
||||
GNUNET_assert (0);
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||
exchange_account_section,
|
||||
"PAYTO_URI",
|
||||
&exchange_payto_uri))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||
exchange_account_section,
|
||||
"PAYTO_URI");
|
||||
GNUNET_assert (0);
|
||||
}
|
||||
rfs = GNUNET_new (struct RunFakebankState);
|
||||
rfs->port = (uint16_t) fakebank_port;
|
||||
GNUNET_asprintf (&rfs->bank_url,
|
||||
"http://localhost:%u/",
|
||||
(unsigned int) rfs->port);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_config_get_currency (cfg,
|
||||
&rfs->currency));
|
||||
{
|
||||
char *exchange_xtalerbank_account;
|
||||
|
||||
exchange_xtalerbank_account
|
||||
= TALER_xtalerbank_account_from_payto (exchange_payto_uri);
|
||||
GNUNET_assert (NULL != exchange_xtalerbank_account);
|
||||
GNUNET_asprintf (&rfs->ba.wire_gateway_url,
|
||||
"http://localhost:%u/%s/",
|
||||
(unsigned int) fakebank_port,
|
||||
exchange_xtalerbank_account);
|
||||
GNUNET_free (exchange_xtalerbank_account);
|
||||
}
|
||||
rfs->ba.method = TALER_BANK_AUTH_NONE;
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = rfs,
|
||||
.label = label,
|
||||
.run = &run_fakebank_run,
|
||||
.cleanup = &run_fakebank_cleanup,
|
||||
.traits = &run_fakebank_traits,
|
||||
.name = "fakebank"
|
||||
};
|
||||
|
||||
return cmd;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
(C) 2018 Taler Systems SA
|
||||
(C) 2018-2023 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
|
||||
@ -45,35 +45,6 @@ struct SerializeKeysState
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Internal state for a connect-with-state CMD.
|
||||
*/
|
||||
struct ConnectWithStateState
|
||||
{
|
||||
|
||||
/**
|
||||
* Reference to a CMD that offers a serialized key-state
|
||||
* that will be used in the reconnection.
|
||||
*/
|
||||
const char *state_reference;
|
||||
|
||||
/**
|
||||
* If set to GNUNET_YES, then the /keys callback has already
|
||||
* been passed the control to the next CMD. This is necessary
|
||||
* because it is not uncommon that the /keys callback gets
|
||||
* invoked multiple times, and without this flag, we would keep
|
||||
* going "next" CMD upon every invocation (causing impredictable
|
||||
* behaviour as for the instruction pointer.)
|
||||
*/
|
||||
unsigned int consumed;
|
||||
|
||||
/**
|
||||
* Interpreter state.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Run the command.
|
||||
*
|
||||
@ -87,16 +58,20 @@ serialize_keys_run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct SerializeKeysState *sks = cls;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
sks->keys = TALER_EXCHANGE_serialize_data (is->exchange);
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
sks->keys = TALER_EXCHANGE_serialize_data (exchange);
|
||||
if (NULL == sks->keys)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
|
||||
sks->exchange_url = GNUNET_strdup
|
||||
(TALER_EXCHANGE_get_base_url (is->exchange));
|
||||
TALER_EXCHANGE_disconnect (is->exchange);
|
||||
is->exchange = NULL;
|
||||
is->working = GNUNET_NO;
|
||||
}
|
||||
sks->exchange_url
|
||||
= GNUNET_strdup (
|
||||
TALER_EXCHANGE_get_base_url (exchange));
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
}
|
||||
|
||||
@ -114,9 +89,7 @@ serialize_keys_cleanup (void *cls,
|
||||
struct SerializeKeysState *sks = cls;
|
||||
|
||||
if (NULL != sks->keys)
|
||||
{
|
||||
json_decref (sks->keys);
|
||||
}
|
||||
GNUNET_free (sks->exchange_url);
|
||||
GNUNET_free (sks);
|
||||
}
|
||||
@ -140,8 +113,7 @@ serialize_keys_traits (void *cls,
|
||||
struct SerializeKeysState *sks = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_exchange_keys (sks->keys),
|
||||
TALER_TESTING_make_trait_exchange_url (
|
||||
(const char **) &sks->exchange_url),
|
||||
TALER_TESTING_make_trait_exchange_url (sks->exchange_url),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
@ -152,87 +124,6 @@ serialize_keys_traits (void *cls,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the command.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command to execute.
|
||||
* @param is the interpreter state.
|
||||
*/
|
||||
static void
|
||||
connect_with_state_run (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct ConnectWithStateState *cwss = cls;
|
||||
const struct TALER_TESTING_Command *state_cmd;
|
||||
const json_t *serialized_keys;
|
||||
const char **exchange_url;
|
||||
|
||||
/* This command usually gets rescheduled after serialized
|
||||
* reconnection. */
|
||||
if (GNUNET_YES == cwss->consumed)
|
||||
{
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
return;
|
||||
}
|
||||
|
||||
cwss->is = is;
|
||||
state_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||
cwss->state_reference);
|
||||
|
||||
/* Command providing serialized keys not found. */
|
||||
if (NULL == state_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_keys (state_cmd,
|
||||
&serialized_keys));
|
||||
{
|
||||
char *dump;
|
||||
|
||||
dump = json_dumps (serialized_keys,
|
||||
JSON_INDENT (1));
|
||||
TALER_LOG_DEBUG ("Serialized key-state: %s\n",
|
||||
dump);
|
||||
free (dump);
|
||||
}
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (state_cmd,
|
||||
&exchange_url));
|
||||
is->exchange = TALER_EXCHANGE_connect (is->ctx,
|
||||
*exchange_url,
|
||||
&TALER_TESTING_cert_cb,
|
||||
cwss,
|
||||
TALER_EXCHANGE_OPTION_DATA,
|
||||
serialized_keys,
|
||||
TALER_EXCHANGE_OPTION_END);
|
||||
cwss->consumed = GNUNET_YES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup the state of a "connect with state" CMD. Just
|
||||
* a placeholder to avoid jumping on an invalid address.
|
||||
*
|
||||
* @param cls closure.
|
||||
* @param cmd the command which is being cleaned up.
|
||||
*/
|
||||
static void
|
||||
connect_with_state_cleanup (void *cls,
|
||||
const struct TALER_TESTING_Command *cmd)
|
||||
{
|
||||
struct ConnectWithStateState *cwss = cls;
|
||||
|
||||
GNUNET_free (cwss);
|
||||
}
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_serialize_keys (const char *label)
|
||||
{
|
||||
@ -251,25 +142,3 @@ TALER_TESTING_cmd_serialize_keys (const char *label)
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct TALER_TESTING_Command
|
||||
TALER_TESTING_cmd_connect_with_state (const char *label,
|
||||
const char *state_reference)
|
||||
{
|
||||
struct ConnectWithStateState *cwss;
|
||||
|
||||
cwss = GNUNET_new (struct ConnectWithStateState);
|
||||
cwss->state_reference = state_reference;
|
||||
cwss->consumed = GNUNET_NO;
|
||||
{
|
||||
struct TALER_TESTING_Command cmd = {
|
||||
.cls = cwss,
|
||||
.label = label,
|
||||
.run = connect_with_state_run,
|
||||
.cleanup = connect_with_state_cleanup
|
||||
};
|
||||
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
@ -97,16 +97,8 @@ set_officer_cb (void *cls,
|
||||
ds->dh = NULL;
|
||||
if (MHD_HTTP_NO_CONTENT != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -128,8 +120,24 @@ set_officer_run (void *cls,
|
||||
struct SetOfficerState *ds = cls;
|
||||
struct GNUNET_TIME_Timestamp now;
|
||||
struct TALER_MasterSignatureP master_sig;
|
||||
const char *exchange_url;
|
||||
|
||||
(void) cmd;
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
}
|
||||
now = GNUNET_TIME_timestamp_get ();
|
||||
ds->is = is;
|
||||
if (NULL == ds->ref_cmd)
|
||||
@ -161,16 +169,33 @@ set_officer_run (void *cls,
|
||||
ds->officer_pub = *officer_pub;
|
||||
ds->officer_priv = *officer_priv;
|
||||
}
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
const struct TALER_MasterPrivateKeyP *master_priv;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_master_priv (exchange_cmd,
|
||||
&master_priv));
|
||||
|
||||
TALER_exchange_offline_aml_officer_status_sign (&ds->officer_pub,
|
||||
ds->name,
|
||||
now,
|
||||
ds->is_active,
|
||||
ds->read_only,
|
||||
&is->master_priv,
|
||||
master_priv,
|
||||
&master_sig);
|
||||
}
|
||||
ds->dh = TALER_EXCHANGE_management_update_aml_officer (
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
&ds->officer_pub,
|
||||
ds->name,
|
||||
now,
|
||||
@ -203,9 +228,7 @@ set_officer_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_management_update_aml_officer_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
@ -234,7 +257,7 @@ set_officer_traits (void *cls,
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_officer_pub (&ws->officer_pub),
|
||||
TALER_TESTING_make_trait_officer_priv (&ws->officer_priv),
|
||||
TALER_TESTING_make_trait_officer_name (&ws->name),
|
||||
TALER_TESTING_make_trait_officer_name (ws->name),
|
||||
TALER_TESTING_trait_end ()
|
||||
};
|
||||
|
||||
|
@ -89,16 +89,8 @@ wire_add_cb (void *cls,
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != hr->http_status)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Unexpected response code %u to command %s in %s:%u\n",
|
||||
hr->http_status,
|
||||
ds->is->commands[ds->is->ip].label,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
json_dumpf (hr->reply,
|
||||
stderr,
|
||||
0);
|
||||
TALER_TESTING_interpreter_fail (ds->is);
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
hr->http_status);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -123,8 +115,24 @@ wire_add_run (void *cls,
|
||||
struct GNUNET_TIME_Timestamp start_time;
|
||||
struct GNUNET_TIME_Timestamp end_time;
|
||||
struct TALER_WireFeeSet fees;
|
||||
const char *exchange_url;
|
||||
|
||||
(void) cmd;
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
|
||||
&exchange_url));
|
||||
}
|
||||
ds->is = is;
|
||||
now = GNUNET_TIME_absolute_get ();
|
||||
start_time = GNUNET_TIME_absolute_to_timestamp (
|
||||
@ -153,16 +161,30 @@ wire_add_run (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
const struct TALER_TESTING_Command *exchange_cmd;
|
||||
const struct TALER_MasterPrivateKeyP *master_priv;
|
||||
|
||||
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
|
||||
"exchange");
|
||||
if (NULL == exchange_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_master_priv (exchange_cmd,
|
||||
&master_priv));
|
||||
TALER_exchange_offline_wire_fee_sign (ds->wire_method,
|
||||
start_time,
|
||||
end_time,
|
||||
&fees,
|
||||
&is->master_priv,
|
||||
master_priv,
|
||||
&master_sig);
|
||||
}
|
||||
ds->dh = TALER_EXCHANGE_management_set_wire_fees (
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
ds->wire_method,
|
||||
start_time,
|
||||
end_time,
|
||||
@ -194,9 +216,7 @@ wire_add_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_management_set_wire_fees_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user