diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-06-08 17:11:33 +0200 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-06-08 17:11:33 +0200 |
commit | feb60291b623193c312c8cc1e3f5289311134c9c (patch) | |
tree | ca9cb9304fd5306e3e89283a135653c830b1ef40 /src | |
parent | 46c593f93ea0bb68c41c55b2ab3f8a9580e77c2e (diff) |
getting banking details through config file in benchmark
Diffstat (limited to 'src')
-rw-r--r-- | src/benchmark/merchant_details.json | 1 | ||||
-rw-r--r-- | src/benchmark/sender_details.json | 1 | ||||
-rw-r--r-- | src/benchmark/taler-exchange-benchmark.c | 48 | ||||
-rw-r--r-- | src/benchmark/taler-exchange-benchmark.conf | 3 |
4 files changed, 39 insertions, 14 deletions
diff --git a/src/benchmark/merchant_details.json b/src/benchmark/merchant_details.json new file mode 100644 index 000000000..d6f60005b --- /dev/null +++ b/src/benchmark/merchant_details.json @@ -0,0 +1 @@ +{"type":"test", "bank_uri":"https://bank.test.taler.net/", "account_number":63} diff --git a/src/benchmark/sender_details.json b/src/benchmark/sender_details.json new file mode 100644 index 000000000..d6f60005b --- /dev/null +++ b/src/benchmark/sender_details.json @@ -0,0 +1 @@ +{"type":"test", "bank_uri":"https://bank.test.taler.net/", "account_number":63} diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index bb4697243..dc670456b 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -26,6 +26,7 @@ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_curl_lib.h> #include <microhttpd.h> +#include <jansson.h> /** * How many coins the benchmark should operate on @@ -48,6 +49,16 @@ struct GNUNET_CONFIGURATION_Handle *cfg; static unsigned int nreserves; /** + * Bank details of who creates reserves + */ +json_t *sender_details; + +/** + * Bank details of who deposits coins + */ +json_t *merchant_details; + +/** * Needed information for a reserve. Other values are the same for all reserves, therefore defined in global variables */ struct Reserve { @@ -387,7 +398,6 @@ reserve_withdraw_cb (void *cls, struct GNUNET_TIME_Absolute timestamp; struct GNUNET_TIME_Absolute refund_deadline; struct GNUNET_HashCode h_contract; - json_t *merchant_details; struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_DepositRequestPS dr; struct TALER_MerchantPublicKeyP merchant_pub; @@ -408,10 +418,6 @@ reserve_withdraw_cb (void *cls, TALER_amount_subtract (&amount, &coins[coin_index].pk->value, &coins[coin_index].pk->fee_deposit); - merchant_details = json_loads ("{ \"type\":\"test\", \"bank_uri\":\"https://bank.test.taler.net/\", \"account_number\":63}", - JSON_REJECT_DUPLICATES, - NULL); - memset (&dr, 0, sizeof (dr)); dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS)); dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT); @@ -523,7 +529,6 @@ benchmark_run (void *cls) unsigned int i; struct GNUNET_CRYPTO_EddsaPrivateKey *priv; json_t *transfer_details; - json_t *sender_details; char *uuid; struct TALER_ReservePublicKeyP reserve_pub; struct GNUNET_TIME_Absolute execution_date; @@ -538,9 +543,6 @@ benchmark_run (void *cls) sizeof (blinding_key)); TALER_amount_get_zero (currency, &reserve_amount); reserve_amount.value = RESERVE_VALUE; - sender_details = json_loads ("{ \"type\":\"test\", \"bank_uri\":\"https://bank.test.taler.net/\", \"account_number\":62}", - JSON_REJECT_DUPLICATES, - NULL); execution_date = GNUNET_TIME_absolute_get (); GNUNET_TIME_round_abs (&execution_date); @@ -708,7 +710,8 @@ do_shutdown (void *cls) static void run (void *cls) { - + char *sender_details_filename; + char *merchant_details_filename; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "running run()\n"); @@ -722,17 +725,36 @@ run (void *cls) fail ("-c option is mandatory\n"); /** - * Read BANK_URI in here + * Read sender_details.json here */ cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_SYSERR == GNUNET_CONFIGURATION_parse (cfg, config_file)) fail ("failed to parse configuration file\n"); - + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, + "benchmark", + "sender_details", + &sender_details_filename)) + fail ("failed to get SENDER_DETAILS value\n"); + + sender_details = json_load_file (sender_details_filename, + JSON_REJECT_DUPLICATES, + NULL); + + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, + "benchmark", + "merchant_details", + &merchant_details_filename)) + fail ("failed to get MERCHANT_DETAILS value\n"); + + merchant_details = json_load_file (merchant_details_filename, + JSON_REJECT_DUPLICATES, + NULL); + + GNUNET_CONFIGURATION_destroy (cfg); GNUNET_array_append (spent_coins, spent_coins_size, 1); spent_coins_size++; - reserves = NULL; coins = NULL; ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule, diff --git a/src/benchmark/taler-exchange-benchmark.conf b/src/benchmark/taler-exchange-benchmark.conf index 1f3538c7a..3dc2128fb 100644 --- a/src/benchmark/taler-exchange-benchmark.conf +++ b/src/benchmark/taler-exchange-benchmark.conf @@ -1,2 +1,3 @@ [benchmark] -BANK_URI = https://bank.test.taler.net/ +SENDER_DETAILS = ~/exchange/src/benchmark/sender_details.json +MERCHANT_DETAILS = ~/exchange/src/benchmark/merchant_details.json |