diff options
Diffstat (limited to 'src/testing/testing_api_cmd_check_keys.c')
-rw-r--r-- | src/testing/testing_api_cmd_check_keys.c | 118 |
1 files changed, 34 insertions, 84 deletions
diff --git a/src/testing/testing_api_cmd_check_keys.c b/src/testing/testing_api_cmd_check_keys.c index f4ea126e6..bb26d10a4 100644 --- a/src/testing/testing_api_cmd_check_keys.c +++ b/src/testing/testing_api_cmd_check_keys.c @@ -27,6 +27,8 @@ #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" +// FIXME: duplicated with testing_api_cmd_connect_with_state +// FIXME: this is now duplicated with testing_api_cmd_get_exchange! /** * State for a "check keys" CMD. @@ -35,13 +37,8 @@ struct CheckKeysState { /** - * If this value is true, then the "cherry picking" facility is turned off; - * whole /keys is downloaded. - */ - bool pull_all_keys; - - /** * Label of a command to use to derive the "last_denom_issue" date to use. + * FIXME: actually use this! */ const char *last_denom_date_ref; @@ -51,6 +48,11 @@ struct CheckKeysState struct TALER_TESTING_Interpreter *is; /** + * Our get keys operation. + */ + struct TALER_EXCHANGE_GetKeysHandle *gkh; + + /** * Last denomination date we received when doing this request. */ struct GNUNET_TIME_Timestamp my_denom_date; @@ -66,7 +68,8 @@ struct CheckKeysState */ static void keys_cb (void *cls, - const struct TALER_EXCHANGE_KeysResponse *kr) + const struct TALER_EXCHANGE_KeysResponse *kr, + struct TALER_EXCHANGE_Keys *keys) { struct CheckKeysState *cks = cls; @@ -77,6 +80,8 @@ keys_cb (void *cls, return; } cks->my_denom_date = kr->details.ok.keys->last_denom_issue_date; + /* FIXME: expose keys (and exchange_url) via trait! */ + TALER_EXCHANGE_keys_decref (keys); TALER_TESTING_interpreter_next (cks->is); } @@ -94,64 +99,19 @@ check_keys_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct CheckKeysState *cks = cls; - struct TALER_EXCHANGE_Handle *exchange - = TALER_TESTING_get_exchange (is); - struct GNUNET_TIME_Timestamp rdate; + const char *exchange_url + = TALER_TESTING_get_exchange_url (is); - (void) cmd; cks->is = is; - if (NULL == exchange) - return; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Triggering GET /keys, cmd `%s'\n", cmd->label); - if (NULL != cks->last_denom_date_ref) - { - if (0 == strcmp ("zero", - cks->last_denom_date_ref)) - { - TALER_LOG_DEBUG ("Forcing last_denom_date URL argument set to zero\n"); - TALER_EXCHANGE_set_last_denom (exchange, - GNUNET_TIME_UNIT_ZERO_TS); - } - else - { - const struct GNUNET_TIME_Timestamp *last_denom_date; - const struct TALER_TESTING_Command *ref; - - ref = TALER_TESTING_interpreter_lookup_command (is, - cks->last_denom_date_ref); - if (NULL == ref) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - if (GNUNET_OK != - TALER_TESTING_get_trait_timestamp (ref, - 0, - &last_denom_date)) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - - TALER_LOG_DEBUG ("Forcing last_denom_date URL argument\n"); - TALER_EXCHANGE_set_last_denom (exchange, - *last_denom_date); - } - } - - rdate = TALER_EXCHANGE_check_keys_current ( - exchange, - cks->pull_all_keys - ? TALER_EXCHANGE_CKF_FORCE_ALL_NOW - : TALER_EXCHANGE_CKF_FORCE_DOWNLOAD, + cks->gkh = TALER_EXCHANGE_get_keys ( + TALER_TESTING_interpreter_get_context (is), + exchange_url, + NULL, /* FIXME: get form last_denom_date_ref! */ &keys_cb, cks); - /* Redownload /keys. */ - GNUNET_break (GNUNET_TIME_absolute_is_zero (rdate.abs_time)); } @@ -168,6 +128,11 @@ check_keys_cleanup (void *cls, struct CheckKeysState *cks = cls; (void) cmd; + if (NULL != cks->gkh) + { + TALER_EXCHANGE_get_keys_cancel (cks->gkh); + cks->gkh = NULL; + } GNUNET_free (cks); } @@ -205,9 +170,20 @@ check_keys_traits (void *cls, struct TALER_TESTING_Command TALER_TESTING_cmd_check_keys (const char *label) { + return TALER_TESTING_cmd_check_keys_with_last_denom (label, + NULL); +} + + +struct TALER_TESTING_Command +TALER_TESTING_cmd_check_keys_with_last_denom ( + const char *label, + const char *last_denom_date_ref) +{ struct CheckKeysState *cks; cks = GNUNET_new (struct CheckKeysState); + cks->last_denom_date_ref = last_denom_date_ref; { struct TALER_TESTING_Command cmd = { .cls = cks, @@ -222,30 +198,4 @@ TALER_TESTING_cmd_check_keys (const char *label) } -struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label) -{ - struct TALER_TESTING_Command cmd - = TALER_TESTING_cmd_check_keys (label); - struct CheckKeysState *cks = cmd.cls; - - cks->pull_all_keys = true; - return cmd; -} - - -struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_with_last_denom ( - const char *label, - const char *last_denom_date_ref) -{ - struct TALER_TESTING_Command cmd - = TALER_TESTING_cmd_check_keys (label); - struct CheckKeysState *cks = cmd.cls; - - cks->last_denom_date_ref = last_denom_date_ref; - return cmd; -} - - /* end of testing_api_cmd_check_keys.c */ |