Excluding old logic from compilation.

This commit is contained in:
Marcello Stanisci 2020-01-16 12:54:05 +01:00
parent f13b8e4db6
commit a444bf31b7
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
3 changed files with 103 additions and 72 deletions

View File

@ -258,6 +258,7 @@ test_taler_exchange_aggregator_postgres_LDADD = \
$(top_builddir)/src/bank-lib/libtalerfakebank.la \ $(top_builddir)/src/bank-lib/libtalerfakebank.la \
$(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \ $(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/lib/libtalertesting.la \
-lmicrohttpd \ -lmicrohttpd \
-lgnunetutil \ -lgnunetutil \
-lgnunetjson \ -lgnunetjson \

View File

@ -26,8 +26,19 @@
#include "taler_exchangedb_plugin.h" #include "taler_exchangedb_plugin.h"
#include <microhttpd.h> #include <microhttpd.h>
#include "taler_fakebank_lib.h" #include "taler_fakebank_lib.h"
#include "taler_testing_lib.h"
/**
* Helper structure to keep exchange configuration values.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/** /**
* Commands for the interpreter. * Commands for the interpreter.
*/ */
@ -252,16 +263,6 @@ static struct GNUNET_CRYPTO_RsaPublicKey *coin_pub;
*/ */
static struct TALER_FAKEBANK_Handle *fb; static struct TALER_FAKEBANK_Handle *fb;
/**
* Interprets the commands from the test program.
*
* @param cls the `struct State` of the interpreter
*/
static void
interpreter (void *cls);
/** /**
* Task triggered whenever we are to shutdown. * Task triggered whenever we are to shutdown.
* *
@ -319,6 +320,7 @@ shutdown_action (void *cls)
plugin = NULL; plugin = NULL;
} }
#if 0
/** /**
* Task triggered whenever we receive a SIGCHLD (child * Task triggered whenever we receive a SIGCHLD (child
@ -349,7 +351,7 @@ maint_child_death (void *cls)
interpreter (state); interpreter (state);
} }
#endif
/** /**
* Setup (fake) information about a coin used in deposit. * Setup (fake) information about a coin used in deposit.
@ -511,6 +513,7 @@ fail (struct Command *cmd)
* *
* @param cls the `struct State` of the interpreter * @param cls the `struct State` of the interpreter
*/ */
#if 0
static void static void
interpreter (void *cls) interpreter (void *cls)
{ {
@ -613,12 +616,13 @@ interpreter (void *cls)
} }
} }
} }
#endif
/** /**
* Contains the test program. Here each step of the testcase * Contains the test program. Here each step of the testcase
* is defined. * is defined.
*/ */
#if 0
static void static void
run_test () run_test ()
{ {
@ -1155,15 +1159,59 @@ run_test ()
int_task = GNUNET_SCHEDULER_add_now (&interpreter, int_task = GNUNET_SCHEDULER_add_now (&interpreter,
&state); &state);
} }
#endif
/**
* @return GNUNET_NO if database could not be prepared,
* otherwise GNUNET_OK
*/
static int
prepare_database (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
// connect to the database.
plugin = TALER_EXCHANGEDB_plugin_load (cfg);
if (NULL == plugin)
{
GNUNET_break (0);
result = 77;
return GNUNET_NO;
}
if (GNUNET_OK !=
plugin->create_tables (plugin->cls))
{
GNUNET_break (0);
TALER_EXCHANGEDB_plugin_unload (plugin);
plugin = NULL;
result = 77;
return GNUNET_NO;
}
session = plugin->get_session (plugin->cls);
GNUNET_assert (NULL != session);
return GNUNET_OK;
}
static void
run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
if (GNUNET_OK != prepare_database (is->cfg))
return;
}
/** /**
* Main function that will be run by the scheduler. * Main function that will be run by the scheduler.
* *
* @param cls closure with configuration * @param cls closure with configuration
*/ */
#if 0
static void static void
run (void *cls) OLDrun (void *cls)
{ {
struct GNUNET_CONFIGURATION_Handle *cfg = cls; struct GNUNET_CONFIGURATION_Handle *cfg = cls;
struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; struct TALER_EXCHANGEDB_DenominationKeyInformationP issue;
@ -1231,7 +1279,7 @@ run (void *cls)
} }
run_test (); run_test ();
} }
#endif
/** /**
* Signal handler called for SIGCHLD. Triggers the * Signal handler called for SIGCHLD. Triggers the
@ -1250,7 +1298,6 @@ sighandler_child_death ()
errno = old_errno; /* restore errno */ errno = old_errno; /* restore errno */
} }
int int
main (int argc, main (int argc,
char *const argv[]) char *const argv[])
@ -1261,7 +1308,11 @@ main (int argc,
struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_SIGNAL_Context *shc_chld; struct GNUNET_SIGNAL_Context *shc_chld;
result = -1;
/* these might get in the way */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
{ {
GNUNET_break (0); GNUNET_break (0);
@ -1274,65 +1325,44 @@ main (int argc,
(void) GNUNET_asprintf (&config_filename, (void) GNUNET_asprintf (&config_filename,
"%s.conf", "%s.conf",
testname); testname);
/* these might get in the way */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test_taler_exchange_aggregator", GNUNET_log_setup ("test_taler_exchange_aggregator",
"WARNING", "DEBUG",
NULL); NULL);
proc = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-exchange-keyup", TALER_TESTING_cleanup_files (config_filename);
"taler-exchange-keyup", if (GNUNET_OK != TALER_TESTING_prepare_exchange (config_filename,
"-c", config_filename, &ec))
NULL);
if (NULL == proc)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_LOG_WARNING ("Could not prepare the exchange (keyup, ..)\n");
"Failed to run `taler-exchange-keyup`, is your PATH correct?\n");
return 77; return 77;
} }
GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc); if (GNUNET_OK != TALER_TESTING_prepare_fakebank (config_filename,
if (GNUNET_OK != "account-1",
GNUNET_NETWORK_test_port_free (IPPROTO_TCP, &bc))
8082))
{ {
fprintf (stderr, TALER_LOG_WARNING ("Could not prepare the fakebank\n");
"Required port %u not available, skipping.\n",
(unsigned int) 8082);
return 77; 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);
coin_pk = GNUNET_CRYPTO_rsa_private_key_create (1024); coin_pk = GNUNET_CRYPTO_rsa_private_key_create (1024);
coin_pub = GNUNET_CRYPTO_rsa_private_key_get_public (coin_pk); coin_pub = GNUNET_CRYPTO_rsa_private_key_get_public (coin_pk);
GNUNET_SCHEDULER_run (&run,
cfg);
result = TALER_TESTING_setup (&run,
NULL,
config_filename,
NULL, // no exchange process handle.
GNUNET_NO); // do not try to connect to the exchange
GNUNET_CRYPTO_rsa_private_key_free (coin_pk); GNUNET_CRYPTO_rsa_private_key_free (coin_pk);
GNUNET_CRYPTO_rsa_public_key_free (coin_pub); GNUNET_CRYPTO_rsa_public_key_free (coin_pub);
GNUNET_SIGNAL_handler_uninstall (shc_chld);
shc_chld = NULL;
GNUNET_DISK_pipe_close (sigpipe);
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free (config_filename); GNUNET_free (config_filename);
GNUNET_free (testname); GNUNET_free (testname);
return result; return GNUNET_OK == result ? 0 : 1;
} }

View File

@ -81,7 +81,7 @@ insert_deposit_run (void *cls,
const struct TALER_TESTING_Command *cmd, const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct InsertDepositState *ks = cls; struct InsertDepositState *ids = cls;
// TODO // TODO
} }
@ -118,7 +118,7 @@ insert_deposit_traits (void *cls,
const char *trait, const char *trait,
unsigned int index) unsigned int index)
{ {
struct AuditorDbinitState *ks = cls; struct InsertDepositState *ids = cls;
struct TALER_TESTING_Trait traits[] = { struct TALER_TESTING_Trait traits[] = {
// FIXME: needed? // FIXME: needed?
TALER_TESTING_trait_end () TALER_TESTING_trait_end ()
@ -154,17 +154,17 @@ TALER_TESTING_cmd_insert_deposit (const char *label,
const char *deposit_fee) const char *deposit_fee)
{ {
struct TALER_TESTING_Command cmd; struct TALER_TESTING_Command cmd;
struct InsertDepositState *ds; struct InsertDepositState *ids;
ds = GNUNET_new (struct InsertDepositState); ids = GNUNET_new (struct InsertDepositState);
ds->config_filename = config_filename; ids->config_filename = config_filename;
ds->merchant_name = merchant_name; ids->merchant_name = merchant_name;
ds->merchant_account = merchant_account; ids->merchant_account = merchant_account;
ds->wire_deadline = wire_deadline; ids->wire_deadline = wire_deadline;
ds->amount_with_fee = amount_with_fee; ids->amount_with_fee = amount_with_fee;
ds->deposit_fee = deposit_fee; ids->deposit_fee = deposit_fee;
cmd.cls = ds; cmd.cls = ids;
cmd.label = label; cmd.label = label;
cmd.run = &insert_deposit_run; cmd.run = &insert_deposit_run;
cmd.cleanup = &insert_deposit_cleanup; cmd.cleanup = &insert_deposit_cleanup;