diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2020-01-15 17:04:58 +0100 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2020-01-15 17:05:58 +0100 |
commit | b71297097a0e1fbf4adb210bbc5dbf6b9e618e95 (patch) | |
tree | a3a1981f97ccf0677ff80c8b75feeddb75456e5a /src/lib/test_taler_exchange_wirewatch.c | |
parent | fccde2518368b3e7109f87c3f04e3197d20c17e1 (diff) | |
download | exchange-b71297097a0e1fbf4adb210bbc5dbf6b9e618e95.tar.xz |
Wirewatch test.
Start the test using the new style. All
commands still to be ported.
Diffstat (limited to 'src/lib/test_taler_exchange_wirewatch.c')
-rw-r--r-- | src/lib/test_taler_exchange_wirewatch.c | 138 |
1 files changed, 64 insertions, 74 deletions
diff --git a/src/lib/test_taler_exchange_wirewatch.c b/src/lib/test_taler_exchange_wirewatch.c index 9c089a54d..6aea21613 100644 --- a/src/lib/test_taler_exchange_wirewatch.c +++ b/src/lib/test_taler_exchange_wirewatch.c @@ -30,9 +30,23 @@ #include "taler_json_lib.h" #include <microhttpd.h> #include "taler_fakebank_lib.h" +#include "taler_testing_lib.h" /** + * Bank configuration data. + */ +static struct TALER_TESTING_BankConfiguration bc; + +/** + * Helper structure to keep exchange configuration values. + */ +struct TALER_TESTING_ExchangeConfiguration ec; + +// just to compile +int result; + +/** * Commands for the interpreter. */ enum OpCode @@ -237,11 +251,6 @@ static struct GNUNET_DISK_PipeHandle *sigpipe; static struct GNUNET_SCHEDULER_Task *timeout_task; /** - * Return value from main(). - */ -static int result; - -/** * Name of the configuration file to use. */ static char *config_filename; @@ -256,7 +265,6 @@ static struct GNUNET_SCHEDULER_Task *int_task; */ static struct TALER_FAKEBANK_Handle *fb; - /** * Interprets the commands from the test program. * @@ -460,6 +468,7 @@ interpreter (void *cls) "Running command %u (%s)\n", state->ioff, cmd->label); +#if 0 switch (cmd->opcode) { case OPCODE_TERMINATE_SKIP: @@ -588,6 +597,29 @@ interpreter (void *cls) GNUNET_SCHEDULER_shutdown (); return; } +#endif +} + +/** + * Main function that will tell the interpreter what commands to + * run. + * + * @param cls closure + */ +static void +run (void *cls, + struct TALER_TESTING_Interpreter *is) +{ + struct TALER_TESTING_Command all[] = { + // TALER_TESTING_cmd_exec_aggregator ("expect-empty-transactions-on-start", + // config_filename), + TALER_TESTING_cmd_end () + }; + + TALER_TESTING_run_with_fakebank (is, + all, + bc.bank_url); + } @@ -597,9 +629,11 @@ interpreter (void *cls) * @param cls closure with configuration */ static void -run (void *cls) +OLDrun (void *cls) { static struct Command commands[] = { + #if 0 + /* test running with empty DB */ { .opcode = OPCODE_EXPECT_TRANSFERS_EMPTY, @@ -720,7 +754,9 @@ run (void *cls) .opcode = OPCODE_TERMINATE_SUCCESS, .label = "testcase-complete-terminating-with-success" } + #endif }; + static struct State state = { .commands = commands }; @@ -773,7 +809,13 @@ main (int argc, struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_SIGNAL_Context *shc_chld; - result = -1; + /* these might get in the way */ + unsetenv ("XDG_DATA_HOME"); + unsetenv ("XDG_CONFIG_HOME"); + GNUNET_log_setup ("test_taler_exchange_wirewatch", + "WARNING", + NULL); + if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) { GNUNET_break (0); @@ -786,12 +828,7 @@ main (int argc, (void) GNUNET_asprintf (&config_filename, "%s.conf", testname); - /* these might get in the way */ - unsetenv ("XDG_DATA_HOME"); - unsetenv ("XDG_CONFIG_HOME"); - GNUNET_log_setup ("test_taler_exchange_wirewatch", - "WARNING", - NULL); + /* check database is working */ { struct GNUNET_PQ_Context *conn; @@ -806,71 +843,24 @@ main (int argc, return 77; GNUNET_PQ_disconnect (conn); } - proc = GNUNET_OS_start_process (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-keyup", - "taler-exchange-keyup", - "-c", config_filename, - NULL); - if (NULL == proc) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); - return 77; - } - GNUNET_OS_process_wait (proc); - GNUNET_OS_process_destroy (proc); - proc = GNUNET_OS_start_process (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-dbinit", - "taler-exchange-dbinit", - "-c", config_filename, - "-r", - NULL); - if (NULL == proc) + + TALER_TESTING_cleanup_files (config_filename); + if (GNUNET_OK != TALER_TESTING_prepare_exchange (config_filename, + &ec)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); + TALER_LOG_INFO ("Could not prepare the exchange\n"); return 77; } - GNUNET_OS_process_wait (proc); - GNUNET_OS_process_destroy (proc); + if (GNUNET_OK != - GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - 8082)) - { - fprintf (stderr, - "Required port %u not available, skipping.\n", - (unsigned int) 8082); + TALER_TESTING_prepare_fakebank (config_filename, + "account-1", + &bc)) return 77; - } - cfg = GNUNET_CONFIGURATION_create (); - if (GNUNET_OK != - GNUNET_CONFIGURATION_parse (cfg, - config_filename)) - { - GNUNET_break (0); - GNUNET_free (config_filename); - GNUNET_free (testname); - return 2; - } - sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, - GNUNET_NO, GNUNET_NO); - GNUNET_assert (NULL != sigpipe); - shc_chld = - GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, - &sighandler_child_death); - GNUNET_SCHEDULER_run (&run, - cfg); - GNUNET_SIGNAL_handler_uninstall (shc_chld); - GNUNET_DISK_pipe_close (sigpipe); - GNUNET_CONFIGURATION_destroy (cfg); - GNUNET_free (config_filename); - GNUNET_free (testname); - return result; -} + return TALER_TESTING_setup_with_exchange (&run, + NULL, + config_filename); +} /* end of test_taler_exchange_wirewatch.c */ |