Merge branch 'master' of git+ssh://taler.net/var/git/exchange

This commit is contained in:
Christian Grothoff 2016-06-09 19:18:30 +02:00
commit ecf0689c75
2 changed files with 27 additions and 6 deletions

View File

@ -1 +1 @@
{"type":"test", "bank_uri":"https://bank.test.taler.net/", "account_number":63} {"type":"test", "bank_uri":"https://bank.test.taler.net/", "account_number":64}

View File

@ -28,6 +28,8 @@
#include <microhttpd.h> #include <microhttpd.h>
#include <jansson.h> #include <jansson.h>
#define RUNXCG
/** /**
* How many coins the benchmark should operate on * How many coins the benchmark should operate on
*/ */
@ -44,7 +46,7 @@ static char *config_file;
struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_CONFIGURATION_Handle *cfg;
/** /**
* How many reservers ought to be created given the pool size * How many reserves ought to be created given the pool size
*/ */
static unsigned int nreserves; static unsigned int nreserves;
@ -385,7 +387,10 @@ reserve_withdraw_cb (void *cls,
coins[coin_index].wsh = NULL; coins[coin_index].wsh = NULL;
if (MHD_HTTP_OK != http_status) if (MHD_HTTP_OK != http_status)
{
fail ("At least one coin has not correctly been withdrawn\n"); fail ("At least one coin has not correctly been withdrawn\n");
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%d-th coin withdrawn\n", "%d-th coin withdrawn\n",
coin_index); coin_index);
@ -462,8 +467,8 @@ reserve_withdraw_cb (void *cls,
{ {
json_decref (merchant_details); json_decref (merchant_details);
fail ("An error occurred while calling deposit API\n"); fail ("An error occurred while calling deposit API\n");
return;
} }
json_decref (merchant_details);
transaction_id++; transaction_id++;
} }
} }
@ -549,7 +554,7 @@ benchmark_run (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"benchmark_run() invoked\n"); "benchmark_run() invoked\n");
nreserves = pool_size / COINS_PER_RESERVE; nreserves = pool_size / COINS_PER_RESERVE;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"creating %d reserves\n", "creating %d reserves\n",
nreserves); nreserves);
@ -727,19 +732,28 @@ run (void *cls)
"config file: %s\n", "config file: %s\n",
config_file); config_file);
if (NULL == config_file) if (NULL == config_file)
{
fail ("-c option is mandatory\n"); fail ("-c option is mandatory\n");
return;
}
/** /**
* Read sender_details.json here * Read sender_details.json here
*/ */
cfg = GNUNET_CONFIGURATION_create (); cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_parse (cfg, config_file)) if (GNUNET_SYSERR == GNUNET_CONFIGURATION_parse (cfg, config_file))
{
fail ("failed to parse configuration file\n"); fail ("failed to parse configuration file\n");
return;
}
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg,
"benchmark", "benchmark",
"sender_details", "sender_details",
&sender_details_filename)) &sender_details_filename))
{
fail ("failed to get SENDER_DETAILS value\n"); fail ("failed to get SENDER_DETAILS value\n");
return;
}
sender_details = json_load_file (sender_details_filename, sender_details = json_load_file (sender_details_filename,
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
@ -749,8 +763,10 @@ run (void *cls)
"benchmark", "benchmark",
"merchant_details", "merchant_details",
&merchant_details_filename)) &merchant_details_filename))
{
fail ("failed to get MERCHANT_DETAILS value\n"); fail ("failed to get MERCHANT_DETAILS value\n");
return;
}
merchant_details = json_load_file (merchant_details_filename, merchant_details = json_load_file (merchant_details_filename,
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
NULL); NULL);
@ -781,9 +797,11 @@ main (int argc,
char * const *argv) char * const *argv)
{ {
#ifdef RUNXCG
struct GNUNET_OS_Process *proc; struct GNUNET_OS_Process *proc;
struct GNUNET_OS_Process *exchanged; struct GNUNET_OS_Process *exchanged;
unsigned int cnt; unsigned int cnt;
#endif
GNUNET_log_setup ("taler-exchange-benchmark", GNUNET_log_setup ("taler-exchange-benchmark",
"WARNING", "WARNING",
@ -800,7 +818,7 @@ main (int argc,
GNUNET_assert (GNUNET_SYSERR != GNUNET_assert (GNUNET_SYSERR !=
GNUNET_GETOPT_run ("taler-exchange-benchmark", GNUNET_GETOPT_run ("taler-exchange-benchmark",
options, argc, argv)); options, argc, argv));
#ifdef RUNXCG
proc = GNUNET_OS_start_process (GNUNET_NO, proc = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL, GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL, NULL, NULL, NULL,
@ -867,10 +885,13 @@ main (int argc,
} }
while (0 != system ("wget -q -t 1 -T 1 " EXCHANGE_URI "keys -o /dev/null -O /dev/null")); while (0 != system ("wget -q -t 1 -T 1 " EXCHANGE_URI "keys -o /dev/null -O /dev/null"));
fprintf (stderr, "\n"); fprintf (stderr, "\n");
#endif
GNUNET_SCHEDULER_run (&run, NULL); GNUNET_SCHEDULER_run (&run, NULL);
#ifdef RUNXCG
GNUNET_OS_process_wait (exchanged); GNUNET_OS_process_wait (exchanged);
GNUNET_OS_process_destroy (exchanged); GNUNET_OS_process_destroy (exchanged);
#endif
return GNUNET_OK; return GNUNET_OK;
} }