fix testcase init with new API

This commit is contained in:
Christian Grothoff 2016-04-01 20:27:57 +02:00
parent 4154e41a41
commit 1c568f8eb6
3 changed files with 50 additions and 63 deletions

View File

@ -486,7 +486,7 @@ PERF_TALER_EXCHANGEDB_refresh_session_free (struct TALER_EXCHANGEDB_RefreshSessi
*/ */
struct TALER_EXCHANGEDB_RefreshMelt * struct TALER_EXCHANGEDB_RefreshMelt *
PERF_TALER_EXCHANGEDB_refresh_melt_init (struct GNUNET_HashCode *session, PERF_TALER_EXCHANGEDB_refresh_melt_init (struct GNUNET_HashCode *session,
struct PERF_TALER_EXCHANGEDB_Coin *coin) struct PERF_TALER_EXCHANGEDB_Coin *coin)
{ {
struct TALER_EXCHANGEDB_RefreshMelt *melt; struct TALER_EXCHANGEDB_RefreshMelt *melt;
struct TALER_CoinSpendSignatureP coin_sig; struct TALER_CoinSpendSignatureP coin_sig;

View File

@ -759,7 +759,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
@ -785,7 +785,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
@ -804,7 +804,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
@ -828,7 +828,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
@ -853,7 +853,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
@ -873,7 +873,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
@ -898,14 +898,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
cmd[i].details.get_refresh_order.label_hash); cmd[i].details.get_refresh_order.label_hash);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
cmd[i].details.get_refresh_order.index_hash = ret; cmd[i].details.get_refresh_order.index_hash = ret;
} }
break; break;
@ -923,15 +923,15 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
cmd[i].details.insert_refresh_commit_coin.label_hash); cmd[i].details.insert_refresh_commit_coin.label_hash);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
cmd[i].details.insert_refresh_commit_coin.index_hash = ret; cmd[i].details.insert_refresh_commit_coin.index_hash = ret;
} }
break; break;
case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_COMMIT_COIN: case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_COMMIT_COIN:
@ -948,14 +948,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
cmd[i].details.get_refresh_commit_coin.label_hash); cmd[i].details.get_refresh_commit_coin.label_hash);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
cmd[i].details.get_refresh_commit_coin.index_hash = ret; cmd[i].details.get_refresh_commit_coin.index_hash = ret;
} }
break; break;
@ -973,14 +973,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
cmd[i].details.insert_refresh_commit_link.label_hash); cmd[i].details.insert_refresh_commit_link.label_hash);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
cmd[i].details.insert_refresh_commit_link.index_hash = ret; cmd[i].details.insert_refresh_commit_link.index_hash = ret;
} }
break; break;
@ -998,14 +998,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
cmd[i].details.get_refresh_commit_link.label_hash); cmd[i].details.get_refresh_commit_link.label_hash);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
cmd[i].details.get_refresh_commit_link.index_hash = ret; cmd[i].details.get_refresh_commit_link.index_hash = ret;
} }
break; break;
@ -1023,14 +1023,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
cmd[i].details.get_melt_commitment.label_hash); cmd[i].details.get_melt_commitment.label_hash);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
cmd[i].details.get_melt_commitment.index_hash = ret; cmd[i].details.get_melt_commitment.index_hash = ret;
} }
break; break;
@ -1048,14 +1048,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
cmd[i].details.insert_refresh_out.label_hash); cmd[i].details.insert_refresh_out.label_hash);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
cmd[i].details.insert_refresh_out.index_hash = ret; cmd[i].details.insert_refresh_out.index_hash = ret;
} }
break; break;
@ -1073,14 +1073,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
cmd[i].details.get_link_data_list.label_hash); cmd[i].details.get_link_data_list.label_hash);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
cmd[i].details.get_link_data_list.index_hash = ret; cmd[i].details.get_link_data_list.index_hash = ret;
} }
break; break;
@ -1098,14 +1098,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%d:Wrong type reference to %s\n", "%d:Wrong type reference to %s\n",
i, i,
cmd[i].details.get_transfer.label_hash); cmd[i].details.get_transfer.label_hash);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
cmd[i].details.get_transfer.index_hash = ret; cmd[i].details.get_transfer.index_hash = ret;
} }
break; break;
@ -1538,7 +1538,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
int ret; int ret;
struct PERF_TALER_EXCHANGEDB_Data *data; struct PERF_TALER_EXCHANGEDB_Data *data;
denom_index = state->cmd[state->i].details.get_denomination.index_denom; denom_index = state->cmd[state->i].details.get_denomination.index_denom;
data = &state->cmd[denom_index].exposed; data = &state->cmd[denom_index].exposed;
ret = state->plugin->get_denomination_info (state->plugin->cls, ret = state->plugin->get_denomination_info (state->plugin->cls,
state->session, state->session,
@ -1735,7 +1735,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
1, 1,
1, 1,
refresh_commit); refresh_commit);
GNUNET_assert (GNUNET_OK == ret); GNUNET_assert (GNUNET_OK == ret);
} }
break; break;
@ -1743,7 +1743,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
{ {
unsigned int hash_index; unsigned int hash_index;
struct TALER_EXCHANGEDB_RefreshCommitCoin refresh_commit; struct TALER_EXCHANGEDB_RefreshCommitCoin refresh_commit;
hash_index = state->cmd[state->i].details.insert_refresh_commit_coin.index_hash; hash_index = state->cmd[state->i].details.insert_refresh_commit_coin.index_hash;
state->plugin->get_refresh_commit_coins (state->plugin->cls, state->plugin->get_refresh_commit_coins (state->plugin->cls,
state->session, state->session,
@ -1837,9 +1837,9 @@ PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin,
*/ */
int int
PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
const char *configuration_file, const char *configuration_file,
struct PERF_TALER_EXCHANGEDB_Cmd *init, struct PERF_TALER_EXCHANGEDB_Cmd *init,
struct PERF_TALER_EXCHANGEDB_Cmd *benchmark) struct PERF_TALER_EXCHANGEDB_Cmd *benchmark)
{ {
struct TALER_EXCHANGEDB_Plugin *plugin; struct TALER_EXCHANGEDB_Plugin *plugin;
struct GNUNET_CONFIGURATION_Handle *config; struct GNUNET_CONFIGURATION_Handle *config;
@ -1927,9 +1927,8 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
"INFO", "INFO",
NULL); NULL);
config = GNUNET_CONFIGURATION_create (); config = GNUNET_CONFIGURATION_create ();
ret = GNUNET_CONFIGURATION_parse (config,
ret = GNUNET_CONFIGURATION_load (config, configuration_file);
configuration_file);
if (GNUNET_OK != ret) if (GNUNET_OK != ret)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,

View File

@ -549,17 +549,14 @@ cb_wtid_check (void *cls,
/** /**
* Main function that will be run by the scheduler. * Main function that will be run by the scheduler.
* *
* @param cls closure * @param cls closure with config
* @param args remaining command-line arguments * @param tc unused
* @param cfgfile name of the configuration file used (for saving, can be NULL!)
* @param cfg configuration
*/ */
static void static void
run (void *cls, run (void *cls,
char *const *args, const struct GNUNET_SCHEDULER_TaskContext *tc)
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{ {
struct GNUNET_CONFIGURATION_Handle *cfg = cls;
struct TALER_EXCHANGEDB_Session *session; struct TALER_EXCHANGEDB_Session *session;
struct TALER_ReservePublicKeyP reserve_pub; struct TALER_ReservePublicKeyP reserve_pub;
struct DenomKeyPair *dkp; struct DenomKeyPair *dkp;
@ -572,7 +569,6 @@ run (void *cls,
struct TALER_EXCHANGEDB_Deposit deposit; struct TALER_EXCHANGEDB_Deposit deposit;
struct TALER_EXCHANGEDB_Deposit deposit2; struct TALER_EXCHANGEDB_Deposit deposit2;
struct TALER_WireTransferIdentifierRawP wtid; struct TALER_WireTransferIdentifierRawP wtid;
struct GNUNET_HashCode hc;
json_t *wire; json_t *wire;
json_t *just; json_t *just;
const char * const json_wire_str = const char * const json_wire_str =
@ -659,6 +655,7 @@ run (void *cls,
value.value * 2, value.value * 2,
value.fraction * 2, value.fraction * 2,
value.currency)); value.currency));
result = 5;
dkp = create_denom_key_pair (1024, session, dkp = create_denom_key_pair (1024, session,
&value, &value,
&fee_withdraw, &fee_withdraw,
@ -667,12 +664,9 @@ run (void *cls,
RND_BLK(&cbc.h_coin_envelope); RND_BLK(&cbc.h_coin_envelope);
RND_BLK(&cbc.reserve_sig); RND_BLK(&cbc.reserve_sig);
cbc.denom_pub = dkp->pub; cbc.denom_pub = dkp->pub;
GNUNET_CRYPTO_hash (&cbc.h_coin_envelope,
sizeof (cbc.h_coin_envelope),
&hc);
cbc.sig.rsa_signature cbc.sig.rsa_signature
= GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, = GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key,
&hc); &cbc.h_coin_envelope);
cbc.reserve_pub = reserve_pub; cbc.reserve_pub = reserve_pub;
cbc.amount_with_fee = value; cbc.amount_with_fee = value;
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
@ -699,10 +693,12 @@ run (void *cls,
FAILIF (0 != memcmp (&cbc2.reserve_pub, FAILIF (0 != memcmp (&cbc2.reserve_pub,
&cbc.reserve_pub, &cbc.reserve_pub,
sizeof (cbc2.reserve_pub))); sizeof (cbc2.reserve_pub)));
result = 6;
FAILIF (GNUNET_OK != FAILIF (GNUNET_OK !=
GNUNET_CRYPTO_rsa_verify (&cbc.h_coin_envelope, GNUNET_CRYPTO_rsa_verify (&cbc.h_coin_envelope,
cbc2.sig.rsa_signature, cbc2.sig.rsa_signature,
dkp->pub.rsa_public_key)); dkp->pub.rsa_public_key));
result = 7;
rh = plugin->get_reserve_history (plugin->cls, rh = plugin->get_reserve_history (plugin->cls,
session, session,
&reserve_pub); &reserve_pub);
@ -873,17 +869,10 @@ int
main (int argc, main (int argc,
char *const argv[]) char *const argv[])
{ {
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
char *argv2[] = {
"test-exchange-db-<plugin_name>", /* will be replaced later */
"-c", "test-exchange-db-<plugin_name>.conf", /* will be replaced later */
NULL,
};
const char *plugin_name; const char *plugin_name;
char *config_filename; char *config_filename;
char *testname; char *testname;
struct GNUNET_CONFIGURATION_Handle *cfg;
result = -1; result = -1;
if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
@ -896,19 +885,18 @@ main (int argc,
"test-exchange-db-%s", plugin_name); "test-exchange-db-%s", plugin_name);
(void) GNUNET_asprintf (&config_filename, (void) GNUNET_asprintf (&config_filename,
"%s.conf", testname); "%s.conf", testname);
cfg = GNUNET_CONFIGURATION_create ();
argv2[0] = argv[0];
argv2[2] = config_filename;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_PROGRAM_run ((sizeof (argv2)/sizeof (char *)) - 1, argv2, GNUNET_CONFIGURATION_parse (cfg,
testname, config_filename))
"Test cases for exchange database helper functions.",
options, &run, NULL))
{ {
GNUNET_break (0);
GNUNET_free (config_filename); GNUNET_free (config_filename);
GNUNET_free (testname); GNUNET_free (testname);
return 3; return 2;
} }
GNUNET_SCHEDULER_run (&run, cfg);
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free (config_filename); GNUNET_free (config_filename);
GNUNET_free (testname); GNUNET_free (testname);
return result; return result;