Merge branch 'master' into age-withdraw

This commit is contained in:
Özgür Kesim 2023-06-10 11:07:06 +02:00
commit 70bfe0ed1b
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
117 changed files with 5699 additions and 5816 deletions

@ -1 +1 @@
Subproject commit f9ea79a6aae074928f44960f69bc3c2d0c9c7e1d Subproject commit 5f377301db4d94c485422ecda277fe850e29504a

View File

@ -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 # What is the Web site of the auditor (i.e. to file complaints about
# a misbehaving exchange)? # a misbehaving exchange)?
# BASE_URL = https://auditor.taler.net/ BASE_URL = http://localhost:8083/
# Network configuration for the normal API/service HTTP server # Network configuration for the normal API/service HTTP server

View File

@ -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 rh context of the handler
* @param connection the MHD connection to handle * @param connection the MHD connection to handle
@ -142,11 +142,11 @@ handle_mhd_completion_callback (void *cls,
* @return MHD result code * @return MHD result code
*/ */
static MHD_RESULT static MHD_RESULT
handle_version (struct TAH_RequestHandler *rh, handle_config (struct TAH_RequestHandler *rh,
struct MHD_Connection *connection, struct MHD_Connection *connection,
void **connection_cls, void **connection_cls,
const char *upload_data, const char *upload_data,
size_t *upload_data_size) size_t *upload_data_size)
{ {
static json_t *ver; /* we build the response only once, keep around for next query! */ static json_t *ver; /* we build the response only once, keep around for next query! */
@ -207,9 +207,9 @@ handle_mhd_request (void *cls,
{ "/exchanges", MHD_HTTP_METHOD_GET, "application/json", { "/exchanges", MHD_HTTP_METHOD_GET, "application/json",
NULL, 0, NULL, 0,
&TAH_EXCHANGES_handler, MHD_HTTP_OK }, &TAH_EXCHANGES_handler, MHD_HTTP_OK },
{ "/version", MHD_HTTP_METHOD_GET, "application/json", { "/config", MHD_HTTP_METHOD_GET, "application/json",
NULL, 0, NULL, 0,
&handle_version, MHD_HTTP_OK }, &handle_config, MHD_HTTP_OK },
/* Landing page, for now tells humans to go away /* Landing page, for now tells humans to go away
* (NOTE: ideally, the reverse proxy will respond with a nicer page) */ * (NOTE: ideally, the reverse proxy will respond with a nicer page) */
{ "/", MHD_HTTP_METHOD_GET, "text/plain", { "/", MHD_HTTP_METHOD_GET, "text/plain",

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
# This file is in the public domain.
set -eu set -eu

View File

@ -12,11 +12,9 @@ endif
bin_PROGRAMS = \ bin_PROGRAMS = \
taler-aggregator-benchmark \ taler-aggregator-benchmark \
taler-bank-benchmark \ taler-bank-benchmark
taler-exchange-benchmark
bin_SCRIPTS = \ # taler-exchange-benchmark
taler-benchmark-setup.sh
taler_aggregator_benchmark_SOURCES = \ taler_aggregator_benchmark_SOURCES = \
@ -75,5 +73,4 @@ EXTRA_DIST = \
bank-benchmark-rsa.conf \ bank-benchmark-rsa.conf \
coins-cs.conf \ coins-cs.conf \
coins-rsa.conf \ coins-rsa.conf \
$(bin_SCRIPTS) \
exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv

View File

@ -58,11 +58,11 @@ MAX_DEBT_BANK=EUR:1000000000000000.0
DATABASE=bank-db.sqlite3 DATABASE=bank-db.sqlite3
[libeufin-nexus] [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" DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
[libeufin-sandbox] [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" DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
[auditor] [auditor]

View File

@ -322,11 +322,8 @@ launch_clients (void)
if (1 == howmany_clients) if (1 == howmany_clients)
{ {
/* do everything in this process */ /* do everything in this process */
result = TALER_TESTING_setup (&run, result = TALER_TESTING_loop (&run,
NULL, NULL);
cfg,
NULL,
GNUNET_NO);
if (verbose) if (verbose)
print_stats (); print_stats ();
return result; return result;
@ -340,11 +337,8 @@ launch_clients (void)
GNUNET_log_setup ("benchmark-worker", GNUNET_log_setup ("benchmark-worker",
NULL == loglev ? "INFO" : loglev, NULL == loglev ? "INFO" : loglev,
logfile); logfile);
result = TALER_TESTING_setup (&run, result = TALER_TESTING_loop (&run,
NULL, NULL);
cfg,
NULL,
GNUNET_NO);
if (verbose) if (verbose)
print_stats (); print_stats ();
if (GNUNET_OK != result) if (GNUNET_OK != result)

View File

@ -85,11 +85,6 @@ enum BenchmarkMode
*/ */
static const struct TALER_EXCHANGEDB_AccountInfo *exchange_bank_account; 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. * Hold information about a user at the bank.
*/ */
@ -146,11 +141,6 @@ static unsigned int refresh_rate = 10;
*/ */
static unsigned int howmany_clients = 1; static unsigned int howmany_clients = 1;
/**
* Bank configuration to use.
*/
static struct TALER_TESTING_BankConfiguration bc;
/** /**
* Log level used during the run. * 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 * Run the benchmark in parallel in many (client) processes
* and summarize result. * and summarize result.
@ -531,148 +482,6 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
pid_t cpids[howmany_clients]; pid_t cpids[howmany_clients];
pid_t fakebank = -1; pid_t fakebank = -1;
int wstatus; 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) if (MODE_CLIENT == mode)
{ {
@ -710,58 +519,16 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to detect running exchange at `%s'\n", "Failed to detect running exchange at `%s'\n",
ec.exchange_url); 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; return 77;
} }
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) ) 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 (); start_time = GNUNET_TIME_absolute_get ();
result = GNUNET_OK; result = GNUNET_OK;
if (1 == howmany_clients) if (1 == howmany_clients)
{ {
result = TALER_TESTING_setup (main_cb, result = TALER_TESTING_run (main_cb,
main_cb_cls, main_cb_cls);
cfg,
exchanged,
GNUNET_YES);
print_stats (); print_stats ();
} }
else else
@ -775,11 +542,8 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
NULL == loglev ? "INFO" : loglev, NULL == loglev ? "INFO" : loglev,
logfile); logfile);
result = TALER_TESTING_setup (main_cb, result = TALER_TESTING_run (main_cb,
main_cb_cls, main_cb_cls);
cfg,
exchanged,
GNUNET_YES);
print_stats (); print_stats ();
if (GNUNET_OK != result) if (GNUNET_OK != result)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@ -845,58 +609,6 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
GNUNET_OS_process_destroy (exchange_slave); 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; return result;
} }
@ -1066,39 +778,8 @@ main (int argc,
GNUNET_free (cfg_filename); GNUNET_free (cfg_filename);
return BAD_CONFIG_FILE; 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 != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, GNUNET_CONFIGURATION_get_value_string (cfg,
"benchmark-remote-exchange", "benchmark-remote-exchange",

View File

@ -3,10 +3,10 @@
[exchange-offline] [exchange-offline]
# Where do we store the offline master private key of the exchange? # 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? # 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. # Base32-encoded public key of the RSA helper.
# SECM_DENOM_PUBKEY = # SECM_DENOM_PUBKEY =

View File

@ -154,6 +154,7 @@ struct TALER_AUDITOR_HttpResponse
* @param vi basic information about the auditor * @param vi basic information about the auditor
* @param compat protocol compatibility information * @param compat protocol compatibility information
*/ */
// FIXME: bad API!
typedef void typedef void
(*TALER_AUDITOR_VersionCallback) ( (*TALER_AUDITOR_VersionCallback) (
void *cls, void *cls,

View File

@ -5873,7 +5873,7 @@ TALER_age_commitment_hash (
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
TALER_age_restriction_commit ( TALER_age_restriction_commit (
const struct TALER_AgeMask *mask, const struct TALER_AgeMask *mask,
const uint8_t age, uint8_t age,
const struct GNUNET_HashCode *seed, const struct GNUNET_HashCode *seed,
struct TALER_AgeCommitmentProof *comm_proof); struct TALER_AgeCommitmentProof *comm_proof);

View File

@ -623,15 +623,20 @@ enum TALER_EXCHANGE_CheckKeysFlags
/** /**
* Check if our current response for /keys is valid, and if * 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 exchange exchange to check keys for
* @param flags options controlling when to download what * @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 * @return until when the existing response is current, 0 if we are re-downloading now
*/ */
struct GNUNET_TIME_Timestamp struct GNUNET_TIME_Timestamp
TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange, 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);
/** /**

View File

@ -219,12 +219,12 @@ struct TALER_Extensions
* Generic functions for extensions * Generic functions for extensions
*/ */
/* /**
* @brief Loads the extensions as shared libraries, as specified in the given * @brief Loads the extensions as shared libraries, as specified in the given
* TALER configuration. * TALER configuration.
* *
* @param cfg Handle to the 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. * or any particular configuration couldn't be parsed.
*/ */
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue

File diff suppressed because it is too large Load Diff

View File

@ -102,7 +102,7 @@ struct TALER_AUDITOR_Handle
void *version_cb_cls; 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. * NULL once we are past stage #MHS_INIT.
*/ */
struct GNUNET_CURL_Job *vr; struct GNUNET_CURL_Job *vr;
@ -113,12 +113,12 @@ struct TALER_AUDITOR_Handle
char *vr_url; char *vr_url;
/** /**
* Task for retrying /version request. * Task for retrying /config request.
*/ */
struct GNUNET_SCHEDULER_Task *retry_task; 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. * @e handshake_complete is past stage #MHS_VERSION.
*/ */
char *version; char *version;
@ -129,7 +129,7 @@ struct TALER_AUDITOR_Handle
struct TALER_AUDITOR_VersionInformation vi; struct TALER_AUDITOR_VersionInformation vi;
/** /**
* Retry /version frequency. * Retry /config frequency.
*/ */
struct GNUNET_TIME_Relative retry_delay; 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. * in the @a key_data.
* *
* @param[in] resp_obj JSON object to parse * @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 static void
request_version (void *cls); 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. * is complete.
* *
* @param cls the `struct TALER_AUDITOR_Handle` * @param cls the `struct TALER_AUDITOR_Handle`
@ -267,7 +267,7 @@ version_completed_cb (void *cls,
if (NULL == resp_obj) if (NULL == resp_obj)
{ {
GNUNET_break_op (0); 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.http_status = 0;
hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break; break;
@ -295,7 +295,7 @@ version_completed_cb (void *cls,
if (MHD_HTTP_OK != response_code) if (MHD_HTTP_OK != response_code)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"/version failed for auditor %s: %u!\n", "/config failed for auditor %s: %u!\n",
auditor->url, auditor->url,
(unsigned int) response_code); (unsigned int) response_code);
auditor->state = MHS_FAILED; auditor->state = MHS_FAILED;
@ -309,7 +309,7 @@ version_completed_cb (void *cls,
TALER_LOG_DEBUG ("Switching auditor state to 'version'\n"); TALER_LOG_DEBUG ("Switching auditor state to 'version'\n");
auditor->state = MHS_VERSION; auditor->state = MHS_VERSION;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Auditor %s is now READY!\n", "Auditor %s is ready!\n",
auditor->url); auditor->url);
/* notify application about the key information */ /* notify application about the key information */
auditor->version_cb (auditor->version_cb_cls, 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 static void
request_version (void *cls) request_version (void *cls)
@ -406,7 +406,7 @@ TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx,
auditor->ctx = ctx; auditor->ctx = ctx;
auditor->url = GNUNET_strdup (url); auditor->url = GNUNET_strdup (url);
auditor->vr_url = TALER_AUDITOR_path_to_url_ (auditor, auditor->vr_url = TALER_AUDITOR_path_to_url_ (auditor,
"/version"); "/config");
if (NULL == auditor->vr_url) if (NULL == auditor->vr_url)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -1268,14 +1268,24 @@ TALER_EXCHANGE_set_last_denom (struct TALER_EXCHANGE_Handle *exchange,
struct GNUNET_TIME_Timestamp struct GNUNET_TIME_Timestamp
TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange, 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 force_download = 0 != (flags & TALER_EXCHANGE_CKF_FORCE_DOWNLOAD);
bool pull_all_keys = 0 != (flags & TALER_EXCHANGE_CKF_PULL_ALL_KEYS); 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) if (NULL != exchange->kr)
return GNUNET_TIME_UNIT_ZERO_TS; return GNUNET_TIME_UNIT_ZERO_TS;
if (pull_all_keys) if (pull_all_keys)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@ -2269,7 +2279,9 @@ const struct TALER_EXCHANGE_Keys *
TALER_EXCHANGE_get_keys (struct TALER_EXCHANGE_Handle *exchange) TALER_EXCHANGE_get_keys (struct TALER_EXCHANGE_Handle *exchange)
{ {
(void) TALER_EXCHANGE_check_keys_current (exchange, (void) TALER_EXCHANGE_check_keys_current (exchange,
TALER_EXCHANGE_CKF_NONE); TALER_EXCHANGE_CKF_NONE,
NULL,
NULL);
return &exchange->key_data; return &exchange->key_data;
} }
@ -2278,7 +2290,9 @@ json_t *
TALER_EXCHANGE_get_keys_raw (struct TALER_EXCHANGE_Handle *exchange) TALER_EXCHANGE_get_keys_raw (struct TALER_EXCHANGE_Handle *exchange)
{ {
(void) TALER_EXCHANGE_check_keys_current (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); return json_deep_copy (exchange->key_data_raw);
} }

View File

@ -46,3 +46,12 @@ test_exchange_api_twisted_cs
test_exchange_api_twisted_rsa test_exchange_api_twisted_rsa
test_exchange_p2p_cs test_exchange_p2p_cs
test_exchange_p2p_rsa 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/

View File

@ -13,6 +13,9 @@ endif
clean-local: clean-local:
rm -rf report* rm -rf report*
bin_SCRIPTS = \
taler-unified-setup.sh
# Libraries # Libraries
lib_LTLIBRARIES = \ lib_LTLIBRARIES = \
@ -54,11 +57,11 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_batch.c \ testing_api_cmd_batch.c \
testing_api_cmd_batch_deposit.c \ testing_api_cmd_batch_deposit.c \
testing_api_cmd_batch_withdraw.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_decision.c \
testing_api_cmd_check_aml_decisions.c \ testing_api_cmd_check_aml_decisions.c \
testing_api_cmd_check_keys.c \ testing_api_cmd_check_keys.c \
testing_api_cmd_common.c \ testing_api_cmd_common.c \
testing_api_cmd_connect_with_state.c \
testing_api_cmd_contract_get.c \ testing_api_cmd_contract_get.c \
testing_api_cmd_deposit.c \ testing_api_cmd_deposit.c \
testing_api_cmd_deposits_get.c \ testing_api_cmd_deposits_get.c \
@ -70,6 +73,8 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_exec_transfer.c \ testing_api_cmd_exec_transfer.c \
testing_api_cmd_exec_wget.c \ testing_api_cmd_exec_wget.c \
testing_api_cmd_exec_wirewatch.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_insert_deposit.c \
testing_api_cmd_kyc_check_get.c \ testing_api_cmd_kyc_check_get.c \
testing_api_cmd_kyc_proof.c \ testing_api_cmd_kyc_proof.c \
@ -85,7 +90,6 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_purse_deposit.c \ testing_api_cmd_purse_deposit.c \
testing_api_cmd_purse_get.c \ testing_api_cmd_purse_get.c \
testing_api_cmd_purse_merge.c \ testing_api_cmd_purse_merge.c \
testing_api_cmd_set_wire_fee.c \
testing_api_cmd_recoup.c \ testing_api_cmd_recoup.c \
testing_api_cmd_recoup_refresh.c \ testing_api_cmd_recoup_refresh.c \
testing_api_cmd_refund.c \ testing_api_cmd_refund.c \
@ -101,12 +105,14 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_revoke.c \ testing_api_cmd_revoke.c \
testing_api_cmd_revoke_denom_key.c \ testing_api_cmd_revoke_denom_key.c \
testing_api_cmd_revoke_sign_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_serialize_keys.c \
testing_api_cmd_set_officer.c \ testing_api_cmd_set_officer.c \
testing_api_cmd_set_wire_fee.c \
testing_api_cmd_signal.c \ testing_api_cmd_signal.c \
testing_api_cmd_sleep.c \ testing_api_cmd_sleep.c \
testing_api_cmd_stat.c \ testing_api_cmd_stat.c \
testing_api_cmd_system_start.c \
testing_api_cmd_take_aml_decision.c \ testing_api_cmd_take_aml_decision.c \
testing_api_cmd_transfer_get.c \ testing_api_cmd_transfer_get.c \
testing_api_cmd_wait.c \ testing_api_cmd_wait.c \
@ -114,14 +120,15 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_wire_add.c \ testing_api_cmd_wire_add.c \
testing_api_cmd_wire_del.c \ testing_api_cmd_wire_del.c \
testing_api_cmd_withdraw.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_loop.c \
testing_api_misc.c \
testing_api_traits.c testing_api_traits.c
libtalertesting_la_LIBADD = \ libtalertesting_la_LIBADD = \
$(top_builddir)/src/lib/libtalerauditor.la \ $(top_builddir)/src/lib/libtalerauditor.la \
$(top_builddir)/src/lib/libtalerexchange.la \ $(top_builddir)/src/lib/libtalerexchange.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
$(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/mhd/libtalermhd.la \ $(top_builddir)/src/mhd/libtalermhd.la \
$(top_builddir)/src/util/libtalerutil.la \ $(top_builddir)/src/util/libtalerutil.la \
@ -140,15 +147,16 @@ libtalertesting_la_LIBADD = \
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; 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: .NOTPARALLEL:
check_PROGRAMS = \ check_PROGRAMS = \
test_auditor_api_cs \ test_auditor_api_cs \
test_auditor_api_rsa \ test_auditor_api_rsa \
test_auditor_api_version_rsa \ test_auditor_api_version \
test_auditor_api_version_cs \
test_bank_api_with_fakebank \ test_bank_api_with_fakebank \
test_bank_api_with_nexus \
test_exchange_api_cs \ test_exchange_api_cs \
test_exchange_api_rsa \ test_exchange_api_rsa \
test_exchange_api_keys_cherry_picking_cs \ test_exchange_api_keys_cherry_picking_cs \
@ -211,22 +219,9 @@ test_auditor_api_rsa_LDADD = \
$(XLIB) $(XLIB)
test_auditor_api_version_cs_SOURCES = \ test_auditor_api_version_SOURCES = \
test_auditor_api_version.c test_auditor_api_version.c
test_auditor_api_version_cs_LDADD = \ test_auditor_api_version_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 = \
libtalertesting.la \ libtalertesting.la \
$(top_builddir)/src/lib/libtalerauditor.la \ $(top_builddir)/src/lib/libtalerauditor.la \
$(LIBGCRYPT_LIBS) \ $(LIBGCRYPT_LIBS) \
@ -241,7 +236,7 @@ test_bank_api_with_nexus_SOURCES = \
test_bank_api.c test_bank_api.c
test_bank_api_with_nexus_LDADD = \ test_bank_api_with_nexus_LDADD = \
libtalertesting.la \ libtalertesting.la \
-ltalerexchange \ $(top_builddir)/src/lib/libtalerexchange.la \
-lgnunetutil \ -lgnunetutil \
$(top_builddir)/src/bank-lib/libtalerbank.la \ $(top_builddir)/src/bank-lib/libtalerbank.la \
$(XLIB) $(XLIB)
@ -250,7 +245,7 @@ test_bank_api_with_fakebank_SOURCES = \
test_bank_api.c test_bank_api.c
test_bank_api_with_fakebank_LDADD = \ test_bank_api_with_fakebank_LDADD = \
libtalertesting.la \ libtalertesting.la \
-ltalerexchange \ $(top_builddir)/src/lib/libtalerexchange.la \
-lgnunetutil \ -lgnunetutil \
$(top_builddir)/src/bank-lib/libtalerbank.la \ $(top_builddir)/src/bank-lib/libtalerbank.la \
$(XLIB) $(XLIB)
@ -542,10 +537,14 @@ test_kyc_api_LDADD = \
# Distribution # Distribution
EXTRA_DIST = \ EXTRA_DIST = \
$(bin_SCRIPTS) \
coins-cs.conf \
coins-rsa.conf \
test_auditor_api-cs.conf \ test_auditor_api-cs.conf \
test_auditor_api-rsa.conf \ test_auditor_api-rsa.conf \
test_auditor_api_expire_reserve_now-cs.conf \ test_auditor_api_expire_reserve_now-cs.conf \
test_auditor_api_expire_reserve_now-rsa.conf \ test_auditor_api_expire_reserve_now-rsa.conf \
test_bank_api.conf \
test_bank_api_fakebank.conf \ test_bank_api_fakebank.conf \
test_bank_api_fakebank_twisted.conf \ test_bank_api_fakebank_twisted.conf \
test_bank_api_nexus.conf \ test_bank_api_nexus.conf \

118
src/testing/coins-cs.conf Normal file
View 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
View 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

View File

@ -57,16 +57,21 @@ START_AUDITOR=0
START_BACKUP=0 START_BACKUP=0
START_EXCHANGE=0 START_EXCHANGE=0
START_FAKEBANK=0 START_FAKEBANK=0
START_AGGREGATOR=0
START_MERCHANT=0 START_MERCHANT=0
START_NEXUS=0 START_NEXUS=0
START_SANDBOX=0 START_SANDBOX=0
START_TRANSFER=0
START_WIREWATCH=0
USE_ACCOUNT="exchange-account-1"
USE_VALGRIND="" USE_VALGRIND=""
WIRE_DOMAIN="x-taler-bank"
CONF_ORIG="~/.config/taler.conf" CONF_ORIG="~/.config/taler.conf"
LOGLEVEL="DEBUG" LOGLEVEL="DEBUG"
DEFAULT_SLEEP="0.2" DEFAULT_SLEEP="0.2"
# Parse command-line options # Parse command-line options
while getopts ':abc:efhl:mnsv' OPTION; do while getopts ':abc:d:efghl:mnr:stu:vw' OPTION; do
case "$OPTION" in case "$OPTION" in
a) a)
START_AUDITOR="1" START_AUDITOR="1"
@ -77,6 +82,9 @@ while getopts ':abc:efhl:mnsv' OPTION; do
c) c)
CONF_ORIG="$OPTARG" CONF_ORIG="$OPTARG"
;; ;;
c)
WIRE_DOMAIN="$OPTARG"
;;
e) e)
START_EXCHANGE="1" START_EXCHANGE="1"
;; ;;
@ -88,16 +96,24 @@ while getopts ':abc:efhl:mnsv' OPTION; do
echo ' -a -- start auditor' echo ' -a -- start auditor'
echo ' -b -- start backup/sync' echo ' -b -- start backup/sync'
echo ' -c $CONF -- set configuration' echo ' -c $CONF -- set configuration'
echo ' -d $METHOD -- use wire method (default: x-taler-bank)'
echo ' -e -- start exchange' echo ' -e -- start exchange'
echo ' -f -- start fakebank' echo ' -f -- start fakebank'
echo ' -h -- print this help' echo ' -h -- print this help'
echo ' -l $LOGLEVEL -- set log level' echo ' -l $LOGLEVEL -- set log level'
echo ' -m -- start merchant' echo ' -m -- start merchant'
echo ' -n -- start nexus' echo ' -n -- start nexus'
echo ' -r $MEX -- which exchange to use at the merchant (optional)'
echo ' -s -- start sandbox' echo ' -s -- start sandbox'
echo ' -t -- start transfer'
echo ' -u $SECTION -- exchange account to use'
echo ' -v -- use valgrind' echo ' -v -- use valgrind'
echo ' -w -- start wirewatch'
exit 0 exit 0
;; ;;
g)
START_AGGREGATOR="1"
;;
l) l)
LOGLEVEL="$OPTARG" LOGLEVEL="$OPTARG"
;; ;;
@ -107,13 +123,25 @@ while getopts ':abc:efhl:mnsv' OPTION; do
n) n)
START_NEXUS="1" START_NEXUS="1"
;; ;;
r)
USE_MERCHANT_EXCHANGE="$OPTARG"
;;
s) s)
START_SANDBOX="1" START_SANDBOX="1"
;; ;;
t)
START_TRANSFER="1"
;;
u)
USE_ACCOUNT="$OPTARG"
;;
v) v)
USE_VALGRIND="valgrind --leak-check=yes" USE_VALGRIND="valgrind --leak-check=yes"
DEFAULT_SLEEP="2" DEFAULT_SLEEP="2"
;; ;;
w)
START_WIREWATCH="1"
;;
?) ?)
exit_fail "Unrecognized command line option" exit_fail "Unrecognized command line option"
;; ;;
@ -156,6 +184,12 @@ then
echo " FOUND" echo " FOUND"
fi 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") EXCHANGE_URL=$(taler-config -c "$CONF" -s "EXCHANGE" -o "BASE_URL")
CURRENCY=$(taler-config -c "$CONF" -s "TALER" -o "CURRENCY") CURRENCY=$(taler-config -c "$CONF" -s "TALER" -o "CURRENCY")
@ -235,7 +269,7 @@ then
export LIBEUFIN_SANDBOX_USERNAME="exchange" export LIBEUFIN_SANDBOX_USERNAME="exchange"
export LIBEUFIN_SANDBOX_PASSWORD="x" export LIBEUFIN_SANDBOX_PASSWORD="x"
EXCHANGE_PAYTO=$(libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri') 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 " OK"
echo -n "Setting this exchange as the bank's default ..." echo -n "Setting this exchange as the bank's default ..."
@ -305,6 +339,7 @@ then
export LIBEUFIN_NEXUS_USERNAME=exchange export LIBEUFIN_NEXUS_USERNAME=exchange
export LIBEUFIN_NEXUS_PASSWORD=x export LIBEUFIN_NEXUS_PASSWORD=x
echo -n "Creating a EBICS connection at Nexus ..." 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 \ libeufin-cli connections new-ebics-connection \
--ebics-url "http://localhost:$SANDBOX_PORT/ebicsweb" \ --ebics-url "http://localhost:$SANDBOX_PORT/ebicsweb" \
--host-id talerebics \ --host-id talerebics \
@ -314,7 +349,7 @@ then
echo "OK" echo "OK"
echo -n "Setup EBICS keying ..." echo -n "Setup EBICS keying ..."
libeufin-cli connections connect talerconn > /dev/null libeufin-cli connections connect talerconn
echo "OK" echo "OK"
echo -n "Download bank account name from Sandbox ..." echo -n "Download bank account name from Sandbox ..."
libeufin-cli connections download-bank-accounts talerconn libeufin-cli connections download-bank-accounts talerconn
@ -364,13 +399,16 @@ fi
if [ "1" = "$START_EXCHANGE" ] if [ "1" = "$START_EXCHANGE" ]
then then
echo -n "Starting exchange ..." echo -n "Starting exchange ..."
EXCHANGE_PORT=$(taler-config -c "$CONF" -s EXCHANGE -o PORT) EXCHANGE_PORT=$(taler-config -c "$CONF" -s EXCHANGE -o PORT)
EXCHANGE_URL="http://localhost:${EXCHANGE_PORT}/" EXCHANGE_URL="http://localhost:${EXCHANGE_PORT}/"
MASTER_PRIV_FILE=$(taler-config -f -c "${CONF}" -s "EXCHANGE-OFFLINE" -o "MASTER_PRIV_FILE") MASTER_PRIV_FILE=$(taler-config -f -c "${CONF}" -s "EXCHANGE-OFFLINE" -o "MASTER_PRIV_FILE")
MASTER_PRIV_DIR=$(dirname "$MASTER_PRIV_FILE") MASTER_PRIV_DIR=$(dirname "$MASTER_PRIV_FILE")
mkdir -p "${MASTER_PRIV_DIR}" mkdir -p "${MASTER_PRIV_DIR}"
gnunet-ecc -g1 "$MASTER_PRIV_FILE" > /dev/null 2> /dev/null 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}") MASTER_PUB=$(gnunet-ecc -p "${MASTER_PRIV_FILE}")
MPUB=$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY) MPUB=$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)
if [ "$MPUB" != "$MASTER_PUB" ] if [ "$MPUB" != "$MASTER_PUB" ]
@ -378,16 +416,34 @@ then
echo -n " patching master_pub ($MASTER_PUB)..." echo -n " patching master_pub ($MASTER_PUB)..."
taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY -V "$MASTER_PUB" taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY -V "$MASTER_PUB"
fi 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-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-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 & $USE_VALGRIND taler-exchange-secmod-cs -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-cs.log &
$USE_VALGRIND taler-exchange-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-httpd.log & $USE_VALGRIND taler-exchange-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-httpd.log &
EXCHANGE_HTTPD_PID=$! EXCHANGE_HTTPD_PID=$!
echo " DONE"
fi
if [ "1" = "$START_WIREWATCH" ]
then
echo -n "Starting wirewatch ..."
$USE_VALGRIND taler-exchange-wirewatch -c "$CONF" 2> taler-exchange-wirewatch.log & $USE_VALGRIND taler-exchange-wirewatch -c "$CONF" 2> taler-exchange-wirewatch.log &
WIREWATCH_PID=$! WIREWATCH_PID=$!
echo " DONE"
fi
if [ "1" = "$START_AGGREGATOR" ]
then
echo -n "Starting aggregator ..."
$USE_VALGRIND taler-exchange-aggregator -c "$CONF" 2> taler-exchange-aggregator.log & $USE_VALGRIND taler-exchange-aggregator -c "$CONF" 2> taler-exchange-aggregator.log &
AGGREGATOR_PID=$! AGGREGATOR_PID=$!
echo " DONE"
fi
if [ "1" = "$START_TRANSFER" ]
then
echo -n "Starting transfer ..."
$USE_VALGRIND taler-exchange-transfer -c "$CONF" 2> taler-exchange-transfer.log & $USE_VALGRIND taler-exchange-transfer -c "$CONF" 2> taler-exchange-transfer.log &
TRANSFER_PID=$! TRANSFER_PID=$!
echo " DONE" echo " DONE"
@ -396,16 +452,19 @@ fi
if [ "1" = "$START_MERCHANT" ] if [ "1" = "$START_MERCHANT" ]
then then
echo -n "Starting merchant ..." echo -n "Starting merchant ..."
MEPUB=$(taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY) if [ ! -z "${USE_MERCHANT_EXCHANGE+x}" ]
MXPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
if [ "$MEPUB" != "$MXPUB" ]
then then
echo -n " patching master_pub ($MXPUB)..." MEPUB=$(taler-config -c "$CONF" -s "${USE_MERCHANT_EXCHANGE}" -o MASTER_KEY)
taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY -V "$MXPUB" 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 "${USE_MERCHANT_EXCHANGE}" -o MASTER_KEY -V "$MXPUB"
fi
fi fi
MERCHANT_PORT=$(taler-config -c "$CONF" -s MERCHANT -o PORT) MERCHANT_PORT=$(taler-config -c "$CONF" -s MERCHANT -o PORT)
MERCHANT_URL="http://localhost:${MERCHANT_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 & $USE_VALGRIND taler-merchant-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-httpd.log &
MERCHANT_HTTPD_PID=$! MERCHANT_HTTPD_PID=$!
$USE_VALGRIND taler-merchant-webhook -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-webhook.log & $USE_VALGRIND taler-merchant-webhook -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-webhook.log &
@ -418,7 +477,7 @@ then
echo -n "Starting sync ..." echo -n "Starting sync ..."
SYNC_PORT=$(taler-config -c "$CONF" -s SYNC -o PORT) SYNC_PORT=$(taler-config -c "$CONF" -s SYNC -o PORT)
SYNC_URL="http://localhost:${SYNC_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 & $USE_VALGRIND sync-httpd -c "$CONF" -L "$LOGLEVEL" 2> sync-httpd.log &
echo " DONE" echo " DONE"
fi fi
@ -427,14 +486,18 @@ fi
if [ "1" = "$START_AUDITOR" ] if [ "1" = "$START_AUDITOR" ]
then then
echo -n "Starting auditor ..." 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_FILE=$(taler-config -f -c "$CONF" -s AUDITOR -o AUDITOR_PRIV_FILE)
AUDITOR_PRIV_DIR=$(dirname "$AUDITOR_PRIV_FILE") AUDITOR_PRIV_DIR=$(dirname "$AUDITOR_PRIV_FILE")
mkdir -p "$AUDITOR_PRIV_DIR" mkdir -p "$AUDITOR_PRIV_DIR"
gnunet-ecc -g1 "$AUDITOR_PRIV_FILE" > /dev/null 2> /dev/null 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}") AUDITOR_PUB=$(gnunet-ecc -p "${AUDITOR_PRIV_FILE}")
MAPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)} 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" taler-auditor-exchange -c "$CONF" -m "$MAPUB" -u "$EXCHANGE_URL"
$USE_VALGRIND taler-auditor-httpd -L "$LOGLEVEL" -c "$CONF" 2> taler-auditor-httpd.log & $USE_VALGRIND taler-auditor-httpd -L "$LOGLEVEL" -c "$CONF" 2> taler-auditor-httpd.log &
echo " DONE" echo " DONE"
@ -472,20 +535,21 @@ echo -n "Waiting for Taler services ..."
# Wait for all other taler services to be available # Wait for all other taler services to be available
for n in $(seq 1 20) for n in $(seq 1 20)
do do
echo -n "."
sleep "$DEFAULT_SLEEP" sleep "$DEFAULT_SLEEP"
OK="0" OK="0"
if [ "1" = "$START_EXCHANGE" ] if [ "1" = "$START_EXCHANGE" ]
then then
echo -n "E"
wget \ wget \
--tries=1 \ --tries=1 \
--timeout=1 \ --timeout=1 \
"http://localhost:8081/config" \ "${EXCHANGE_URL}config" \
-o /dev/null \ -o /dev/null \
-O /dev/null >/dev/null || continue -O /dev/null >/dev/null || continue
fi fi
if [ "1" = "$START_MERCHANT" ] if [ "1" = "$START_MERCHANT" ]
then then
echo -n "M"
wget \ wget \
--tries=1 \ --tries=1 \
--timeout=1 \ --timeout=1 \
@ -495,6 +559,7 @@ do
fi fi
if [ "1" = "$START_BACKUP" ] if [ "1" = "$START_BACKUP" ]
then then
echo -n "S"
wget \ wget \
--tries=1 \ --tries=1 \
--timeout=1 \ --timeout=1 \
@ -504,6 +569,7 @@ do
fi fi
if [ "1" = "$START_AUDITOR" ] if [ "1" = "$START_AUDITOR" ]
then then
echo -n "A"
wget \ wget \
--tries=1 \ --tries=1 \
--timeout=1 \ --timeout=1 \
@ -553,23 +619,20 @@ then
taler-exchange-offline -c "$CONF" \ taler-exchange-offline -c "$CONF" \
download \ download \
sign \ 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 \ global-fee now "$CURRENCY:0.01" "$CURRENCY:0.01" "$CURRENCY:0.01" 1h 1year 5 \
upload &> taler-exchange-offline.log upload &> taler-exchange-offline.log
echo "OK" echo "OK"
for ASEC in $(taler-config -c "$CONF" -S | grep -i "exchange-account-") ENABLED=$(taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "ENABLE_CREDIT")
do if [ "YES" = "$ENABLED" ]
ENABLED=$(taler-config -c "$CONF" -s "$ASEC" -o "ENABLE_CREDIT") then
if [ "YES" = "$ENABLED" ] echo -n "Configuring bank account $USE_ACCOUNT ..."
then EXCHANGE_PAYTO_URI=$(taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "PAYTO_URI")
echo -n "Configuring bank account $ASEC ..." taler-exchange-offline -c "$CONF" \
EXCHANGE_PAYTO_URI=$(taler-config -c "$CONF" -s "$ASEC" -o "PAYTO_URI") enable-account "$EXCHANGE_PAYTO_URI" \
taler-exchange-offline -c "$CONF" \ upload &> "taler-exchange-offline-account.log"
enable-account "$EXCHANGE_PAYTO_URI" \ echo " OK"
upload &> "taler-exchange-offline-account-$ASEC.log" fi
echo " OK"
fi
done
if [ "1" = "$START_AUDITOR" ] if [ "1" = "$START_AUDITOR" ]
then then
echo -n "Enabling auditor ..." echo -n "Enabling auditor ..."

View File

@ -1,75 +1,43 @@
# This file is in the public domain.
[PATHS] [PATHS]
# Persistent data storage for the testcase # Persistent data storage for the testcase
TALER_TEST_HOME = test_taler_exchange_httpd_home/ TALER_TEST_HOME = test_taler_exchange_httpd_home/
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
[taler-exchange-secmod-rsa] [taler-exchange-secmod-rsa]
# Reduce from 1 year to speed up test # Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days LOOKAHEAD_SIGN = 24 days
[taler-exchange-secmod-eddsa] [taler-exchange-secmod-eddsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days LOOKAHEAD_SIGN = 24 days
# Reduce from 12 weeks to ensure we have multiple
DURATION = 14 days DURATION = 14 days
[taler] [taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01 CURRENCY_ROUND_UNIT = EUR:0.01
[exchange] [exchange]
AML_THRESHOLD = EUR:1000000 AML_THRESHOLD = EUR:1000000
# The DB plugin to use
DB = postgres DB = postgres
# HTTP port the exchange listens to
PORT = 8081 PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# Expected base URL of the exchange. Used in wire transfers for
# the tracking API.
BASE_URL = "http://localhost:8081/" BASE_URL = "http://localhost:8081/"
[auditor] [auditor]
BASE_URL = "http://auditor.example.com/" BASE_URL = "http://auditor.example.com/"
PORT = 8083
[auditordb-postgres] [auditordb-postgres]
CONFIG = "postgres:///talercheck" CONFIG = "postgres:///talercheck"
[exchangedb] [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 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 LEGAL_RESERVE_EXPIRATION_TIME = 7 years
[exchange-account-1] [exchangedb-postgres]
CONFIG = postgres:///talercheck
[exchange-account-1]
# What is the account URL? # What is the account URL?
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2" PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES ENABLE_DEBIT = YES
@ -81,7 +49,6 @@ WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange USERNAME = Exchange
PASSWORD = x PASSWORD = x
[bank] [bank]
HTTP_PORT = 8082 HTTP_PORT = 8082

View File

@ -1,62 +1,41 @@
# This file is in the public domain.
[PATHS] [PATHS]
# Persistent data storage for the testcase # Persistent data storage for the testcase
TALER_TEST_HOME = test_taler_exchange_httpd_home/ TALER_TEST_HOME = test_taler_exchange_httpd_home/
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
[taler-exchange-secmod-rsa] [taler-exchange-secmod-rsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days LOOKAHEAD_SIGN = 24 days
[taler-exchange-secmod-eddsa] [taler-exchange-secmod-eddsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days LOOKAHEAD_SIGN = 24 days
# Reduce from 12 weeks to ensure we have multiple
DURATION = 14 days DURATION = 14 days
[taler] [taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01 CURRENCY_ROUND_UNIT = EUR:0.01
[exchange] [exchange]
AML_THRESHOLD = EUR:1000000 AML_THRESHOLD = EUR:1000000
# The DB plugin to use
DB = postgres DB = postgres
# HTTP port the exchange listens to
PORT = 8081 PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# Expected base URL of the exchange.
BASE_URL = "http://localhost:8081/" BASE_URL = "http://localhost:8081/"
[exchangedb] [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! # This is THE test that requires a short reserve expiration time!
IDLE_RESERVE_EXPIRATION_TIME = 4 s IDLE_RESERVE_EXPIRATION_TIME = 4 s
[exchangedb-postgres] [exchangedb-postgres]
#The connection string the plugin has to use for connecting to the database
CONFIG = "postgres:///talercheck"
[auditordb-postgres]
CONFIG = "postgres:///talercheck" CONFIG = "postgres:///talercheck"
[auditor] [auditor]
BASE_URL = "http://localhost:8083/" BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to
PORT = 8083 PORT = 8083
[auditordb-postgres]
CONFIG = "postgres:///talercheck"
[exchange-account-1] [exchange-account-1]
# What is the account URL? # What is the account URL?
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2" PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"

View File

@ -1,141 +1,4 @@
# This file is in the public domain. # This file is in the public domain.
# #
[PATHS] @INLINE@ coins-cs.conf
# Persistent data storage for the testcase @INLINE@ test_exchange_api.conf
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

View File

@ -1,147 +1,4 @@
# This file is in the public domain. # This file is in the public domain.
# #
[PATHS] @INLINE@ coins-rsa.conf
# Persistent data storage for the testcase @INLINE@ test_exchange_api.conf
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

View File

@ -45,14 +45,9 @@ static char *config_file;
static char *config_file_expire_reserve_now; static char *config_file_expire_reserve_now;
/** /**
* Exchange configuration data. * Our credentials.
*/ */
static struct TALER_TESTING_ExchangeConfiguration ec; static struct TALER_TESTING_Credentials cred;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/** /**
* Execute the taler-exchange-wirewatch command with * Execute the taler-exchange-wirewatch command with
@ -83,8 +78,8 @@ static struct TALER_TESTING_BankConfiguration bc;
*/ */
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_admin_add_incoming (label, amount, \ TALER_TESTING_cmd_admin_add_incoming (label, amount, \
&bc.exchange_auth, \ &cred.ba, \
bc.user42_payto) cred.user42_payto)
/** /**
* Run the taler-auditor. * Run the taler-auditor.
@ -116,7 +111,7 @@ run (void *cls,
"EUR:5.01"), "EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer TALER_TESTING_cmd_check_bank_admin_transfer
("check-create-reserve-1", ("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"), "create-reserve-1"),
/** /**
* Make a reserve exist, according to the previous transfer. * Make a reserve exist, according to the previous transfer.
@ -140,7 +135,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-simple", TALER_TESTING_cmd_deposit ("deposit-simple",
"withdraw-coin-1", "withdraw-coin-1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:5", "EUR:5",
@ -157,7 +152,7 @@ run (void *cls,
"EUR:5.01"), "EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer TALER_TESTING_cmd_check_bank_admin_transfer
("check-refresh-create-reserve-1", ("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"), "refresh-create-reserve-1"),
/** /**
* Make previous command effective. * Make previous command effective.
@ -178,7 +173,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-partial", TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
"refresh-withdraw-coin-1", "refresh-withdraw-coin-1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:1\"}]}", "{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -203,7 +198,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b", TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
"refresh-reveal-1", "refresh-reveal-1",
3, 3,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:0.1", "EUR:0.1",
@ -225,75 +220,75 @@ run (void *cls,
*/ */
TALER_TESTING_cmd_check_bank_transfer ( TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-499c", "check_bank_transfer-499c",
ec.exchange_url, cred.exchange_url,
"EUR:4.98", "EUR:4.98",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ( TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-99c1", "check_bank_transfer-99c1",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ( TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-99c", "check_bank_transfer-99c",
ec.exchange_url, cred.exchange_url,
"EUR:0.08", "EUR:0.08",
bc.exchange_payto, cred.exchange_payto,
bc.user43_payto), cred.user43_payto),
/* The following transactions got originated within /* The following transactions got originated within
* the "massive deposit confirms" batch. */ * the "massive deposit confirms" batch. */
TALER_TESTING_cmd_check_bank_transfer ( TALER_TESTING_cmd_check_bank_transfer (
"check-massive-transfer-1", "check-massive-transfer-1",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-2", ("check-massive-transfer-2",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-3", ("check-massive-transfer-3",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-4", ("check-massive-transfer-4",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-5", ("check-massive-transfer-5",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-6", ("check-massive-transfer-6",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-7", ("check-massive-transfer-7",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-8", ("check-massive-transfer-8",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-9", ("check-massive-transfer-9",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, bc.user43_payto), cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-10", ("check-massive-transfer-10",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "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_check_bank_empty ("check_bank_empty"),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
@ -311,8 +306,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer ( TALER_TESTING_cmd_check_bank_admin_transfer (
"check_bank_transfer-unaggregated", "check_bank_transfer-unaggregated",
"EUR:5.01", "EUR:5.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-unaggregated"), "create-reserve-unaggregated"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated", TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
"create-reserve-unaggregated", "create-reserve-unaggregated",
@ -322,7 +317,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-unaggregated", TALER_TESTING_cmd_deposit ("deposit-unaggregated",
"withdraw-coin-unaggregated", "withdraw-coin-unaggregated",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_relative_multiply GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_YEARS, (GNUNET_TIME_UNIT_YEARS,
@ -359,7 +354,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-1", TALER_TESTING_cmd_deposit ("deposit-refund-1",
"withdraw-coin-r1", "withdraw-coin-r1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:5\"}]}", "{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_MINUTES,
"EUR:5", "EUR:5",
@ -376,7 +371,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-2", TALER_TESTING_cmd_deposit ("deposit-refund-2",
"withdraw-coin-r1", "withdraw-coin-r1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"more\",\"value\":\"EUR:5\"}]}", "{\"items\":[{\"name\":\"more\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:4.99", "EUR:4.99",
@ -466,7 +461,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("recoup-deposit-partial", TALER_TESTING_cmd_deposit ("recoup-deposit-partial",
"recoup-withdraw-coin-2a", "recoup-withdraw-coin-2a",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:0.5", "EUR:0.5",
@ -493,7 +488,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer ( TALER_TESTING_cmd_check_bank_admin_transfer (
"check-massive-transfer", "check-massive-transfer",
"EUR:10.10", "EUR:10.10",
bc.user42_payto, bc.exchange_payto, cred.user42_payto,
cred.exchange_payto,
"massive-reserve"), "massive-reserve"),
CMD_EXEC_WIREWATCH ("massive-wirewatch"), CMD_EXEC_WIREWATCH ("massive-wirewatch"),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-1", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-1",
@ -550,7 +546,7 @@ run (void *cls,
"massive-deposit-1", "massive-deposit-1",
"massive-withdraw-1", "massive-withdraw-1",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -559,7 +555,7 @@ run (void *cls,
("massive-deposit-2", ("massive-deposit-2",
"massive-withdraw-2", "massive-withdraw-2",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -568,7 +564,7 @@ run (void *cls,
("massive-deposit-3", ("massive-deposit-3",
"massive-withdraw-3", "massive-withdraw-3",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -577,7 +573,7 @@ run (void *cls,
("massive-deposit-4", ("massive-deposit-4",
"massive-withdraw-4", "massive-withdraw-4",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -586,7 +582,7 @@ run (void *cls,
("massive-deposit-5", ("massive-deposit-5",
"massive-withdraw-5", "massive-withdraw-5",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -595,7 +591,7 @@ run (void *cls,
("massive-deposit-6", ("massive-deposit-6",
"massive-withdraw-6", "massive-withdraw-6",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -604,7 +600,7 @@ run (void *cls,
("massive-deposit-7", ("massive-deposit-7",
"massive-withdraw-7", "massive-withdraw-7",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -613,7 +609,7 @@ run (void *cls,
("massive-deposit-8", ("massive-deposit-8",
"massive-withdraw-8", "massive-withdraw-8",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -622,7 +618,7 @@ run (void *cls,
("massive-deposit-9", ("massive-deposit-9",
"massive-withdraw-9", "massive-withdraw-9",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -631,13 +627,12 @@ run (void *cls,
"massive-deposit-10", "massive-deposit-10",
"massive-withdraw-10", "massive-withdraw-10",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_deposit_confirmation ("deposit-confirmation", TALER_TESTING_cmd_deposit_confirmation ("deposit-confirmation",
is->auditor,
"massive-deposit-10", "massive-deposit-10",
0, 0,
"EUR:0.99", "EUR:0.99",
@ -648,21 +643,22 @@ run (void *cls,
}; };
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees", TALER_TESTING_cmd_run_fakebank ("run-fakebank",
config_file, cred.cfg,
"EUR:0.01", "exchange-account-2"),
"EUR:0.01"), TALER_TESTING_cmd_system_start ("start-taler",
TALER_TESTING_cmd_auditor_add ("add-auditor-OK", config_file,
MHD_HTTP_NO_CONTENT, "-u", "exchange-account-2",
false), "-ae",
TALER_TESTING_cmd_wire_add ("add-wire-account", NULL),
"payto://x-taler-bank/localhost/2?receiver-name=2", TALER_TESTING_cmd_get_exchange ("get-exchange",
MHD_HTTP_NO_CONTENT, cred.cfg,
false), true,
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", true),
config_file), TALER_TESTING_cmd_get_auditor ("get-auditor",
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", cred.cfg,
2), true),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
TALER_TESTING_cmd_exec_auditor_offline ("auditor-offline", TALER_TESTING_cmd_exec_auditor_offline ("auditor-offline",
config_file), config_file),
CMD_RUN_AUDITOR ("virgin-auditor"), CMD_RUN_AUDITOR ("virgin-auditor"),
@ -690,9 +686,8 @@ run (void *cls,
}; };
(void) cls; (void) cls;
TALER_TESTING_run_with_fakebank (is, TALER_TESTING_run (is,
commands, commands);
bc.exchange_auth.wire_gateway_url);
} }
@ -700,60 +695,28 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
char *cipher;
(void) argc; (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_auditor_api-%s.conf",
cipher);
GNUNET_asprintf (&config_file_expire_reserve_now,
"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: char *cipher;
GNUNET_break (0);
return 1; cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
case GNUNET_NO: GNUNET_assert (NULL != cipher);
return 78; GNUNET_asprintf (&config_file,
case GNUNET_OK: "test_auditor_api-%s.conf",
if (GNUNET_OK != cipher);
/* Set up event loop and reschedule context, plus GNUNET_asprintf (&config_file_expire_reserve_now,
* start/stop the exchange. It calls TALER_TESTING_setup "test_auditor_api_expire_reserve_now-%s.conf",
* which creates the 'is' object. cipher);
*/ GNUNET_free (cipher);
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);
} }

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as it under the terms of the GNU General Public License as
@ -39,7 +39,7 @@
* Configuration file we use. One (big) configuration is used * Configuration file we use. One (big) configuration is used
* for the various components for this test. * 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; static struct TALER_AUDITOR_Handle *ah;
@ -51,6 +51,7 @@ static int global_ret;
static struct GNUNET_SCHEDULER_Task *tt; static struct GNUNET_SCHEDULER_Task *tt;
static void static void
do_shutdown (void *cls) do_shutdown (void *cls)
{ {
@ -148,15 +149,16 @@ main (int argc,
"taler-auditor-httpd", "taler-auditor-httpd",
"taler-auditor-httpd", "taler-auditor-httpd",
"-c", CONFIG_FILE, "-c", CONFIG_FILE,
"-L", "INFO",
NULL); NULL);
if (NULL == proc) if (NULL == proc)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to run `taler-auditor-httpd`," "Failed to run `taler-auditor-httpd`, is your PATH correct?\n");
" is your PATH correct?\n");
return 77; 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, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to launch `taler-auditor-httpd`\n"); "Failed to launch `taler-auditor-httpd`\n");
@ -166,7 +168,8 @@ main (int argc,
GNUNET_SCHEDULER_run (&run, GNUNET_SCHEDULER_run (&run,
NULL); NULL);
} }
GNUNET_OS_process_kill (proc, SIGTERM); GNUNET_OS_process_kill (proc,
SIGTERM);
GNUNET_OS_process_wait (proc); GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc); GNUNET_OS_process_destroy (proc);
return global_ret; return global_ret;

View File

@ -34,6 +34,7 @@
#include "taler_testing_lib.h" #include "taler_testing_lib.h"
#define CONFIG_FILE_FAKEBANK "test_bank_api_fakebank.conf" #define CONFIG_FILE_FAKEBANK "test_bank_api_fakebank.conf"
#define CONFIG_FILE_NEXUS "test_bank_api_nexus.conf" #define CONFIG_FILE_NEXUS "test_bank_api_nexus.conf"
@ -41,28 +42,19 @@
* Configuration file. It changes based on * Configuration file. It changes based on
* whether Nexus or Fakebank are used. * 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 * Which bank is the test running against?
* Fakebank. Set up at runtime. * 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 * Main function that will tell the interpreter what commands to
@ -75,20 +67,36 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct TALER_WireTransferIdentifierRawP wtid; struct TALER_WireTransferIdentifierRawP wtid;
const char *ssoptions;
(void) cls; (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[] = { struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_system_start ("start-taler",
cfgfile,
ssoptions,
NULL),
TALER_TESTING_cmd_bank_credits ("history-0", TALER_TESTING_cmd_bank_credits ("history-0",
&bc.exchange_auth, &cred.ba,
NULL, NULL,
1), 1),
TALER_TESTING_cmd_admin_add_incoming ("credit-1", TALER_TESTING_cmd_admin_add_incoming ("credit-1",
"KUDOS:5.01", "EUR:5.01",
&bc.exchange_auth, &cred.ba,
bc.user42_payto), cred.user42_payto),
/** /**
* This CMD doesn't care about the HTTP response code; that's * This CMD doesn't care about the HTTP response code; that's
* because Fakebank and euFin behaves differently when a reserve * 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. * with 200 but it bounces the payment back to the customer.
*/ */
TALER_TESTING_cmd_admin_add_incoming_with_ref ("credit-1-fail", TALER_TESTING_cmd_admin_add_incoming_with_ref ("credit-1-fail",
"KUDOS:2.01", "EUR:2.01",
&bc.exchange_auth, &cred.ba,
bc.user42_payto, cred.user42_payto,
"credit-1", "credit-1",
-1), -1),
TALER_TESTING_cmd_sleep ("Waiting 4s for 'credit-1' to settle", 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. * reserve public key didn't make it to the exchange.
*/ */
TALER_TESTING_cmd_bank_credits ("history-1c", TALER_TESTING_cmd_bank_credits ("history-1c",
&bc.exchange_auth, &cred.ba,
NULL, NULL,
5), 5),
TALER_TESTING_cmd_bank_debits ("history-1d", TALER_TESTING_cmd_bank_debits ("history-1d",
&bc.exchange_auth, &cred.ba,
NULL, NULL,
5), 5),
TALER_TESTING_cmd_admin_add_incoming ("credit-2", TALER_TESTING_cmd_admin_add_incoming ("credit-2",
"KUDOS:3.21", "EUR:3.21",
&bc.exchange_auth, &cred.ba,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_transfer ("debit-1", TALER_TESTING_cmd_transfer ("debit-1",
"KUDOS:3.22", "EUR:3.22",
&bc.exchange_auth, &cred.ba,
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto, cred.user42_payto,
&wtid, &wtid,
"http://exchange.example.com/"), "http://exchange.example.com/"),
TALER_TESTING_cmd_sleep ("Waiting 5s for 'debit-1' to settle", TALER_TESTING_cmd_sleep ("Waiting 5s for 'debit-1' to settle",
5), 5),
with_libeufin (bs == TALER_TESTING_BS_IBAN)
? TALER_TESTING_cmd_nexus_fetch_transactions ( ? TALER_TESTING_cmd_nexus_fetch_transactions (
"fetch-transactions-at-nexus", "fetch-transactions-at-nexus",
"exchange", /* from taler-nexus-prepare */ "exchange", /* from taler-nexus-prepare */
@ -139,7 +147,7 @@ run (void *cls,
: TALER_TESTING_cmd_sleep ("nop", : TALER_TESTING_cmd_sleep ("nop",
0), 0),
TALER_TESTING_cmd_bank_debits ("history-2b", TALER_TESTING_cmd_bank_debits ("history-2b",
&bc.exchange_auth, &cred.ba,
NULL, NULL,
5), 5),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
@ -147,116 +155,44 @@ run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Bank serves at `%s'\n", "Bank serves at `%s'\n",
bc.exchange_auth.wire_gateway_url); cred.ba.wire_gateway_url);
if (GNUNET_YES == with_fakebank) TALER_TESTING_run (is,
TALER_TESTING_run_with_fakebank (is, commands);
commands,
bc.exchange_auth.wire_gateway_url);
else
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 int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
int rv;
(void) argc; (void) argc;
(void) argv; if (TALER_TESTING_has_in_name (argv[0],
/* These environment variables get in the way... */ "_with_fakebank"))
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)
{ {
TALER_LOG_DEBUG ("Running against the Fakebank.\n"); bs = TALER_TESTING_BS_FAKEBANK;
cfgfile = CONFIG_FILE_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")) "_with_nexus"))
{ {
TALER_LOG_DEBUG ("Running with Nexus.\n"); bs = TALER_TESTING_BS_IBAN;
with_libeufin = GNUNET_YES;
cfgfile = CONFIG_FILE_NEXUS; cfgfile = CONFIG_FILE_NEXUS;
if (GNUNET_OK !=
TALER_TESTING_prepare_libeufin (CONFIG_FILE_NEXUS,
GNUNET_YES,
"exchange-account-2",
&bc))
{
GNUNET_break (0);
return 77;
}
libeufin_services = TALER_TESTING_run_libeufin (&bc);
if ( (NULL == libeufin_services.nexus) ||
(NULL == libeufin_services.sandbox) )
return 77;
} }
else else
{ {
/* no bank service was ever invoked. */ /* no bank service was specified. */
GNUNET_break (0);
return 77; return 77;
} }
return TALER_TESTING_main (argv,
if (GNUNET_OK != "INFO",
GNUNET_CONFIGURATION_parse_and_run (cfgfile, cfgfile,
&setup_with_cfg, "exchange-account-2",
NULL)) bs,
rv = 1; &cred,
else &run,
rv = 0; NULL);
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;
} }

View 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

View File

@ -1,21 +1,14 @@
# This file is in the public domain. # This file is in the public domain.
@INLINE@ test_bank_api.conf
[taler] [exchange-account-1]
currency = KUDOS PAYTO_URI = "payto://x-taler-bank/localhost:8082/1?receiver-name=1"
[exchange-account-2] [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] [exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:8081/2/" WIRE_GATEWAY_URL = "http://localhost:8082/2/"
WIRE_GATEWAY_AUTH_METHOD = basic WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange USERNAME = Exchange
PASSWORD = x PASSWORD = x
[bank]
SERVE = http
HTTP_PORT = 8081
DATABASE = postgres:///talercheck
[auditor]
BASE_URL = "http://localhost:8083/"

View File

@ -1,12 +1,15 @@
# This file is in the public domain.
@INLINE@ test_bank_api_fakebank.conf
[twister] [twister]
# HTTP listen port for twister # HTTP listen port for twister
HTTP_PORT = 8888 HTTP_PORT = 8888
SERVE = tcp SERVE = tcp
# HTTP Destination for twister. The test-Webserver needs # HTTP Destination for twister. The test-Webserver needs
# to listen on the port used here. Note: no trailing '/'! # 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 # Control port for TCP
# PORT = 8889 # PORT = 8889
@ -18,20 +21,3 @@ ACCEPT_FROM6 = ::1;
UNIXPATH = /tmp/taler-service-twister.sock UNIXPATH = /tmp/taler-service-twister.sock
UNIX_MATCH_UID = NO UNIX_MATCH_UID = NO
UNIX_MATCH_GID = YES 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/"

View File

@ -1,21 +1,19 @@
# This file is in the public domain. # This file is in the public domain.
@INLINE@ test_bank_api.conf
[taler]
currency = TESTKUDOS
[exchange-account-2] [exchange-account-2]
PAYTO_URI = payto://iban/BIC/ES9121000418450200051332?receiver-name=Exchange PAYTO_URI = payto://iban/BIC/ES9121000418450200051332?receiver-name=Exchange
[exchange-accountcredentials-2] [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 WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = exchange USERNAME = exchange
PASSWORD = x PASSWORD = x
[bank] [libeufin-nexus]
# not (!) used by the nexus, only by the helper #DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
# check to make sure the port is free for Nexus. DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
HTTP_PORT = 5001
[auditor] [libeufin-sandbox]
BASE_URL = "http://localhost:8083/" #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"

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as it under the terms of the GNU General Public License as
@ -17,7 +17,7 @@
<http://www.gnu.org/licenses/> <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 Marcello Stanisci
* @author Sree Harsha Totakura <sreeharsha@totakura.in> * @author Sree Harsha Totakura <sreeharsha@totakura.in>
* @author Christian Grothoff * @author Christian Grothoff
@ -42,14 +42,20 @@
#define CONFIG_FILE_FAKEBANK "test_bank_api_fakebank_twisted.conf" #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. * (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; static struct GNUNET_OS_Process *twisterd;
/**
* Python bank process handle.
*/
static struct GNUNET_OS_Process *bankd;
/** /**
* Main function that will tell * Main function that will tell
@ -78,156 +79,118 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct TALER_WireTransferIdentifierRawP wtid; struct TALER_WireTransferIdentifierRawP wtid;
/* Route our commands through twister. */ /* Authentication data to route our commands through twister. */
struct TALER_BANK_AuthenticationData exchange_auth_twisted; struct TALER_BANK_AuthenticationData exchange_auth_twisted;
const char *systype = NULL;
(void) cls; (void) cls;
memset (&wtid, memset (&wtid,
0x5a, 0x5a,
sizeof (wtid)); sizeof (wtid));
GNUNET_memcpy (&exchange_auth_twisted, GNUNET_memcpy (&exchange_auth_twisted,
&bc.exchange_auth, &cred.ba,
sizeof (struct TALER_BANK_AuthenticationData)); sizeof (struct TALER_BANK_AuthenticationData));
if (with_fakebank) switch (bs)
exchange_auth_twisted.wire_gateway_url = {
"http://localhost:8888/2/"; case TALER_TESTING_BS_FAKEBANK:
else exchange_auth_twisted.wire_gateway_url
exchange_auth_twisted.wire_gateway_url = = "http://localhost:8888/2/";
"http://localhost:8888/taler-wire-gateway/Exchange/"; 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[] = { {
/* Test retrying transfer after failure. */ struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_malform_response ("malform-transfer", TALER_TESTING_cmd_system_start ("start-taler",
CONFIG_FILE_FAKEBANK), cfgfile,
TALER_TESTING_cmd_transfer_retry ( systype,
TALER_TESTING_cmd_transfer ("debit-1", NULL),
"KUDOS:3.22", /* Test retrying transfer after failure. */
&exchange_auth_twisted, TALER_TESTING_cmd_malform_response ("malform-transfer",
bc.exchange_payto, cfgfile),
bc.user42_payto, TALER_TESTING_cmd_transfer_retry (
&wtid, TALER_TESTING_cmd_transfer ("debit-1",
"http://exchange.example.com/")), "EUR:3.22",
TALER_TESTING_cmd_end () &exchange_auth_twisted,
}; 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, TALER_TESTING_run (is,
commands); commands);
}
} }
/** /**
* Kill, wait, and destroy convenience function. * Kill, wait, and destroy convenience function.
* *
* @param process process to purge. * @param[in] process process to purge.
*/ */
static void static void
purge_process (struct GNUNET_OS_Process *process) 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_wait (process);
GNUNET_OS_process_destroy (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 int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
int ret; int ret;
const char *cfgfilename;
(void) argc; (void) argc;
/* These environment variables get in the way... */ if (TALER_TESTING_has_in_name (argv[0],
unsetenv ("XDG_DATA_HOME"); "_with_fakebank"))
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test-bank-api-with-(fake)bank-twisted",
"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); bs = TALER_TESTING_BS_FAKEBANK;
return 77; cfgfile = CONFIG_FILE_FAKEBANK;
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, else if (TALER_TESTING_has_in_name (argv[0],
"twister_url is %s\n", "_with_nexus"))
twister_url);
if (NULL == (twisterd = TALER_TWISTER_run_twister (cfgfilename)))
{ {
GNUNET_break (0); GNUNET_assert (0); /* FIXME: test with nexus not yet implemented */
GNUNET_free (twister_url); bs = TALER_TESTING_BS_IBAN;
return 77; /* cfgfile = CONFIG_FILE_NEXUS; */
}
if (GNUNET_YES == with_fakebank)
{
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (cfgfilename,
"exchange-account-2",
&bc))
{
GNUNET_break (0);
GNUNET_free (twister_url);
return 77;
}
} }
else else
{ {
GNUNET_assert (0); /* no bank service was specified. */
GNUNET_break (0);
return 77;
} }
sleep (5); /* FIXME: introduce commands for twister! */
ret = GNUNET_CONFIGURATION_parse_and_run (cfgfilename, twister_url = TALER_TWISTER_prepare_twister (cfgfile);
&setup_with_cfg, if (NULL == twister_url)
NULL); return 77;
twisterd = TALER_TWISTER_run_twister (cfgfile);
if (NULL == twisterd)
return 77;
ret = TALER_TESTING_main (argv,
"INFO",
cfgfile,
"exchange-account-2",
bs,
&cred,
&run,
NULL);
purge_process (twisterd); 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); GNUNET_free (twister_url);
if (GNUNET_OK == ret) return ret;
return 0;
return 1;
} }

View File

@ -1,120 +1,4 @@
# This file is in the public domain. # This file is in the public domain.
# #
@INLINE@ coins-cs.conf
@INLINE@ test_exchange_api.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

View File

@ -1,130 +1,4 @@
# This file is in the public domain. # This file is in the public domain.
# #
@INLINE@ test_exchange_api.conf @INLINE@ test_exchange_api.conf
@INLINE@ coins-rsa.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

View File

@ -49,14 +49,9 @@ static char *config_file;
static char *config_file_expire_reserve_now; static char *config_file_expire_reserve_now;
/** /**
* Exchange configuration data. * Our credentials.
*/ */
static struct TALER_TESTING_ExchangeConfiguration ec; static struct TALER_TESTING_Credentials cred;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/** /**
* Some tests behave differently when using CS as we cannot * 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) \ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_admin_add_incoming (label, amount, \ TALER_TESTING_cmd_admin_add_incoming (label, amount, \
&bc.exchange_auth, \ &cred.ba, \
bc.user42_payto) cred.user42_payto)
/** /**
* Main function that will tell the interpreter what commands to * Main function that will tell the interpreter what commands to
@ -142,8 +137,8 @@ run (void *cls,
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
"EUR:6.02", "EUR:6.02",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-1"), "create-reserve-1"),
/** /**
* Make a reserve exist, according to the previous * Make a reserve exist, according to the previous
@ -201,7 +196,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-simple", TALER_TESTING_cmd_deposit ("deposit-simple",
"withdraw-coin-1", "withdraw-coin-1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:5", "EUR:5",
@ -219,7 +214,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-reused-coin-key-failure", TALER_TESTING_cmd_deposit ("deposit-reused-coin-key-failure",
"withdraw-coin-1x", "withdraw-coin-1x",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -232,7 +227,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-double-1", TALER_TESTING_cmd_deposit ("deposit-double-1",
"withdraw-coin-1", "withdraw-coin-1",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:5", "EUR:5",
@ -246,7 +241,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-double-1", TALER_TESTING_cmd_deposit ("deposit-double-1",
"withdraw-coin-1", "withdraw-coin-1",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:5", "EUR:5",
@ -257,7 +252,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-double-2", TALER_TESTING_cmd_deposit ("deposit-double-2",
"withdraw-coin-1", "withdraw-coin-1",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:5", "EUR:5",
@ -282,8 +277,8 @@ run (void *cls,
"EUR:5.01"), "EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("ck-refresh-create-reserve-1", TALER_TESTING_cmd_check_bank_admin_transfer ("ck-refresh-create-reserve-1",
"EUR:5.01", "EUR:5.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"refresh-create-reserve-1"), "refresh-create-reserve-1"),
/** /**
* Make previous command effective. * Make previous command effective.
@ -304,7 +299,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-partial", TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
"refresh-withdraw-coin-1", "refresh-withdraw-coin-1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -341,7 +336,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1a", TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1a",
"refresh-reveal-1-idempotency", "refresh-reveal-1-idempotency",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -352,7 +347,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b", TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
"refresh-reveal-1", "refresh-reveal-1",
3, 3,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:0.1", "EUR:0.1",
@ -390,8 +385,8 @@ run (void *cls,
"EUR:6.01"), "EUR:6.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age",
"EUR:6.01", "EUR:6.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-age"), "create-reserve-age"),
/** /**
* Make a reserve exist, according to the previous * Make a reserve exist, according to the previous
@ -417,7 +412,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-simple-age", TALER_TESTING_cmd_deposit ("deposit-simple-age",
"withdraw-coin-age-1", "withdraw-coin-age-1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:4.99", "EUR:4.99",
@ -464,53 +459,53 @@ run (void *cls,
* Check all the transfers took place. * Check all the transfers took place.
*/ */
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c", TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c",
ec.exchange_url, cred.exchange_url,
"EUR:4.98", "EUR:4.98",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c2", TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c2",
ec.exchange_url, cred.exchange_url,
"EUR:4.97", "EUR:4.97",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1", TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c2", TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c2",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c3", TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c3",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c4", TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c4",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c", TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c",
ec.exchange_url, cred.exchange_url,
"EUR:0.08", "EUR:0.08",
bc.exchange_payto, cred.exchange_payto,
bc.user43_payto), cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c2", TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c2",
ec.exchange_url, cred.exchange_url,
"EUR:0.08", "EUR:0.08",
bc.exchange_payto, cred.exchange_payto,
bc.user43_payto), cred.user43_payto),
/* In case of CS, one transaction above succeeded that /* In case of CS, one transaction above succeeded that
failed for RSA, hence we need to check for an extra transfer here */ failed for RSA, hence we need to check for an extra transfer here */
uses_cs uses_cs
? TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-98c", ? TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-98c",
ec.exchange_url, cred.exchange_url,
"EUR:0.98", "EUR:0.98",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto) cred.user42_payto)
: TALER_TESTING_cmd_sleep ("dummy", : TALER_TESTING_cmd_sleep ("dummy",
0), 0),
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
@ -544,8 +539,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer ( TALER_TESTING_cmd_check_bank_admin_transfer (
"check-create-reserve-unaggregated", "check-create-reserve-unaggregated",
"EUR:5.01", "EUR:5.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-unaggregated"), "create-reserve-unaggregated"),
CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"), CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated", TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
@ -556,7 +551,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-unaggregated", TALER_TESTING_cmd_deposit ("deposit-unaggregated",
"withdraw-coin-unaggregated", "withdraw-coin-unaggregated",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_relative_multiply ( GNUNET_TIME_relative_multiply (
GNUNET_TIME_UNIT_YEARS, GNUNET_TIME_UNIT_YEARS,
@ -578,8 +573,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer ( TALER_TESTING_cmd_check_bank_admin_transfer (
"ck-refresh-create-reserve-age-1", "ck-refresh-create-reserve-age-1",
"EUR:6.01", "EUR:6.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"refresh-create-reserve-age-1"), "refresh-create-reserve-age-1"),
/** /**
* Make previous command effective. * Make previous command effective.
@ -600,7 +595,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age", TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age",
"refresh-withdraw-coin-age-1", "refresh-withdraw-coin-age-1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -637,7 +632,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1a", TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1a",
"refresh-reveal-age-1-idempotency", "refresh-reveal-age-1-idempotency",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -648,7 +643,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1b", TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1b",
"refresh-reveal-age-1", "refresh-reveal-age-1",
3, 3,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:0.1", "EUR:0.1",
@ -680,8 +675,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer ( TALER_TESTING_cmd_check_bank_admin_transfer (
"check-create-reserve-aggtest", "check-create-reserve-aggtest",
"EUR:5.01", "EUR:5.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-aggtest"), "create-reserve-aggtest"),
CMD_EXEC_WIREWATCH ("wirewatch-aggtest"), CMD_EXEC_WIREWATCH ("wirewatch-aggtest"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aggtest", TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aggtest",
@ -692,7 +687,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-aggtest-1", TALER_TESTING_cmd_deposit ("deposit-aggtest-1",
"withdraw-coin-aggtest", "withdraw-coin-aggtest",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:2", "EUR:2",
@ -700,7 +695,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit_with_ref ("deposit-aggtest-2", TALER_TESTING_cmd_deposit_with_ref ("deposit-aggtest-2",
"withdraw-coin-aggtest", "withdraw-coin-aggtest",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}", "{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:2", "EUR:2",
@ -708,10 +703,10 @@ run (void *cls,
"deposit-aggtest-1"), "deposit-aggtest-1"),
CMD_EXEC_AGGREGATOR ("aggregation-aggtest"), CMD_EXEC_AGGREGATOR ("aggregation-aggtest"),
TALER_TESTING_cmd_check_bank_transfer ("check-bank-transfer-aggtest", TALER_TESTING_cmd_check_bank_transfer ("check-bank-transfer-aggtest",
ec.exchange_url, cred.exchange_url,
"EUR:3.97", "EUR:3.97",
bc.exchange_payto, cred.exchange_payto,
bc.user43_payto), cred.user43_payto),
TALER_TESTING_cmd_check_bank_empty ("check-bank-empty-aggtest"), TALER_TESTING_cmd_check_bank_empty ("check-bank-empty-aggtest"),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
@ -725,8 +720,8 @@ run (void *cls,
"EUR:5.01"), "EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-r1", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-r1",
"EUR:5.01", "EUR:5.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-r1"), "create-reserve-r1"),
/** /**
* Run wire-watch to trigger the reserve creation. * Run wire-watch to trigger the reserve creation.
@ -745,7 +740,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-1", TALER_TESTING_cmd_deposit ("deposit-refund-1",
"withdraw-coin-r1", "withdraw-coin-r1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_MINUTES,
"EUR:5", "EUR:5",
@ -779,7 +774,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-insufficient-refund", TALER_TESTING_cmd_deposit ("deposit-refund-insufficient-refund",
"withdraw-coin-r1", "withdraw-coin-r1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:4\"}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:4\"}]}",
GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_MINUTES,
"EUR:4", "EUR:4",
@ -796,7 +791,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-2", TALER_TESTING_cmd_deposit ("deposit-refund-2",
"withdraw-coin-r1", "withdraw-coin-r1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}", "{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:4.99", "EUR:4.99",
@ -810,10 +805,10 @@ run (void *cls,
* Check that deposit did run. * Check that deposit did run.
*/ */
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund", TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund",
ec.exchange_url, cred.exchange_url,
"EUR:4.97", "EUR:4.97",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
/** /**
* Run failing refund, as past deadline & aggregation. * Run failing refund, as past deadline & aggregation.
*/ */
@ -830,8 +825,8 @@ run (void *cls,
"EUR:5.01"), "EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-rb", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-rb",
"EUR:5.01", "EUR:5.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-rb"), "create-reserve-rb"),
CMD_EXEC_WIREWATCH ("wirewatch-rb"), CMD_EXEC_WIREWATCH ("wirewatch-rb"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb", TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb",
@ -842,7 +837,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-1b", TALER_TESTING_cmd_deposit ("deposit-refund-1b",
"withdraw-coin-rb", "withdraw-coin-rb",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:5", "EUR:5",
@ -876,8 +871,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer ( TALER_TESTING_cmd_check_bank_admin_transfer (
"recoup-create-reserve-1-check", "recoup-create-reserve-1-check",
"EUR:15.02", "EUR:15.02",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"recoup-create-reserve-1"), "recoup-create-reserve-1"),
/** /**
* Run wire-watch to trigger the reserve creation. * Run wire-watch to trigger the reserve creation.
@ -1006,8 +1001,8 @@ run (void *cls,
"EUR:5.01"), "EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-short-lived-reserve", TALER_TESTING_cmd_check_bank_admin_transfer ("check-short-lived-reserve",
"EUR:5.01", "EUR:5.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"short-lived-reserve"), "short-lived-reserve"),
TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation", TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation",
config_file_expire_reserve_now), config_file_expire_reserve_now),
@ -1029,10 +1024,10 @@ run (void *cls,
0, /* age restriction off */ 0, /* age restriction off */
MHD_HTTP_CONFLICT), MHD_HTTP_CONFLICT),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_reimburse", TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_reimburse",
ec.exchange_url, cred.exchange_url,
"EUR:5", "EUR:5",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
/* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per /* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per
* config, then withdraw two coin, partially spend one, and * config, then withdraw two coin, partially spend one, and
* then have the rest paid back. Check deposit of other coin * then have the rest paid back. Check deposit of other coin
@ -1042,8 +1037,8 @@ run (void *cls,
"EUR:2.02"), "EUR:2.02"),
TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2", TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2",
"EUR:2.02", "EUR:2.02",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"recoup-create-reserve-2"), "recoup-create-reserve-2"),
/* Make previous command effective. */ /* Make previous command effective. */
CMD_EXEC_WIREWATCH ("wirewatch-5"), CMD_EXEC_WIREWATCH ("wirewatch-5"),
@ -1062,7 +1057,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("recoup-deposit-partial", TALER_TESTING_cmd_deposit ("recoup-deposit-partial",
"recoup-withdraw-coin-2a", "recoup-withdraw-coin-2a",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:0.5", "EUR:0.5",
@ -1090,7 +1085,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("recoup-deposit-revoked", TALER_TESTING_cmd_deposit ("recoup-deposit-revoked",
"recoup-withdraw-coin-2b", "recoup-withdraw-coin-2b",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -1102,7 +1097,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("recoup-deposit-partial-after-recoup", TALER_TESTING_cmd_deposit ("recoup-deposit-partial-after-recoup",
"recoup-withdraw-coin-2a", "recoup-withdraw-coin-2a",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:0.5", "EUR:0.5",
@ -1113,8 +1108,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer ( TALER_TESTING_cmd_check_bank_admin_transfer (
"check-recoup-create-reserve-3", "check-recoup-create-reserve-3",
"EUR:1.01", "EUR:1.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"recoup-create-reserve-3"), "recoup-create-reserve-3"),
CMD_EXEC_WIREWATCH ("wirewatch-6"), CMD_EXEC_WIREWATCH ("wirewatch-6"),
TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-3-revoked", TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-3-revoked",
@ -1144,8 +1139,8 @@ run (void *cls,
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1",
"EUR:6.03", "EUR:6.03",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-batch-reserve-1"), "create-batch-reserve-1"),
/* /*
* Make a reserve exist, according to the previous * Make a reserve exist, according to the previous
@ -1184,7 +1179,7 @@ run (void *cls,
* Spend the coins. * Spend the coins.
*/ */
TALER_TESTING_cmd_batch_deposit ("batch-deposit-1", TALER_TESTING_cmd_batch_deposit ("batch-deposit-1",
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
MHD_HTTP_OK, MHD_HTTP_OK,
@ -1232,33 +1227,18 @@ run (void *cls,
{ {
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
/* setup exchange */ TALER_TESTING_cmd_run_fakebank ("run-fakebank",
TALER_TESTING_cmd_auditor_add ("add-auditor-OK", cred.cfg,
MHD_HTTP_NO_CONTENT, "exchange-account-2"),
false), TALER_TESTING_cmd_system_start ("start-taler",
TALER_TESTING_cmd_exec_offline_sign_extensions ("offline-sign-extensions", config_file,
config_file), "-e",
TALER_TESTING_cmd_wire_add ("add-wire-account", NULL),
"payto://x-taler-bank/localhost/2?receiver-name=2", TALER_TESTING_cmd_get_exchange ("get-exchange",
MHD_HTTP_NO_CONTENT, cred.cfg,
false), true,
TALER_TESTING_cmd_exec_offline_sign_global_fees ( true),
"offline-sign-global-fees", TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
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),
TALER_TESTING_cmd_batch ("wire", TALER_TESTING_cmd_batch ("wire",
wire), wire),
TALER_TESTING_cmd_batch ("withdraw", TALER_TESTING_cmd_batch ("withdraw",
@ -1291,9 +1271,8 @@ run (void *cls,
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
TALER_TESTING_run_with_fakebank (is, TALER_TESTING_run (is,
commands, commands);
bc.exchange_auth.wire_gateway_url);
} }
} }
@ -1302,62 +1281,30 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
char *cipher;
(void) argc; (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);
uses_cs = (0 == strcmp (cipher, "cs"));
GNUNET_asprintf (&config_file,
"test_exchange_api-%s.conf",
cipher);
GNUNET_asprintf (&config_file_expire_reserve_now,
"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: char *cipher;
GNUNET_break (0);
return 1; cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
case GNUNET_NO: GNUNET_assert (NULL != cipher);
return 78; uses_cs = (0 == strcmp (cipher,
case GNUNET_OK: "cs"));
if (GNUNET_OK != GNUNET_asprintf (&config_file,
/* Set up event loop and reschedule context, plus "test_exchange_api-%s.conf",
* start/stop the exchange. It calls TALER_TESTING_setup cipher);
* which creates the 'is' object. GNUNET_asprintf (&config_file_expire_reserve_now,
*/ "test_exchange_api_expire_reserve_now-%s.conf",
TALER_TESTING_setup_with_exchange (&run, cipher);
NULL, GNUNET_free (cipher);
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);
} }

View File

@ -2,30 +2,64 @@
# #
[PATHS] [PATHS]
# Persistent data storage for the testcase
TALER_TEST_HOME = test_exchange_api_home/ 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] [taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01 CURRENCY_ROUND_UNIT = EUR:0.01
[auditor] [auditor]
BASE_URL = "http://localhost:8083/" BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to
PORT = 8083 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] [kyc-provider-test-oauth2]
@ -48,68 +82,6 @@ REQUIRED_CHECKS = DUMMY
THRESHOLD = EUR:0 THRESHOLD = EUR:0
TIMEFRAME = 1d 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] [exchange-extension-age_restriction]
ENABLED = YES ENABLED = YES
# default age groups:
#AGE_GROUPS = "8:10:12:14:16:18:21" #AGE_GROUPS = "8:10:12:14:16:18:21"

View File

@ -0,0 +1 @@
p<EFBFBD>^<5E>-<2D>33<33><33>XX<>!<04>\0q<30><71><EFBFBD><EFBFBD><18>mU<6D>_<EFBFBD><5F>

View File

@ -43,9 +43,9 @@ lished
static char *config_file; 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_Interpreter *is)
{ {
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_auditor_add ("add-auditor-OK", TALER_TESTING_cmd_system_start ("start-taler",
MHD_HTTP_NO_CONTENT, config_file,
false), "-e",
TALER_TESTING_cmd_wire_add ("add-wire-account", NULL),
"payto://x-taler-bank/localhost/2?receiver-name=2", TALER_TESTING_cmd_get_exchange ("get-exchange",
MHD_HTTP_NO_CONTENT, cred.cfg,
false), true,
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees", true),
config_file, TALER_TESTING_cmd_check_keys_pull_all_keys ("initial-/keys"),
"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),
TALER_TESTING_cmd_sleep ("sleep", TALER_TESTING_cmd_sleep ("sleep",
6 /* seconds */), 6 /* seconds */),
TALER_TESTING_cmd_check_keys ("check-keys-1", TALER_TESTING_cmd_check_keys ("check-keys-1"),
2 /* generation */),
TALER_TESTING_cmd_check_keys_with_last_denom ("check-keys-2", TALER_TESTING_cmd_check_keys_with_last_denom ("check-keys-2",
3 /* generation */,
"check-keys-1"), "check-keys-1"),
TALER_TESTING_cmd_serialize_keys ("serialize-keys"), TALER_TESTING_cmd_serialize_keys ("serialize-keys"),
TALER_TESTING_cmd_connect_with_state ("reconnect-with-state", 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 * Make sure we have the same keys situation as
* it was before the serialization. * it was before the serialization.
*/ */
TALER_TESTING_cmd_check_keys ("check-keys-after-deserialization", TALER_TESTING_cmd_check_keys ("check-keys-after-deserialization"),
4),
/** /**
* Use one of the deserialized keys. * Use one of the deserialized keys.
*/ */
@ -110,50 +101,25 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
char *cipher;
(void) argc; (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: char *cipher;
GNUNET_break (0);
return 1; cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
case GNUNET_NO: GNUNET_assert (NULL != cipher);
return 77; GNUNET_asprintf (&config_file,
case GNUNET_OK: "test_exchange_api_keys_cherry_picking-%s.conf",
if (GNUNET_OK != cipher);
/* Set up event loop and reschedule context, plus GNUNET_free (cipher);
* 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);
} }

View File

@ -3,48 +3,21 @@
[PATHS] [PATHS]
# Persistent data storage for the testcase # Persistent data storage for the testcase
TALER_TEST_HOME = test_exchange_api_keys_cherry_picking_home/ 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] [taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[taler-exchange-secmod-eddsa] [taler-exchange-secmod-eddsa]
OVERLAP_DURATION = 1 s OVERLAP_DURATION = 1 s
DURATION = 30 s DURATION = 30 s
LOOKAHEAD_SIGN = 20 s LOOKAHEAD_SIGN = 20 s
[auditor]
BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to
PORT = 8083
[exchange] [exchange]
AML_THRESHOLD = EUR:1000000 AML_THRESHOLD = EUR:1000000
# HTTP port the exchange listens to
PORT = 8081 PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres 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/" BASE_URL = "http://localhost:8081/"
[exchangedb-postgres] [exchangedb-postgres]
@ -55,6 +28,8 @@ CONFIG = "postgres:///talercheck"
[exchange-account-1] [exchange-account-1]
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42" PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
[exchange-accountcredentials-1] [exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:9082/42/" WIRE_GATEWAY_URL = "http://localhost:9082/42/"
@ -66,11 +41,9 @@ ENABLE_CREDIT = YES
[exchange-accountcredentials-2] [exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:9082/2/" WIRE_GATEWAY_URL = "http://localhost:9082/2/"
WIRE_GATEWAY_AUTH_METHOD = basic
# Authentication information for basic authentication USERNAME = Exchange
TALER_BANK_AUTH_METHOD = "basic" PASSWORD = x
USERNAME = user
PASSWORD = pass
[bank] [bank]
HTTP_PORT=8082 HTTP_PORT=8082

View File

@ -44,9 +44,9 @@
static char *config_file; 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_Interpreter *is)
{ {
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_auditor_add ("add-auditor-OK", TALER_TESTING_cmd_run_fakebank ("run-fakebank",
MHD_HTTP_NO_CONTENT, cred.cfg,
false), "exchange-account-2"),
TALER_TESTING_cmd_wire_add ("add-wire-account", TALER_TESTING_cmd_system_start ("start-taler",
"payto://x-taler-bank/localhost/2?receiver-name=2", config_file,
MHD_HTTP_NO_CONTENT, "-e",
false), NULL),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", TALER_TESTING_cmd_get_exchange ("get-exchange",
config_file), cred.cfg,
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", true,
1), true),
TALER_TESTING_cmd_check_keys ("first-download", TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
1), TALER_TESTING_cmd_check_keys ("first-download"),
/* Causes GET /keys?last_denom_issue=0 */ /* Causes GET /keys?last_denom_issue=0 */
TALER_TESTING_cmd_check_keys_with_last_denom ("second-download", TALER_TESTING_cmd_check_keys_with_last_denom ("second-download",
1,
"zero"), "zero"),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
@ -90,50 +89,25 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
char *cipher;
(void) argc; (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: char *cipher;
GNUNET_break (0);
return 1; cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
case GNUNET_NO: GNUNET_assert (NULL != cipher);
return 77; GNUNET_asprintf (&config_file,
case GNUNET_OK: "test_exchange_api_keys_cherry_picking-%s.conf",
if (GNUNET_OK != cipher);
/* Set up event loop and reschedule context, plus GNUNET_free (cipher);
* 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);
} }

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as it under the terms of the GNU General Public License as
@ -42,14 +42,9 @@
static char *config_file; static char *config_file;
/** /**
* Exchange configuration data. * Our credentials.
*/ */
static struct TALER_TESTING_ExchangeConfiguration ec; static struct TALER_TESTING_Credentials cred;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/** /**
@ -63,6 +58,18 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct TALER_TESTING_Command revocation[] = { 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", TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT, MHD_HTTP_NO_CONTENT,
false), false),
@ -72,20 +79,20 @@ run (void *cls,
false), false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
config_file), config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", #endif
1), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
/** /**
* Fill reserve with EUR:10.02, as withdraw fee is 1 ct per * Fill reserve with EUR:10.02, as withdraw fee is 1 ct per
* config. * config.
*/ */
TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1", TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1",
"EUR:10.02", "EUR:10.02",
&bc.exchange_auth, &cred.ba,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
"EUR:10.02", "EUR:10.02",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-1"), "create-reserve-1"),
/** /**
* Run wire-watch to trigger the reserve creation. * Run wire-watch to trigger the reserve creation.
@ -109,7 +116,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-partial", TALER_TESTING_cmd_deposit ("deposit-partial",
"withdraw-revocation-coin-1", "withdraw-revocation-coin-1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -118,7 +125,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-full", TALER_TESTING_cmd_deposit ("deposit-full",
"withdraw-revocation-coin-2", "withdraw-revocation-coin-2",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:5", "EUR:5",
@ -241,9 +248,8 @@ run (void *cls,
}; };
(void) cls; (void) cls;
TALER_TESTING_run_with_fakebank (is, TALER_TESTING_run (is,
revocation, revocation);
bc.exchange_auth.wire_gateway_url);
} }
@ -251,56 +257,25 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
char *cipher;
(void) argc; (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: char *cipher;
GNUNET_break (0);
return 1; cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
case GNUNET_NO: GNUNET_assert (NULL != cipher);
return 77; GNUNET_asprintf (&config_file,
case GNUNET_OK: "test_exchange_api-%s.conf",
if (GNUNET_OK != cipher);
/* Set up event loop and reschedule context, plus GNUNET_free (cipher);
* 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);
} }

View File

@ -43,21 +43,16 @@
*/ */
static char *config_file; static char *config_file;
/**
* Our credentials.
*/
static struct TALER_TESTING_Credentials cred;
/** /**
* (real) Twister URL. Used at startup time to check if it runs. * (real) Twister URL. Used at startup time to check if it runs.
*/ */
static char *twister_url; static char *twister_url;
/**
* Exchange configuration data.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/** /**
* Twister process. * Twister process.
*/ */
@ -92,8 +87,8 @@ CMD_TRANSFER_TO_EXCHANGE (const char *label,
{ {
return TALER_TESTING_cmd_admin_add_incoming (label, return TALER_TESTING_cmd_admin_add_incoming (label,
amount, amount,
&bc.exchange_auth, &cred.ba,
bc.user42_payto); cred.user42_payto);
} }
@ -132,7 +127,7 @@ run (void *cls,
"refresh-deposit-partial", "refresh-deposit-partial",
"refresh-withdraw-coin", "refresh-withdraw-coin",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
@ -178,7 +173,7 @@ run (void *cls,
"deposit-refund-1", "deposit-refund-1",
"withdraw-coin-r1", "withdraw-coin-r1",
0, 0,
bc.user42_payto, cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_MINUTES,
"EUR:5", "EUR:5",
@ -201,7 +196,7 @@ run (void *cls,
"deposit-refund-to-fail", "deposit-refund-to-fail",
"withdraw-coin-r1", "withdraw-coin-r1",
0, /* coin index. */ 0, /* coin index. */
bc.user42_payto, cred.user42_payto,
/* This parameter will make any comparison about /* This parameter will make any comparison about
h_contract_terms fail, when /refund will be handled. h_contract_terms fail, when /refund will be handled.
So in other words, this is h_contract mismatch. */ So in other words, this is h_contract mismatch. */
@ -251,17 +246,17 @@ run (void *cls,
#endif #endif
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_wire_add ( TALER_TESTING_cmd_run_fakebank ("run-fakebank",
"add-wire-account", cred.cfg,
"payto://x-taler-bank/localhost/2?receiver-name=2", "exchange-account-2"),
MHD_HTTP_NO_CONTENT, TALER_TESTING_cmd_system_start ("start-taler",
false), config_file,
TALER_TESTING_cmd_exec_offline_sign_keys ( "-e",
"offline-sign-future-keys", NULL),
config_file), TALER_TESTING_cmd_get_exchange ("get-exchange",
TALER_TESTING_cmd_check_keys_pull_all_keys ( cred.cfg,
"refetch /keys", true,
1), true),
TALER_TESTING_cmd_batch ( TALER_TESTING_cmd_batch (
"refresh-reveal-409-conflict", "refresh-reveal-409-conflict",
refresh_409_conflict), refresh_409_conflict),
@ -276,16 +271,15 @@ run (void *cls,
}; };
(void) cls; (void) cls;
TALER_TESTING_run_with_fakebank (is, TALER_TESTING_run (is,
commands, commands);
bc.exchange_auth.wire_gateway_url);
} }
/** /**
* Kill, wait, and destroy convenience function. * Kill, wait, and destroy convenience function.
* *
* @param process process to purge. * @param[in] process process to purge.
*/ */
static void static void
purge_process (struct GNUNET_OS_Process *process) purge_process (struct GNUNET_OS_Process *process)
@ -301,57 +295,37 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
char *cipher;
int ret; int ret;
(void) argc; (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_twisted-%s.conf",
cipher);
GNUNET_free (cipher);
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (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: char *cipher;
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);
purge_process (twisterd);
GNUNET_free (twister_url);
if (GNUNET_OK != ret) cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
return 1; GNUNET_assert (NULL != cipher);
break; GNUNET_asprintf (&config_file,
default: "test_exchange_api_twisted-%s.conf",
GNUNET_break (0); cipher);
return 1; GNUNET_free (cipher);
} }
return 0; /* 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",
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
purge_process (twisterd);
GNUNET_free (twister_url);
return ret;
} }

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as it under the terms of the GNU General Public License as
@ -35,16 +35,10 @@
*/ */
static char *config_file; static char *config_file;
/** /**
* Exchange configuration data. * Our credentials.
*/ */
static struct TALER_TESTING_ExchangeConfiguration ec; static struct TALER_TESTING_Credentials cred;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/** /**
@ -58,10 +52,20 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
/* this currently fails, because the TALER_TESTING_cmd_system_start ("start-taler",
auditor is already added by the test setup logic */ config_file,
TALER_TESTING_cmd_auditor_del ("del-auditor-NOT-FOUND", "-u", "exchange-account-2",
MHD_HTTP_NOT_FOUND, "-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), false),
TALER_TESTING_cmd_auditor_add ("add-auditor-BAD-SIG", TALER_TESTING_cmd_auditor_add ("add-auditor-BAD-SIG",
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
@ -141,15 +145,13 @@ run (void *cls,
false), false),
TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys", TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys",
config_file), config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
1),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
(void) cls; (void) cls;
TALER_TESTING_run_with_fakebank (is, TALER_TESTING_run (is,
commands, commands);
bc.exchange_auth.wire_gateway_url);
} }
@ -157,56 +159,25 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
char *cipher;
(void) argc; (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: char *cipher;
GNUNET_break (0);
return 1; cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
case GNUNET_NO: GNUNET_assert (NULL != cipher);
return 77; GNUNET_asprintf (&config_file,
case GNUNET_OK: "test_exchange_api-%s.conf",
if (GNUNET_OK != cipher);
/* Set up event loop and reschedule context, plus GNUNET_free (cipher);
* 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);
} }

View File

@ -42,14 +42,9 @@
static char *config_file; static char *config_file;
/** /**
* 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;
/** /**
* Some tests behave differently when using CS as we cannot * 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) \ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_admin_add_incoming (label, amount, \ TALER_TESTING_cmd_admin_add_incoming (label, amount, \
&bc.exchange_auth, \ &cred.ba, \
bc.user42_payto) cred.user42_payto)
/** /**
* Main function that will tell the interpreter what commands to * Main function that will tell the interpreter what commands to
@ -122,13 +117,13 @@ run (void *cls,
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
"EUR:5.04", "EUR:5.04",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-1"), "create-reserve-1"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-2", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-2",
"EUR:5.01", "EUR:5.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-2"), "create-reserve-2"),
/** /**
* Make a reserve exist, according to the previous * Make a reserve exist, according to the previous
@ -380,15 +375,15 @@ run (void *cls,
"EUR:1.04"), "EUR:1.04"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-100", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-100",
"EUR:1.04", "EUR:1.04",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-100"), "create-reserve-100"),
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-101", CMD_TRANSFER_TO_EXCHANGE ("create-reserve-101",
"EUR:1.04"), "EUR:1.04"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-101", TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-101",
"EUR:1.04", "EUR:1.04",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-101"), "create-reserve-101"),
CMD_EXEC_WIREWATCH ("wirewatch-100"), CMD_EXEC_WIREWATCH ("wirewatch-100"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-100", TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-100",
@ -500,32 +495,18 @@ run (void *cls,
}; };
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
/* setup exchange */ TALER_TESTING_cmd_run_fakebank ("run-fakebank",
TALER_TESTING_cmd_auditor_add ("add-auditor-OK", cred.cfg,
MHD_HTTP_NO_CONTENT, "exchange-account-2"),
false), TALER_TESTING_cmd_system_start ("start-taler",
TALER_TESTING_cmd_exec_offline_sign_extensions ("offline-sign-extensions", config_file,
config_file), "-e",
TALER_TESTING_cmd_wire_add ("add-wire-account", NULL),
"payto://x-taler-bank/localhost/2?receiver-name=2", TALER_TESTING_cmd_get_exchange ("get-exchange",
MHD_HTTP_NO_CONTENT, cred.cfg,
false), true,
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-wire-fees", true),
config_file, TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
"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),
TALER_TESTING_cmd_batch ("withdraw", TALER_TESTING_cmd_batch ("withdraw",
withdraw), withdraw),
TALER_TESTING_cmd_batch ("push", TALER_TESTING_cmd_batch ("push",
@ -541,9 +522,8 @@ run (void *cls,
}; };
(void) cls; (void) cls;
TALER_TESTING_run_with_fakebank (is, TALER_TESTING_run (is,
commands, commands);
bc.exchange_auth.wire_gateway_url);
} }
@ -551,59 +531,26 @@ int
main (int argc, main (int argc,
char *const *argv) char *const *argv)
{ {
char *cipher;
(void) argc; (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);
uses_cs = (0 == strcmp (cipher, "cs"));
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: char *cipher;
GNUNET_break (0);
return 1; cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
case GNUNET_NO: GNUNET_assert (NULL != cipher);
return 78; uses_cs = (0 == strcmp (cipher, "cs"));
case GNUNET_OK: GNUNET_asprintf (&config_file,
if (GNUNET_OK != "test_exchange_api-%s.conf",
/* Set up event loop and reschedule context, plus cipher);
* start/stop the exchange. It calls TALER_TESTING_setup GNUNET_free (cipher);
* 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);
} }

View File

@ -41,14 +41,10 @@
#define CONFIG_FILE "test_kyc_api.conf" #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 * Execute the taler-exchange-wirewatch command with
@ -79,8 +75,8 @@ static struct TALER_TESTING_BankConfiguration bc;
*/ */
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_admin_add_incoming (label, amount, \ TALER_TESTING_cmd_admin_add_incoming (label, amount, \
&bc.exchange_auth, \ &cred.ba, \
bc.user42_payto) cred.user42_payto)
/** /**
* Main function that will tell the interpreter what commands to * Main function that will tell the interpreter what commands to
@ -98,8 +94,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer ( TALER_TESTING_cmd_check_bank_admin_transfer (
"check-create-reserve-1", "check-create-reserve-1",
"EUR:15.02", "EUR:15.02",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"create-reserve-1"), "create-reserve-1"),
CMD_EXEC_WIREWATCH ("wirewatch-1"), CMD_EXEC_WIREWATCH ("wirewatch-1"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-no-kyc", TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-no-kyc",
@ -150,7 +146,7 @@ run (void *cls,
"deposit-simple", "deposit-simple",
"withdraw-coin-1", "withdraw-coin-1",
0, 0,
bc.user43_payto, cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:5", "EUR:5",
@ -196,10 +192,10 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-after-kyc"), CMD_EXEC_AGGREGATOR ("run-aggregator-after-kyc"),
TALER_TESTING_cmd_check_bank_transfer ( TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-499c", "check_bank_transfer-499c",
ec.exchange_url, cred.exchange_url,
"EUR:4.98", "EUR:4.98",
bc.exchange_payto, cred.exchange_payto,
bc.user43_payto), cred.user43_payto),
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
@ -255,13 +251,13 @@ run (void *cls,
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-1", TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-1",
"EUR:5.04", "EUR:5.04",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"p2p_create-reserve-1"), "p2p_create-reserve-1"),
TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-2", TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-2",
"EUR:5.01", "EUR:5.01",
bc.user42_payto, cred.user42_payto,
bc.exchange_payto, cred.exchange_payto,
"p2p_create-reserve-2"), "p2p_create-reserve-2"),
/** /**
* Make a reserve exist, according to the previous * Make a reserve exist, according to the previous
@ -518,29 +514,18 @@ run (void *cls,
}; };
struct TALER_TESTING_Command commands[] = { struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees", TALER_TESTING_cmd_run_fakebank ("run-fakebank",
CONFIG_FILE, cred.cfg,
"EUR:0.01", "exchange-account-2"),
"EUR:0.01"), TALER_TESTING_cmd_system_start ("start-taler",
TALER_TESTING_cmd_exec_offline_sign_global_fees ("offline-sign-global-fees", CONFIG_FILE,
CONFIG_FILE, "-e",
"EUR:0.01", NULL),
"EUR:0.01", TALER_TESTING_cmd_get_exchange ("get-exchange",
"EUR:0.01", cred.cfg,
GNUNET_TIME_UNIT_MINUTES, true,
GNUNET_TIME_UNIT_DAYS, true),
1), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
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),
TALER_TESTING_cmd_batch ("withdraw", TALER_TESTING_cmd_batch ("withdraw",
withdraw), withdraw),
TALER_TESTING_cmd_batch ("spend", TALER_TESTING_cmd_batch ("spend",
@ -563,9 +548,8 @@ run (void *cls,
}; };
(void) cls; (void) cls;
TALER_TESTING_run_with_fakebank (is, TALER_TESTING_run (is,
commands, commands);
bc.exchange_auth.wire_gateway_url);
} }
@ -574,48 +558,14 @@ main (int argc,
char *const *argv) char *const *argv)
{ {
(void) argc; (void) argc;
(void) argv; return TALER_TESTING_main (argv,
/* These environment variables get in the way... */ "INFO",
unsetenv ("XDG_DATA_HOME"); CONFIG_FILE,
unsetenv ("XDG_CONFIG_HOME"); "exchange-account-2",
GNUNET_log_setup ("test-kyc-api", TALER_TESTING_BS_FAKEBANK,
"INFO", &cred,
NULL); &run,
/* Check fakebank port is available and get configuration data. */ NULL);
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;
} }

View File

@ -1,51 +1,7 @@
# This file is in the public domain. # This file is in the public domain.
# #
[PATHS] @INLINE@ coins-rsa.conf
# Persistent data storage for the testcase @INLINE@ test_exchange_api.conf
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/"
[kyc-provider-test-oauth2] [kyc-provider-test-oauth2]
COST = 0 COST = 0
@ -83,157 +39,3 @@ OPERATION_TYPE = MERGE
REQUIRED_CHECKS = DUMMY REQUIRED_CHECKS = DUMMY
THRESHOLD = EUR:0 THRESHOLD = EUR:0
TIMEFRAME = 1d 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

View File

@ -31,24 +31,9 @@
/** /**
* Helper structure to keep exchange configuration values. * Our credentials.
*/ */
static struct TALER_TESTING_ExchangeConfiguration ec; struct TALER_TESTING_Credentials cred;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/**
* Contains plugin.
*/
static struct TALER_TESTING_DatabaseConnection dbc;
/**
* Return value from main().
*/
static int result;
/** /**
* Name of the configuration file to use. * Name of the configuration file to use.
@ -70,24 +55,6 @@ static char *config_filename;
TALER_TESTING_cmd_exec_transfer (label "-transfer", cfg_fn) 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. * Collects all the tests.
*/ */
@ -96,11 +63,13 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct TALER_TESTING_Command all[] = { struct TALER_TESTING_Command all[] = {
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees", TALER_TESTING_cmd_run_fakebank ("run-fakebank",
config_filename, cred.cfg,
"EUR:0.01", "exchange-account-1"),
"EUR:0.01"), TALER_TESTING_cmd_system_start ("start-taler",
// check no aggregation happens on a empty database config_filename,
"-e",
NULL),
CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty-db", CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty-db",
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"), 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: /* check aggregation happens on the simplest case:
one deposit into the database. */ one deposit into the database. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-1", TALER_TESTING_cmd_insert_deposit ("do-deposit-1",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -119,15 +88,15 @@ run (void *cls,
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
ec.exchange_url, cred.exchange_url,
"EUR:0.89", "EUR:0.89",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-1"), TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-1"),
/* check aggregation accumulates well. */ /* check aggregation accumulates well. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-2a", TALER_TESTING_cmd_insert_deposit ("do-deposit-2a",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -136,7 +105,7 @@ run (void *cls,
"EUR:0.1"), "EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-2b", TALER_TESTING_cmd_insert_deposit ("do-deposit-2b",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -148,15 +117,15 @@ run (void *cls,
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-2", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-2",
ec.exchange_url, cred.exchange_url,
"EUR:1.79", "EUR:1.79",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-2"), TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-2"),
/* check that different merchants stem different aggregations. */ /* check that different merchants stem different aggregations. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-3a", TALER_TESTING_cmd_insert_deposit ("do-deposit-3a",
&dbc, cred.cfg,
"bob", "bob",
"4", "4",
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -164,7 +133,7 @@ run (void *cls,
"EUR:1", "EUR:1",
"EUR:0.1"), "EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-3b", TALER_TESTING_cmd_insert_deposit ("do-deposit-3b",
&dbc, cred.cfg,
"bob", "bob",
"5", "5",
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -172,7 +141,7 @@ run (void *cls,
"EUR:1", "EUR:1",
"EUR:0.1"), "EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-3c", TALER_TESTING_cmd_insert_deposit ("do-deposit-3c",
&dbc, cred.cfg,
"alice", "alice",
"4", "4",
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -183,25 +152,25 @@ run (void *cls,
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3a", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3a",
ec.exchange_url, cred.exchange_url,
"EUR:0.89", "EUR:0.89",
bc.exchange_payto, cred.exchange_payto,
"payto://x-taler-bank/localhost/4?receiver-name=4"), "payto://x-taler-bank/localhost/4?receiver-name=4"),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b",
ec.exchange_url, cred.exchange_url,
"EUR:0.89", "EUR:0.89",
bc.exchange_payto, cred.exchange_payto,
"payto://x-taler-bank/localhost/4?receiver-name=4"), "payto://x-taler-bank/localhost/4?receiver-name=4"),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c",
ec.exchange_url, cred.exchange_url,
"EUR:0.89", "EUR:0.89",
bc.exchange_payto, cred.exchange_payto,
"payto://x-taler-bank/localhost/5?receiver-name=5"), "payto://x-taler-bank/localhost/5?receiver-name=5"),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-3"), TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-3"),
/* checking that aggregator waits for the deadline. */ /* checking that aggregator waits for the deadline. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-4a", TALER_TESTING_cmd_insert_deposit ("do-deposit-4a",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -211,7 +180,7 @@ run (void *cls,
"EUR:0.2", "EUR:0.2",
"EUR:0.1"), "EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-4b", TALER_TESTING_cmd_insert_deposit ("do-deposit-4b",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -230,14 +199,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-4-delayed", CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-4-delayed",
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-4", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-4",
ec.exchange_url, cred.exchange_url,
"EUR:0.19", "EUR:0.19",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
// test picking all deposits at earliest deadline // test picking all deposits at earliest deadline
TALER_TESTING_cmd_insert_deposit ("do-deposit-5a", TALER_TESTING_cmd_insert_deposit ("do-deposit-5a",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -248,7 +217,7 @@ run (void *cls,
"EUR:0.1"), "EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-5b", TALER_TESTING_cmd_insert_deposit ("do-deposit-5b",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -267,13 +236,13 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-5-delayed", CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-5-delayed",
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-5", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-5",
ec.exchange_url, cred.exchange_url,
"EUR:0.19", "EUR:0.19",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
/* Test NEVER running 'tiny' unless they make up minimum unit */ /* Test NEVER running 'tiny' unless they make up minimum unit */
TALER_TESTING_cmd_insert_deposit ("do-deposit-6a", TALER_TESTING_cmd_insert_deposit ("do-deposit-6a",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -285,7 +254,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty ( TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-6a-tiny"), "expect-empty-transactions-after-6a-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-6b", TALER_TESTING_cmd_insert_deposit ("do-deposit-6b",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -293,7 +262,7 @@ run (void *cls,
"EUR:0.102", "EUR:0.102",
"EUR:0.1"), "EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-6c", TALER_TESTING_cmd_insert_deposit ("do-deposit-6c",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -305,7 +274,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty ( TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-6c-tiny"), "expect-empty-transactions-after-6c-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-6d", TALER_TESTING_cmd_insert_deposit ("do-deposit-6d",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -317,7 +286,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty ( TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-6d-tiny"), "expect-empty-transactions-after-6d-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-6e", TALER_TESTING_cmd_insert_deposit ("do-deposit-6e",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -327,14 +296,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-6e", CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-6e",
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-6", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-6",
ec.exchange_url, cred.exchange_url,
"EUR:0.01", "EUR:0.01",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
/* Test profiteering if wire deadline is short */ /* Test profiteering if wire deadline is short */
TALER_TESTING_cmd_insert_deposit ("do-deposit-7a", TALER_TESTING_cmd_insert_deposit ("do-deposit-7a",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -346,7 +315,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty ( TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-7a-tiny"), "expect-empty-transactions-after-7a-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-7b", TALER_TESTING_cmd_insert_deposit ("do-deposit-7b",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -356,14 +325,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-profit", CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-profit",
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
ec.exchange_url, cred.exchange_url,
"EUR:0.01", "EUR:0.01",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
/* Now check profit was actually taken */ /* Now check profit was actually taken */
TALER_TESTING_cmd_insert_deposit ("do-deposit-7c", TALER_TESTING_cmd_insert_deposit ("do-deposit-7c",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -373,14 +342,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-loss", CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-loss",
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
ec.exchange_url, cred.exchange_url,
"EUR:0.01", "EUR:0.01",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
/* Test that aggregation would happen fully if wire deadline is long */ /* Test that aggregation would happen fully if wire deadline is long */
TALER_TESTING_cmd_insert_deposit ("do-deposit-8a", TALER_TESTING_cmd_insert_deposit ("do-deposit-8a",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -394,7 +363,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty ( TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-8a-tiny"), "expect-empty-transactions-after-8a-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-8b", TALER_TESTING_cmd_insert_deposit ("do-deposit-8b",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -410,7 +379,7 @@ run (void *cls,
/* now trigger aggregate with large transaction and short deadline */ /* now trigger aggregate with large transaction and short deadline */
TALER_TESTING_cmd_insert_deposit ("do-deposit-8c", TALER_TESTING_cmd_insert_deposit ("do-deposit-8c",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -420,14 +389,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-8", CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-8",
config_filename), config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-8", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-8",
ec.exchange_url, cred.exchange_url,
"EUR:0.03", "EUR:0.03",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
/* Test aggregation with fees and rounding profits. */ /* Test aggregation with fees and rounding profits. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-9a", TALER_TESTING_cmd_insert_deposit ("do-deposit-9a",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -441,7 +410,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty ( TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-9a-tiny"), "expect-empty-transactions-after-9a-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-9b", TALER_TESTING_cmd_insert_deposit ("do-deposit-9b",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -457,7 +426,7 @@ run (void *cls,
/* now trigger aggregate with large transaction and short deadline */ /* now trigger aggregate with large transaction and short deadline */
TALER_TESTING_cmd_insert_deposit ("do-deposit-9c", TALER_TESTING_cmd_insert_deposit ("do-deposit-9c",
&dbc, cred.cfg,
"bob", "bob",
USER42_ACCOUNT, USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (), GNUNET_TIME_timestamp_get (),
@ -468,49 +437,15 @@ run (void *cls,
config_filename), config_filename),
/* 0.009 + 0.009 + 0.022 - 0.001 - 0.002 - 0.008 = 0.029 => 0.02 */ /* 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", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-9",
ec.exchange_url, cred.exchange_url,
"EUR:0.01", "EUR:0.01",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
TALER_TESTING_run_with_fakebank (is, TALER_TESTING_run (is,
all, 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);
} }
@ -519,7 +454,6 @@ main (int argc,
char *const argv[]) char *const argv[])
{ {
const char *plugin_name; const char *plugin_name;
char *testname;
if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
{ {
@ -527,52 +461,17 @@ main (int argc,
return -1; return -1;
} }
plugin_name++; plugin_name++;
(void) GNUNET_asprintf (&testname,
"test-taler-exchange-aggregator-%s",
plugin_name);
(void) GNUNET_asprintf (&config_filename, (void) GNUNET_asprintf (&config_filename,
"%s.conf", "test-taler-exchange-aggregator-%s.conf",
testname); plugin_name);
return TALER_TESTING_main (argv,
GNUNET_log_setup ("test_taler_exchange_aggregator", "INFO",
"INFO", config_filename,
NULL); "exchange-account-1",
TALER_TESTING_BS_FAKEBANK,
/* these might get in the way */ &cred,
unsetenv ("XDG_DATA_HOME"); &run,
unsetenv ("XDG_CONFIG_HOME"); NULL);
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,
"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;
} }

View File

@ -34,14 +34,9 @@
/** /**
* Bank configuration data. * Our credentials.
*/ */
static struct TALER_TESTING_BankConfiguration bc; static struct TALER_TESTING_Credentials cred;
/**
* Helper structure to keep exchange configuration values.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/** /**
* Name of the configuration file to use. * 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, return TALER_TESTING_cmd_admin_add_incoming (label,
amount, amount,
&bc.exchange_auth, &cred.ba,
bc.user42_payto); cred.user42_payto);
} }
@ -82,21 +77,19 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct TALER_TESTING_Command all[] = { struct TALER_TESTING_Command all[] = {
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees", TALER_TESTING_cmd_run_fakebank ("run-fakebank",
config_filename, cred.cfg,
"EUR:0.01", "exchange-account-1"),
"EUR:0.01"), TALER_TESTING_cmd_system_start ("start-taler",
TALER_TESTING_cmd_auditor_add ("add-auditor-OK", config_filename,
MHD_HTTP_NO_CONTENT, "-e",
false), "-u", "exchange-account-1",
TALER_TESTING_cmd_wire_add ("add-wire-account", NULL),
"payto://x-taler-bank/localhost/2?receiver-name=2", TALER_TESTING_cmd_get_exchange ("get-exchange",
MHD_HTTP_NO_CONTENT, cred.cfg,
false), true,
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", true),
config_filename), TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"), TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),
CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty"), CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty"),
TALER_TESTING_cmd_exec_wirewatch ("run-wirewatch-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 ( TALER_TESTING_cmd_check_bank_admin_transfer (
"clear-good-transfer-to-the-exchange", "clear-good-transfer-to-the-exchange",
"EUR:5", "EUR:5",
bc.user42_payto, // debit cred.user42_payto, // debit
bc.exchange_payto, // credit cred.exchange_payto, // credit
"run-transfer-good-to-exchange"), "run-transfer-good-to-exchange"),
TALER_TESTING_cmd_exec_closer ("run-closer-non-expired-reserve", TALER_TESTING_cmd_exec_closer ("run-closer-non-expired-reserve",
@ -135,18 +128,17 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-closer-on-expired-reserve"), CMD_EXEC_AGGREGATOR ("run-closer-on-expired-reserve"),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1", TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
ec.exchange_url, cred.exchange_url,
"EUR:4.99", "EUR:4.99",
bc.exchange_payto, cred.exchange_payto,
bc.user42_payto), cred.user42_payto),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-2"), TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-2"),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
(void) cls; (void) cls;
TALER_TESTING_run_with_fakebank (is, TALER_TESTING_run (is,
all, all);
bc.exchange_auth.wire_gateway_url);
} }
@ -154,69 +146,29 @@ int
main (int argc, main (int argc,
char *const argv[]) char *const argv[])
{ {
const char *plugin_name;
(void) argc; (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) '-')))
{ {
GNUNET_break (0); const char *plugin_name;
return -1;
}
plugin_name++;
{
char *testname;
GNUNET_asprintf (&testname, plugin_name = strrchr (argv[0], (int) '-');
"test-taler-exchange-wirewatch-%s", if (NULL == plugin_name)
plugin_name); {
GNUNET_break (0);
return -1;
}
plugin_name++;
GNUNET_asprintf (&config_filename, GNUNET_asprintf (&config_filename,
"%s.conf", "test-taler-exchange-wirewatch-%s.conf",
testname); plugin_name);
GNUNET_free (testname);
} }
/* check database is working */ return TALER_TESTING_main (argv,
{ "INFO",
struct GNUNET_PQ_Context *conn; config_filename,
struct GNUNET_PQ_ExecuteStatement es[] = { "exchange-account-1",
GNUNET_PQ_EXECUTE_STATEMENT_END TALER_TESTING_BS_FAKEBANK,
}; &cred,
&run,
conn = GNUNET_PQ_connect ("postgres:///talercheck", NULL);
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,
"exchange-account-1",
&bc))
return 77;
return (GNUNET_OK ==
TALER_TESTING_setup_with_exchange (&run,
NULL,
config_filename)) ? 0 : 1;
} }

View File

@ -18,7 +18,7 @@
*/ */
/** /**
* @file testing/testing_api_cmd_auditor_add.c * @file testing/testing_api_cmd_auditor_add.c
* @brief command for testing /auditor_add. * @brief command for testing auditor_add
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#include "platform.h" #include "platform.h"
@ -75,16 +75,8 @@ auditor_add_cb (
ds->dh = NULL; ds->dh = NULL;
if (ds->expected_response_code != hr->http_status) if (ds->expected_response_code != hr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", hr->http_status);
hr->http_status,
ds->is->commands[ds->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (ds->is);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);
@ -106,10 +98,43 @@ auditor_add_run (void *cls,
struct AuditorAddState *ds = cls; struct AuditorAddState *ds = cls;
struct GNUNET_TIME_Timestamp now; struct GNUNET_TIME_Timestamp now;
struct TALER_MasterSignatureP master_sig; 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; (void) cmd;
now = GNUNET_TIME_timestamp_get (); now = GNUNET_TIME_timestamp_get ();
ds->is = is; 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) if (ds->bad_sig)
{ {
memset (&master_sig, memset (&master_sig,
@ -118,17 +143,22 @@ auditor_add_run (void *cls,
} }
else else
{ {
TALER_exchange_offline_auditor_add_sign (&is->auditor_pub, const struct TALER_MasterPrivateKeyP *master_priv;
is->auditor_url,
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, now,
&is->master_priv, master_priv,
&master_sig); &master_sig);
} }
ds->dh = TALER_EXCHANGE_management_enable_auditor ( ds->dh = TALER_EXCHANGE_management_enable_auditor (
is->ctx, TALER_TESTING_interpreter_get_context (is),
is->exchange_url, exchange_url,
&is->auditor_pub, auditor_pub,
is->auditor_url, auditor_url,
"test-case auditor", /* human-readable auditor name */ "test-case auditor", /* human-readable auditor name */
now, now,
&master_sig, &master_sig,
@ -158,10 +188,8 @@ auditor_add_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_management_enable_auditor_cancel (ds->dh); TALER_EXCHANGE_management_enable_auditor_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -80,16 +80,8 @@ denom_sig_add_cb (
ds->dh = NULL; ds->dh = NULL;
if (ds->expected_response_code != hr->http_status) if (ds->expected_response_code != hr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", hr->http_status);
hr->http_status,
ds->is->commands[ds->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (ds->is);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);
@ -112,6 +104,11 @@ auditor_add_run (void *cls,
struct TALER_AuditorSignatureP auditor_sig; struct TALER_AuditorSignatureP auditor_sig;
struct TALER_DenominationHashP h_denom_pub; struct TALER_DenominationHashP h_denom_pub;
const struct TALER_EXCHANGE_DenomPublicKey *dk; 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; (void) cmd;
/* Get denom pub from trait */ /* Get denom pub from trait */
@ -120,7 +117,6 @@ auditor_add_run (void *cls,
denom_cmd = TALER_TESTING_interpreter_lookup_command (is, denom_cmd = TALER_TESTING_interpreter_lookup_command (is,
ds->denom_ref); ds->denom_ref);
if (NULL == denom_cmd) if (NULL == denom_cmd)
{ {
GNUNET_break (0); GNUNET_break (0);
@ -133,6 +129,31 @@ auditor_add_run (void *cls,
&dk)); &dk));
} }
ds->is = is; 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) if (ds->bad_sig)
{ {
memset (&auditor_sig, memset (&auditor_sig,
@ -141,28 +162,33 @@ auditor_add_run (void *cls,
} }
else 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, GNUNET_assert (GNUNET_OK ==
&master_pub.eddsa_pub); 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 ( TALER_auditor_denom_validity_sign (
is->auditor_url, auditor_url,
&dk->h_key, &dk->h_key,
&master_pub, master_pub,
dk->valid_from, dk->valid_from,
dk->withdraw_valid_until, dk->withdraw_valid_until,
dk->expire_deposit, dk->expire_deposit,
dk->expire_legal, dk->expire_legal,
&dk->value, &dk->value,
&dk->fees, &dk->fees,
&is->auditor_priv, auditor_priv,
&auditor_sig); &auditor_sig);
} }
ds->dh = TALER_EXCHANGE_add_auditor_denomination ( ds->dh = TALER_EXCHANGE_add_auditor_denomination (
is->ctx, TALER_TESTING_interpreter_get_context (is),
is->exchange_url, exchange_url,
&h_denom_pub, &h_denom_pub,
&is->auditor_pub, auditor_pub,
&auditor_sig, &auditor_sig,
&denom_sig_add_cb, &denom_sig_add_cb,
ds); ds);
@ -190,10 +216,8 @@ auditor_add_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_add_auditor_denomination_cancel (ds->dh); TALER_EXCHANGE_add_auditor_denomination_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -76,16 +76,8 @@ auditor_del_cb (
ds->dh = NULL; ds->dh = NULL;
if (ds->expected_response_code != hr->http_status) if (ds->expected_response_code != hr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", hr->http_status);
hr->http_status,
ds->is->commands[ds->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (ds->is);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);
@ -107,10 +99,36 @@ auditor_del_run (void *cls,
struct AuditorDelState *ds = cls; struct AuditorDelState *ds = cls;
struct TALER_MasterSignatureP master_sig; struct TALER_MasterSignatureP master_sig;
struct GNUNET_TIME_Timestamp now; 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; (void) cmd;
now = GNUNET_TIME_timestamp_get (); now = GNUNET_TIME_timestamp_get ();
ds->is = is; 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) if (ds->bad_sig)
{ {
memset (&master_sig, memset (&master_sig,
@ -119,15 +137,20 @@ auditor_del_run (void *cls,
} }
else 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, now,
&is->master_priv, master_priv,
&master_sig); &master_sig);
} }
ds->dh = TALER_EXCHANGE_management_disable_auditor ( ds->dh = TALER_EXCHANGE_management_disable_auditor (
is->ctx, TALER_TESTING_interpreter_get_context (is),
is->exchange_url, exchange_url,
&is->auditor_pub, auditor_pub,
now, now,
&master_sig, &master_sig,
&auditor_del_cb, &auditor_del_cb,
@ -156,10 +179,8 @@ auditor_del_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_management_disable_auditor_cancel (ds->dh); TALER_EXCHANGE_management_disable_auditor_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -68,11 +68,6 @@ struct DepositConfirmationState
*/ */
struct TALER_AUDITOR_DepositConfirmationHandle *dc; struct TALER_AUDITOR_DepositConfirmationHandle *dc;
/**
* Auditor connection.
*/
struct TALER_AUDITOR_Handle *auditor;
/** /**
* Interpreter state. * Interpreter state.
*/ */
@ -125,8 +120,7 @@ do_retry (void *cls)
struct DepositConfirmationState *dcs = cls; struct DepositConfirmationState *dcs = cls;
dcs->retry_task = NULL; dcs->retry_task = NULL;
dcs->is->commands[dcs->is->ip].last_req_time TALER_TESTING_touch_cmd (dcs->is);
= GNUNET_TIME_absolute_get ();
deposit_confirmation_run (dcs, deposit_confirmation_run (dcs,
NULL, NULL,
dcs->is); dcs->is);
@ -166,21 +160,15 @@ deposit_confirmation_cb (void *cls,
else else
dcs->backoff = GNUNET_TIME_randomized_backoff (dcs->backoff, dcs->backoff = GNUNET_TIME_randomized_backoff (dcs->backoff,
MAX_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, dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff,
&do_retry, &do_retry,
dcs); dcs);
return; return;
} }
} }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (dcs->is,
"Unexpected response code %u to command %s in %s:%u\n", hr->http_status);
hr->http_status,
dcs->is->commands[dcs->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply, stderr, 0);
TALER_TESTING_interpreter_fail (dcs->is);
return; return;
} }
TALER_TESTING_interpreter_next (dcs->is); TALER_TESTING_interpreter_next (dcs->is);
@ -220,10 +208,31 @@ deposit_confirmation_run (void *cls,
const struct TALER_CoinSpendPrivateKeyP *coin_priv; const struct TALER_CoinSpendPrivateKeyP *coin_priv;
const struct TALER_EXCHANGE_Keys *keys; const struct TALER_EXCHANGE_Keys *keys;
const struct TALER_EXCHANGE_SigningPublicKey *spk; const struct TALER_EXCHANGE_SigningPublicKey *spk;
struct TALER_AUDITOR_Handle *auditor;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
dcs->is = is; dcs->is = is;
GNUNET_assert (NULL != dcs->deposit_reference); 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 deposit_cmd
= TALER_TESTING_interpreter_lookup_command (is, = TALER_TESTING_interpreter_lookup_command (is,
dcs->deposit_reference); dcs->deposit_reference);
@ -251,7 +260,7 @@ deposit_confirmation_run (void *cls,
dcs->coin_index, dcs->coin_index,
&wire_deadline)); &wire_deadline));
GNUNET_assert (NULL != exchange_timestamp); GNUNET_assert (NULL != exchange_timestamp);
keys = TALER_EXCHANGE_get_keys (dcs->is->exchange); keys = TALER_EXCHANGE_get_keys (exchange);
GNUNET_assert (NULL != keys); GNUNET_assert (NULL != keys);
spk = TALER_EXCHANGE_get_signing_key_info (keys, spk = TALER_EXCHANGE_get_signing_key_info (keys,
exchange_pub); exchange_pub);
@ -308,7 +317,7 @@ deposit_confirmation_run (void *cls,
if (GNUNET_TIME_absolute_is_zero (refund_deadline.abs_time)) if (GNUNET_TIME_absolute_is_zero (refund_deadline.abs_time))
refund_deadline = timestamp; refund_deadline = timestamp;
} }
dcs->dc = TALER_AUDITOR_deposit_confirmation (dcs->auditor, dcs->dc = TALER_AUDITOR_deposit_confirmation (auditor,
&h_wire, &h_wire,
&no_h_policy, &no_h_policy,
&h_contract_terms, &h_contract_terms,
@ -353,10 +362,8 @@ deposit_confirmation_cleanup (void *cls,
if (NULL != dcs->dc) if (NULL != dcs->dc)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (dcs->is,
"Command %u (%s) did not complete\n", cmd->label);
dcs->is->ip,
cmd->label);
TALER_AUDITOR_deposit_confirmation_cancel (dcs->dc); TALER_AUDITOR_deposit_confirmation_cancel (dcs->dc);
dcs->dc = NULL; dcs->dc = NULL;
} }
@ -371,7 +378,6 @@ deposit_confirmation_cleanup (void *cls,
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_deposit_confirmation (const char *label, TALER_TESTING_cmd_deposit_confirmation (const char *label,
struct TALER_AUDITOR_Handle *auditor,
const char *deposit_reference, const char *deposit_reference,
unsigned int coin_index, unsigned int coin_index,
const char *amount_without_fee, const char *amount_without_fee,
@ -380,7 +386,6 @@ TALER_TESTING_cmd_deposit_confirmation (const char *label,
struct DepositConfirmationState *dcs; struct DepositConfirmationState *dcs;
dcs = GNUNET_new (struct DepositConfirmationState); dcs = GNUNET_new (struct DepositConfirmationState);
dcs->auditor = auditor;
dcs->deposit_reference = deposit_reference; dcs->deposit_reference = deposit_reference;
dcs->coin_index = coin_index; dcs->coin_index = coin_index;
dcs->amount_without_fee = amount_without_fee; dcs->amount_without_fee = amount_without_fee;

View File

@ -53,11 +53,6 @@ struct ExchangesState
*/ */
struct TALER_AUDITOR_ListExchangesHandle *leh; struct TALER_AUDITOR_ListExchangesHandle *leh;
/**
* Auditor connection.
*/
struct TALER_AUDITOR_Handle *auditor;
/** /**
* Interpreter state. * Interpreter state.
*/ */
@ -115,8 +110,7 @@ do_retry (void *cls)
struct ExchangesState *es = cls; struct ExchangesState *es = cls;
es->retry_task = NULL; es->retry_task = NULL;
es->is->commands[es->is->ip].last_req_time TALER_TESTING_touch_cmd (es->is);
= GNUNET_TIME_absolute_get ();
exchanges_run (es, exchanges_run (es,
NULL, NULL,
es->is); es->is);
@ -159,24 +153,15 @@ exchanges_cb (void *cls,
else else
es->backoff = GNUNET_TIME_randomized_backoff (es->backoff, es->backoff = GNUNET_TIME_randomized_backoff (es->backoff,
MAX_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, es->retry_task = GNUNET_SCHEDULER_add_delayed (es->backoff,
&do_retry, &do_retry,
es); es);
return; return;
} }
} }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (es->is,
"Unexpected response code %u/%d to command %s in %s:%u\n", hr->http_status);
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);
return; return;
} }
if (NULL != es->exchange_url) if (NULL != es->exchange_url)
@ -217,13 +202,26 @@ exchanges_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct ExchangesState *es = cls; struct ExchangesState *es = cls;
const struct TALER_TESTING_Command *auditor_cmd;
struct TALER_AUDITOR_Handle *auditor;
(void) cmd; (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->is = is;
es->leh = TALER_AUDITOR_list_exchanges es->leh = TALER_AUDITOR_list_exchanges (auditor,
(is->auditor, &exchanges_cb,
&exchanges_cb, es);
es);
if (NULL == es->leh) if (NULL == es->leh)
{ {
@ -250,10 +248,8 @@ exchanges_cleanup (void *cls,
if (NULL != es->leh) if (NULL != es->leh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (es->is,
"Command %u (%s) did not complete\n", cmd->label);
es->is->ip,
cmd->label);
TALER_AUDITOR_list_exchanges_cancel (es->leh); TALER_AUDITOR_list_exchanges_cancel (es->leh);
es->leh = NULL; es->leh = NULL;
} }
@ -275,7 +271,7 @@ exchanges_cleanup (void *cls,
* @param index index number of the traits to be returned. * @param index index number of the traits to be returned.
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
static int static enum GNUNET_GenericReturnValue
exchanges_traits (void *cls, exchanges_traits (void *cls,
const void **ret, const void **ret,
const char *trait, const char *trait,
@ -301,13 +297,11 @@ exchanges_traits (void *cls,
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_exchanges (const char *label, TALER_TESTING_cmd_exchanges (const char *label,
struct TALER_AUDITOR_Handle *auditor,
unsigned int expected_response_code) unsigned int expected_response_code)
{ {
struct ExchangesState *es; struct ExchangesState *es;
es = GNUNET_new (struct ExchangesState); es = GNUNET_new (struct ExchangesState);
es->auditor = auditor;
es->expected_response_code = expected_response_code; es->expected_response_code = expected_response_code;
{ {

View File

@ -180,8 +180,7 @@ do_retry (void *cls)
struct AdminAddIncomingState *fts = cls; struct AdminAddIncomingState *fts = cls;
fts->retry_task = NULL; fts->retry_task = NULL;
fts->is->commands[fts->is->ip].last_req_time TALER_TESTING_touch_cmd (fts->is);
= GNUNET_TIME_absolute_get ();
admin_add_incoming_run (fts, admin_add_incoming_run (fts,
NULL, NULL,
fts->is); fts->is);
@ -279,7 +278,7 @@ confirmation_cb (void *cls,
else else
fts->backoff = GNUNET_TIME_randomized_backoff (fts->backoff, fts->backoff = GNUNET_TIME_randomized_backoff (fts->backoff,
MAX_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->retry_task = GNUNET_SCHEDULER_add_delayed (
fts->backoff, fts->backoff,
&do_retry, &do_retry,
@ -314,6 +313,7 @@ admin_add_incoming_run (void *cls,
bool have_public = false; bool have_public = false;
(void) cmd; (void) cmd;
fts->is = is;
/* Use reserve public key as subject */ /* Use reserve public key as subject */
if (NULL != fts->reserve_reference) if (NULL != fts->reserve_reference)
{ {
@ -364,7 +364,6 @@ admin_add_incoming_run (void *cls,
fts->reserve_history.amount = fts->amount; fts->reserve_history.amount = fts->amount;
fts->reserve_history.details.in_details.sender_url fts->reserve_history.details.in_details.sender_url
= (char *) fts->payto_debit_account; /* remember to NOT free this one... */ = (char *) fts->payto_debit_account; /* remember to NOT free this one... */
fts->is = is;
fts->aih fts->aih
= TALER_BANK_admin_add_incoming ( = TALER_BANK_admin_add_incoming (
TALER_TESTING_interpreter_get_context (is), TALER_TESTING_interpreter_get_context (is),
@ -398,9 +397,8 @@ admin_add_incoming_cleanup (void *cls,
if (NULL != fts->aih) if (NULL != fts->aih)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (fts->is,
"Command %s did not complete\n", cmd->label);
cmd->label);
TALER_BANK_admin_add_incoming_cancel (fts->aih); TALER_BANK_admin_add_incoming_cancel (fts->aih);
fts->aih = NULL; fts->aih = NULL;
} }
@ -439,12 +437,12 @@ admin_add_incoming_traits (void *cls,
{ {
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_bank_row (&fts->serial_id), 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),
TALER_TESTING_make_trait_payto_uri (&fts->payto_debit_account), TALER_TESTING_make_trait_payto_uri (fts->payto_debit_account),
/* Used as a marker, content does not matter */ /* 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 ( 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_amount (&fts->amount),
TALER_TESTING_make_trait_timestamp (0, TALER_TESTING_make_trait_timestamp (0,
&fts->timestamp), &fts->timestamp),
@ -464,13 +462,14 @@ admin_add_incoming_traits (void *cls,
{ {
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_bank_row (&fts->serial_id), 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 */ /* 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 ( 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_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_pub (&fts->reserve_pub),
TALER_TESTING_make_trait_reserve_history (0, TALER_TESTING_make_trait_reserve_history (0,
&fts->reserve_history), &fts->reserve_history),

View File

@ -82,8 +82,30 @@ check_bank_admin_transfer_run (void *cls,
const char *credit_payto; const char *credit_payto;
const struct TALER_ReservePublicKeyP *reserve_pub; const struct TALER_ReservePublicKeyP *reserve_pub;
const struct TALER_TESTING_Command *cmd_ref; const struct TALER_TESTING_Command *cmd_ref;
struct TALER_FAKEBANK_Handle *fakebank;
(void) cmd; (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 cmd_ref
= TALER_TESTING_interpreter_lookup_command (is, = TALER_TESTING_interpreter_lookup_command (is,
bcs->reserve_pub_ref); bcs->reserve_pub_ref);
@ -109,9 +131,9 @@ check_bank_admin_transfer_run (void *cls,
&amount)) &amount))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to parse amount `%s' at %u\n", "Failed to parse amount `%s' at %s\n",
bcs->amount, bcs->amount,
is->ip); TALER_TESTING_interpreter_get_current_label (is));
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }
@ -122,7 +144,7 @@ check_bank_admin_transfer_run (void *cls,
debit_payto, debit_payto,
debit_account); debit_account);
if (GNUNET_OK != if (GNUNET_OK !=
TALER_FAKEBANK_check_credit (is->fakebank, TALER_FAKEBANK_check_credit (fakebank,
&amount, &amount,
debit_account, debit_account,
credit_account, credit_account,

View File

@ -91,26 +91,48 @@ check_bank_transfer_run (void *cls,
struct TALER_Amount amount; struct TALER_Amount amount;
char *debit_account; char *debit_account;
char *credit_account; char *credit_account;
const char **exchange_base_url; const char *exchange_base_url;
const char **debit_payto; const char *debit_payto;
const char **credit_payto; const char *credit_payto;
struct TALER_FAKEBANK_Handle *fakebank;
(void) cmd; (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) if (NULL == bcs->deposit_reference)
{ {
TALER_LOG_INFO ("Deposit reference NOT given\n"); TALER_LOG_INFO ("Deposit reference NOT given\n");
debit_payto = &bcs->debit_payto; debit_payto = bcs->debit_payto;
credit_payto = &bcs->credit_payto; credit_payto = bcs->credit_payto;
exchange_base_url = &bcs->exchange_base_url; exchange_base_url = bcs->exchange_base_url;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_string_to_amount (bcs->amount, TALER_string_to_amount (bcs->amount,
&amount)) &amount))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to parse amount `%s' at %u\n", "Failed to parse amount `%s' at %s\n",
bcs->amount, bcs->amount,
is->ip); TALER_TESTING_interpreter_get_current_label (is));
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }
@ -145,27 +167,22 @@ check_bank_transfer_run (void *cls,
TALER_TESTING_FAIL (is); TALER_TESTING_FAIL (is);
amount = *amount_ptr; 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, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"converted debit_payto (%s) to debit_account (%s)\n", "converted debit_payto (%s) to debit_account (%s)\n",
*debit_payto, debit_payto,
debit_account); debit_account);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"converted credit_payto (%s) to credit_account (%s)\n", "converted credit_payto (%s) to credit_account (%s)\n",
*credit_payto, credit_payto,
credit_account); credit_account);
if (GNUNET_OK != if (GNUNET_OK !=
TALER_FAKEBANK_check_debit (is->fakebank, TALER_FAKEBANK_check_debit (fakebank,
&amount, &amount,
debit_account, debit_account,
credit_account, credit_account,
*exchange_base_url, exchange_base_url,
&bcs->wtid)) &bcs->wtid))
{ {
GNUNET_break (0); GNUNET_break (0);
@ -217,7 +234,7 @@ check_bank_transfer_traits (void *cls,
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_wtid (wtid_ptr), TALER_TESTING_make_trait_wtid (wtid_ptr),
TALER_TESTING_make_trait_exchange_url ( TALER_TESTING_make_trait_exchange_url (
&bcs->exchange_base_url), bcs->exchange_base_url),
TALER_TESTING_trait_end () TALER_TESTING_trait_end ()
}; };

View File

@ -58,9 +58,33 @@ check_bank_empty_run (void *cls,
const struct TALER_TESTING_Command *cmd, const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct TALER_FAKEBANK_Handle *fakebank;
(void) cls; (void) cls;
(void) cmd; (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); GNUNET_break (0);
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);

View File

@ -82,6 +82,11 @@ struct HistoryState
*/ */
struct TALER_BANK_CreditHistoryHandle *hh; struct TALER_BANK_CreditHistoryHandle *hh;
/**
* The interpreter.
*/
struct TALER_TESTING_Interpreter *is;
/** /**
* Authentication data for the operation. * Authentication data for the operation.
*/ */
@ -143,6 +148,139 @@ print_expected (struct History *h,
} }
/**
* Closure for command_cb().
*/
struct IteratorContext
{
/**
* Array of history items to return.
*/
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)
{
struct IteratorContext *ic = cls;
struct HistoryState *hs = ic->hs;
const uint64_t *row_id;
const char *credit_account;
const char *debit_account;
const struct TALER_Amount *amount;
const struct TALER_ReservePublicKeyP *reserve_pub;
const char *exchange_credit_url;
/**
* The following command allows us to skip over those CMDs
* that do not offer a "row_id" trait. Such skipped CMDs are
* not interesting for building a history.
*/
if ( (GNUNET_OK !=
TALER_TESTING_get_trait_bank_row (cmd,
&row_id)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_credit_payto_uri (cmd,
&credit_account)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_debit_payto_uri (cmd,
&debit_account)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_amount (cmd,
&amount)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_reserve_pub (cmd,
&reserve_pub)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_exchange_bank_account_url (
cmd,
&exchange_credit_url)) )
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 != ic->row_id_start) &&
(*(ic->row_id_start) == *row_id) &&
(! ic->ok) )
{
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 (! ic->ok)
return;
if (0 != strcasecmp (hs->account_url,
exchange_credit_url))
return; // Account mismatch
if (ic->total >= GNUNET_MAX (hs->num_results,
-hs->num_results) )
{
TALER_LOG_DEBUG ("Hit history limit\n");
return;
}
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
debit_account,
credit_account,
hs->account_url);
/* found matching record, make sure we have room */
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++;
}
/** /**
* This function constructs the list of history elements that * This function constructs the list of history elements that
* interest the account number of the caller. It has two main * interest the account number of the caller. It has two main
@ -156,23 +294,18 @@ print_expected (struct History *h,
* @return number of entries in @a rh. * @return number of entries in @a rh.
*/ */
static unsigned int static unsigned int
build_history (struct TALER_TESTING_Interpreter *is, build_history (struct HistoryState *hs,
struct History **rh) struct History **rh)
{ {
struct HistoryState *hs = is->commands[is->ip].cls; struct TALER_TESTING_Interpreter *is = hs->is;
unsigned int total; struct IteratorContext ic = {
unsigned int pos; .hs = hs
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) 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_LOG_INFO ("`%s': start row given via reference `%s'\n",
TALER_TESTING_interpreter_get_current_label (is), TALER_TESTING_interpreter_get_current_label (is),
hs->start_row_reference); hs->start_row_reference);
@ -182,131 +315,28 @@ build_history (struct TALER_TESTING_Interpreter *is,
GNUNET_assert (NULL != add_incoming_cmd); GNUNET_assert (NULL != add_incoming_cmd);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_row (add_incoming_cmd, TALER_TESTING_get_trait_row (add_incoming_cmd,
&row_id_start)); &ic.row_id_start));
} }
GNUNET_assert (0 != hs->num_results); ic.ok = false;
if (0 == is->ip) if (NULL == ic.row_id_start)
{ ic.ok = true;
TALER_LOG_DEBUG ("Checking history at FIRST transaction (EMPTY)\n"); GNUNET_array_grow (ic.h,
*rh = NULL; ic.total,
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.
*/
ok = GNUNET_NO;
if (NULL == row_id_start)
ok = GNUNET_YES;
h = NULL;
total = 0;
GNUNET_array_grow (h,
total,
4); 4);
pos = 0; GNUNET_assert (0 != hs->num_results);
for (unsigned int off = start; off != end + inc; off += inc) TALER_TESTING_iterate (is,
{ hs->num_results > 0,
const struct TALER_TESTING_Command *cmd = &is->commands[off]; &command_cb,
const uint64_t *row_id; &ic);
const char **credit_account; GNUNET_assert (ic.ok);
const char **debit_account; GNUNET_array_grow (ic.h,
const struct TALER_Amount *amount; ic.total,
const struct TALER_ReservePublicKeyP *reserve_pub; ic.pos);
const char **exchange_credit_url; if (0 == ic.pos)
/**
* The following command allows us to skip over those CMDs
* that do not offer a "row_id" trait. Such skipped CMDs are
* not interesting for building a history.
*/
if ( (GNUNET_OK !=
TALER_TESTING_get_trait_bank_row (cmd,
&row_id)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_credit_payto_uri (cmd,
&credit_account)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_debit_payto_uri (cmd,
&debit_account)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_amount (cmd,
&amount)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_reserve_pub (cmd,
&reserve_pub)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_exchange_bank_account_url (
cmd,
&exchange_credit_url)) )
continue; // 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) )
{
ok = GNUNET_YES;
continue;
}
/**
* 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 (0 != strcasecmp (hs->account_url,
*exchange_credit_url))
continue; // Account mismatch
if (total >= GNUNET_MAX (hs->num_results,
-hs->num_results) )
{
TALER_LOG_DEBUG ("Hit history limit\n");
break;
}
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
*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++;
}
GNUNET_assert (GNUNET_YES == ok);
GNUNET_array_grow (h,
total,
pos);
if (0 == pos)
TALER_LOG_DEBUG ("Empty credit history computed\n"); TALER_LOG_DEBUG ("Empty credit history computed\n");
*rh = h; *rh = ic.h;
return total; return ic.pos;
} }
@ -376,8 +406,8 @@ static void
history_cb (void *cls, history_cb (void *cls,
const struct TALER_BANK_CreditHistoryResponse *chr) const struct TALER_BANK_CreditHistoryResponse *chr)
{ {
struct TALER_TESTING_Interpreter *is = cls; struct HistoryState *hs = cls;
struct HistoryState *hs = is->commands[is->ip].cls; struct TALER_TESTING_Interpreter *is = hs->is;
hs->hh = NULL; hs->hh = NULL;
switch (chr->http_status) switch (chr->http_status)
@ -470,6 +500,7 @@ history_run (void *cls,
const uint64_t *row_ptr; const uint64_t *row_ptr;
(void) cmd; (void) cmd;
hs->is = is;
/* Get row_id from trait. */ /* Get row_id from trait. */
if (NULL != hs->start_row_reference) if (NULL != hs->start_row_reference)
{ {
@ -490,15 +521,16 @@ history_run (void *cls,
TALER_LOG_DEBUG ("row id (from trait) is %llu\n", TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
(unsigned long long) row_id); (unsigned long long) row_id);
} }
hs->total = build_history (is, hs->total = build_history (hs,
&hs->h); &hs->h);
hs->hh = TALER_BANK_credit_history (is->ctx, hs->hh = TALER_BANK_credit_history (
&hs->auth, TALER_TESTING_interpreter_get_context (is),
row_id, &hs->auth,
hs->num_results, row_id,
GNUNET_TIME_UNIT_ZERO, hs->num_results,
&history_cb, GNUNET_TIME_UNIT_ZERO,
is); &history_cb,
hs);
GNUNET_assert (NULL != hs->hh); GNUNET_assert (NULL != hs->hh);
} }
@ -519,7 +551,8 @@ history_cleanup (void *cls,
(void) cmd; (void) cmd;
if (NULL != hs->hh) 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); TALER_BANK_credit_history_cancel (hs->hh);
} }
GNUNET_free (hs->account_url); GNUNET_free (hs->account_url);

View File

@ -91,6 +91,11 @@ struct HistoryState
*/ */
struct TALER_BANK_DebitHistoryHandle *hh; struct TALER_BANK_DebitHistoryHandle *hh;
/**
* Our interpreter.
*/
struct TALER_TESTING_Interpreter *is;
/** /**
* Expected number of results (= rows). * Expected number of results (= rows).
*/ */
@ -146,6 +151,131 @@ print_expected (struct History *h,
} }
/**
* Closure for command_cb().
*/
struct IteratorContext
{
/**
* Array of history items to return.
*/
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)
{
struct IteratorContext *ic = cls;
struct HistoryState *hs = ic->hs;
const uint64_t *row_id;
const char *debit_account;
const char *credit_account;
const struct TALER_Amount *amount;
const struct TALER_WireTransferIdentifierRawP *wtid;
const char *exchange_base_url;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking if command %s is relevant for debit history\n",
cmd->label);
if ( (GNUNET_OK !=
TALER_TESTING_get_trait_bank_row (cmd,
&row_id)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_debit_payto_uri (cmd,
&debit_account)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_credit_payto_uri (cmd,
&credit_account)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_amount (cmd,
&amount)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_wtid (cmd,
&wtid)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_exchange_url (cmd,
&exchange_base_url)) )
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 != ic->row_id_start) &&
(*(ic->row_id_start) == *row_id) &&
(! ic->ok) )
{
/* Until here, nothing counted. */
ic->ok = true;
return;
}
/* when 'start' was _not_ given, then ok == GNUNET_YES */
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");
return;
}
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
debit_account,
credit_account,
hs->account_url);
/* found matching record, make sure we have room */
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++;
}
/** /**
* This function constructs the list of history elements that * This function constructs the list of history elements that
* interest the account number of the caller. It has two main * interest the account number of the caller. It has two main
@ -153,32 +283,25 @@ print_expected (struct History *h,
* to be allocated, and the second to actually populate every * to be allocated, and the second to actually populate every
* element. * element.
* *
* @param is interpreter state (supposedly having the * @param hs history state command context
* current CMD pointing at a "history" CMD).
* @param[out] rh history array to initialize. * @param[out] rh history array to initialize.
* @return number of entries in @a rh. * @return number of entries in @a rh.
*/ */
static unsigned int static unsigned int
build_history (struct TALER_TESTING_Interpreter *is, build_history (struct HistoryState *hs,
struct History **rh) struct History **rh)
{ {
struct HistoryState *hs = is->commands[is->ip].cls; struct TALER_TESTING_Interpreter *is = hs->is;
unsigned int total; struct IteratorContext ic = {
unsigned int pos; .hs = hs
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) if (NULL != hs->start_row_reference)
{ {
TALER_LOG_INFO const struct TALER_TESTING_Command *add_incoming_cmd;
("`%s': start row given via reference `%s'\n",
TALER_LOG_INFO (
"`%s': start row given via reference `%s'\n",
TALER_TESTING_interpreter_get_current_label (is), TALER_TESTING_interpreter_get_current_label (is),
hs->start_row_reference); hs->start_row_reference);
add_incoming_cmd = TALER_TESTING_interpreter_lookup_command ( add_incoming_cmd = TALER_TESTING_interpreter_lookup_command (
@ -187,124 +310,28 @@ build_history (struct TALER_TESTING_Interpreter *is,
GNUNET_assert (NULL != add_incoming_cmd); GNUNET_assert (NULL != add_incoming_cmd);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_row (add_incoming_cmd, TALER_TESTING_get_trait_row (add_incoming_cmd,
&row_id_start)); &ic.row_id_start));
} }
GNUNET_assert (0 != hs->num_results); ic.ok = false;
if (0 == is->ip) if (NULL == ic.row_id_start)
{ ic.ok = true;
TALER_LOG_DEBUG ("Checking history at first CMD..\n"); GNUNET_array_grow (ic.h,
*rh = NULL; ic.total,
return 0;
}
/* 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! */
}
ok = GNUNET_NO;
if (NULL == row_id_start)
ok = GNUNET_YES;
h = NULL;
total = 0;
GNUNET_array_grow (h,
total,
4); 4);
pos = 0; GNUNET_assert (0 != hs->num_results);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, TALER_TESTING_iterate (is,
"Checking commands %u to %u for debit history\n", hs->num_results > 0,
start, &command_cb,
end); &ic);
for (int off = start; off != end; off += inc) GNUNET_assert (ic.ok);
{ GNUNET_array_grow (ic.h,
const struct TALER_TESTING_Command *cmd = &is->commands[off]; ic.total,
const uint64_t *row_id; ic.pos);
const char **debit_account; if (0 == ic.pos)
const char **credit_account; TALER_LOG_DEBUG ("Empty credit history computed\n");
const struct TALER_Amount *amount; *rh = ic.h;
const struct TALER_WireTransferIdentifierRawP *wtid; return ic.pos;
const char **exchange_base_url;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking if command %s is relevant for debit history\n",
cmd->label);
if ( (GNUNET_OK !=
TALER_TESTING_get_trait_bank_row (cmd,
&row_id)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_debit_payto_uri (cmd,
&debit_account)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_credit_payto_uri (cmd,
&credit_account)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_amount (cmd,
&amount)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_wtid (cmd,
&wtid)) ||
(GNUNET_OK !=
TALER_TESTING_get_trait_exchange_url (cmd,
&exchange_base_url)) )
continue; /* 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) )
{
/* Until here, nothing counted. */
ok = GNUNET_YES;
continue;
}
/* 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,
-hs->num_results) )
{
TALER_LOG_DEBUG ("Hit history limit\n");
break;
}
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
*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++;
}
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;
} }
@ -368,8 +395,8 @@ static void
history_cb (void *cls, history_cb (void *cls,
const struct TALER_BANK_DebitHistoryResponse *dhr) const struct TALER_BANK_DebitHistoryResponse *dhr)
{ {
struct TALER_TESTING_Interpreter *is = cls; struct HistoryState *hs = cls;
struct HistoryState *hs = is->commands[is->ip].cls; struct TALER_TESTING_Interpreter *is = hs->is;
hs->hh = NULL; hs->hh = NULL;
switch (dhr->http_status) switch (dhr->http_status)
@ -462,6 +489,7 @@ history_run (void *cls,
const uint64_t *row_ptr; const uint64_t *row_ptr;
(void) cmd; (void) cmd;
hs->is = is;
/* Get row_id from trait. */ /* Get row_id from trait. */
if (NULL != hs->start_row_reference) if (NULL != hs->start_row_reference)
{ {
@ -482,14 +510,16 @@ history_run (void *cls,
TALER_LOG_DEBUG ("row id (from trait) is %llu\n", TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
(unsigned long long) row_id); (unsigned long long) row_id);
} }
hs->total = build_history (is, &hs->h); hs->total = build_history (hs,
hs->hh = TALER_BANK_debit_history (is->ctx, &hs->h);
&hs->auth, hs->hh = TALER_BANK_debit_history (
row_id, TALER_TESTING_interpreter_get_context (is),
hs->num_results, &hs->auth,
GNUNET_TIME_UNIT_ZERO, row_id,
&history_cb, hs->num_results,
is); GNUNET_TIME_UNIT_ZERO,
&history_cb,
hs);
GNUNET_assert (NULL != hs->hh); GNUNET_assert (NULL != hs->hh);
} }
@ -510,7 +540,8 @@ history_cleanup (void *cls,
(void) cmd; (void) cmd;
if (NULL != hs->hh) 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); TALER_BANK_debit_history_cancel (hs->hh);
} }
for (unsigned int off = 0; off<hs->total; off++) for (unsigned int off = 0; off<hs->total; off++)

View File

@ -149,8 +149,7 @@ do_retry (void *cls)
struct TransferState *fts = cls; struct TransferState *fts = cls;
fts->retry_task = NULL; fts->retry_task = NULL;
fts->is->commands[fts->is->ip].last_req_time TALER_TESTING_touch_cmd (fts->is);
= GNUNET_TIME_absolute_get ();
transfer_run (fts, transfer_run (fts,
NULL, NULL,
fts->is); fts->is);
@ -191,7 +190,7 @@ confirmation_cb (void *cls,
fts->backoff = GNUNET_TIME_UNIT_ZERO; fts->backoff = GNUNET_TIME_UNIT_ZERO;
else else
fts->backoff = EXCHANGE_LIB_BACKOFF (fts->backoff); fts->backoff = EXCHANGE_LIB_BACKOFF (fts->backoff);
fts->is->commands[fts->is->ip].num_tries++; TALER_TESTING_inc_tries (fts->is);
fts->retry_task fts->retry_task
= GNUNET_SCHEDULER_add_delayed (fts->backoff, = GNUNET_SCHEDULER_add_delayed (fts->backoff,
&do_retry, &do_retry,
@ -199,12 +198,8 @@ confirmation_cb (void *cls,
return; return;
} }
} }
GNUNET_break (0); TALER_TESTING_unexpected_status (is,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, tr->http_status);
"Bank returned HTTP status %u/%d\n",
tr->http_status,
(int) tr->ec);
TALER_TESTING_interpreter_fail (is);
return; return;
} }
@ -276,9 +271,8 @@ transfer_cleanup (void *cls,
if (NULL != fts->weh) if (NULL != fts->weh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (fts->is,
"Command %s did not complete\n", cmd->label);
cmd->label);
TALER_BANK_transfer_cancel (fts->weh); TALER_BANK_transfer_cancel (fts->weh);
fts->weh = NULL; fts->weh = NULL;
} }
@ -311,12 +305,12 @@ transfer_traits (void *cls,
struct TransferState *fts = cls; struct TransferState *fts = cls;
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_exchange_url ( 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_bank_row (&fts->serial_id),
TALER_TESTING_make_trait_credit_payto_uri ( TALER_TESTING_make_trait_credit_payto_uri (
(const char **) &fts->payto_credit_account), fts->payto_credit_account),
TALER_TESTING_make_trait_debit_payto_uri ( 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_amount (&fts->amount),
TALER_TESTING_make_trait_timestamp (0, &fts->timestamp), TALER_TESTING_make_trait_timestamp (0, &fts->timestamp),
TALER_TESTING_make_trait_wtid (&fts->wtid), TALER_TESTING_make_trait_wtid (&fts->wtid),

View File

@ -37,6 +37,11 @@ struct BatchState
*/ */
struct TALER_TESTING_Command *batch; struct TALER_TESTING_Command *batch;
/**
* My command (the batch command).
*/
const struct TALER_TESTING_Command *cmd;
/** /**
* Internal command pointer. * Internal command pointer.
*/ */
@ -58,6 +63,7 @@ batch_run (void *cls,
{ {
struct BatchState *bs = cls; struct BatchState *bs = cls;
bs->cmd = cmd;
if (NULL != bs->batch[bs->batch_ip].label) if (NULL != bs->batch[bs->batch_ip].label)
TALER_LOG_INFO ("Running batched command: %s\n", TALER_LOG_INFO ("Running batched command: %s\n",
bs->batch[bs->batch_ip].label); bs->batch[bs->batch_ip].label);
@ -167,19 +173,33 @@ TALER_TESTING_cmd_batch (const char *label,
} }
void bool
TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is) 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 (); /* This batch is done */
is->ip++; return true;
return;
} }
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++; bs->batch_ip++;
return false;
} }

View File

@ -198,16 +198,8 @@ batch_deposit_cb (void *cls,
ds->dh = NULL; ds->dh = NULL;
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", dr->hr.http_status);
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);
return; return;
} }
if (MHD_HTTP_OK == dr->hr.http_status) if (MHD_HTTP_OK == dr->hr.http_status)
@ -259,8 +251,12 @@ batch_deposit_run (void *cls,
&wire_salt), &wire_salt),
GNUNET_JSON_spec_end () GNUNET_JSON_spec_end ()
}; };
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
memset (cdds, memset (cdds,
0, 0,
sizeof (cdds)); sizeof (cdds));
@ -387,7 +383,7 @@ batch_deposit_run (void *cls,
.refund_deadline = ds->refund_deadline .refund_deadline = ds->refund_deadline
}; };
ds->dh = TALER_EXCHANGE_batch_deposit (is->exchange, ds->dh = TALER_EXCHANGE_batch_deposit (exchange,
&dcd, &dcd,
ds->num_coins, ds->num_coins,
cdds, cdds,
@ -422,10 +418,8 @@ batch_deposit_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_batch_deposit_cancel (ds->dh); TALER_EXCHANGE_batch_deposit_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -189,18 +189,8 @@ reserve_batch_withdraw_cb (void *cls,
ws->wsh = NULL; ws->wsh = NULL;
if (ws->expected_response_code != wr->hr.http_status) if (ws->expected_response_code != wr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (is,
"Unexpected response code %u/%d to command %s in %s:%u\n", wr->hr.http_status);
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);
return; return;
} }
switch (wr->hr.http_status) switch (wr->hr.http_status)
@ -263,8 +253,12 @@ batch_withdraw_run (void *cls,
const struct TALER_TESTING_Command *create_reserve; const struct TALER_TESTING_Command *create_reserve;
const struct TALER_EXCHANGE_DenomPublicKey *dpk; const struct TALER_EXCHANGE_DenomPublicKey *dpk;
struct TALER_EXCHANGE_WithdrawCoinInput wcis[ws->num_coins]; struct TALER_EXCHANGE_WithdrawCoinInput wcis[ws->num_coins];
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
ws->is = is; ws->is = is;
create_reserve create_reserve
= TALER_TESTING_interpreter_lookup_command ( = TALER_TESTING_interpreter_lookup_command (
@ -287,7 +281,7 @@ batch_withdraw_run (void *cls,
} }
if (NULL == ws->exchange_url) if (NULL == ws->exchange_url)
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; ws->reserve_priv = *rp;
GNUNET_CRYPTO_eddsa_key_get_public (&ws->reserve_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_key_get_public (&ws->reserve_priv.eddsa_priv,
&ws->reserve_pub.eddsa_pub); &ws->reserve_pub.eddsa_pub);
@ -301,7 +295,7 @@ batch_withdraw_run (void *cls,
struct TALER_EXCHANGE_WithdrawCoinInput *wci = &wcis[i]; struct TALER_EXCHANGE_WithdrawCoinInput *wci = &wcis[i];
TALER_planchet_master_setup_random (&cs->ps); 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, &cs->amount,
ws->age > 0); ws->age > 0);
if (NULL == dpk) if (NULL == dpk)
@ -327,7 +321,7 @@ batch_withdraw_run (void *cls,
wci->ps = &cs->ps; wci->ps = &cs->ps;
wci->ach = cs->h_age_commitment; wci->ach = cs->h_age_commitment;
} }
ws->wsh = TALER_EXCHANGE_batch_withdraw (is->exchange, ws->wsh = TALER_EXCHANGE_batch_withdraw (exchange,
rp, rp,
wcis, wcis,
ws->num_coins, ws->num_coins,
@ -357,9 +351,8 @@ batch_withdraw_cleanup (void *cls,
if (NULL != ws->wsh) if (NULL != ws->wsh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ws->is,
"Command %s did not complete\n", cmd->label);
cmd->label);
TALER_EXCHANGE_batch_withdraw_cancel (ws->wsh); TALER_EXCHANGE_batch_withdraw_cancel (ws->wsh);
ws->wsh = NULL; ws->wsh = NULL;
} }
@ -427,12 +420,9 @@ batch_withdraw_traits (void *cls,
TALER_TESTING_make_trait_amounts (index, TALER_TESTING_make_trait_amounts (index,
&cs->amount), &cs->amount),
TALER_TESTING_make_trait_legi_requirement_row (&ws->requirement_row), TALER_TESTING_make_trait_legi_requirement_row (&ws->requirement_row),
TALER_TESTING_make_trait_h_payto ( TALER_TESTING_make_trait_h_payto (&ws->h_payto),
&ws->h_payto), TALER_TESTING_make_trait_payto_uri (ws->reserve_payto_uri),
TALER_TESTING_make_trait_payto_uri ( TALER_TESTING_make_trait_exchange_url (ws->exchange_url),
(const char **) &ws->reserve_payto_uri),
TALER_TESTING_make_trait_exchange_url (
(const char **) &ws->exchange_url),
TALER_TESTING_make_trait_age_commitment_proof (index, TALER_TESTING_make_trait_age_commitment_proof (index,
cs->age_commitment_proof), cs->age_commitment_proof),
TALER_TESTING_make_trait_h_age_commitment (index, TALER_TESTING_make_trait_h_age_commitment (index,

View File

@ -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 */

View File

@ -79,22 +79,14 @@ check_aml_decision_cb (void *cls,
ds->dh = NULL; ds->dh = NULL;
if (ds->expected_http_status != adr->hr.http_status) if (ds->expected_http_status != adr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", adr->hr.http_status);
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);
return; return;
} }
if (MHD_HTTP_OK == adr->hr.http_status) if (MHD_HTTP_OK == adr->hr.http_status)
{ {
const struct TALER_TESTING_Command *ref; const struct TALER_TESTING_Command *ref;
const char **justification; const char *justification;
enum TALER_AmlDecisionState *new_state; enum TALER_AmlDecisionState *new_state;
const struct TALER_Amount *amount; const struct TALER_Amount *amount;
const struct TALER_EXCHANGE_AmlDecisionDetail *oldest = NULL; const struct TALER_EXCHANGE_AmlDecisionDetail *oldest = NULL;
@ -138,7 +130,7 @@ check_aml_decision_cb (void *cls,
} }
if ( (oldest->new_state != *new_state) || if ( (oldest->new_state != *new_state) ||
(0 != strcmp (oldest->justification, (0 != strcmp (oldest->justification,
*justification) ) ) justification) ) )
{ {
GNUNET_break (0); GNUNET_break (0);
TALER_TESTING_interpreter_fail (ds->is); 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_PaytoHashP *h_payto;
const struct TALER_AmlOfficerPrivateKeyP *officer_priv; const struct TALER_AmlOfficerPrivateKeyP *officer_priv;
const struct TALER_TESTING_Command *ref; const struct TALER_TESTING_Command *ref;
const char *exchange_url;
(void) cmd; (void) cmd;
ds->is = is; 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, ref = TALER_TESTING_interpreter_lookup_command (is,
ds->ref_operation); ds->ref_operation);
if (NULL == ref) if (NULL == ref)
@ -191,8 +200,8 @@ check_aml_decision_run (void *cls,
TALER_TESTING_get_trait_officer_priv (ref, TALER_TESTING_get_trait_officer_priv (ref,
&officer_priv)); &officer_priv));
ds->dh = TALER_EXCHANGE_lookup_aml_decision ( ds->dh = TALER_EXCHANGE_lookup_aml_decision (
is->ctx, TALER_TESTING_interpreter_get_context (is),
is->exchange_url, exchange_url,
h_payto, h_payto,
officer_priv, officer_priv,
true, /* history */ true, /* history */
@ -222,10 +231,8 @@ check_aml_decision_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_lookup_aml_decision_cancel (ds->dh); TALER_EXCHANGE_lookup_aml_decision_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -79,16 +79,8 @@ check_aml_decisions_cb (void *cls,
ds->dh = NULL; ds->dh = NULL;
if (ds->expected_http_status != adr->hr.http_status) if (ds->expected_http_status != adr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", adr->hr.http_status);
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);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);
@ -110,9 +102,25 @@ check_aml_decisions_run (void *cls,
struct AmlCheckState *ds = cls; struct AmlCheckState *ds = cls;
const struct TALER_AmlOfficerPrivateKeyP *officer_priv; const struct TALER_AmlOfficerPrivateKeyP *officer_priv;
const struct TALER_TESTING_Command *ref; const struct TALER_TESTING_Command *ref;
const char *exchange_url;
(void) cmd; (void) cmd;
ds->is = is; 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, ref = TALER_TESTING_interpreter_lookup_command (is,
ds->ref_officer); ds->ref_officer);
if (NULL == ref) if (NULL == ref)
@ -125,8 +133,8 @@ check_aml_decisions_run (void *cls,
TALER_TESTING_get_trait_officer_priv (ref, TALER_TESTING_get_trait_officer_priv (ref,
&officer_priv)); &officer_priv));
ds->dh = TALER_EXCHANGE_lookup_aml_decisions ( ds->dh = TALER_EXCHANGE_lookup_aml_decisions (
is->ctx, TALER_TESTING_interpreter_get_context (is),
is->exchange_url, exchange_url,
INT64_MAX, INT64_MAX,
-1, /* return last one for testing */ -1, /* return last one for testing */
ds->filter, ds->filter,
@ -157,10 +165,8 @@ check_aml_decisions_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_lookup_aml_decisions_cancel (ds->dh); TALER_EXCHANGE_lookup_aml_decisions_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -33,17 +33,10 @@
*/ */
struct CheckKeysState 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 * If this value is true, then the "cherry picking" facility is turned off;
* picking" facility is turned off; whole /keys is * whole /keys is downloaded.
* downloaded.
*/ */
bool pull_all_keys; bool pull_all_keys;
@ -52,6 +45,11 @@ struct CheckKeysState
*/ */
const char *last_denom_date_ref; const char *last_denom_date_ref;
/**
* Our interpreter state.
*/
struct TALER_TESTING_Interpreter *is;
/** /**
* Last denomination date we received when doing this request. * 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. * Run the "check keys" command.
* *
@ -72,80 +94,64 @@ check_keys_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct CheckKeysState *cks = cls; struct CheckKeysState *cks = cls;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
struct GNUNET_TIME_Timestamp rdate;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, (void) cmd;
"cmd `%s' (ip: %u), key generation: %d\n", cks->is = is;
cmd->label, if (NULL == exchange)
is->ip,
is->key_generation);
if (is->key_generation < cks->generation)
{
struct GNUNET_TIME_Timestamp rdate;
is->working = GNUNET_NO;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Triggering GET /keys, cmd `%s'\n",
cmd->label);
if (NULL != cks->last_denom_date_ref)
{
if (0 == strcmp ("zero",
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,
GNUNET_TIME_UNIT_ZERO_TS);
}
else
{
const struct GNUNET_TIME_Timestamp *last_denom_date;
const struct TALER_TESTING_Command *ref;
ref = TALER_TESTING_interpreter_lookup_command (is,
cks->last_denom_date_ref);
if (NULL == ref)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_timestamp (ref,
0,
&last_denom_date))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
TALER_LOG_DEBUG ("Forcing last_denom_date URL argument\n");
TALER_EXCHANGE_set_last_denom (is->exchange,
*last_denom_date);
}
}
rdate = TALER_EXCHANGE_check_keys_current (
is->exchange,
cks->pull_all_keys
? TALER_EXCHANGE_CKF_FORCE_ALL_NOW
: TALER_EXCHANGE_CKF_FORCE_DOWNLOAD);
/* Redownload /keys. */
GNUNET_break (GNUNET_TIME_absolute_is_zero (rdate.abs_time));
return; return;
} GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Triggering GET /keys, cmd `%s'\n",
cmd->label);
if (NULL != cks->last_denom_date_ref)
{ {
const struct TALER_EXCHANGE_Keys *keys; if (0 == strcmp ("zero",
cks->last_denom_date_ref))
keys = TALER_EXCHANGE_get_keys (is->exchange);
if (NULL == keys)
{ {
GNUNET_break (0); TALER_LOG_DEBUG ("Forcing last_denom_date URL argument set to zero\n");
TALER_TESTING_interpreter_fail (is); TALER_EXCHANGE_set_last_denom (exchange,
return; GNUNET_TIME_UNIT_ZERO_TS);
}
else
{
const struct GNUNET_TIME_Timestamp *last_denom_date;
const struct TALER_TESTING_Command *ref;
ref = TALER_TESTING_interpreter_lookup_command (is,
cks->last_denom_date_ref);
if (NULL == ref)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_timestamp (ref,
0,
&last_denom_date))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
TALER_LOG_DEBUG ("Forcing last_denom_date URL argument\n");
TALER_EXCHANGE_set_last_denom (exchange,
*last_denom_date);
} }
cks->my_denom_date = keys->last_denom_issue_date;
} }
TALER_TESTING_interpreter_next (is);
rdate = TALER_EXCHANGE_check_keys_current (
exchange,
cks->pull_all_keys
? TALER_EXCHANGE_CKF_FORCE_ALL_NOW
: TALER_EXCHANGE_CKF_FORCE_DOWNLOAD,
&keys_cb,
cks);
/* Redownload /keys. */
GNUNET_break (GNUNET_TIME_absolute_is_zero (rdate.abs_time));
} }
@ -176,7 +182,7 @@ check_keys_cleanup (void *cls,
* @param index index number of the object to offer. * @param index index number of the object to offer.
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
static int static enum GNUNET_GenericReturnValue
check_keys_traits (void *cls, check_keys_traits (void *cls,
const void **ret, const void **ret,
const char *trait, const char *trait,
@ -184,7 +190,6 @@ check_keys_traits (void *cls,
{ {
struct CheckKeysState *cks = cls; struct CheckKeysState *cks = cls;
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
/* history entry MUST be first due to response code logic below! */
TALER_TESTING_make_trait_timestamp (0, TALER_TESTING_make_trait_timestamp (0,
&cks->my_denom_date), &cks->my_denom_date),
TALER_TESTING_trait_end () TALER_TESTING_trait_end ()
@ -198,13 +203,11 @@ check_keys_traits (void *cls,
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_check_keys (const char *label, TALER_TESTING_cmd_check_keys (const char *label)
unsigned int generation)
{ {
struct CheckKeysState *cks; struct CheckKeysState *cks;
cks = GNUNET_new (struct CheckKeysState); cks = GNUNET_new (struct CheckKeysState);
cks->generation = generation;
{ {
struct TALER_TESTING_Command cmd = { struct TALER_TESTING_Command cmd = {
.cls = cks, .cls = cks,
@ -220,12 +223,10 @@ TALER_TESTING_cmd_check_keys (const char *label,
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label, TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label)
unsigned int generation)
{ {
struct TALER_TESTING_Command cmd struct TALER_TESTING_Command cmd
= TALER_TESTING_cmd_check_keys (label, = TALER_TESTING_cmd_check_keys (label);
generation);
struct CheckKeysState *cks = cmd.cls; struct CheckKeysState *cks = cmd.cls;
cks->pull_all_keys = true; cks->pull_all_keys = true;
@ -236,13 +237,12 @@ TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label,
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_check_keys_with_last_denom ( TALER_TESTING_cmd_check_keys_with_last_denom (
const char *label, const char *label,
unsigned int generation,
const char *last_denom_date_ref) const char *last_denom_date_ref)
{ {
struct TALER_TESTING_Command cmd struct TALER_TESTING_Command cmd
= TALER_TESTING_cmd_check_keys (label, = TALER_TESTING_cmd_check_keys (label);
generation);
struct CheckKeysState *cks = cmd.cls; struct CheckKeysState *cks = cmd.cls;
cks->last_denom_date_ref = last_denom_date_ref; cks->last_denom_date_ref = last_denom_date_ref;
return cmd; return cmd;
} }

View 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;
}
}

View File

@ -101,16 +101,8 @@ get_cb (void *cls,
ds->dh = NULL; ds->dh = NULL;
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", dr->hr.http_status);
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);
return; return;
} }
ref = TALER_TESTING_interpreter_lookup_command (ds->is, ref = TALER_TESTING_interpreter_lookup_command (ds->is,
@ -198,8 +190,12 @@ get_run (void *cls,
struct ContractGetState *ds = cls; struct ContractGetState *ds = cls;
const struct TALER_ContractDiffiePrivateP *contract_priv; const struct TALER_ContractDiffiePrivateP *contract_priv;
const struct TALER_TESTING_Command *ref; const struct TALER_TESTING_Command *ref;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
ds->is = is; ds->is = is;
ref = TALER_TESTING_interpreter_lookup_command (ds->is, ref = TALER_TESTING_interpreter_lookup_command (ds->is,
ds->contract_ref); ds->contract_ref);
@ -214,7 +210,7 @@ get_run (void *cls,
} }
ds->contract_priv = *contract_priv; ds->contract_priv = *contract_priv;
ds->dh = TALER_EXCHANGE_contract_get ( ds->dh = TALER_EXCHANGE_contract_get (
is->exchange, exchange,
contract_priv, contract_priv,
&get_cb, &get_cb,
ds); ds);
@ -244,10 +240,8 @@ get_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_contract_get_cancel (ds->dh); TALER_EXCHANGE_contract_get_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -199,8 +199,7 @@ do_retry (void *cls)
struct DepositState *ds = cls; struct DepositState *ds = cls;
ds->retry_task = NULL; ds->retry_task = NULL;
ds->is->commands[ds->is->ip].last_req_time TALER_TESTING_touch_cmd (ds->is);
= GNUNET_TIME_absolute_get ();
deposit_run (ds, deposit_run (ds,
NULL, NULL,
ds->is); ds->is);
@ -240,7 +239,7 @@ deposit_cb (void *cls,
else else
ds->backoff = GNUNET_TIME_randomized_backoff (ds->backoff, ds->backoff = GNUNET_TIME_randomized_backoff (ds->backoff,
MAX_BACKOFF); MAX_BACKOFF);
ds->is->commands[ds->is->ip].num_tries++; TALER_TESTING_inc_tries (ds->is);
GNUNET_assert (NULL == ds->retry_task); GNUNET_assert (NULL == ds->retry_task);
ds->retry_task ds->retry_task
= GNUNET_SCHEDULER_add_delayed (ds->backoff, = GNUNET_SCHEDULER_add_delayed (ds->backoff,
@ -249,16 +248,8 @@ deposit_cb (void *cls,
return; return;
} }
} }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", dr->hr.http_status);
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);
return; return;
} }
if (MHD_HTTP_OK == dr->hr.http_status) if (MHD_HTTP_OK == dr->hr.http_status)
@ -305,8 +296,12 @@ deposit_run (void *cls,
&wire_salt), &wire_salt),
GNUNET_JSON_spec_end () GNUNET_JSON_spec_end ()
}; };
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
ds->is = is; ds->is = is;
if (NULL != ds->deposit_reference) if (NULL != ds->deposit_reference)
{ {
@ -474,7 +469,7 @@ deposit_run (void *cls,
.refund_deadline = ds->refund_deadline .refund_deadline = ds->refund_deadline
}; };
ds->dh = TALER_EXCHANGE_deposit (is->exchange, ds->dh = TALER_EXCHANGE_deposit (exchange,
&dcd, &dcd,
&cdd, &cdd,
&deposit_cb, &deposit_cb,
@ -508,10 +503,8 @@ deposit_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_deposit_cancel (ds->dh); TALER_EXCHANGE_deposit_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -39,6 +39,11 @@ struct TrackTransactionState
*/ */
const char *bank_transfer_reference; const char *bank_transfer_reference;
/**
* Our command.
*/
const struct TALER_TESTING_Command *cmd;
/** /**
* The WTID associated by the transaction being tracked. * The WTID associated by the transaction being tracked.
*/ */
@ -107,22 +112,12 @@ deposit_wtid_cb (void *cls,
{ {
struct TrackTransactionState *tts = cls; struct TrackTransactionState *tts = cls;
struct TALER_TESTING_Interpreter *is = tts->is; struct TALER_TESTING_Interpreter *is = tts->is;
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
tts->tth = NULL; tts->tth = NULL;
if (tts->expected_response_code != dr->hr.http_status) if (tts->expected_response_code != dr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (is,
"Unexpected response code %u/%d to command %s in %s:%u\n", dr->hr.http_status);
dr->hr.http_status,
(int) dr->hr.ec,
cmd->label,
__FILE__,
__LINE__);
json_dumpf (dr->hr.reply,
stderr,
0);
TALER_TESTING_interpreter_fail (is);
return; return;
} }
switch (dr->hr.http_status) switch (dr->hr.http_status)
@ -203,8 +198,12 @@ track_transaction_run (void *cls,
struct TALER_MerchantWireHashP h_wire_details; struct TALER_MerchantWireHashP h_wire_details;
struct TALER_PrivateContractHashP h_contract_terms; struct TALER_PrivateContractHashP h_contract_terms;
const struct TALER_MerchantPrivateKeyP *merchant_priv; 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; tts->is = is;
transaction_cmd transaction_cmd
= TALER_TESTING_interpreter_lookup_command (tts->is, = TALER_TESTING_interpreter_lookup_command (tts->is,
@ -276,7 +275,7 @@ track_transaction_run (void *cls,
return; return;
} }
tts->tth = TALER_EXCHANGE_deposits_get (is->exchange, tts->tth = TALER_EXCHANGE_deposits_get (exchange,
merchant_priv, merchant_priv,
&h_wire_details, &h_wire_details,
&h_contract_terms, &h_contract_terms,
@ -303,10 +302,8 @@ track_transaction_cleanup (void *cls,
if (NULL != tts->tth) if (NULL != tts->tth)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (tts->is,
"Command %u (%s) did not complete\n", cmd->label);
tts->is->ip,
cmd->label);
TALER_EXCHANGE_deposits_get_cancel (tts->tth); TALER_EXCHANGE_deposits_get_cancel (tts->tth);
tts->tth = NULL; tts->tth = NULL;
} }
@ -335,10 +332,8 @@ track_transaction_traits (void *cls,
TALER_TESTING_make_trait_wtid (&tts->wtid), TALER_TESTING_make_trait_wtid (&tts->wtid),
TALER_TESTING_make_trait_legi_requirement_row ( TALER_TESTING_make_trait_legi_requirement_row (
&tts->requirement_row), &tts->requirement_row),
TALER_TESTING_make_trait_h_payto ( TALER_TESTING_make_trait_h_payto (&tts->h_payto),
&tts->h_payto), TALER_TESTING_make_trait_payto_uri (tts->merchant_payto_uri),
TALER_TESTING_make_trait_payto_uri (
(const char **) &tts->merchant_payto_uri),
TALER_TESTING_trait_end () TALER_TESTING_trait_end ()
}; };

View 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;
}
}

View 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;
}
}

View File

@ -29,6 +29,7 @@
#include "taler_signatures.h" #include "taler_signatures.h"
#include "taler_testing_lib.h" #include "taler_testing_lib.h"
#include "taler_exchangedb_plugin.h" #include "taler_exchangedb_plugin.h"
#include "taler_exchangedb_lib.h"
/** /**
@ -37,9 +38,9 @@
struct InsertDepositState 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. * Human-readable name of the shop.
@ -71,6 +72,11 @@ struct InsertDepositState
* Deposit fee. * Deposit fee.
*/ */
const char *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; struct TALER_DenominationPrivateKey denom_priv;
(void) cmd; (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. // prepare and store issue first.
fake_issue (&issue); fake_issue (&issue);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
@ -144,14 +163,14 @@ insert_deposit_run (void *cls,
&issue.denom_hash); &issue.denom_hash);
if ( (GNUNET_OK != if ( (GNUNET_OK !=
ids->dbc->plugin->start (ids->dbc->plugin->cls, ids->plugin->start (ids->plugin->cls,
"talertestinglib: denomination insertion")) || "talertestinglib: denomination insertion")) ||
(GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != (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, &dpk,
&issue)) || &issue)) ||
(GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != (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_TESTING_interpreter_fail (is);
TALER_denom_pub_free (&dpk); TALER_denom_pub_free (&dpk);
@ -248,23 +267,23 @@ insert_deposit_run (void *cls,
struct TALER_AgeCommitmentHash agh; struct TALER_AgeCommitmentHash agh;
if ( (GNUNET_OK != if ( (GNUNET_OK !=
ids->dbc->plugin->start (ids->dbc->plugin->cls, ids->plugin->start (ids->plugin->cls,
"libtalertesting: insert deposit")) || "libtalertesting: insert deposit")) ||
(0 > (0 >
ids->dbc->plugin->ensure_coin_known (ids->dbc->plugin->cls, ids->plugin->ensure_coin_known (ids->plugin->cls,
&deposit.coin, &deposit.coin,
&known_coin_id, &known_coin_id,
&dph, &dph,
&agh)) || &agh)) ||
(GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != (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, ids->exchange_timestamp,
&deposit)) || &deposit)) ||
(GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
ids->dbc->plugin->commit (ids->dbc->plugin->cls)) ) ids->plugin->commit (ids->plugin->cls)) )
{ {
GNUNET_break (0); GNUNET_break (0);
ids->dbc->plugin->rollback (ids->dbc->plugin->cls); ids->plugin->rollback (ids->plugin->cls);
GNUNET_free (deposit.receiver_wire_account); GNUNET_free (deposit.receiver_wire_account);
TALER_denom_pub_free (&dpk); TALER_denom_pub_free (&dpk);
TALER_denom_priv_free (&denom_priv); TALER_denom_priv_free (&denom_priv);
@ -295,6 +314,14 @@ insert_deposit_cleanup (void *cls,
struct InsertDepositState *ids = cls; struct InsertDepositState *ids = cls;
(void) cmd; (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); GNUNET_free (ids);
} }
@ -302,7 +329,7 @@ insert_deposit_cleanup (void *cls,
struct TALER_TESTING_Command struct TALER_TESTING_Command
TALER_TESTING_cmd_insert_deposit ( TALER_TESTING_cmd_insert_deposit (
const char *label, const char *label,
const struct TALER_TESTING_DatabaseConnection *dbc, const struct GNUNET_CONFIGURATION_Handle *db_cfg,
const char *merchant_name, const char *merchant_name,
const char *merchant_account, const char *merchant_account,
struct GNUNET_TIME_Timestamp exchange_timestamp, struct GNUNET_TIME_Timestamp exchange_timestamp,
@ -310,10 +337,22 @@ TALER_TESTING_cmd_insert_deposit (
const char *amount_with_fee, const char *amount_with_fee,
const char *deposit_fee) const char *deposit_fee)
{ {
static struct TALER_EXCHANGEDB_Plugin *pluginc;
static const struct GNUNET_CONFIGURATION_Handle *db_cfgc;
struct InsertDepositState *ids; struct InsertDepositState *ids;
ids = GNUNET_new (struct InsertDepositState); 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_name = merchant_name;
ids->merchant_account = merchant_account; ids->merchant_account = merchant_account;
ids->exchange_timestamp = exchange_timestamp; ids->exchange_timestamp = exchange_timestamp;

View File

@ -73,19 +73,12 @@ check_kyc_cb (void *cls,
{ {
struct KycCheckGetState *kcg = cls; struct KycCheckGetState *kcg = cls;
struct TALER_TESTING_Interpreter *is = kcg->is; struct TALER_TESTING_Interpreter *is = kcg->is;
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
kcg->kwh = NULL; kcg->kwh = NULL;
if (kcg->expected_response_code != ks->http_status) if (kcg->expected_response_code != ks->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (is,
"Unexpected response code %u/%d to command %s in %s:%u\n", ks->http_status);
ks->http_status,
(int) ks->ec,
cmd->label,
__FILE__,
__LINE__);
TALER_TESTING_interpreter_fail (is);
return; return;
} }
switch (ks->http_status) switch (ks->http_status)
@ -121,8 +114,12 @@ check_kyc_run (void *cls,
const struct TALER_TESTING_Command *res_cmd; const struct TALER_TESTING_Command *res_cmd;
const uint64_t *requirement_row; const uint64_t *requirement_row;
const struct TALER_PaytoHashP *h_payto; const struct TALER_PaytoHashP *h_payto;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
kcg->is = is; kcg->is = is;
res_cmd = TALER_TESTING_interpreter_lookup_command (kcg->is, res_cmd = TALER_TESTING_interpreter_lookup_command (kcg->is,
kcg-> kcg->
@ -155,7 +152,7 @@ check_kyc_run (void *cls,
TALER_TESTING_interpreter_fail (kcg->is); TALER_TESTING_interpreter_fail (kcg->is);
return; return;
} }
kcg->kwh = TALER_EXCHANGE_kyc_check (is->exchange, kcg->kwh = TALER_EXCHANGE_kyc_check (exchange,
*requirement_row, *requirement_row,
h_payto, h_payto,
TALER_KYCLOGIC_KYC_UT_INDIVIDUAL, TALER_KYCLOGIC_KYC_UT_INDIVIDUAL,
@ -181,10 +178,8 @@ check_kyc_cleanup (void *cls,
if (NULL != kcg->kwh) if (NULL != kcg->kwh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (kcg->is,
"Command %u (%s) did not complete\n", cmd->label);
kcg->is->ip,
cmd->label);
TALER_EXCHANGE_kyc_check_cancel (kcg->kwh); TALER_EXCHANGE_kyc_check_cancel (kcg->kwh);
kcg->kwh = NULL; kcg->kwh = NULL;
} }
@ -210,8 +205,7 @@ check_kyc_traits (void *cls,
{ {
struct KycCheckGetState *kcg = cls; struct KycCheckGetState *kcg = cls;
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_kyc_url ( TALER_TESTING_make_trait_kyc_url (kcg->kyc_url),
(const char **) &kcg->kyc_url),
TALER_TESTING_trait_end () TALER_TESTING_trait_end ()
}; };

View File

@ -83,18 +83,12 @@ proof_kyc_cb (void *cls,
{ {
struct KycProofGetState *kcg = cls; struct KycProofGetState *kcg = cls;
struct TALER_TESTING_Interpreter *is = kcg->is; struct TALER_TESTING_Interpreter *is = kcg->is;
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
kcg->kph = NULL; kcg->kph = NULL;
if (kcg->expected_response_code != kpr->http_status) if (kcg->expected_response_code != kpr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (is,
"Unexpected response code %u to command %s in %s:%u\n", kpr->http_status);
kpr->http_status,
cmd->label,
__FILE__,
__LINE__);
TALER_TESTING_interpreter_fail (is);
return; return;
} }
switch (kpr->http_status) switch (kpr->http_status)
@ -133,8 +127,12 @@ proof_kyc_run (void *cls,
const struct TALER_TESTING_Command *res_cmd; const struct TALER_TESTING_Command *res_cmd;
const struct TALER_PaytoHashP *h_payto; const struct TALER_PaytoHashP *h_payto;
char *uargs; char *uargs;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
kps->is = is; kps->is = is;
res_cmd = TALER_TESTING_interpreter_lookup_command ( res_cmd = TALER_TESTING_interpreter_lookup_command (
kps->is, kps->is,
@ -159,7 +157,7 @@ proof_kyc_run (void *cls,
GNUNET_asprintf (&uargs, GNUNET_asprintf (&uargs,
"&code=%s", "&code=%s",
kps->code); kps->code);
kps->kph = TALER_EXCHANGE_kyc_proof (is->exchange, kps->kph = TALER_EXCHANGE_kyc_proof (exchange,
h_payto, h_payto,
kps->logic, kps->logic,
uargs, uargs,
@ -185,10 +183,8 @@ proof_kyc_cleanup (void *cls,
if (NULL != kps->kph) if (NULL != kps->kph)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (kps->is,
"Command %u (%s) did not complete\n", cmd->label);
kps->is->ip,
cmd->label);
TALER_EXCHANGE_kyc_proof_cancel (kps->kph); TALER_EXCHANGE_kyc_proof_cancel (kps->kph);
kps->kph = NULL; kps->kph = NULL;
} }
@ -214,8 +210,7 @@ proof_kyc_traits (void *cls,
{ {
struct KycProofGetState *kps = cls; struct KycProofGetState *kps = cls;
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_web_url ( TALER_TESTING_make_trait_web_url (kps->redirect_url),
(const char **) &kps->redirect_url),
TALER_TESTING_trait_end () TALER_TESTING_trait_end ()
}; };

View File

@ -48,6 +48,11 @@ struct KycWalletGetState
*/ */
char *reserve_payto_uri; char *reserve_payto_uri;
/**
* Our command.
*/
const struct TALER_TESTING_Command *cmd;
/** /**
* Command to get a reserve private key from. * Command to get a reserve private key from.
*/ */
@ -99,20 +104,12 @@ wallet_kyc_cb (void *cls,
{ {
struct KycWalletGetState *kwg = cls; struct KycWalletGetState *kwg = cls;
struct TALER_TESTING_Interpreter *is = kwg->is; struct TALER_TESTING_Interpreter *is = kwg->is;
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
kwg->kwh = NULL; kwg->kwh = NULL;
if (kwg->expected_response_code != wkr->http_status) if (kwg->expected_response_code != wkr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (is,
"Unexpected response code %u/%d (wanted %u) to command %s in %s:%u\n", wkr->http_status);
wkr->http_status,
(int) wkr->ec,
kwg->expected_response_code,
cmd->label,
__FILE__,
__LINE__);
TALER_TESTING_interpreter_fail (is);
return; return;
} }
switch (wkr->http_status) switch (wkr->http_status)
@ -150,8 +147,12 @@ wallet_kyc_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct KycWalletGetState *kwg = cls; 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; kwg->is = is;
if (NULL != kwg->reserve_reference) 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, GNUNET_CRYPTO_eddsa_key_get_public (&kwg->reserve_priv.eddsa_priv,
&kwg->reserve_pub.eddsa_pub); &kwg->reserve_pub.eddsa_pub);
kwg->reserve_payto_uri 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->reserve_pub);
kwg->kwh = TALER_EXCHANGE_kyc_wallet (is->exchange, kwg->kwh = TALER_EXCHANGE_kyc_wallet (exchange,
&kwg->reserve_priv, &kwg->reserve_priv,
&kwg->balance, &kwg->balance,
&wallet_kyc_cb, &wallet_kyc_cb,
@ -210,10 +211,8 @@ wallet_kyc_cleanup (void *cls,
if (NULL != kwg->kwh) if (NULL != kwg->kwh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (kwg->is,
"Command %u (%s) did not complete\n", cmd->label);
kwg->is->ip,
cmd->label);
TALER_EXCHANGE_kyc_wallet_cancel (kwg->kwh); TALER_EXCHANGE_kyc_wallet_cancel (kwg->kwh);
kwg->kwh = NULL; 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_reserve_pub (&kwg->reserve_pub),
TALER_TESTING_make_trait_legi_requirement_row (&kwg->requirement_row), TALER_TESTING_make_trait_legi_requirement_row (&kwg->requirement_row),
TALER_TESTING_make_trait_h_payto (&kwg->h_payto), TALER_TESTING_make_trait_h_payto (&kwg->h_payto),
TALER_TESTING_make_trait_payto_uri ( TALER_TESTING_make_trait_payto_uri (kwg->reserve_payto_uri),
(const char **) &kwg->reserve_payto_uri),
TALER_TESTING_trait_end () TALER_TESTING_trait_end ()
}; };

View File

@ -162,16 +162,8 @@ deposit_cb (void *cls,
ds->dh = NULL; ds->dh = NULL;
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", dr->hr.http_status);
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);
return; return;
} }
if (MHD_HTTP_OK == dr->hr.http_status) if (MHD_HTTP_OK == dr->hr.http_status)
@ -197,8 +189,12 @@ deposit_run (void *cls,
{ {
struct PurseCreateDepositState *ds = cls; struct PurseCreateDepositState *ds = cls;
struct TALER_EXCHANGE_PurseDeposit deposits[ds->num_coin_references]; struct TALER_EXCHANGE_PurseDeposit deposits[ds->num_coin_references];
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
ds->is = is; ds->is = is;
for (unsigned int i = 0; i<ds->num_coin_references; i++) for (unsigned int i = 0; i<ds->num_coin_references; i++)
{ {
@ -263,7 +259,7 @@ deposit_run (void *cls,
"pay_deadline", "pay_deadline",
GNUNET_JSON_from_timestamp (ds->purse_expiration))); GNUNET_JSON_from_timestamp (ds->purse_expiration)));
ds->dh = TALER_EXCHANGE_purse_create_with_deposit ( ds->dh = TALER_EXCHANGE_purse_create_with_deposit (
is->exchange, exchange,
&ds->purse_priv, &ds->purse_priv,
&ds->merge_priv, &ds->merge_priv,
&ds->contract_priv, &ds->contract_priv,
@ -299,10 +295,8 @@ deposit_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_purse_create_with_deposit_cancel (ds->dh); TALER_EXCHANGE_purse_create_with_deposit_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -74,16 +74,8 @@ purse_delete_cb (void *cls,
pds->pdh = NULL; pds->pdh = NULL;
if (pds->expected_response_code != pdr->hr.http_status) if (pds->expected_response_code != pdr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (pds->is,
"Unexpected response code %u to command %s in %s:%u\n", pdr->hr.http_status);
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);
return; return;
} }
TALER_TESTING_interpreter_next (pds->is); TALER_TESTING_interpreter_next (pds->is);
@ -105,8 +97,12 @@ purse_delete_run (void *cls,
struct PurseDeleteState *pds = cls; struct PurseDeleteState *pds = cls;
const struct TALER_PurseContractPrivateKeyP *purse_priv; const struct TALER_PurseContractPrivateKeyP *purse_priv;
const struct TALER_TESTING_Command *ref; const struct TALER_TESTING_Command *ref;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
ref = TALER_TESTING_interpreter_lookup_command (is, ref = TALER_TESTING_interpreter_lookup_command (is,
pds->purse_cmd); pds->purse_cmd);
if (NULL == ref) if (NULL == ref)
@ -125,7 +121,7 @@ purse_delete_run (void *cls,
} }
pds->is = is; pds->is = is;
pds->pdh = TALER_EXCHANGE_purse_delete ( pds->pdh = TALER_EXCHANGE_purse_delete (
is->exchange, exchange,
purse_priv, purse_priv,
&purse_delete_cb, &purse_delete_cb,
pds); pds);
@ -153,10 +149,8 @@ purse_delete_cleanup (void *cls,
if (NULL != pds->pdh) if (NULL != pds->pdh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (pds->is,
"Command %u (%s) did not complete\n", cmd->label);
pds->is->ip,
cmd->label);
TALER_EXCHANGE_purse_delete_cancel (pds->pdh); TALER_EXCHANGE_purse_delete_cancel (pds->pdh);
pds->pdh = NULL; pds->pdh = NULL;
} }

View File

@ -133,20 +133,15 @@ deposit_cb (void *cls,
const struct TALER_EXCHANGE_PurseDepositResponse *dr) const struct TALER_EXCHANGE_PurseDepositResponse *dr)
{ {
struct PurseDepositState *ds = cls; struct PurseDepositState *ds = cls;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (ds->is);
ds->dh = NULL; ds->dh = NULL;
GNUNET_assert (NULL != exchange);
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", dr->hr.http_status);
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);
return; return;
} }
if (MHD_HTTP_OK == dr->hr.http_status) 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_Keys *keys;
const struct TALER_EXCHANGE_GlobalFee *gf; const struct TALER_EXCHANGE_GlobalFee *gf;
keys = TALER_EXCHANGE_get_keys (ds->is->exchange); keys = TALER_EXCHANGE_get_keys (exchange);
GNUNET_assert (NULL != keys); GNUNET_assert (NULL != keys);
gf = TALER_EXCHANGE_get_global_fee (keys, gf = TALER_EXCHANGE_get_global_fee (keys,
*merge_timestamp); *merge_timestamp);
@ -264,10 +259,13 @@ deposit_run (void *cls,
struct TALER_EXCHANGE_PurseDeposit deposits[ds->num_coin_references]; struct TALER_EXCHANGE_PurseDeposit deposits[ds->num_coin_references];
const struct TALER_PurseContractPublicKeyP *purse_pub; const struct TALER_PurseContractPublicKeyP *purse_pub;
const struct TALER_TESTING_Command *purse_cmd; const struct TALER_TESTING_Command *purse_cmd;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
(void) cmd; (void) cmd;
ds->is = is; ds->is = is;
purse_cmd = TALER_TESTING_interpreter_lookup_command (is, purse_cmd = TALER_TESTING_interpreter_lookup_command (is,
ds->purse_ref); ds->purse_ref);
GNUNET_assert (NULL != purse_cmd); GNUNET_assert (NULL != purse_cmd);
@ -323,7 +321,7 @@ deposit_run (void *cls,
} }
ds->dh = TALER_EXCHANGE_purse_deposit ( ds->dh = TALER_EXCHANGE_purse_deposit (
is->exchange, exchange,
NULL, /* FIXME #7271: WADs support: purse exchange URL */ NULL, /* FIXME #7271: WADs support: purse exchange URL */
&ds->purse_pub, &ds->purse_pub,
ds->min_age, ds->min_age,
@ -357,10 +355,8 @@ deposit_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_purse_deposit_cancel (ds->dh); TALER_EXCHANGE_purse_deposit_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -183,7 +183,11 @@ status_run (void *cls,
{ {
struct StatusState *ss = cls; struct StatusState *ss = cls;
const struct TALER_TESTING_Command *create_purse; const struct TALER_TESTING_Command *create_purse;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
ss->is = is; ss->is = is;
create_purse create_purse
= TALER_TESTING_interpreter_lookup_command (is, = TALER_TESTING_interpreter_lookup_command (is,
@ -198,7 +202,7 @@ status_run (void *cls,
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }
ss->pgh = TALER_EXCHANGE_purse_get (is->exchange, ss->pgh = TALER_EXCHANGE_purse_get (exchange,
ss->purse_pub, ss->purse_pub,
ss->timeout, ss->timeout,
ss->wait_for_merge, ss->wait_for_merge,
@ -227,10 +231,8 @@ status_cleanup (void *cls,
if (NULL != ss->pgh) if (NULL != ss->pgh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ss->is,
"Command %u (%s) did not complete\n", cmd->label);
ss->is->ip,
cmd->label);
TALER_EXCHANGE_purse_get_cancel (ss->pgh); TALER_EXCHANGE_purse_get_cancel (ss->pgh);
ss->pgh = NULL; ss->pgh = NULL;
} }

View File

@ -177,16 +177,8 @@ merge_cb (void *cls,
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", dr->hr.http_status);
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);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);
@ -209,8 +201,12 @@ merge_run (void *cls,
const struct TALER_PurseMergePrivateKeyP *merge_priv; const struct TALER_PurseMergePrivateKeyP *merge_priv;
const json_t *ct; const json_t *ct;
const struct TALER_TESTING_Command *ref; const struct TALER_TESTING_Command *ref;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
ds->is = is; ds->is = is;
ref = TALER_TESTING_interpreter_lookup_command (ds->is, ref = TALER_TESTING_interpreter_lookup_command (ds->is,
ds->merge_ref); ds->merge_ref);
@ -302,8 +298,21 @@ merge_run (void *cls,
&ds->reserve_pub.eddsa_pub); &ds->reserve_pub.eddsa_pub);
{ {
char *payto_uri; 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); &ds->reserve_pub);
TALER_payto_hash (payto_uri, TALER_payto_hash (payto_uri,
&ds->h_payto); &ds->h_payto);
@ -313,7 +322,7 @@ merge_run (void *cls,
&ds->merge_pub.eddsa_pub); &ds->merge_pub.eddsa_pub);
ds->merge_timestamp = GNUNET_TIME_timestamp_get (); ds->merge_timestamp = GNUNET_TIME_timestamp_get ();
ds->dh = TALER_EXCHANGE_account_merge ( ds->dh = TALER_EXCHANGE_account_merge (
is->exchange, exchange,
NULL, /* no wad */ NULL, /* no wad */
&ds->reserve_priv, &ds->reserve_priv,
&ds->purse_pub, &ds->purse_pub,
@ -351,10 +360,8 @@ merge_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_account_merge_cancel (ds->dh); TALER_EXCHANGE_account_merge_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -82,7 +82,6 @@ recoup_cb (void *cls,
struct RecoupState *ps = cls; struct RecoupState *ps = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr; const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr;
struct TALER_TESTING_Interpreter *is = ps->is; struct TALER_TESTING_Interpreter *is = ps->is;
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
const struct TALER_TESTING_Command *reserve_cmd; const struct TALER_TESTING_Command *reserve_cmd;
char *cref; char *cref;
unsigned int idx; unsigned int idx;
@ -90,18 +89,8 @@ recoup_cb (void *cls,
ps->ph = NULL; ps->ph = NULL;
if (ps->expected_response_code != hr->http_status) if (ps->expected_response_code != hr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (is,
"Unexpected response code %u/%d to command %s in %s:%u\n", hr->http_status);
hr->http_status,
(int) hr->ec,
cmd->label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
fprintf (stderr, "\n");
TALER_TESTING_interpreter_fail (is);
return; return;
} }
@ -193,7 +182,11 @@ recoup_run (void *cls,
char *cref; char *cref;
unsigned int idx; unsigned int idx;
const struct TALER_ExchangeWithdrawValues *ewv; const struct TALER_ExchangeWithdrawValues *ewv;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
ps->is = is; ps->is = is;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_TESTING_parse_coin_reference ( TALER_TESTING_parse_coin_reference (
@ -266,7 +259,7 @@ recoup_run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Trying to recoup denomination '%s'\n", "Trying to recoup denomination '%s'\n",
TALER_B2S (&denom_pub->h_key)); TALER_B2S (&denom_pub->h_key));
ps->ph = TALER_EXCHANGE_recoup (is->exchange, ps->ph = TALER_EXCHANGE_recoup (exchange,
denom_pub, denom_pub,
coin_sig, coin_sig,
ewv, ewv,

View File

@ -82,25 +82,14 @@ recoup_refresh_cb (void *cls,
struct RecoupRefreshState *rrs = cls; struct RecoupRefreshState *rrs = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &rrr->hr; const struct TALER_EXCHANGE_HttpResponse *hr = &rrr->hr;
struct TALER_TESTING_Interpreter *is = rrs->is; struct TALER_TESTING_Interpreter *is = rrs->is;
struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
char *cref; char *cref;
unsigned int idx; unsigned int idx;
rrs->ph = NULL; rrs->ph = NULL;
if (rrs->expected_response_code != hr->http_status) if (rrs->expected_response_code != hr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (is,
"Unexpected response code %u/%d to command %s in %s:%u\n", hr->http_status);
hr->http_status,
(int) hr->ec,
cmd->label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
fprintf (stderr, "\n");
TALER_TESTING_interpreter_fail (is);
return; return;
} }
@ -195,7 +184,11 @@ recoup_refresh_run (void *cls,
const struct TALER_ExchangeWithdrawValues *ewv; const struct TALER_ExchangeWithdrawValues *ewv;
char *cref; char *cref;
unsigned int idx; unsigned int idx;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
rrs->is = is; rrs->is = is;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_TESTING_parse_coin_reference ( TALER_TESTING_parse_coin_reference (
@ -280,7 +273,7 @@ recoup_refresh_run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Trying to recoup_refresh denomination '%s'\n", "Trying to recoup_refresh denomination '%s'\n",
TALER_B2S (&denom_pub->h_key)); TALER_B2S (&denom_pub->h_key));
rrs->ph = TALER_EXCHANGE_recoup_refresh (is->exchange, rrs->ph = TALER_EXCHANGE_recoup_refresh (exchange,
denom_pub, denom_pub,
coin_sig, coin_sig,
ewv, ewv,

View File

@ -102,6 +102,11 @@ struct RefreshMeltState
*/ */
struct TALER_EXCHANGE_RefreshData refresh_data; struct TALER_EXCHANGE_RefreshData refresh_data;
/**
* Our command.
*/
const struct TALER_TESTING_Command *cmd;
/** /**
* Reference to a previous melt command. * Reference to a previous melt command.
*/ */
@ -209,6 +214,11 @@ struct RefreshRevealState
*/ */
struct TALER_EXCHANGE_RefreshesRevealHandle *rrh; struct TALER_EXCHANGE_RefreshesRevealHandle *rrh;
/**
* Our command.
*/
const struct TALER_TESTING_Command *cmd;
/** /**
* Convenience struct to keep in one place all the * Convenience struct to keep in one place all the
* data related to one fresh coin, set by the reveal callback * data related to one fresh coin, set by the reveal callback
@ -272,6 +282,11 @@ struct RefreshLinkState
*/ */
const char *reveal_reference; const char *reveal_reference;
/**
* Our command.
*/
const struct TALER_TESTING_Command *cmd;
/** /**
* Handle to the ongoing operation. * Handle to the ongoing operation.
*/ */
@ -334,8 +349,7 @@ do_reveal_retry (void *cls)
struct RefreshRevealState *rrs = cls; struct RefreshRevealState *rrs = cls;
rrs->retry_task = NULL; rrs->retry_task = NULL;
rrs->is->commands[rrs->is->ip].last_req_time TALER_TESTING_touch_cmd (rrs->is);
= GNUNET_TIME_absolute_get ();
refresh_reveal_run (rrs, refresh_reveal_run (rrs,
NULL, NULL,
rrs->is); rrs->is);
@ -357,8 +371,12 @@ reveal_cb (void *cls,
struct RefreshRevealState *rrs = cls; struct RefreshRevealState *rrs = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr; const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr;
const struct TALER_TESTING_Command *melt_cmd; const struct TALER_TESTING_Command *melt_cmd;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (rrs->is);
rrs->rrh = NULL; rrs->rrh = NULL;
if (NULL == exchange)
return;
if (rrs->expected_response_code != hr->http_status) if (rrs->expected_response_code != hr->http_status)
{ {
if (0 != rrs->do_retry) if (0 != rrs->do_retry)
@ -380,24 +398,15 @@ reveal_cb (void *cls,
MAX_BACKOFF); MAX_BACKOFF);
rrs->total_backoff = GNUNET_TIME_relative_add (rrs->total_backoff, rrs->total_backoff = GNUNET_TIME_relative_add (rrs->total_backoff,
rrs->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, rrs->retry_task = GNUNET_SCHEDULER_add_delayed (rrs->backoff,
&do_reveal_retry, &do_reveal_retry,
rrs); rrs);
return; return;
} }
} }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (rrs->is,
"Unexpected response code %u/%d to command %s in %s:%u\n", hr->http_status);
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);
return; return;
} }
melt_cmd = TALER_TESTING_interpreter_lookup_command (rrs->is, melt_cmd = TALER_TESTING_interpreter_lookup_command (rrs->is,
@ -444,9 +453,9 @@ reveal_cb (void *cls,
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Total reveal backoff for %s was %s\n", "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_STRINGS_relative_time_to_string (rrs->total_backoff,
GNUNET_YES)); true));
} }
break; break;
default: default:
@ -487,7 +496,12 @@ refresh_reveal_run (void *cls,
struct RefreshRevealState *rrs = cls; struct RefreshRevealState *rrs = cls;
struct RefreshMeltState *rms; struct RefreshMeltState *rms;
const struct TALER_TESTING_Command *melt_cmd; 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; rrs->is = is;
melt_cmd = TALER_TESTING_interpreter_lookup_command (is, melt_cmd = TALER_TESTING_interpreter_lookup_command (is,
rrs->melt_reference); rrs->melt_reference);
@ -504,7 +518,7 @@ refresh_reveal_run (void *cls,
for (unsigned int i = 0; i<rms->num_fresh_coins; i++) for (unsigned int i = 0; i<rms->num_fresh_coins; i++)
alg_values[i] = rms->mbds[i].alg_value; 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->rms,
&rms->refresh_data, &rms->refresh_data,
rms->num_fresh_coins, rms->num_fresh_coins,
@ -538,10 +552,8 @@ refresh_reveal_cleanup (void *cls,
(void) cmd; (void) cmd;
if (NULL != rrs->rrh) if (NULL != rrs->rrh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (rrs->is,
"Command %u (%s) did not complete\n", cmd->label);
rrs->is->ip,
cmd->label);
TALER_EXCHANGE_refreshes_reveal_cancel (rrs->rrh); TALER_EXCHANGE_refreshes_reveal_cancel (rrs->rrh);
rrs->rrh = NULL; rrs->rrh = NULL;
} }
@ -585,8 +597,7 @@ do_link_retry (void *cls)
struct RefreshLinkState *rls = cls; struct RefreshLinkState *rls = cls;
rls->retry_task = NULL; rls->retry_task = NULL;
rls->is->commands[rls->is->ip].last_req_time TALER_TESTING_touch_cmd (rls->is);
= GNUNET_TIME_absolute_get ();
refresh_link_run (rls, refresh_link_run (rls,
NULL, NULL,
rls->is); rls->is);
@ -608,7 +619,6 @@ link_cb (void *cls,
struct RefreshLinkState *rls = cls; struct RefreshLinkState *rls = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &lr->hr; const struct TALER_EXCHANGE_HttpResponse *hr = &lr->hr;
const struct TALER_TESTING_Command *reveal_cmd; const struct TALER_TESTING_Command *reveal_cmd;
struct TALER_TESTING_Command *link_cmd = &rls->is->commands[rls->is->ip];
unsigned int found; unsigned int found;
const unsigned int *num_fresh_coins; const unsigned int *num_fresh_coins;
@ -634,24 +644,15 @@ link_cb (void *cls,
MAX_BACKOFF); MAX_BACKOFF);
rls->total_backoff = GNUNET_TIME_relative_add (rls->total_backoff, rls->total_backoff = GNUNET_TIME_relative_add (rls->total_backoff,
rls->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, rls->retry_task = GNUNET_SCHEDULER_add_delayed (rls->backoff,
&do_link_retry, &do_link_retry,
rls); rls);
return; return;
} }
} }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (rls->is,
"Unexpected response code %u/%d to command %s in %s:%u\n", hr->http_status);
hr->http_status,
(int) hr->ec,
link_cmd->label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (rls->is);
return; return;
} }
reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is, reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
@ -749,9 +750,9 @@ link_cb (void *cls,
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Total link backoff for %s was %s\n", "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_STRINGS_relative_time_to_string (rls->total_backoff,
GNUNET_YES)); true));
} }
break; break;
default: default:
@ -782,8 +783,12 @@ refresh_link_run (void *cls,
const struct TALER_TESTING_Command *reveal_cmd; const struct TALER_TESTING_Command *reveal_cmd;
const struct TALER_TESTING_Command *melt_cmd; const struct TALER_TESTING_Command *melt_cmd;
const struct TALER_TESTING_Command *coin_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; rls->is = is;
reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is, reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
rls->reveal_reference); rls->reveal_reference);
@ -827,7 +832,7 @@ refresh_link_run (void *cls,
} }
/* finally, use private key from withdraw sign command */ /* finally, use private key from withdraw sign command */
rls->rlh = TALER_EXCHANGE_link (is->exchange, rls->rlh = TALER_EXCHANGE_link (exchange,
coin_priv, coin_priv,
rms->refresh_data.melt_age_commitment_proof, rms->refresh_data.melt_age_commitment_proof,
&link_cb, &link_cb,
@ -857,11 +862,8 @@ refresh_link_cleanup (void *cls,
if (NULL != rls->rlh) if (NULL != rls->rlh)
{ {
TALER_TESTING_command_incomplete (rls->is,
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, cmd->label);
"Command %u (%s) did not complete\n",
rls->is->ip,
cmd->label);
TALER_EXCHANGE_link_cancel (rls->rlh); TALER_EXCHANGE_link_cancel (rls->rlh);
rls->rlh = NULL; rls->rlh = NULL;
} }
@ -885,8 +887,7 @@ do_melt_retry (void *cls)
struct RefreshMeltState *rms = cls; struct RefreshMeltState *rms = cls;
rms->retry_task = NULL; rms->retry_task = NULL;
rms->is->commands[rms->is->ip].last_req_time TALER_TESTING_touch_cmd (rms->is);
= GNUNET_TIME_absolute_get ();
melt_run (rms, melt_run (rms,
NULL, NULL,
rms->is); rms->is);
@ -907,8 +908,12 @@ melt_cb (void *cls,
{ {
struct RefreshMeltState *rms = cls; struct RefreshMeltState *rms = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &mr->hr; const struct TALER_EXCHANGE_HttpResponse *hr = &mr->hr;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (rms->is);
rms->rmh = NULL; rms->rmh = NULL;
if (NULL == exchange)
return;
if (rms->expected_response_code != hr->http_status) if (rms->expected_response_code != hr->http_status)
{ {
if (0 != rms->do_retry) if (0 != rms->do_retry)
@ -930,24 +935,15 @@ melt_cb (void *cls,
MAX_BACKOFF); MAX_BACKOFF);
rms->total_backoff = GNUNET_TIME_relative_add (rms->total_backoff, rms->total_backoff = GNUNET_TIME_relative_add (rms->total_backoff,
rms->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, rms->retry_task = GNUNET_SCHEDULER_add_delayed (rms->backoff,
&do_melt_retry, &do_melt_retry,
rms); rms);
return; return;
} }
} }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (rms->is,
"Unexpected response code %u/%d to command %s in %s:%u\n", hr->http_status);
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);
return; return;
} }
if (MHD_HTTP_OK == hr->http_status) if (MHD_HTTP_OK == hr->http_status)
@ -969,15 +965,15 @@ melt_cb (void *cls,
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Total melt backoff for %s was %s\n", "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_STRINGS_relative_time_to_string (rms->total_backoff,
GNUNET_YES)); true));
} }
if (rms->double_melt) if (rms->double_melt)
{ {
TALER_LOG_DEBUG ("Doubling the melt (%s)\n", TALER_LOG_DEBUG ("Doubling the melt (%s)\n",
rms->is->commands[rms->is->ip].label); rms->cmd->label);
rms->rmh = TALER_EXCHANGE_melt (rms->is->exchange, rms->rmh = TALER_EXCHANGE_melt (exchange,
&rms->rms, &rms->rms,
&rms->refresh_data, &rms->refresh_data,
&melt_cb, &melt_cb,
@ -1008,8 +1004,12 @@ melt_run (void *cls,
NULL NULL
}; };
const char **melt_fresh_amounts; 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)) if (NULL == (melt_fresh_amounts = rms->melt_fresh_amounts))
melt_fresh_amounts = default_melt_fresh_amounts; melt_fresh_amounts = default_melt_fresh_amounts;
rms->is = is; rms->is = is;
@ -1113,7 +1113,7 @@ melt_run (void *cls,
TALER_TESTING_interpreter_fail (rms->is); TALER_TESTING_interpreter_fail (rms->is);
return; 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, &fresh_amount,
age_restricted); age_restricted);
if (NULL == fresh_pk) if (NULL == fresh_pk)
@ -1149,7 +1149,7 @@ melt_run (void *cls,
GNUNET_assert (age_restricted == GNUNET_assert (age_restricted ==
(NULL != age_commitment_proof)); (NULL != age_commitment_proof));
rms->rmh = TALER_EXCHANGE_melt (is->exchange, rms->rmh = TALER_EXCHANGE_melt (exchange,
&rms->rms, &rms->rms,
&rms->refresh_data, &rms->refresh_data,
&melt_cb, &melt_cb,
@ -1181,10 +1181,8 @@ melt_cleanup (void *cls,
(void) cmd; (void) cmd;
if (NULL != rms->rmh) if (NULL != rms->rmh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (rms->is,
"Command %u (%s) did not complete\n", cmd->label);
rms->is->ip,
rms->is->commands[rms->is->ip].label);
TALER_EXCHANGE_melt_cancel (rms->rmh); TALER_EXCHANGE_melt_cancel (rms->rmh);
rms->rmh = NULL; rms->rmh = NULL;
} }

View File

@ -83,23 +83,12 @@ refund_cb (void *cls,
{ {
struct RefundState *rs = cls; struct RefundState *rs = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr; 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; rs->rh = NULL;
if (rs->expected_response_code != hr->http_status) if (rs->expected_response_code != hr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (rs->is,
"Unexpected response code %u/%d to command %s in %s:%u\n", hr->http_status);
hr->http_status,
hr->ec,
refund_cmd->label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (rs->is);
return; return;
} }
TALER_TESTING_interpreter_next (rs->is); TALER_TESTING_interpreter_next (rs->is);
@ -127,17 +116,17 @@ refund_run (void *cls,
const struct TALER_MerchantPrivateKeyP *merchant_priv; const struct TALER_MerchantPrivateKeyP *merchant_priv;
const struct TALER_TESTING_Command *coin_cmd; 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; rs->is = is;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_string_to_amount (rs->refund_amount, TALER_string_to_amount (rs->refund_amount,
&refund_amount)) &refund_amount))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 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, rs->refund_amount,
is->ip,
cmd->label); cmd->label);
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
@ -210,10 +199,8 @@ refund_cleanup (void *cls,
if (NULL != rs->rh) if (NULL != rs->rh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (rs->is,
"Command %u (%s) did not complete\n", cmd->label);
rs->is->ip,
cmd->label);
TALER_EXCHANGE_refund_cancel (rs->rh); TALER_EXCHANGE_refund_cancel (rs->rh);
rs->rh = NULL; rs->rh = NULL;
} }

View File

@ -152,7 +152,11 @@ attest_run (void *cls,
{ {
struct AttestState *ss = cls; struct AttestState *ss = cls;
const struct TALER_TESTING_Command *create_reserve; const struct TALER_TESTING_Command *create_reserve;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
ss->is = is; ss->is = is;
create_reserve create_reserve
= TALER_TESTING_interpreter_lookup_command (is, = 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, GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
&ss->reserve_pub.eddsa_pub); &ss->reserve_pub.eddsa_pub);
ss->rsh = TALER_EXCHANGE_reserves_attest (is->exchange, ss->rsh = TALER_EXCHANGE_reserves_attest (exchange,
ss->reserve_priv, ss->reserve_priv,
ss->attrs_len, ss->attrs_len,
ss->attrs, ss->attrs,
@ -199,10 +203,8 @@ attest_cleanup (void *cls,
if (NULL != ss->rsh) if (NULL != ss->rsh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ss->is,
"Command %u (%s) did not complete\n", cmd->label);
ss->is->ip,
cmd->label);
TALER_EXCHANGE_reserves_attest_cancel (ss->rsh); TALER_EXCHANGE_reserves_attest_cancel (ss->rsh);
ss->rsh = NULL; ss->rsh = NULL;
} }

View File

@ -142,7 +142,11 @@ close_run (void *cls,
{ {
struct CloseState *ss = cls; struct CloseState *ss = cls;
const struct TALER_TESTING_Command *create_reserve; const struct TALER_TESTING_Command *create_reserve;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
ss->is = is; ss->is = is;
create_reserve create_reserve
= TALER_TESTING_interpreter_lookup_command (is, = 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, GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
&ss->reserve_pub.eddsa_pub); &ss->reserve_pub.eddsa_pub);
ss->rsh = TALER_EXCHANGE_reserves_close (is->exchange, ss->rsh = TALER_EXCHANGE_reserves_close (exchange,
ss->reserve_priv, ss->reserve_priv,
ss->target_account, ss->target_account,
&reserve_close_cb, &reserve_close_cb,
@ -188,10 +192,8 @@ close_cleanup (void *cls,
if (NULL != ss->rsh) if (NULL != ss->rsh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ss->is,
"Command %u (%s) did not complete\n", cmd->label);
ss->is->ip,
cmd->label);
TALER_EXCHANGE_reserves_close_cancel (ss->rsh); TALER_EXCHANGE_reserves_close_cancel (ss->rsh);
ss->rsh = NULL; ss->rsh = NULL;
} }

View File

@ -178,7 +178,11 @@ status_run (void *cls,
{ {
struct StatusState *ss = cls; struct StatusState *ss = cls;
const struct TALER_TESTING_Command *create_reserve; const struct TALER_TESTING_Command *create_reserve;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
ss->is = is; ss->is = is;
create_reserve create_reserve
= TALER_TESTING_interpreter_lookup_command (is, = TALER_TESTING_interpreter_lookup_command (is,
@ -193,7 +197,7 @@ status_run (void *cls,
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }
ss->rsh = TALER_EXCHANGE_reserves_get (is->exchange, ss->rsh = TALER_EXCHANGE_reserves_get (exchange,
ss->reserve_pubp, ss->reserve_pubp,
ss->timeout, ss->timeout,
&reserve_status_cb, &reserve_status_cb,
@ -221,10 +225,8 @@ status_cleanup (void *cls,
if (NULL != ss->rsh) if (NULL != ss->rsh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ss->is,
"Command %u (%s) did not complete\n", cmd->label);
ss->is->ip,
cmd->label);
TALER_EXCHANGE_reserves_get_cancel (ss->rsh); TALER_EXCHANGE_reserves_get_cancel (ss->rsh);
ss->rsh = NULL; ss->rsh = NULL;
} }

View File

@ -125,7 +125,11 @@ get_attestable_run (void *cls,
const struct TALER_TESTING_Command *ref_reserve; const struct TALER_TESTING_Command *ref_reserve;
const struct TALER_ReservePrivateKeyP *reserve_priv; const struct TALER_ReservePrivateKeyP *reserve_priv;
const struct TALER_ReservePublicKeyP *reserve_pub; const struct TALER_ReservePublicKeyP *reserve_pub;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
ss->is = is; ss->is = is;
ref_reserve ref_reserve
= TALER_TESTING_interpreter_lookup_command (is, = TALER_TESTING_interpreter_lookup_command (is,
@ -158,7 +162,7 @@ get_attestable_run (void *cls,
} }
ss->reserve_pub = *reserve_pub; 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, &ss->reserve_pub,
&reserve_get_attestable_cb, &reserve_get_attestable_cb,
ss); ss);
@ -180,10 +184,8 @@ get_attestable_cleanup (void *cls,
if (NULL != ss->rgah) if (NULL != ss->rgah)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ss->is,
"Command %u (%s) did not complete\n", cmd->label);
ss->is->ip,
cmd->label);
TALER_EXCHANGE_reserves_get_attestable_cancel (ss->rgah); TALER_EXCHANGE_reserves_get_attestable_cancel (ss->rgah);
ss->rgah = NULL; ss->rgah = NULL;
} }

View File

@ -79,24 +79,55 @@ struct HistoryState
/** /**
* Check if @a cmd changed the reserve, if so, find the * Closure for analysis_cb().
* 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
*/ */
static enum GNUNET_GenericReturnValue struct AnalysisContext
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)
{ {
/**
* 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)) if (TALER_TESTING_cmd_is_batch (cmd))
{ {
struct TALER_TESTING_Command *cur; struct TALER_TESTING_Command *cur;
@ -108,28 +139,26 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
&bcmd)) &bcmd))
{ {
GNUNET_break (0); GNUNET_break (0);
return GNUNET_SYSERR; ac->failure = true;
return;
} }
for (unsigned int i = 0; NULL != (*bcmd)[i].label; i++) for (unsigned int i = 0; NULL != (*bcmd)[i].label; i++)
{ {
struct TALER_TESTING_Command *step = &(*bcmd)[i]; struct TALER_TESTING_Command *step = &(*bcmd)[i];
if (GNUNET_OK != analyze_command (ac,
analyze_command (reserve_pub, step);
step, if (ac->failure)
history_length,
history,
found))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Entry for batch step `%s' missing in history\n", "Entry for batch step `%s' missing in history\n",
step->label); step->label);
return GNUNET_SYSERR; return;
} }
if (step == cur) if (step == cur)
break; /* if *we* are in a batch, make sure not to analyze commands past 'now' */ 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 != if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_pub (cmd, TALER_TESTING_get_trait_reserve_pub (cmd,
&rp)) &rp))
return GNUNET_OK; /* command does nothing for reserves */ return; /* command does nothing for reserves */
if (0 != if (0 !=
GNUNET_memcmp (rp, GNUNET_memcmp (rp,
reserve_pub)) reserve_pub))
return GNUNET_OK; /* command affects some _other_ reserve */ return; /* command affects some _other_ reserve */
for (unsigned int j = 0; true; j++) for (unsigned int j = 0; true; j++)
{ {
const struct TALER_EXCHANGE_ReserveHistoryEntry *he; const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
@ -156,9 +185,9 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
/* NOTE: only for debugging... */ /* NOTE: only for debugging... */
if (0 == j) if (0 == j)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 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); 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++) 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", "Command `%s' reserve history entry #%u not found\n",
cmd->label, cmd->label,
j); j);
return GNUNET_SYSERR; ac->failure = true;
return;
} }
} }
} }
@ -200,15 +230,19 @@ reserve_history_cb (void *cls,
struct HistoryState *ss = cls; struct HistoryState *ss = cls;
struct TALER_TESTING_Interpreter *is = ss->is; struct TALER_TESTING_Interpreter *is = ss->is;
struct TALER_Amount eb; struct TALER_Amount eb;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
ss->rsh = NULL; ss->rsh = NULL;
if (NULL == exchange)
return;
if (MHD_HTTP_OK == rs->hr.http_status) if (MHD_HTTP_OK == rs->hr.http_status)
{ {
const struct TALER_EXCHANGE_Keys *keys; const struct TALER_EXCHANGE_Keys *keys;
const struct TALER_EXCHANGE_GlobalFee *gf; const struct TALER_EXCHANGE_GlobalFee *gf;
ss->reserve_history.type = TALER_EXCHANGE_RTT_HISTORY; 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); GNUNET_assert (NULL != keys);
gf = TALER_EXCHANGE_get_global_fee (keys, gf = TALER_EXCHANGE_get_global_fee (keys,
rs->ts); rs->ts);
@ -254,44 +288,42 @@ reserve_history_cb (void *cls,
} }
{ {
bool found[rs->details.ok.history_len]; 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, memset (found,
0, 0,
sizeof (found)); 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]; json_dumpf (rs->hr.reply,
stderr,
if (GNUNET_OK != JSON_INDENT (2));
analyze_command (&ss->reserve_pub, TALER_TESTING_interpreter_fail (ss->is);
cmd, return;
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++) for (unsigned int i = 0; i<rs->details.ok.history_len; i++)
if (! found[i]) {
{ if (found[i])
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, continue;
"History entry at index %u of type %d not justified by command history\n", GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
i, "History entry at index %u of type %d not justified by command history\n",
rs->details.ok.history[i].type); i,
json_dumpf (rs->hr.reply, rs->details.ok.history[i].type);
stderr, json_dumpf (rs->hr.reply,
JSON_INDENT (2)); stderr,
TALER_TESTING_interpreter_fail (ss->is); JSON_INDENT (2));
return; TALER_TESTING_interpreter_fail (ss->is);
} return;
}
} }
TALER_TESTING_interpreter_next (is); TALER_TESTING_interpreter_next (is);
} }
@ -311,7 +343,11 @@ history_run (void *cls,
{ {
struct HistoryState *ss = cls; struct HistoryState *ss = cls;
const struct TALER_TESTING_Command *create_reserve; const struct TALER_TESTING_Command *create_reserve;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
ss->is = is; ss->is = is;
create_reserve create_reserve
= TALER_TESTING_interpreter_lookup_command (is, = 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, GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
&ss->reserve_pub.eddsa_pub); &ss->reserve_pub.eddsa_pub);
ss->rsh = TALER_EXCHANGE_reserves_history (is->exchange, ss->rsh = TALER_EXCHANGE_reserves_history (exchange,
ss->reserve_priv, ss->reserve_priv,
&reserve_history_cb, &reserve_history_cb,
ss); ss);
@ -388,10 +424,8 @@ history_cleanup (void *cls,
if (NULL != ss->rsh) if (NULL != ss->rsh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ss->is,
"Command %u (%s) did not complete\n", cmd->label);
ss->is->ip,
cmd->label);
TALER_EXCHANGE_reserves_history_cancel (ss->rsh); TALER_EXCHANGE_reserves_history_cancel (ss->rsh);
ss->rsh = NULL; ss->rsh = NULL;
} }

View File

@ -165,7 +165,11 @@ open_run (void *cls,
struct OpenState *ss = cls; struct OpenState *ss = cls;
const struct TALER_TESTING_Command *create_reserve; const struct TALER_TESTING_Command *create_reserve;
struct TALER_EXCHANGE_PurseDeposit cp[GNUNET_NZL (ss->cpl)]; 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; ss->is = is;
create_reserve create_reserve
= TALER_TESTING_interpreter_lookup_command (is, = TALER_TESTING_interpreter_lookup_command (is,
@ -252,7 +256,7 @@ open_run (void *cls,
cpi->h_denom_pub = denom_pub->h_key; cpi->h_denom_pub = denom_pub->h_key;
} }
ss->rsh = TALER_EXCHANGE_reserves_open ( ss->rsh = TALER_EXCHANGE_reserves_open (
is->exchange, exchange,
ss->reserve_priv, ss->reserve_priv,
&ss->reserve_pay, &ss->reserve_pay,
ss->cpl, ss->cpl,
@ -279,10 +283,8 @@ open_cleanup (void *cls,
if (NULL != ss->rsh) if (NULL != ss->rsh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ss->is,
"Command %u (%s) did not complete\n", cmd->label);
ss->is->ip,
cmd->label);
TALER_EXCHANGE_reserves_open_cancel (ss->rsh); TALER_EXCHANGE_reserves_open_cancel (ss->rsh);
ss->rsh = NULL; ss->rsh = NULL;
} }

View File

@ -153,16 +153,8 @@ purse_cb (void *cls,
ds->reserve_sig = *dr->reserve_sig; ds->reserve_sig = *dr->reserve_sig;
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (ds->is,
"Unexpected response code %u to command %s in %s:%u\n", dr->hr.http_status);
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);
return; return;
} }
switch (dr->hr.http_status) switch (dr->hr.http_status)
@ -192,8 +184,12 @@ purse_run (void *cls,
struct ReservePurseState *ds = cls; struct ReservePurseState *ds = cls;
const struct TALER_ReservePrivateKeyP *reserve_priv; const struct TALER_ReservePrivateKeyP *reserve_priv;
const struct TALER_TESTING_Command *ref; const struct TALER_TESTING_Command *ref;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd; (void) cmd;
if (NULL == exchange)
return;
ds->is = is; ds->is = is;
ref = TALER_TESTING_interpreter_lookup_command (ds->is, ref = TALER_TESTING_interpreter_lookup_command (ds->is,
ds->reserve_ref); ds->reserve_ref);
@ -221,8 +217,21 @@ purse_run (void *cls,
{ {
char *payto_uri; 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); &ds->reserve_pub);
TALER_payto_hash (payto_uri, TALER_payto_hash (payto_uri,
&ds->h_payto); &ds->h_payto);
@ -236,7 +245,7 @@ purse_run (void *cls,
GNUNET_JSON_from_timestamp (ds->purse_expiration))); GNUNET_JSON_from_timestamp (ds->purse_expiration)));
ds->merge_timestamp = GNUNET_TIME_timestamp_get (); ds->merge_timestamp = GNUNET_TIME_timestamp_get ();
ds->dh = TALER_EXCHANGE_purse_create_with_merge ( ds->dh = TALER_EXCHANGE_purse_create_with_merge (
is->exchange, exchange,
&ds->reserve_priv, &ds->reserve_priv,
&ds->purse_priv, &ds->purse_priv,
&ds->merge_priv, &ds->merge_priv,
@ -273,10 +282,8 @@ purse_cleanup (void *cls,
if (NULL != ds->dh) if (NULL != ds->dh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ds->is,
"Command %u (%s) did not complete\n", cmd->label);
ds->is->ip,
cmd->label);
TALER_EXCHANGE_purse_create_with_merge_cancel (ds->dh); TALER_EXCHANGE_purse_create_with_merge_cancel (ds->dh);
ds->dh = NULL; ds->dh = NULL;
} }

View File

@ -69,26 +69,56 @@ struct StatusState
struct TALER_TESTING_Interpreter *is; 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 * Check if @a cmd changed the reserve, if so, find the
* entry in @a history and set the respective index in @a found * entry in our history and set the respective index in found
* to #GNUNET_YES. If the entry is not found, return #GNUNET_SYSERR. * 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 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 static void
analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub, analyze_command (void *cls,
const struct TALER_TESTING_Command *cmd, const struct TALER_TESTING_Command *cmd)
unsigned int history_length,
const struct TALER_EXCHANGE_ReserveHistoryEntry *history,
bool *found)
{ {
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)) if (TALER_TESTING_cmd_is_batch (cmd))
{ {
struct TALER_TESTING_Command *cur; struct TALER_TESTING_Command *cur;
@ -100,7 +130,8 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
&bcmd)) &bcmd))
{ {
GNUNET_break (0); GNUNET_break (0);
return GNUNET_SYSERR; ac->failure = true;
return;
} }
for (unsigned int i = 0; NULL != (*bcmd)[i].label; i++) 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) if (step == cur)
break; /* if *we* are in a batch, make sure not to analyze commands past 'now' */ break; /* if *we* are in a batch, make sure not to analyze commands past 'now' */
if (GNUNET_OK != analyze_command (ac,
analyze_command (reserve_pub, step);
step, if (ac->failure)
history_length,
history,
found))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Entry for batch step `%s' missing in history\n", "Entry for batch step `%s' missing in history\n",
step->label); step->label);
return GNUNET_SYSERR; return;
} }
} }
return GNUNET_OK; return;
} }
else
{ {
const struct TALER_ReservePublicKeyP *rp; const struct TALER_ReservePublicKeyP *rp;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_pub (cmd, TALER_TESTING_get_trait_reserve_pub (cmd,
&rp)) &rp))
return GNUNET_OK; /* command does nothing for reserves */ return; /* command does nothing for reserves */
if (0 != if (0 !=
GNUNET_memcmp (rp, GNUNET_memcmp (rp,
reserve_pub)) reserve_pub))
return GNUNET_OK; /* command affects some _other_ reserve */ return; /* command affects some _other_ reserve */
for (unsigned int j = 0; true; j++) for (unsigned int j = 0; true; j++)
{ {
const struct TALER_EXCHANGE_ReserveHistoryEntry *he; const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
@ -149,7 +177,7 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 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 trait, but does not reserve history trait\n",
cmd->label); 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++) 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", "Command `%s' reserve history entry #%u not found\n",
cmd->label, cmd->label,
j); j);
return GNUNET_SYSERR; ac->failure = true;
return;
} }
} }
} }
@ -230,44 +259,42 @@ reserve_status_cb (void *cls,
} }
{ {
bool found[rs->details.ok.history_len]; 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, memset (found,
0, 0,
sizeof (found)); 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]; json_dumpf (rs->hr.reply,
stderr,
if (GNUNET_OK != JSON_INDENT (2));
analyze_command (&ss->reserve_pub, TALER_TESTING_interpreter_fail (ss->is);
cmd, return;
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++) for (unsigned int i = 0; i<rs->details.ok.history_len; i++)
if (! found[i]) {
{ if (found[i])
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, continue;
"History entry at index %u of type %d not justified by command status\n", GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
i, "History entry at index %u of type %d not justified by command status\n",
rs->details.ok.history[i].type); i,
json_dumpf (rs->hr.reply, rs->details.ok.history[i].type);
stderr, json_dumpf (rs->hr.reply,
JSON_INDENT (2)); stderr,
TALER_TESTING_interpreter_fail (ss->is); JSON_INDENT (2));
return; TALER_TESTING_interpreter_fail (ss->is);
} return;
}
} }
TALER_TESTING_interpreter_next (is); TALER_TESTING_interpreter_next (is);
} }
@ -287,7 +314,11 @@ status_run (void *cls,
{ {
struct StatusState *ss = cls; struct StatusState *ss = cls;
const struct TALER_TESTING_Command *create_reserve; const struct TALER_TESTING_Command *create_reserve;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
if (NULL == exchange)
return;
ss->is = is; ss->is = is;
create_reserve create_reserve
= TALER_TESTING_interpreter_lookup_command (is, = 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, GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
&ss->reserve_pub.eddsa_pub); &ss->reserve_pub.eddsa_pub);
ss->rsh = TALER_EXCHANGE_reserves_status (is->exchange, ss->rsh = TALER_EXCHANGE_reserves_status (exchange,
ss->reserve_priv, ss->reserve_priv,
&reserve_status_cb, &reserve_status_cb,
ss); ss);
@ -332,10 +363,8 @@ status_cleanup (void *cls,
if (NULL != ss->rsh) if (NULL != ss->rsh)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, TALER_TESTING_command_incomplete (ss->is,
"Command %u (%s) did not complete\n", cmd->label);
ss->is->ip,
cmd->label);
TALER_EXCHANGE_reserves_status_cancel (ss->rsh); TALER_EXCHANGE_reserves_status_cancel (ss->rsh);
ss->rsh = NULL; ss->rsh = NULL;
} }

View File

@ -78,16 +78,8 @@ success_cb (
rs->kh = NULL; rs->kh = NULL;
if (rs->expected_response_code != hr->http_status) if (rs->expected_response_code != hr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (rs->is,
"Unexpected response code %u to command %s in %s:%u\n", hr->http_status);
hr->http_status,
rs->is->commands[rs->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (rs->is);
return; return;
} }
TALER_TESTING_interpreter_next (rs->is); TALER_TESTING_interpreter_next (rs->is);
@ -159,7 +151,23 @@ revoke_run (void *cls,
const struct TALER_TESTING_Command *coin_cmd; const struct TALER_TESTING_Command *coin_cmd;
const struct TALER_EXCHANGE_DenomPublicKey *denom_pub; const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
struct TALER_MasterSignatureP master_sig; 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; rs->is = is;
/* Get denom pub from trait */ /* Get denom pub from trait */
coin_cmd = TALER_TESTING_interpreter_lookup_command (is, coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
@ -186,13 +194,27 @@ revoke_run (void *cls,
} }
else 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, TALER_exchange_offline_denomination_revoke_sign (&denom_pub->h_key,
&is->master_priv, master_priv,
&master_sig); &master_sig);
} }
rs->kh = TALER_EXCHANGE_management_revoke_denomination_key ( rs->kh = TALER_EXCHANGE_management_revoke_denomination_key (
is->ctx, TALER_TESTING_interpreter_get_context (is),
is->exchange_url, exchange_url,
&denom_pub->h_key, &denom_pub->h_key,
&master_sig, &master_sig,
&success_cb, &success_cb,

View File

@ -78,16 +78,8 @@ success_cb (
rs->kh = NULL; rs->kh = NULL;
if (rs->expected_response_code != hr->http_status) if (rs->expected_response_code != hr->http_status)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_TESTING_unexpected_status (rs->is,
"Unexpected response code %u to command %s in %s:%u\n", hr->http_status);
hr->http_status,
rs->is->commands[rs->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (rs->is);
return; return;
} }
TALER_TESTING_interpreter_next (rs->is); TALER_TESTING_interpreter_next (rs->is);
@ -159,7 +151,23 @@ revoke_run (void *cls,
const struct TALER_TESTING_Command *coin_cmd; const struct TALER_TESTING_Command *coin_cmd;
const struct TALER_ExchangePublicKeyP *exchange_pub; const struct TALER_ExchangePublicKeyP *exchange_pub;
struct TALER_MasterSignatureP master_sig; 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; rs->is = is;
/* Get sign pub from trait */ /* Get sign pub from trait */
coin_cmd = TALER_TESTING_interpreter_lookup_command (is, coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
@ -186,13 +194,27 @@ revoke_run (void *cls,
} }
else 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, TALER_exchange_offline_signkey_revoke_sign (exchange_pub,
&is->master_priv, master_priv,
&master_sig); &master_sig);
} }
rs->kh = TALER_EXCHANGE_management_revoke_signing_key ( rs->kh = TALER_EXCHANGE_management_revoke_signing_key (
is->ctx, TALER_TESTING_interpreter_get_context (is),
is->exchange_url, exchange_url,
exchange_pub, exchange_pub,
&master_sig, &master_sig,
&success_cb, &success_cb,

View File

@ -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;
}
}

View 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;
}
}

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as it under the terms of the GNU General Public License as
@ -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. * Run the command.
* *
@ -87,16 +58,20 @@ serialize_keys_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct SerializeKeysState *sks = cls; 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) if (NULL == sks->keys)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
}
sks->exchange_url = GNUNET_strdup sks->exchange_url
(TALER_EXCHANGE_get_base_url (is->exchange)); = GNUNET_strdup (
TALER_EXCHANGE_disconnect (is->exchange); TALER_EXCHANGE_get_base_url (exchange));
is->exchange = NULL;
is->working = GNUNET_NO;
TALER_TESTING_interpreter_next (is); TALER_TESTING_interpreter_next (is);
} }
@ -114,9 +89,7 @@ serialize_keys_cleanup (void *cls,
struct SerializeKeysState *sks = cls; struct SerializeKeysState *sks = cls;
if (NULL != sks->keys) if (NULL != sks->keys)
{
json_decref (sks->keys); json_decref (sks->keys);
}
GNUNET_free (sks->exchange_url); GNUNET_free (sks->exchange_url);
GNUNET_free (sks); GNUNET_free (sks);
} }
@ -140,8 +113,7 @@ serialize_keys_traits (void *cls,
struct SerializeKeysState *sks = cls; struct SerializeKeysState *sks = cls;
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_exchange_keys (sks->keys), TALER_TESTING_make_trait_exchange_keys (sks->keys),
TALER_TESTING_make_trait_exchange_url ( TALER_TESTING_make_trait_exchange_url (sks->exchange_url),
(const char **) &sks->exchange_url),
TALER_TESTING_trait_end () 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 struct TALER_TESTING_Command
TALER_TESTING_cmd_serialize_keys (const char *label) TALER_TESTING_cmd_serialize_keys (const char *label)
{ {
@ -251,25 +142,3 @@ TALER_TESTING_cmd_serialize_keys (const char *label)
return cmd; 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;
}
}

Some files were not shown because too many files have changed in this diff Show More