add test mode option to mint

This commit is contained in:
Christian Grothoff 2015-06-18 14:25:09 +02:00
parent 3a4429aa00
commit 5e87b47c48
6 changed files with 51 additions and 7 deletions

View File

@ -14,7 +14,8 @@ MASTER_PUBLIC_KEY = NEGTF62MNGVPZNW19V7S3CRS9D7K04MAHDGX3N6WY2NXREN26J80
# How to access our database # How to access our database
DB = postgres DB = postgres
TESTRUN = YES
[mintdb-postgres] [mintdb-postgres]
DB_CONN_STR = "postgres:///taler" DB_CONN_STR = "postgres:///talercheck"

View File

@ -0,0 +1 @@
p<EFBFBD>^<5E>-<2D>33<33><33>XX<>!<04>\0q<30><71><EFBFBD><EFBFBD><18>mU<6D>_<EFBFBD><5F>

View File

@ -204,11 +204,22 @@ int
main (int argc, main (int argc,
char * const *argv) char * const *argv)
{ {
struct GNUNET_OS_Process *proc;
struct GNUNET_OS_Process *mintd; struct GNUNET_OS_Process *mintd;
GNUNET_log_setup ("test-mint-api", GNUNET_log_setup ("test-mint-api",
"WARNING", "WARNING",
NULL); NULL);
proc = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-mint-keyup",
"taler-mint-keyup",
"-d", "test-mint-home",
"-m", "test-mint-home/master.priv",
NULL);
GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc);
mintd = GNUNET_OS_start_process (GNUNET_NO, mintd = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL, GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL, NULL, NULL, NULL,

View File

@ -68,6 +68,11 @@ char *TMH_expected_wire_format;
*/ */
struct TALER_MINTDB_Plugin *TMH_plugin; struct TALER_MINTDB_Plugin *TMH_plugin;
/**
* Are we running in test mode?
*/
int TMH_test_mode;
/** /**
* The HTTP Daemon. * The HTTP Daemon.
*/ */
@ -368,6 +373,17 @@ mint_serve_process_config (const char *mint_directory)
"Failed to initialize DB subsystem\n"); "Failed to initialize DB subsystem\n");
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (GNUNET_YES ==
GNUNET_CONFIGURATION_get_value_yesno (cfg,
"mint",
"TESTRUN"))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Running in TEST mode! Database contents will not persist!\n");
TMH_test_mode = GNUNET_YES;
TMH_plugin->create_tables (TMH_plugin->cls,
GNUNET_YES);
}
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg, GNUNET_CONFIGURATION_get_value_number (cfg,
@ -452,6 +468,16 @@ main (int argc, char *const *argv)
ret = TMH_KS_loop (); ret = TMH_KS_loop ();
MHD_stop_daemon (mydaemon); MHD_stop_daemon (mydaemon);
if (GNUNET_YES == TMH_test_mode)
{
struct TALER_MINTDB_Session *session;
session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_YES);
TMH_plugin->drop_temporary (TMH_plugin->cls,
session);
}
TALER_MINTDB_plugin_unload (TMH_plugin); TALER_MINTDB_plugin_unload (TMH_plugin);
return (GNUNET_OK == ret) ? 0 : 1; return (GNUNET_OK == ret) ? 0 : 1;
} }

View File

@ -37,6 +37,11 @@ extern char *TMH_mint_currency_string;
*/ */
extern struct GNUNET_CONFIGURATION_Handle *cfg; extern struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* Are we running in test mode?
*/
extern int TMH_test_mode;
/** /**
* Main directory with mint data. * Main directory with mint data.
*/ */

View File

@ -107,7 +107,7 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
int ret; int ret;
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) TMH_test_mode)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
@ -222,7 +222,7 @@ TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
int res; int res;
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) TMH_test_mode)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
@ -288,7 +288,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
&h_blind); &h_blind);
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) TMH_test_mode)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
@ -615,7 +615,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
if (NULL == if (NULL ==
(session = TMH_plugin->get_session (TMH_plugin->cls, (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) TMH_test_mode)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
@ -1071,7 +1071,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
unsigned int off; unsigned int off;
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) TMH_test_mode)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
@ -1335,7 +1335,7 @@ TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
unsigned int i; unsigned int i;
if (NULL == (ctx.session = TMH_plugin->get_session (TMH_plugin->cls, if (NULL == (ctx.session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) TMH_test_mode)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);