diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-01 20:27:57 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-01 20:27:57 +0200 |
commit | 1c568f8eb61e97dfefb61f7372e7338ed997e8c1 (patch) | |
tree | 74dae566f7c817e8203c4bb37c6dd05feb082234 /src/exchangedb | |
parent | 4154e41a411df9d30ab0213a7409642c924e78b0 (diff) |
fix testcase init with new API
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/perf_taler_exchangedb_init.c | 2 | ||||
-rw-r--r-- | src/exchangedb/perf_taler_exchangedb_interpreter.c | 67 | ||||
-rw-r--r-- | src/exchangedb/test_exchangedb.c | 44 |
3 files changed, 50 insertions, 63 deletions
diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c index c669518ad..516f3ea58 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.c +++ b/src/exchangedb/perf_taler_exchangedb_init.c @@ -486,7 +486,7 @@ PERF_TALER_EXCHANGEDB_refresh_session_free (struct TALER_EXCHANGEDB_RefreshSessi */ struct TALER_EXCHANGEDB_RefreshMelt * 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_CoinSpendSignatureP coin_sig; diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c index 75b32cb60..78b58a5ae 100644 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.c +++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c @@ -759,7 +759,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -785,7 +785,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -804,7 +804,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -828,7 +828,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -853,7 +853,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -873,7 +873,7 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, @@ -898,14 +898,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_refresh_order.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_refresh_order.index_hash = ret; + cmd[i].details.get_refresh_order.index_hash = ret; } break; @@ -923,15 +923,15 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.insert_refresh_commit_coin.label_hash); return GNUNET_SYSERR; } - cmd[i].details.insert_refresh_commit_coin.index_hash = ret; - } + cmd[i].details.insert_refresh_commit_coin.index_hash = ret; + } break; case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_COMMIT_COIN: @@ -948,14 +948,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_refresh_commit_coin.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_refresh_commit_coin.index_hash = ret; + cmd[i].details.get_refresh_commit_coin.index_hash = ret; } break; @@ -973,14 +973,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.insert_refresh_commit_link.label_hash); return GNUNET_SYSERR; } - cmd[i].details.insert_refresh_commit_link.index_hash = ret; + cmd[i].details.insert_refresh_commit_link.index_hash = ret; } break; @@ -998,14 +998,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_refresh_commit_link.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_refresh_commit_link.index_hash = ret; + cmd[i].details.get_refresh_commit_link.index_hash = ret; } break; @@ -1023,14 +1023,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_melt_commitment.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_melt_commitment.index_hash = ret; + cmd[i].details.get_melt_commitment.index_hash = ret; } break; @@ -1048,14 +1048,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.insert_refresh_out.label_hash); return GNUNET_SYSERR; } - cmd[i].details.insert_refresh_out.index_hash = ret; + cmd[i].details.insert_refresh_out.index_hash = ret; } break; @@ -1073,14 +1073,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_link_data_list.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_link_data_list.index_hash = ret; + cmd[i].details.get_link_data_list.index_hash = ret; } break; @@ -1098,14 +1098,14 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) return GNUNET_SYSERR; } if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%d:Wrong type reference to %s\n", i, cmd[i].details.get_transfer.label_hash); return GNUNET_SYSERR; } - cmd[i].details.get_transfer.index_hash = ret; + cmd[i].details.get_transfer.index_hash = ret; } break; @@ -1538,7 +1538,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) int ret; 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; ret = state->plugin->get_denomination_info (state->plugin->cls, state->session, @@ -1735,7 +1735,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) 1, 1, refresh_commit); - GNUNET_assert (GNUNET_OK == ret); + GNUNET_assert (GNUNET_OK == ret); } break; @@ -1743,7 +1743,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) { unsigned int hash_index; struct TALER_EXCHANGEDB_RefreshCommitCoin refresh_commit; - + hash_index = state->cmd[state->i].details.insert_refresh_commit_coin.index_hash; state->plugin->get_refresh_commit_coins (state->plugin->cls, state->session, @@ -1837,9 +1837,9 @@ PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin, */ int PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, - const char *configuration_file, - struct PERF_TALER_EXCHANGEDB_Cmd *init, - struct PERF_TALER_EXCHANGEDB_Cmd *benchmark) + const char *configuration_file, + struct PERF_TALER_EXCHANGEDB_Cmd *init, + struct PERF_TALER_EXCHANGEDB_Cmd *benchmark) { struct TALER_EXCHANGEDB_Plugin *plugin; struct GNUNET_CONFIGURATION_Handle *config; @@ -1927,9 +1927,8 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, "INFO", NULL); config = GNUNET_CONFIGURATION_create (); - - ret = GNUNET_CONFIGURATION_load (config, - configuration_file); + ret = GNUNET_CONFIGURATION_parse (config, + configuration_file); if (GNUNET_OK != ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 56c300678..f33bb18c3 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -549,17 +549,14 @@ cb_wtid_check (void *cls, /** * Main function that will be run by the scheduler. * - * @param cls closure - * @param args remaining command-line arguments - * @param cfgfile name of the configuration file used (for saving, can be NULL!) - * @param cfg configuration + * @param cls closure with config + * @param tc unused */ static void run (void *cls, - char *const *args, - const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_SCHEDULER_TaskContext *tc) { + struct GNUNET_CONFIGURATION_Handle *cfg = cls; struct TALER_EXCHANGEDB_Session *session; struct TALER_ReservePublicKeyP reserve_pub; struct DenomKeyPair *dkp; @@ -572,7 +569,6 @@ run (void *cls, struct TALER_EXCHANGEDB_Deposit deposit; struct TALER_EXCHANGEDB_Deposit deposit2; struct TALER_WireTransferIdentifierRawP wtid; - struct GNUNET_HashCode hc; json_t *wire; json_t *just; const char * const json_wire_str = @@ -659,6 +655,7 @@ run (void *cls, value.value * 2, value.fraction * 2, value.currency)); + result = 5; dkp = create_denom_key_pair (1024, session, &value, &fee_withdraw, @@ -667,12 +664,9 @@ run (void *cls, RND_BLK(&cbc.h_coin_envelope); RND_BLK(&cbc.reserve_sig); cbc.denom_pub = dkp->pub; - GNUNET_CRYPTO_hash (&cbc.h_coin_envelope, - sizeof (cbc.h_coin_envelope), - &hc); cbc.sig.rsa_signature = GNUNET_CRYPTO_rsa_sign_fdh (dkp->priv.rsa_private_key, - &hc); + &cbc.h_coin_envelope); cbc.reserve_pub = reserve_pub; cbc.amount_with_fee = value; GNUNET_assert (GNUNET_OK == @@ -699,10 +693,12 @@ run (void *cls, FAILIF (0 != memcmp (&cbc2.reserve_pub, &cbc.reserve_pub, sizeof (cbc2.reserve_pub))); + result = 6; FAILIF (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (&cbc.h_coin_envelope, cbc2.sig.rsa_signature, dkp->pub.rsa_public_key)); + result = 7; rh = plugin->get_reserve_history (plugin->cls, session, &reserve_pub); @@ -873,17 +869,10 @@ int main (int argc, 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; char *config_filename; char *testname; + struct GNUNET_CONFIGURATION_Handle *cfg; result = -1; if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) @@ -896,19 +885,18 @@ main (int argc, "test-exchange-db-%s", plugin_name); (void) GNUNET_asprintf (&config_filename, "%s.conf", testname); - - argv2[0] = argv[0]; - argv2[2] = config_filename; + cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != - GNUNET_PROGRAM_run ((sizeof (argv2)/sizeof (char *)) - 1, argv2, - testname, - "Test cases for exchange database helper functions.", - options, &run, NULL)) + GNUNET_CONFIGURATION_parse (cfg, + config_filename)) { + GNUNET_break (0); GNUNET_free (config_filename); GNUNET_free (testname); - return 3; + return 2; } + GNUNET_SCHEDULER_run (&run, cfg); + GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free (config_filename); GNUNET_free (testname); return result; |