From cd5fafffe22608d3d9ec6c620417ecdbd6c076d3 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 15 Jul 2023 22:33:49 +0200 Subject: -get taler-exchange-benchmark to work --- src/benchmark/benchmark-common.conf | 6 ++- src/benchmark/taler-exchange-benchmark.c | 39 +++++++++++------- src/include/taler_testing_lib.h | 2 +- src/testing/taler-unified-setup.sh | 13 +++++- src/testing/test_exchange_api.conf | 1 + .../testing_api_cmd_bank_admin_add_incoming.c | 5 ++- src/testing/testing_api_cmd_batch.c | 2 +- src/testing/testing_api_cmd_reserve_history.c | 6 +-- src/testing/testing_api_cmd_reserve_status.c | 6 +-- src/testing/testing_api_cmd_stat.c | 47 ++++++++++++++++------ src/testing/testing_api_cmd_withdraw.c | 3 +- src/testing/testing_api_loop.c | 13 +++--- 12 files changed, 94 insertions(+), 49 deletions(-) diff --git a/src/benchmark/benchmark-common.conf b/src/benchmark/benchmark-common.conf index 6ff5a727a..fc93b2a90 100644 --- a/src/benchmark/benchmark-common.conf +++ b/src/benchmark/benchmark-common.conf @@ -39,18 +39,20 @@ ENABLE_DEBIT = YES ENABLE_CREDIT = YES [exchange-accountcredentials-1] +WIRE_GATEWAY_AUTH_METHOD = none WIRE_GATEWAY_URL = "http://localhost:8082/42/" # account-2 is suitable for libeufin [exchange-account-2] ENABLE_DEBIT = YES ENABLE_CREDIT = YES +PAYTO_URI = payto://iban/SANDBOXX/DE033310?receiver-name=Exchange+Company [exchange-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic -USERNAME = Exchange +USERNAME = exchange PASSWORD = x -WIRE_GATEWAY_URL = "http://localhost:8082/2/" +WIRE_GATEWAY_URL = "http://localhost:8082/facades/test-facade/taler-wire-gateway/" # Trust local exchange for "EUR" currency diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 68adffd3b..b7f9189b5 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -102,7 +102,7 @@ static int use_fakebank; * Section with the configuration data for the exchange * bank account. */ -static char *exchange_bank_section = "exchange-account-1"; +static char *exchange_bank_section; /** * Currency used. @@ -211,11 +211,18 @@ run (void *cls, (void) cls; all_commands = GNUNET_new_array ( - howmany_reserves * (1 /* Withdraw block */ - + howmany_coins) /* All units */ + 1 /* exchange CMD */ + + howmany_reserves * (1 /* Withdraw block */ + + howmany_coins) /* All units */ + 1 /* stat CMD */ + 1 /* End CMD */, struct TALER_TESTING_Command); + all_commands[0] + = TALER_TESTING_cmd_get_exchange ("get-exchange", + cred.cfg, + NULL, + true, + true); GNUNET_asprintf (&amount_5, "%s:5", currency); GNUNET_asprintf (&amount_4, "%s:4", currency); GNUNET_asprintf (&amount_1, "%s:1", currency); @@ -252,9 +259,9 @@ run (void *cls, GNUNET_asprintf (&batch_label, "batch-start-%u", j); - all_commands[reserves_first - ? j - : j * (howmany_coins + 1)] + all_commands[1 + (reserves_first + ? j + : j * (howmany_coins + 1))] = TALER_TESTING_cmd_batch (add_label (batch_label), make_reserve); } @@ -334,16 +341,16 @@ run (void *cls, "unit-%u-%u", i, j); - all_commands[reserves_first - ? howmany_reserves + j * howmany_coins + i - : j * (howmany_coins + 1) + (1 + i)] + all_commands[1 + (reserves_first + ? howmany_reserves + j * howmany_coins + i + : j * (howmany_coins + 1) + (1 + i))] = TALER_TESTING_cmd_batch (add_label (unit_label), unit); } } - all_commands[howmany_reserves * (1 + howmany_coins)] + all_commands[1 + howmany_reserves * (1 + howmany_coins)] = TALER_TESTING_cmd_stat (timings); - all_commands[howmany_reserves * (1 + howmany_coins) + 1] + all_commands[1 + howmany_reserves * (1 + howmany_coins) + 1] = TALER_TESTING_cmd_end (); TALER_TESTING_run2 (is, all_commands, @@ -417,7 +424,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb, { /* I am the child, do the work! */ GNUNET_log_setup ("benchmark-worker", - NULL == loglev ? "INFO" : loglev, + loglev, logfile); result = TALER_TESTING_loop (main_cb, main_cb_cls); @@ -556,10 +563,12 @@ main (int argc, return 0; return EXIT_INVALIDARGUMENT; } + if (NULL == exchange_bank_section) + exchange_bank_section = "exchange-account-1"; + if (NULL == loglev) + loglev = "INFO"; GNUNET_log_setup ("taler-exchange-benchmark", - NULL == loglev - ? "INFO" - : loglev, + loglev, logfile); if (NULL == cfg_filename) cfg_filename = GNUNET_CONFIGURATION_default_filename (); diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 4a1c2c8ff..90984b9f1 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -2668,7 +2668,7 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, op (order_id, const char) \ op (amount, const struct TALER_Amount) \ op (amount_with_fee, const struct TALER_Amount) \ - op (batch_cmds, struct TALER_TESTING_Command *) \ + op (batch_cmds, struct TALER_TESTING_Command) \ op (uuid, const struct GNUNET_Uuid) \ op (fresh_coins, const struct TALER_TESTING_FreshCoinData *) \ op (claim_token, const struct TALER_ClaimTokenP) \ diff --git a/src/testing/taler-unified-setup.sh b/src/testing/taler-unified-setup.sh index bd05c9bc1..7a19091a3 100755 --- a/src/testing/taler-unified-setup.sh +++ b/src/testing/taler-unified-setup.sh @@ -102,6 +102,7 @@ while getopts ':abc:d:efghL:mnr:stu:vwW' OPTION; do echo ' -d $METHOD -- use wire method (default: x-taler-bank)' echo ' -e -- start exchange' echo ' -f -- start fakebank' + echo ' -g -- start aggregator' echo ' -h -- print this help' echo ' -L $LOGLEVEL -- set log level' echo ' -m -- start merchant' @@ -249,7 +250,11 @@ then # Create the default demobank. echo -n "Configuring sandbox " - libeufin-sandbox config --currency "$CURRENCY" default &> libeufin-sandbox-config.log + libeufin-sandbox config \ + --currency "$CURRENCY" \ + --users-debt-limit 99999999 \ + --bank-debt-limit 99999999 \ + default &> libeufin-sandbox-config.log echo "DONE" echo -n "Launching sandbox ... " export LIBEUFIN_SANDBOX_ADMIN_PASSWORD="secret" @@ -456,7 +461,11 @@ 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 \ + --account="$USE_ACCOUNT" \ + -c "$CONF" \ + --longpoll-timeout="1 s" \ + 2> taler-exchange-wirewatch.log & WIREWATCH_PID=$! echo " DONE" fi diff --git a/src/testing/test_exchange_api.conf b/src/testing/test_exchange_api.conf index 6a285f55d..4b0ac2cb6 100644 --- a/src/testing/test_exchange_api.conf +++ b/src/testing/test_exchange_api.conf @@ -51,6 +51,7 @@ ENABLE_DEBIT = YES ENABLE_CREDIT = YES [exchange-accountcredentials-1] +WIRE_GATEWAY_AUTH_METHOD = none WIRE_GATEWAY_URL = "http://localhost:8082/42/" [exchange-account-2] diff --git a/src/testing/testing_api_cmd_bank_admin_add_incoming.c b/src/testing/testing_api_cmd_bank_admin_add_incoming.c index fcf6079a1..5c031d0b3 100644 --- a/src/testing/testing_api_cmd_bank_admin_add_incoming.c +++ b/src/testing/testing_api_cmd_bank_admin_add_incoming.c @@ -225,8 +225,9 @@ confirmation_cb (void *cls, } if (air->http_status != fts->expected_http_status) { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); + TALER_TESTING_unexpected_status (is, + air->http_status, + fts->expected_http_status); return; } switch (air->http_status) diff --git a/src/testing/testing_api_cmd_batch.c b/src/testing/testing_api_cmd_batch.c index bd6454a56..5bb7b974e 100644 --- a/src/testing/testing_api_cmd_batch.c +++ b/src/testing/testing_api_cmd_batch.c @@ -128,7 +128,7 @@ batch_traits (void *cls, { struct BatchState *bs = cls; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_batch_cmds (&bs->batch), + TALER_TESTING_make_trait_batch_cmds (bs->batch), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_reserve_history.c b/src/testing/testing_api_cmd_reserve_history.c index a7df69e6e..ff0a8a554 100644 --- a/src/testing/testing_api_cmd_reserve_history.c +++ b/src/testing/testing_api_cmd_reserve_history.c @@ -131,7 +131,7 @@ analyze_command (void *cls, if (TALER_TESTING_cmd_is_batch (cmd)) { struct TALER_TESTING_Command *cur; - struct TALER_TESTING_Command **bcmd; + struct TALER_TESTING_Command *bcmd; cur = TALER_TESTING_cmd_batch_get_current (cmd); if (GNUNET_OK != @@ -142,9 +142,9 @@ analyze_command (void *cls, 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]; analyze_command (ac, step); diff --git a/src/testing/testing_api_cmd_reserve_status.c b/src/testing/testing_api_cmd_reserve_status.c index 001582ed8..2438b2c21 100644 --- a/src/testing/testing_api_cmd_reserve_status.c +++ b/src/testing/testing_api_cmd_reserve_status.c @@ -122,7 +122,7 @@ analyze_command (void *cls, if (TALER_TESTING_cmd_is_batch (cmd)) { struct TALER_TESTING_Command *cur; - struct TALER_TESTING_Command **bcmd; + struct TALER_TESTING_Command *bcmd; cur = TALER_TESTING_cmd_batch_get_current (cmd); if (GNUNET_OK != @@ -133,9 +133,9 @@ analyze_command (void *cls, 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 (step == cur) break; /* if *we* are in a batch, make sure not to analyze commands past 'now' */ diff --git a/src/testing/testing_api_cmd_stat.c b/src/testing/testing_api_cmd_stat.c index f85072a17..8723aac0d 100644 --- a/src/testing/testing_api_cmd_stat.c +++ b/src/testing/testing_api_cmd_stat.c @@ -27,6 +27,19 @@ #include "taler_testing_lib.h" +/** + * Run a "stat" CMD. + * + * @param cls closure. + * @param cmd the command being run. + * @param is the interpreter state. + */ +static void +stat_run (void *cls, + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is); + + /** * Add the time @a cmd took to the respective duration in @a timings. * @@ -40,9 +53,20 @@ stat_cmd (struct TALER_TESTING_Timer *timings, struct GNUNET_TIME_Relative duration; struct GNUNET_TIME_Relative lat; - if (cmd->start_time.abs_value_us > cmd->finish_time.abs_value_us) + if (GNUNET_TIME_absolute_cmp (cmd->start_time, + >, + cmd->finish_time)) { - GNUNET_break (0); + /* This is a problem, except of course for + this command itself, as we clearly did not yet + finish... */ + if (cmd->run != &stat_run) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Bad timings for `%s'\n", + cmd->label); + GNUNET_break (0); + } return; } duration = GNUNET_TIME_absolute_get_difference (cmd->start_time, @@ -85,7 +109,7 @@ do_stat (void *cls, if (TALER_TESTING_cmd_is_batch (cmd)) { - struct TALER_TESTING_Command **bcmd; + struct TALER_TESTING_Command *bcmd; if (GNUNET_OK != TALER_TESTING_get_trait_batch_cmds (cmd, @@ -94,18 +118,15 @@ do_stat (void *cls, GNUNET_break (0); return; } - for (unsigned int j = 0; - NULL != (*bcmd)[j].label; + NULL != bcmd[j].label; j++) do_stat (timings, - &(*bcmd)[j]); - } - else - { - stat_cmd (timings, - cmd); + &bcmd[j]); + return; } + stat_cmd (timings, + cmd); } @@ -136,7 +157,7 @@ TALER_TESTING_cmd_stat (struct TALER_TESTING_Timer *timers) { struct TALER_TESTING_Command cmd = { .label = "stat", - .run = stat_run, + .run = &stat_run, .cls = (void *) timers }; @@ -144,4 +165,4 @@ TALER_TESTING_cmd_stat (struct TALER_TESTING_Timer *timers) } -/* end of testing_api_cmd_sleep.c */ +/* end of testing_api_cmd_stat.c */ diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c index 2550e55a4..cf0b49983 100644 --- a/src/testing/testing_api_cmd_withdraw.c +++ b/src/testing/testing_api_cmd_withdraw.c @@ -349,7 +349,8 @@ withdraw_run (void *cls, const struct TALER_TESTING_Command *create_reserve; const struct TALER_EXCHANGE_DenomPublicKey *dpk; - ws->cmd = cmd; + if (NULL != cmd) + ws->cmd = cmd; ws->is = is; create_reserve = TALER_TESTING_interpreter_lookup_command ( diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 411e47c45..2a8e3d0b7 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c @@ -107,7 +107,7 @@ TALER_TESTING_interpreter_lookup_command (struct TALER_TESTING_Interpreter *is, if (TALER_TESTING_cmd_is_batch (cmd)) { - struct TALER_TESTING_Command **batch; + struct TALER_TESTING_Command *batch; struct TALER_TESTING_Command *current; struct TALER_TESTING_Command *icmd; const struct TALER_TESTING_Command *match; @@ -119,7 +119,7 @@ TALER_TESTING_interpreter_lookup_command (struct TALER_TESTING_Interpreter *is, /* We must do the loop forward, but we can find the last match */ match = NULL; for (unsigned int j = 0; - NULL != (icmd = &(*batch)[j])->label; + NULL != (icmd = &batch[j])->label; j++) { if (current == icmd) @@ -205,8 +205,9 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is) if (TALER_TESTING_cmd_batch_next (is, cmd->cls)) { + /* batch is done */ cmd->finish_time = GNUNET_TIME_absolute_get (); - is->ip++; /* batch is done */ + is->ip++; } } else @@ -221,7 +222,7 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is) "Interpreter executed 1000 instructions in %s\n", GNUNET_STRINGS_relative_time_to_string ( GNUNET_TIME_absolute_get_duration (last_report), - GNUNET_YES)); + true)); last_report = GNUNET_TIME_absolute_get (); } ipc++; @@ -733,7 +734,7 @@ seek_batch (struct TALER_TESTING_Interpreter *is, const struct TALER_TESTING_Command *target) { unsigned int new_ip; - struct TALER_TESTING_Command **batch; + struct TALER_TESTING_Command *batch; struct TALER_TESTING_Command *current; struct TALER_TESTING_Command *icmd; struct TALER_TESTING_Command *match; @@ -744,7 +745,7 @@ seek_batch (struct TALER_TESTING_Interpreter *is, &batch)); match = NULL; for (new_ip = 0; - NULL != (icmd = &(*batch)[new_ip]); + NULL != (icmd = &batch[new_ip]); new_ip++) { if (current == target) -- cgit v1.2.3