From feb60291b623193c312c8cc1e3f5289311134c9c Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Wed, 8 Jun 2016 17:11:33 +0200 Subject: [PATCH] getting banking details through config file in benchmark --- src/benchmark/merchant_details.json | 1 + src/benchmark/sender_details.json | 1 + src/benchmark/taler-exchange-benchmark.c | 46 +++++++++++++++------ src/benchmark/taler-exchange-benchmark.conf | 3 +- 4 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 src/benchmark/merchant_details.json create mode 100644 src/benchmark/sender_details.json 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 #include #include +#include /** * How many coins the benchmark should operate on @@ -47,6 +48,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 */ @@ -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