diff options
Diffstat (limited to 'src/include/taler_testing_lib.h')
-rw-r--r-- | src/include/taler_testing_lib.h | 2806 |
1 files changed, 1155 insertions, 1651 deletions
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 7768a7f61..f07d9be20 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2018 Taler Systems SA + (C) 2018-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -20,6 +20,8 @@ /** * @file include/taler_testing_lib.h * @brief API for writing an interpreter to test Taler components + * This library is not thread-safe, all APIs must only be used from a single thread. + * This library calls abort() if it runs out of memory. Be aware of these limitations. * @author Christian Grothoff <christian@grothoff.org> * @author Marcello Stanisci */ @@ -27,11 +29,13 @@ #define TALER_TESTING_LIB_H #include "taler_util.h" -#include "taler_exchange_service.h" +#include <microhttpd.h> #include <gnunet/gnunet_json_lib.h> #include "taler_json_lib.h" +#include "taler_auditor_service.h" #include "taler_bank_service.h" -#include <microhttpd.h> +#include "taler_exchange_service.h" +#include "taler_fakebank_lib.h" /* ********************* Helper functions ********************* */ @@ -50,155 +54,156 @@ /** - * Allocate and return a piece of wire-details. Combines - * a @a payto -URL and adds some salt to create the JSON. + * Log an error message about us receiving an unexpected HTTP + * status code at the current command and fail the test. * - * @param payto payto://-URL to encapsulate - * @return JSON describing the account, including the - * payto://-URL of the account, must be manually decref'd + * @param is interpreter to fail + * @param status unexpected HTTP status code received + * @param expected expected HTTP status code */ -json_t * -TALER_TESTING_make_wire_details (const char *payto); +#define TALER_TESTING_unexpected_status(is,status,expected) \ + do { \ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ + "Unexpected response code %u (expected: %u) to command %s in %s:%u\n", \ + status, \ + expected, \ + TALER_TESTING_interpreter_get_current_label (is), \ + __FILE__, \ + __LINE__); \ + TALER_TESTING_interpreter_fail (is); \ + } while (0) + +/** + * Log an error message about us receiving an unexpected HTTP + * status code at the current command and fail the test and print the response + * body (expected as json). + * + * @param is interpreter to fail + * @param status unexpected HTTP status code received + * @param expected expected HTTP status code + * @param body received JSON-reply + */ +#define TALER_TESTING_unexpected_status_with_body(is,status,expected,body) \ + do { \ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ + "Unexpected response code %u (expected: %u) to " \ + "command %s in %s:%u\nwith body:\n>>%s<<\n", \ + status, \ + expected, \ + TALER_TESTING_interpreter_get_current_label (is), \ + __FILE__, \ + __LINE__, \ + json_dumps (body, JSON_INDENT (2))); \ + TALER_TESTING_interpreter_fail (is); \ + } while (0) /** - * Find denomination key matching the given amount. + * Log an error message about a command not having + * run to completion. * - * @param keys array of keys to search - * @param amount coin value to look for - * @return NULL if no matching key was found + * @param is interpreter + * @param label command label of the incomplete command */ -const struct TALER_EXCHANGE_DenomPublicKey * -TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys, - const struct TALER_Amount *amount); +#define TALER_TESTING_command_incomplete(is,label) \ + do { \ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ + "Command %s (%s:%u) did not complete (at %s)\n", \ + label, \ + __FILE__, \ + __LINE__, \ + TALER_TESTING_interpreter_get_current_label (is)); \ + } while (0) /** - * Configuration data for an exchange. + * Common credentials used in a test. */ -struct TALER_TESTING_ExchangeConfiguration +struct TALER_TESTING_Credentials { /** - * Exchange base URL as it appears in the configuration. Note - * that it might differ from the one where the exchange actually - * listens from. + * Bank authentication details for the exchange bank + * account. */ - char *exchange_url; + struct TALER_BANK_AuthenticationData ba; /** - * Auditor base URL as it appears in the configuration. Note - * that it might differ from the one where the auditor actually - * listens from. + * Bank authentication details for the admin bank + * account. */ - char *auditor_url; + struct TALER_BANK_AuthenticationData ba_admin; -}; + /** + * Configuration file data. + */ + struct GNUNET_CONFIGURATION_Handle *cfg; -/** - * Connection to the database: aggregates - * plugin and session handles. - */ -struct TALER_TESTING_DatabaseConnection -{ /** - * Database plugin. + * Base URL of the exchange. */ - struct TALER_EXCHANGEDB_Plugin *plugin; + char *exchange_url; -}; + /** + * Base URL of the auditor. + */ + char *auditor_url; -struct TALER_TESTING_LibeufinServices -{ /** - * Nexus + * RFC 8905 URI of the exchange. */ - struct GNUNET_OS_Process *nexus; + char *exchange_payto; /** - * Sandbox + * RFC 8905 URI of a user. */ - struct GNUNET_OS_Process *sandbox; + char *user42_payto; + /** + * RFC 8905 URI of a user. + */ + char *user43_payto; }; -/** - * Prepare launching an exchange. Checks that the configured - * port is available, runs taler-exchange-keyup, - * taler-auditor-sign and taler-exchange-dbinit. Does not - * launch the exchange process itself. - * - * @param config_filename configuration file to use - * @param reset_db should we reset the database - * @param[out] ec will be set to the exchange configuration data - * @return #GNUNET_OK on success, #GNUNET_NO if test should be - * skipped, #GNUNET_SYSERR on test failure - */ -int -TALER_TESTING_prepare_exchange (const char *config_filename, - int reset_db, - struct TALER_TESTING_ExchangeConfiguration *ec); - /** - * "Canonical" cert_cb used when we are connecting to the - * Exchange. - * - * @param cls closure, typically, the "run" method containing - * all the commands to be run, and a closure for it. - * @param hr http response details - * @param keys the exchange's keys. - * @param compat protocol compatibility information. + * What type of bank are we using? */ -void -TALER_TESTING_cert_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - const struct TALER_EXCHANGE_Keys *keys, - enum TALER_EXCHANGE_VersionCompatibility compat); - - -/** - * Wait for the exchange to have started. Waits for at - * most 10s, after that returns 77 to indicate an error. - * - * @param base_url what URL should we expect the exchange - * to be running at - * @return 0 on success - */ -int -TALER_TESTING_wait_exchange_ready (const char *base_url); - - -/** - * Wait for an HTTPD service to have started. Waits for at - * most 10s, after that returns 77 to indicate an error. - * - * @param base_url what URL should we expect the exchange - * to be running at - * @return 0 on success - */ -int -TALER_TESTING_wait_httpd_ready (const char *base_url); +enum TALER_TESTING_BankSystem +{ + TALER_TESTING_BS_FAKEBANK = 1, + TALER_TESTING_BS_IBAN = 2 +}; /** - * Wait for the auditor to have started. Waits for at - * most 10s, after that returns 77 to indicate an error. + * Obtain bank credentials for a given @a cfg_file using + * @a exchange_account_section as the basis for the + * exchange account. * - * @param base_url what URL should we expect the auditor - * to be running at - * @return 0 on success + * @param cfg_file name of configuration to parse + * @param exchange_account_section configuration section name for the exchange account to use + * @param bs type of bank to use + * @param[out] ua where to write user account details + * and other credentials */ -int -TALER_TESTING_wait_auditor_ready (const char *base_url); +enum GNUNET_GenericReturnValue +TALER_TESTING_get_credentials ( + const char *cfg_file, + const char *exchange_account_section, + enum TALER_TESTING_BankSystem bs, + struct TALER_TESTING_Credentials *ua); /** - * Remove files from previous runs + * Allocate and return a piece of wire-details. Combines + * a @a payto -URL and adds some salt to create the JSON. * - * @param config_name configuration file to use+ + * @param payto payto://-URL to encapsulate + * @return JSON describing the account, including the + * payto://-URL of the account, must be manually decref'd */ -void -TALER_TESTING_cleanup_files (const char *config_name); +json_t * +TALER_TESTING_make_wire_details (const char *payto); /** @@ -208,71 +213,23 @@ TALER_TESTING_cleanup_files (const char *config_name); * @param cfg configuration * @return #GNUNET_OK on success */ -int +enum GNUNET_GenericReturnValue TALER_TESTING_cleanup_files_cfg (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg); /** - * Run `taler-exchange-offline`. - * - * @param config_filename configuration file to use - * @param payto_uri bank account to enable, can be NULL - * @param auditor_pub public key of auditor to enable, can be NULL - * @param auditor_url URL of auditor to enable, can be NULL - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_run_exchange_offline (const char *config_filename, - const char *payto_uri, - const char *auditor_pub, - const char *auditor_url); - - -/** - * Run `taler-auditor-dbinit -r` (reset auditor database). - * - * @param config_filename configuration file to use - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_auditor_db_reset (const char *config_filename); - - -/** - * Run `taler-exchange-dbinit -r` (reset exchange database). - * - * @param config_filename configuration file to use - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_exchange_db_reset (const char *config_filename); - - -/** - * Run `taler-auditor-offline` tool. - * - * @param config_filename configuration file to use - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_run_auditor_offline (const char *config_filename); - - -/** - * Run `taler-auditor-exchange`. + * Find denomination key matching the given amount. * - * @param config_filename configuration file to use - * @param exchange_master_pub master public key of the exchange - * @param exchange_base_url what is the base URL of the exchange - * @param do_remove #GNUNET_NO to add exchange, #GNUNET_YES to remove - * @return #GNUNET_OK on success + * @param keys array of keys to search + * @param amount coin value to look for + * @param age_restricted must the denomination be age restricted? + * @return NULL if no matching key was found */ -int -TALER_TESTING_run_auditor_exchange (const char *config_filename, - const char *exchange_master_pub, - const char *exchange_base_url, - int do_remove); +const struct TALER_EXCHANGE_DenomPublicKey * +TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys, + const struct TALER_Amount *amount, + bool age_restricted); /** @@ -281,198 +238,17 @@ TALER_TESTING_run_auditor_exchange (const char *config_filename, * @param url URL to extract port from, 80 is default * @return #GNUNET_OK if the port is free */ -int +enum GNUNET_GenericReturnValue TALER_TESTING_url_port_free (const char *url); -/** - * Configuration data for a bank. - */ -struct TALER_TESTING_BankConfiguration -{ - - /** - * Authentication data for the exchange user at the bank. - */ - struct TALER_BANK_AuthenticationData exchange_auth; - - /** - * Payto URL of the exchange's account ("2") - */ - char *exchange_payto; - - /** - * Payto URL of a user account ("42") - */ - char *user42_payto; - - /** - * Payto URL of another user's account ("43") - */ - char *user43_payto; - -}; - -/** - * Prepare launching a fakebank. Check that the configuration - * file has the right option, and that the port is available. - * If everything is OK, return the configuration data of the fakebank. - * - * @param config_filename configuration file to use - * @param config_section which account to use - * (must match x-taler-bank) - * @param[out] bc set to the bank's configuration data - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_prepare_fakebank (const char *config_filename, - const char *config_section, - struct TALER_TESTING_BankConfiguration *bc); - - /* ******************* Generic interpreter logic ************ */ /** * Global state of the interpreter, used by a command * to access information about other commands. */ -struct TALER_TESTING_Interpreter -{ - - /** - * Commands the interpreter will run. - */ - struct TALER_TESTING_Command *commands; - - /** - * Interpreter task (if one is scheduled). - */ - struct GNUNET_SCHEDULER_Task *task; - - /** - * ID of task called whenever we get a SIGCHILD. - * Used for #TALER_TESTING_wait_for_sigchld(). - */ - struct GNUNET_SCHEDULER_Task *child_death_task; - - /** - * Main execution context for the main loop. - */ - struct GNUNET_CURL_Context *ctx; - - /** - * Our configuration. - */ - const struct GNUNET_CONFIGURATION_Handle *cfg; - - /** - * Context for running the CURL event loop. - */ - struct GNUNET_CURL_RescheduleContext *rc; - - /** - * Handle to our fakebank, if #TALER_TESTING_run_with_fakebank() - * was used. Otherwise NULL. - */ - struct TALER_FAKEBANK_Handle *fakebank; - - /** - * Task run on timeout. - */ - struct GNUNET_SCHEDULER_Task *timeout_task; - - /** - * Function to call for cleanup at the end. Can be NULL. - */ - GNUNET_SCHEDULER_TaskCallback final_cleanup_cb; - - /** - * Closure for #final_cleanup_cb(). - */ - void *final_cleanup_cb_cls; - - /** - * Instruction pointer. Tells #interpreter_run() which instruction to run - * next. Need (signed) int because it gets -1 when rewinding the - * interpreter to the first CMD. - */ - int ip; - - /** - * Result of the testcases, #GNUNET_OK on success - */ - int result; - - /** - * Handle to the exchange. - */ - struct TALER_EXCHANGE_Handle *exchange; - - /** - * Handle to the auditor. NULL unless specifically initialized - * as part of #TALER_TESTING_auditor_setup(). - */ - struct TALER_AUDITOR_Handle *auditor; - - /** - * Handle to exchange process; some commands need it - * to send signals. E.g. to trigger the key state reload. - */ - struct GNUNET_OS_Process *exchanged; - - /** - * Public key of the auditor. - */ - struct TALER_AuditorPublicKeyP auditor_pub; - - /** - * Private key of the auditor. - */ - struct TALER_AuditorPrivateKeyP auditor_priv; - - /** - * Private offline signing key. - */ - struct TALER_MasterPrivateKeyP master_priv; - - /** - * Public offline signing key. - */ - struct TALER_MasterPublicKeyP master_pub; - - /** - * URL of the auditor (as per configuration). - */ - char *auditor_url; - - /** - * URL of the exchange (as per configuration). - */ - char *exchange_url; - - /** - * Is the interpreter running (#GNUNET_YES) or waiting - * for /keys (#GNUNET_NO)? - */ - int working; - - /** - * Is the auditor running (#GNUNET_YES) or waiting - * for /version (#GNUNET_NO)? - */ - int auditor_working; - - /** - * How often have we gotten a /keys response so far? - */ - unsigned int key_generation; - - /** - * Exchange keys from last download. - */ - const struct TALER_EXCHANGE_Keys *keys; - -}; +struct TALER_TESTING_Interpreter; /** @@ -493,6 +269,11 @@ struct TALER_TESTING_Command const char *label; /** + * Variable name for the command, NULL for none. + */ + const char *name; + + /** * Runs the command. Note that upon return, the interpreter * will not automatically run the next command, as the command * may continue asynchronously in other scheduler tasks. Thus, @@ -502,12 +283,12 @@ struct TALER_TESTING_Command * * @param cls closure * @param cmd command being run - * @param i interpreter state + * @param is interpreter state */ void (*run)(void *cls, const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *i); + struct TALER_TESTING_Interpreter *is); /** @@ -531,7 +312,7 @@ struct TALER_TESTING_Command * @param index index number of the object to extract. * @return #GNUNET_OK on success */ - int + enum GNUNET_GenericReturnValue (*traits)(void *cls, const void **ret, const char *trait, @@ -574,8 +355,43 @@ const struct TALER_TESTING_Command * TALER_TESTING_interpreter_lookup_command (struct TALER_TESTING_Interpreter *is, const char *label); + +/** + * Get command from hash map by variable name. + * + * @param is interpreter state. + * @param name name of the variable to get command by + * @return the command, if it is found, or NULL. + */ +const struct TALER_TESTING_Command * +TALER_TESTING_interpreter_get_command (struct TALER_TESTING_Interpreter *is, + const char *name); + + +/** + * Update the last request time of the current command + * to the current time. + * + * @param[in,out] is interpreter state where to show + * that we are doing something + */ +void +TALER_TESTING_touch_cmd (struct TALER_TESTING_Interpreter *is); + + /** - * Obtain main execution context for the main loop. + * Increment the 'num_tries' counter for the current + * command. + * + * @param[in,out] is interpreter state where to + * increment the counter + */ +void +TALER_TESTING_inc_tries (struct TALER_TESTING_Interpreter *is); + + +/** + * Obtain CURL context for the main loop. * * @param is interpreter state. * @return CURL execution context. @@ -596,15 +412,6 @@ TALER_TESTING_interpreter_get_current_label ( /** - * Get connection handle to the fakebank. - * - * @param is interpreter state. - * @return the handle. - */ -struct TALER_FAKEBANK_Handle * -TALER_TESTING_interpreter_get_fakebank (struct TALER_TESTING_Interpreter *is); - -/** * Current command is done, run the next one. * * @param is interpreter state. @@ -620,14 +427,6 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is); void TALER_TESTING_interpreter_fail (struct TALER_TESTING_Interpreter *is); -/** - * Create command array terminator. - * - * @return a end-command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_end (void); - /** * Make the instruction pointer point to @a target_label @@ -684,20 +483,6 @@ TALER_TESTING_run2 (struct TALER_TESTING_Interpreter *is, /** - * First launch the fakebank, then schedule the first CMD - * in the array of all the CMDs to execute. - * - * @param is interpreter state. - * @param commands array of all the commands to execute. - * @param bank_url base URL of the fake bank. - */ -void -TALER_TESTING_run_with_fakebank (struct TALER_TESTING_Interpreter *is, - struct TALER_TESTING_Command *commands, - const char *bank_url); - - -/** * The function that contains the array of all the CMDs to run, * which is then on charge to call some fashion of * TALER_TESTING_run*. In all the test cases, this function is @@ -712,233 +497,197 @@ typedef void /** - * Install signal handlers plus schedules the main wrapper - * around the "run" method. + * Run Taler testing loop. Starts the GNUnet SCHEDULER (event loop). * - * @param main_cb the "run" method which coontains all the - * commands. - * @param main_cb_cls a closure for "run", typically NULL. - * @param cfg configuration to use - * @param exchanged exchange process handle: will be put in the - * state as some commands - e.g. revoke - need to send - * signal to it, for example to let it know to reload the - * key state. If NULL, the interpreter will run without - * trying to connect to the exchange first. - * @param exchange_connect #GNUNET_YES if the test should connect - * to the exchange, #GNUNET_NO otherwise - * @return #GNUNET_OK if all is okay, != #GNUNET_OK otherwise. - * non-#GNUNET_OK codes are #GNUNET_SYSERR most of the - * times. + * @param main_cb main function to run + * @param main_cb_cls closure for @a main_cb */ -int -TALER_TESTING_setup (TALER_TESTING_Main main_cb, - void *main_cb_cls, - const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_OS_Process *exchanged, - int exchange_connect); +enum GNUNET_GenericReturnValue +TALER_TESTING_loop (TALER_TESTING_Main main_cb, + void *main_cb_cls); /** - * Install signal handlers plus schedules the main wrapper - * around the "run" method. + * Convenience function to run a test. * - * @param main_cb the "run" method which contains all the - * commands. - * @param main_cb_cls a closure for "run", typically NULL. - * @param config_filename configuration filename. - * @return #GNUNET_OK if all is okay, != #GNUNET_OK otherwise. - * non-GNUNET_OK codes are #GNUNET_SYSERR most of the - * times. + * @param argv command-line arguments given + * @param loglevel log level to use + * @param cfg_file configuration file to use + * @param exchange_account_section configuration section + * with exchange bank account to use + * @param bs bank system to use + * @param[in,out] cred global credentials to initialize + * @param main_cb main test function to run + * @param main_cb_cls closure for @a main_cb + * @return 0 on success, 77 on setup trouble, non-zero process status code otherwise */ int -TALER_TESTING_auditor_setup (TALER_TESTING_Main main_cb, - void *main_cb_cls, - const char *config_filename); +TALER_TESTING_main (char *const *argv, + const char *loglevel, + const char *cfg_file, + const char *exchange_account_section, + enum TALER_TESTING_BankSystem bs, + struct TALER_TESTING_Credentials *cred, + TALER_TESTING_Main main_cb, + void *main_cb_cls); /** - * Closure for #TALER_TESTING_setup_with_exchange_cfg(). + * Callback over commands of an interpreter. + * + * @param cls closure + * @param cmd a command to process */ -struct TALER_TESTING_SetupContext -{ - /** - * Main function of the test to run. - */ - TALER_TESTING_Main main_cb; - - /** - * Closure for @e main_cb. - */ - void *main_cb_cls; - - /** - * Name of the configuration file. - */ - const char *config_filename; -}; +typedef void +(*TALER_TESTING_CommandIterator)( + void *cls, + const struct TALER_TESTING_Command *cmd); /** - * Initialize scheduler loop and curl context for the test case - * including starting and stopping the exchange using the given - * configuration file. + * Iterates over all of the top-level commands of an + * interpreter. * - * @param cls must be a `struct TALER_TESTING_SetupContext *` - * @param cfg configuration to use. - * @return #GNUNET_OK if no errors occurred. + * @param[in] is interpreter to iterate over + * @param asc true in execution order, false for reverse execution order + * @param cb function to call on each command + * @param cb_cls closure for cb */ -int -TALER_TESTING_setup_with_exchange_cfg ( - void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg); +void +TALER_TESTING_iterate (struct TALER_TESTING_Interpreter *is, + bool asc, + TALER_TESTING_CommandIterator cb, + void *cb_cls); /** - * Initialize scheduler loop and curl context for the test case - * including starting and stopping the exchange using the given - * configuration file. + * Look for substring in a programs' name. * - * @param main_cb main method. - * @param main_cb_cls main method closure. - * @param config_file configuration file name. Is is used - * by both this function and the exchange itself. In the - * first case it gives out the exchange port number and - * the exchange base URL so as to check whether the port - * is available and the exchange responds when requested - * at its base URL. - * @return #GNUNET_OK if no errors occurred. + * @param prog program's name to look into + * @param marker chunk to find in @a prog + * @return true if @a marker is in @a prog */ -int -TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, - void *main_cb_cls, - const char *config_file); +bool +TALER_TESTING_has_in_name (const char *prog, + const char *marker); /** - * Initialize scheduler loop and curl context for the test case - * including starting and stopping the auditor and exchange using - * the given configuration file. + * Wait for an HTTPD service to have started. Waits for at + * most 10s, after that returns 77 to indicate an error. * - * @param cls must be a `struct TALER_TESTING_SetupContext *` - * @param cfg configuration to use. - * @return #GNUNET_OK if no errors occurred. + * @param base_url what URL should we expect the exchange + * to be running at + * @return 0 on success */ int -TALER_TESTING_setup_with_auditor_and_exchange_cfg ( - void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg); +TALER_TESTING_wait_httpd_ready (const char *base_url); /** - * Initialize scheduler loop and curl context for the test case - * including starting and stopping the auditor and exchange using - * the given configuration file. + * Parse reference to a coin. * - * @param main_cb main method. - * @param main_cb_cls main method closure. - * @param config_file configuration file name. Is is used - * by both this function and the exchange itself. In the - * first case it gives out the exchange port number and - * the exchange base URL so as to check whether the port - * is available and the exchange responds when requested - * at its base URL. - * @return #GNUNET_OK if no errors occurred. + * @param coin_reference of format $LABEL['#' $INDEX]? + * @param[out] cref where we return a copy of $LABEL + * @param[out] idx where we set $INDEX + * @return #GNUNET_SYSERR if $INDEX is present but not numeric */ -int -TALER_TESTING_setup_with_auditor_and_exchange (TALER_TESTING_Main main_cb, - void *main_cb_cls, - const char *config_file); +enum GNUNET_GenericReturnValue +TALER_TESTING_parse_coin_reference ( + const char *coin_reference, + char **cref, + unsigned int *idx); + + +/* ************** Specific interpreter commands ************ */ /** - * Start the (Python) bank process. Assume the port - * is available and the database is clean. Use the "prepare - * bank" function to do such tasks. + * Create command array terminator. * - * @param config_filename configuration filename. - * @param bank_url base URL of the bank, used by `wget' to check - * that the bank was started right. - * @return the process, or NULL if the process could not - * be started. + * @return a end-command. */ -struct GNUNET_OS_Process * -TALER_TESTING_run_bank (const char *config_filename, - const char *bank_url); +struct TALER_TESTING_Command +TALER_TESTING_cmd_end (void); + /** - * Start the (nexus) bank process. Assume the port - * is available and the database is clean. Use the "prepare - * bank" function to do such tasks. This function is also - * responsible to create the exchange EBICS subscriber at - * the nexus. + * Set variable to command as side-effect of + * running a command. * - * @param bc bank configuration of the bank - * @return the process, or NULL if the process could not - * be started. + * @param name name of the variable to set + * @param cmd command to set to variable when run + * @return modified command */ -struct TALER_TESTING_LibeufinServices -TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc); +struct TALER_TESTING_Command +TALER_TESTING_cmd_set_var (const char *name, + struct TALER_TESTING_Command cmd); /** - * Runs the Fakebank by guessing / extracting the portnumber - * from the base URL. + * Launch GNU Taler setup. * - * @param bank_url bank's base URL. - * @param currency currency the bank uses - * @return the fakebank process handle, or NULL if any - * error occurs. + * @param label command label. + * @param config_file configuration file to use + * @param ... NULL-terminated (const char *) arguments to pass to taler-benchmark-setup.sh + * @return the command. */ -struct TALER_FAKEBANK_Handle * -TALER_TESTING_run_fakebank (const char *bank_url, - const char *currency); +struct TALER_TESTING_Command +TALER_TESTING_cmd_system_start ( + const char *label, + const char *config_file, + ...); /** - * Prepare the bank execution. Check if the port is available - * and reset database. + * Connects to the exchange. * - * @param config_filename configuration file name. - * @param reset_db should we reset the bank's database - * @param config_section which configuration section should be used - * @param[out] bc set to the bank's configuration data - * @return #GNUNET_OK on success + * @param label command label + * @param cfg configuration to use + * @param last_keys_ref reference to command with prior /keys response, NULL for none + * @param wait_for_keys block until we got /keys + * @param load_private_key obtain private key from file indicated in @a cfg + * @return the command. */ -int -TALER_TESTING_prepare_bank (const char *config_filename, - int reset_db, - const char *config_section, - struct TALER_TESTING_BankConfiguration *bc); +struct TALER_TESTING_Command +TALER_TESTING_cmd_get_exchange ( + const char *label, + const struct GNUNET_CONFIGURATION_Handle *cfg, + const char *last_keys_ref, + bool wait_for_keys, + bool load_private_key); + /** - * Prepare the Nexus execution. Check if the port is available - * and delete old database. + * Connects to the auditor. * - * @param config_filename configuration file name. - * @param reset_db should we reset the bank's database - * @param config_section section of the configuration with the exchange's account - * @param[out] bc set to the bank's configuration data - * @return the base url, or NULL upon errors. Must be freed - * by the caller. + * @param label command label + * @param cfg configuration to use + * @param load_auditor_keys obtain auditor keys from file indicated in @a cfg + * @return the command. */ -int -TALER_TESTING_prepare_nexus (const char *config_filename, - int reset_db, - const char *config_section, - struct TALER_TESTING_BankConfiguration *bc); +struct TALER_TESTING_Command +TALER_TESTING_cmd_get_auditor ( + const char *label, + const struct GNUNET_CONFIGURATION_Handle *cfg, + bool load_auditor_keys); + /** - * Look for substring in a programs' name. + * Runs the Fakebank in-process by guessing / extracting the portnumber + * from the base URL. * - * @param prog program's name to look into - * @param marker chunk to find in @a prog + * @param label command label + * @param cfg configuration to use + * @param exchange_account_section configuration section + * to use to determine bank account of the exchange + * @return the command. */ -int -TALER_TESTING_has_in_name (const char *prog, - const char *marker); - - -/* ************** Specific interpreter commands ************ */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_run_fakebank ( + const char *label, + const struct GNUNET_CONFIGURATION_Handle *cfg, + const char *exchange_account_section); /** @@ -997,10 +746,11 @@ TALER_TESTING_cmd_bank_debits (const char *label, /** * Create transfer command. * - * @param label command label. - * @param amount amount to transfer. + * @param label command label + * @param amount amount to transfer * @param auth authentication data to use - * @param payto_credit_account which account receives money. + * @param payto_debit_account which account to withdraw money from + * @param payto_credit_account which account receives money * @param wtid wire transfer identifier to use * @param exchange_base_url exchange URL to use * @return the command. @@ -1054,24 +804,20 @@ TALER_TESTING_cmd_exec_auditor_dbinit (const char *label, * Create a "deposit-confirmation" command. * * @param label command label. - * @param auditor auditor connection. * @param deposit_reference reference to any operation that can * provide a coin. - * @param coin_index if @a deposit_reference offers an array of - * coins, this parameter selects which one in that array. - * This value is currently ignored, as only one-coin - * deposits are implemented. + * @param num_coins number of coins expected in the batch deposit * @param amount_without_fee deposited amount without the fee * @param expected_response_code expected HTTP response code. * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit_confirmation (const char *label, - struct TALER_AUDITOR_Handle *auditor, - const char *deposit_reference, - unsigned int coin_index, - const char *amount_without_fee, - unsigned int expected_response_code); +TALER_TESTING_cmd_deposit_confirmation ( + const char *label, + const char *deposit_reference, + unsigned int num_coins, + const char *amount_without_fee, + unsigned int expected_response_code); /** @@ -1083,48 +829,7 @@ TALER_TESTING_cmd_deposit_confirmation (const char *label, */ struct TALER_TESTING_Command TALER_TESTING_cmd_deposit_confirmation_with_retry ( - struct TALER_TESTING_Command - cmd); - - -/** - * Create a "list exchanges" command. - * - * @param label command label. - * @param auditor auditor connection. - * @param expected_response_code expected HTTP response code. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exchanges (const char *label, - struct TALER_AUDITOR_Handle *auditor, - unsigned int expected_response_code); - - -/** - * Create a "list exchanges" command and check whether - * a particular exchange belongs to the returned bundle. - * - * @param label command label. - * @param expected_response_code expected HTTP response code. - * @param exchange_url URL of the exchange supposed to - * be included in the response. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exchanges_with_url (const char *label, - unsigned int expected_response_code, - const char *exchange_url); - -/** - * Modify an exchanges command to enable retries when we get - * transient errors from the auditor. - * - * @param cmd a deposit confirmation command - * @return the command with retries enabled - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exchanges_with_retry (struct TALER_TESTING_Command cmd); + struct TALER_TESTING_Command cmd); /** @@ -1186,15 +891,65 @@ TALER_TESTING_cmd_admin_add_incoming_retry (struct TALER_TESTING_Command cmd); * * @param label command label. * @param config_filename configuration filename. - * * @return the command. */ struct TALER_TESTING_Command TALER_TESTING_cmd_exec_wirewatch (const char *label, const char *config_filename); + +/** + * Make a "wirewatch" CMD. + * + * @param label command label. + * @param config_filename configuration filename. + * @param account_section section to run wirewatch against + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_wirewatch2 (const char *label, + const char *config_filename, + const char *account_section); + + /** - * Make a "aggregator" CMD. + * Request URL via "wget". + * + * @param label command label. + * @param url URL to fetch + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_wget (const char *label, + const char *url); + + +/** + * Make a "expire" CMD. + * + * @param label command label. + * @param config_filename configuration filename. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_expire (const char *label, + const char *config_filename); + + +/** + * Make a "router" CMD. + * + * @param label command label. + * @param config_filename configuration filename. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_router (const char *label, + const char *config_filename); + + +/** + * Run a "taler-exchange-aggregator" CMD. * * @param label command label. * @param config_filename configuration file for the @@ -1207,6 +962,32 @@ TALER_TESTING_cmd_exec_aggregator (const char *label, /** + * Run a "taler-auditor-offline" CMD. + * + * @param label command label. + * @param config_filename configuration file for the + * aggregator to use. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_auditor_offline (const char *label, + const char *config_filename); + + +/** + * Make a "aggregator" CMD and do not disable KYC checks. + * + * @param label command label. + * @param config_filename configuration file for the + * aggregator to use. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_aggregator_with_kyc (const char *label, + const char *config_filename); + + +/** * Make a "closer" CMD. Note that it is right now not supported to run the * closer to close multiple reserves in combination with a subsequent reserve * status call, as we cannot generate the traits necessary for multiple closed @@ -1250,6 +1031,7 @@ TALER_TESTING_cmd_exec_transfer (const char *label, * @param label command label. * @param reserve_reference command providing us with a reserve to withdraw from * @param amount how much we withdraw. + * @param age if > 0, age restriction applies * @param expected_response_code which HTTP response code * we expect from the exchange. * @return the withdraw command to be executed by the interpreter. @@ -1258,10 +1040,107 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_withdraw_amount (const char *label, const char *reserve_reference, const char *amount, + uint8_t age, unsigned int expected_response_code); /** + * Create a batch withdraw command, letting the caller specify the type of + * conflict between the coins and the desired amounts as string. + * + * Takes a variable, non-empty list of the denomination amounts via VARARGS, + * similar to #TALER_TESTING_cmd_withdraw_amount(), just using a batch + * withdraw. + * + * @param label command label. + * @param reserve_reference command providing us with a reserve to withdraw from + * @param conflict if true, enforce a conflict (same priv key, different denom and age commiment) + * @param age if > 0, age restriction applies (same for all coins) + * @param expected_response_code which HTTP response code + * we expect from the exchange. + * @param amount how much we withdraw for the first coin + * @param ... NULL-terminated list of additional amounts to withdraw (one per coin) + * @return the withdraw command to be executed by the interpreter. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_batch_withdraw_with_conflict ( + const char *label, + const char *reserve_reference, + bool conflict, + uint8_t age, + unsigned int expected_response_code, + const char *amount, + ...); + +/** + * Create a batch withdraw command, letting the caller specify + * the desired amounts as string. Takes a variable, non-empty + * list of the denomination amounts via VARARGS, similar to + * #TALER_TESTING_cmd_withdraw_amount(), just using a batch withdraw. + * The coins are generated without a conflict (different private keys). + * + * @param label command label. + * @param reserve_reference command providing us with a reserve to withdraw from + * @param age if > 0, age restriction applies (same for all coins) + * @param expected_response_code which HTTP response code + * we expect from the exchange. + * @param amount how much we withdraw for the first coin + * @param ... NULL-terminated list of additional amounts to withdraw (one per coin) + * @return the withdraw command to be executed by the interpreter. + */ +#define TALER_TESTING_cmd_batch_withdraw(label, \ + reserve_reference, \ + age, \ + expected_response_code, \ + amount, \ + ...) \ + TALER_TESTING_cmd_batch_withdraw_with_conflict ( \ + (label), \ + (reserve_reference), \ + false, \ + (age), \ + (expected_response_code), \ + (amount), \ + __VA_ARGS__) + +/** + * Create an age-withdraw command, letting the caller specify + * the maximum agend and desired amounts as string. Takes a variable, + * non-empty list of the denomination amounts via VARARGS, similar to + * #TALER_TESTING_cmd_withdraw_amount(), just using a batch withdraw. + * + * @param label command label. + * @param reserve_reference command providing us with a reserve to withdraw from + * @param max_age maximum allowed age, same for each coin + * @param expected_response_code which HTTP response code + * we expect from the exchange. + * @param amount how much we withdraw for the first coin + * @param ... NULL-terminated list of additional amounts to withdraw (one per coin) + * @return the withdraw command to be executed by the interpreter. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_age_withdraw (const char *label, + const char *reserve_reference, + uint8_t max_age, + unsigned int expected_response_code, + const char *amount, + ...); + +/** + * Create a "age-withdraw reveal" command. + * + * @param label command label. + * @param age_withdraw_reference reference to a "age-withdraw" command. + * @param expected_response_code expected HTTP response code. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_age_withdraw_reveal ( + const char *label, + const char *age_withdraw_reference, + unsigned int expected_response_code); + +/** * Create a withdraw command, letting the caller specify * the desired amount as string and also re-using an existing * coin private key in the process (violating the specification, @@ -1270,8 +1149,9 @@ TALER_TESTING_cmd_withdraw_amount (const char *label, * @param label command label. * @param reserve_reference command providing us with a reserve to withdraw from * @param amount how much we withdraw. + * @param age if > 0, age restriction applies. * @param coin_ref reference to (withdraw/reveal) command of a coin - * from which we should re-use the private key + * from which we should reuse the private key * @param expected_response_code which HTTP response code * we expect from the exchange. * @return the withdraw command to be executed by the interpreter. @@ -1281,6 +1161,7 @@ TALER_TESTING_cmd_withdraw_amount_reuse_key ( const char *label, const char *reserve_reference, const char *amount, + uint8_t age, const char *coin_ref, unsigned int expected_response_code); @@ -1317,25 +1198,56 @@ TALER_TESTING_cmd_withdraw_with_retry (struct TALER_TESTING_Command cmd); /** - * Create a "wire" command. + * Create a GET "reserves" command. + * + * @param label the command label. + * @param reserve_reference reference to the reserve to check. + * @param expected_balance expected balance for the reserve. + * @param expected_response_code expected HTTP response code. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_status (const char *label, + const char *reserve_reference, + const char *expected_balance, + unsigned int expected_response_code); + + +/** + * Create a GET "reserves" command with a @a timeout. * * @param label the command label. - * @param expected_method which wire-transfer method is expected - * to be offered by the exchange. - * @param expected_fee the fee the exchange should charge. - * @param expected_response_code the HTTP response the exchange - * should return. + * @param reserve_reference reference to the reserve to check. + * @param expected_balance expected balance for the reserve. + * @param timeout how long to long-poll for the reserve to exist. + * @param expected_response_code expected HTTP response code. * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_wire (const char *label, - const char *expected_method, - const char *expected_fee, - unsigned int expected_response_code); +TALER_TESTING_cmd_reserve_poll (const char *label, + const char *reserve_reference, + const char *expected_balance, + struct GNUNET_TIME_Relative timeout, + unsigned int expected_response_code); /** - * Create a GET "reserves" command. + * Wait for #TALER_TESTING_cmd_reserve_poll() to finish. + * Fail if it did not conclude by the timeout. + * + * @param label our label + * @param timeout how long to give the long poll to finish + * @param poll_reference reference to a #TALER_TESTING_cmd_reserve_poll() command + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_reserve_poll_finish (const char *label, + struct GNUNET_TIME_Relative timeout, + const char *poll_reference); + + +/** + * Create a GET "/reserves/$RID/history" command. * * @param label the command label. * @param reserve_reference reference to the reserve to check. @@ -1344,20 +1256,97 @@ TALER_TESTING_cmd_wire (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_status (const char *label, - const char *reserve_reference, - const char *expected_balance, - unsigned int expected_response_code); +TALER_TESTING_cmd_reserve_history (const char *label, + const char *reserve_reference, + const char *expected_balance, + unsigned int expected_response_code); + + +/** + * Create a GET "/coins/$COIN_PUB/history" command. + * + * @param label the command label. + * @param coin_reference reference to the coin to check. + * @param expected_balance expected balance for the coin. + * @param expected_response_code expected HTTP response code. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_coin_history (const char *label, + const char *coin_reference, + const char *expected_balance, + unsigned int expected_response_code); + /** - * Index of the deposit value trait of a deposit command. + * Create a POST "/reserves/$RID/open" command. + * + * @param label the command label. + * @param reserve_reference reference to the reserve to open. + * @param reserve_pay amount to pay from the reserve balance + * @param expiration_time how long into the future should the reserve remain open + * @param min_purses minimum number of purses to allow + * @param expected_response_code expected HTTP response code. + * @param ... NULL terminated list of pairs of coin references and amounts + * @return the command. */ -#define TALER_TESTING_CMD_DEPOSIT_TRAIT_IDX_DEPOSIT_VALUE 0 +struct TALER_TESTING_Command +TALER_TESTING_cmd_reserve_open (const char *label, + const char *reserve_reference, + const char *reserve_pay, + struct GNUNET_TIME_Relative expiration_time, + uint32_t min_purses, + unsigned int expected_response_code, + ...); + /** - * Index of the deposit fee trait of a deposit command. + * Create a GET "/reserves/$RID/attest" command. + * + * @param label the command label. + * @param reserve_reference reference to the reserve to get attestable attributes of. + * @param expected_response_code expected HTTP response code. + * @param ... NULL-terminated list of attributes expected + * @return the command. */ -#define TALER_TESTING_CMD_DEPOSIT_TRAIT_IDX_DEPOSIT_FEE 1 +struct TALER_TESTING_Command +TALER_TESTING_cmd_reserve_get_attestable (const char *label, + const char *reserve_reference, + unsigned int expected_response_code, + ...); + + +/** + * Create a POST "/reserves/$RID/attest" command. + * + * @param label the command label. + * @param reserve_reference reference to the reserve to get attests for + * @param expected_response_code expected HTTP response code. + * @param ... NULL-terminated list of attributes that should be attested + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_reserve_attest (const char *label, + const char *reserve_reference, + unsigned int expected_response_code, + ...); + + +/** + * Create a POST "/reserves/$RID/close" command. + * + * @param label the command label. + * @param reserve_reference reference to the reserve to close. + * @param target_account where to wire funds remaining, can be NULL + * @param expected_response_code expected HTTP response code. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_reserve_close (const char *label, + const char *reserve_reference, + const char *target_account, + unsigned int expected_response_code); + /** * Create a "deposit" command. @@ -1450,6 +1439,31 @@ TALER_TESTING_cmd_deposit_replay (const char *label, /** + * Create a "batch deposit" command. + * + * @param label command label. + * @param target_account_payto target account for the "deposit" + * request. + * @param contract_terms contract terms to be signed over by the + * coin. + * @param refund_deadline refund deadline, zero means 'no refunds'. + * @param expected_response_code expected HTTP response code. + * @param ... NULL-terminated list with an even number of + * strings that alternate referring to coins + * (possibly with index using label#index notation) + * and the amount of that coin to deposit + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_batch_deposit (const char *label, + const char *target_account_payto, + const char *contract_terms, + struct GNUNET_TIME_Relative refund_deadline, + unsigned int expected_response_code, + ...); + + +/** * Create a "refresh melt" command. * * @param label command label. @@ -1554,7 +1568,6 @@ TALER_TESTING_cmd_refresh_link_with_retry (struct TALER_TESTING_Command cmd); * @param bank_transfer_reference reference to a command that * can offer a WTID so as to check that against what WTID * the tracked operation has. Set as NULL if not needed. - * * @return the command. */ struct TALER_TESTING_Command @@ -1575,15 +1588,12 @@ TALER_TESTING_cmd_track_transaction (const char *label, * a wtid. If NULL is given, then a all zeroed WTID is * used that will at 99.9999% probability NOT match any * existing WTID known to the exchange. - * @param index index number of the WTID to track, in case there - * are multiple on offer. * @param expected_response_code expected HTTP response code. * @return the command. */ struct TALER_TESTING_Command TALER_TESTING_cmd_track_transfer_empty (const char *label, const char *wtid_reference, - unsigned int index, unsigned int expected_response_code); @@ -1594,8 +1604,6 @@ TALER_TESTING_cmd_track_transfer_empty (const char *label, * @param label the command label. * @param wtid_reference reference to any command which can provide * a wtid. Will be the one tracked. - * @param index in case there are multiple WTID offered, this - * parameter selects a particular one. * @param expected_response_code expected HTTP response code. * @param expected_total_amount how much money we expect being moved * with this wire-transfer. @@ -1605,11 +1613,11 @@ TALER_TESTING_cmd_track_transfer_empty (const char *label, struct TALER_TESTING_Command TALER_TESTING_cmd_track_transfer (const char *label, const char *wtid_reference, - unsigned int index, unsigned int expected_response_code, const char *expected_total_amount, const char *expected_wire_fee); + /** * Make a "bank check" CMD. It checks whether a particular wire transfer from * the exchange (debit) has been made or not. @@ -1688,14 +1696,13 @@ TALER_TESTING_cmd_check_bank_empty (const char *label); * provide a coin to be refunded. * @param refund_transaction_id transaction id to use * in the request. - * * @return the command. */ struct TALER_TESTING_Command TALER_TESTING_cmd_refund_with_id (const char *label, unsigned int expected_response_code, const char *refund_amount, - const char *deposit_reference, + const char *coin_reference, uint64_t refund_transaction_id); @@ -1707,14 +1714,13 @@ TALER_TESTING_cmd_refund_with_id (const char *label, * @param refund_amount the amount to ask a refund for. * @param coin_reference reference to a command that can * provide a coin to be refunded. - * * @return the command. */ struct TALER_TESTING_Command TALER_TESTING_cmd_refund (const char *label, unsigned int expected_response_code, const char *refund_amount, - const char *deposit_reference); + const char *coin_reference); /** @@ -1726,7 +1732,6 @@ TALER_TESTING_cmd_refund (const char *label, * offers a coin and reserve private key. May specify * the index of the coin using "$LABEL#$INDEX" syntax. * Here, $INDEX must be a non-negative number. - * @param melt_reference NULL if coin was not refreshed, otherwise label of the melt operation * @param amount how much do we expect to recoup, NULL for nothing * @return the command. */ @@ -1734,11 +1739,31 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_recoup (const char *label, unsigned int expected_response_code, const char *coin_reference, - const char *melt_reference, const char *amount); /** + * Make a "recoup-refresh" command. + * + * @param label the command label + * @param expected_response_code expected HTTP status code + * @param coin_reference reference to any command which + * offers a coin and reserve private key. May specify + * the index of the coin using "$LABEL#$INDEX" syntax. + * Here, $INDEX must be a non-negative number. + * @param melt_reference label of the melt operation + * @param amount how much do we expect to recoup, NULL for nothing + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_recoup_refresh (const char *label, + unsigned int expected_response_code, + const char *coin_reference, + const char *melt_reference, + const char *amount); + + +/** * Make a "revoke" command. * * @param label the command label. @@ -1794,60 +1819,6 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_wait_service (const char *label, const char *url); - -/** - * Make a "check keys" command. - * - * @param label command label - * @param generation how many /keys responses are expected to - * have been returned when this CMD will be run. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys (const char *label, - unsigned int generation); - - -/** - * Make a "check keys" command that forcedly does NOT cherry pick; - * just redownload the whole /keys. - * - * @param label command label - * @param generation when this command is run, exactly @a - * generation /keys downloads took place. If the number - * of downloads is less than @a generation, the logic will - * first make sure that @a generation downloads are done, - * and _then_ execute the rest of the command. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_pull_all_keys (const char *label, - unsigned int generation); - - -/** - * Make a "check keys" command. It lets the user set a last denom issue date to be - * used in the request for /keys. - * - * @param label command label - * @param generation when this command is run, exactly @a - * generation /keys downloads took place. If the number - * of downloads is less than @a generation, the logic will - * first make sure that @a generation downloads are done, - * and _then_ execute the rest of the command. - * @param last_denom_date_ref previous /keys command to use to - * obtain the "last_denom_date" value from; "zero" can be used - * as a special value to force an absolute time of zero to be - * given to as an argument - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_with_last_denom ( - const char *label, - unsigned int generation, - const char *last_denom_date_ref); - - /** * Create a "batch" command. Such command takes a * end_CMD-terminated array of CMDs and executed them. @@ -1870,16 +1841,21 @@ TALER_TESTING_cmd_batch (const char *label, * * @return false if not, true if it is a batch command */ -int +bool TALER_TESTING_cmd_is_batch (const struct TALER_TESTING_Command *cmd); + /** * Advance internal pointer to next command. * * @param is interpreter state. + * @param[in,out] cls closure of the batch + * @return true to advance IP in parent */ -void -TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is); +bool +TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is, + void *cls); + /** * Obtain what command the batch is at. @@ -1902,34 +1878,10 @@ TALER_TESTING_cmd_batch_set_current (const struct TALER_TESTING_Command *cmd, /** - * Make a serialize-keys CMD. - * - * @param label CMD label - * @return the CMD. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_serialize_keys (const char *label); - - -/** - * Make a connect-with-state CMD. This command - * will use a serialized key state to reconnect - * to the exchange. - * - * @param label command label - * @param state_reference label of a CMD offering - * a serialized key state. - * @return the CMD. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_connect_with_state (const char *label, - const char *state_reference); - -/** * Make the "insert-deposit" CMD. * * @param label command label. - * @param dbc collects plugin and session handles + * @param db_cfg configuration to talk to the DB * @param merchant_name Human-readable name of the merchant. * @param merchant_account merchant's account name (NOT a payto:// URI) * @param exchange_timestamp when did the exchange receive the deposit @@ -1942,10 +1894,10 @@ TALER_TESTING_cmd_connect_with_state (const char *label, struct TALER_TESTING_Command TALER_TESTING_cmd_insert_deposit ( const char *label, - const struct TALER_TESTING_DatabaseConnection *dbc, + const struct GNUNET_CONFIGURATION_Handle *db_cfg, const char *merchant_name, const char *merchant_account, - struct GNUNET_TIME_Absolute exchange_timestamp, + struct GNUNET_TIME_Timestamp exchange_timestamp, struct GNUNET_TIME_Relative wire_deadline, const char *amount_with_fee, const char *deposit_fee); @@ -1967,7 +1919,7 @@ struct TALER_TESTING_Timer struct GNUNET_TIME_Relative total_duration; /** - * Total time spend waiting for the *successful* exeuction + * Total time spend waiting for the *successful* execution * in all commands of this type. */ struct GNUNET_TIME_Relative success_latency; @@ -2044,6 +1996,7 @@ TALER_TESTING_cmd_auditor_add_denom_sig (const char *label, const char *denom_ref, bool bad_sig); + /** * Add statement about wire fees of the exchange. This is always * done for a few hours around the current time (for the test). @@ -2098,6 +2051,19 @@ TALER_TESTING_cmd_wire_del (const char *label, unsigned int expected_http_status, bool bad_sig); +/** + * Sign all extensions that the exchange has to offer, f. e. the extension for + * age restriction. This has to be run before any withdrawal of age restricted + * can be performed. + * + * @param label command label. + * @param config_filename configuration filename. + * @return the command + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_offline_sign_extensions (const char *label, + const char *config_filename); + /** * Sign all exchange denomination and online signing keys @@ -2115,7 +2081,7 @@ TALER_TESTING_cmd_exec_offline_sign_keys (const char *label, /** - * Sign a wire fee. + * Sign a wire fee structure. * * @param label command label. * @param config_filename configuration filename. @@ -2131,6 +2097,31 @@ TALER_TESTING_cmd_exec_offline_sign_fees (const char *label, /** + * Sign global fee structure. + * + * @param label command label. + * @param config_filename configuration filename. + * @param history_fee the history fee to charge (for the current year) + * @param account_fee the account fee to charge (for the current year) + * @param purse_fee the purse fee to charge (for the current year) + * @param purse_timeout when do purses time out + * @param history_expiration when does an account history expire + * @param num_purses number of (free) active purses per account + * @return the command + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exec_offline_sign_global_fees ( + const char *label, + const char *config_filename, + const char *history_fee, + const char *account_fee, + const char *purse_fee, + struct GNUNET_TIME_Relative purse_timeout, + struct GNUNET_TIME_Relative history_expiration, + unsigned int num_purses); + + +/** * Revoke an exchange denomination key. * * @param label command label. @@ -2169,482 +2160,340 @@ TALER_TESTING_cmd_revoke_sign_key ( /** - * Have the auditor affirm that it is auditing the given - * denomination key and upload the auditor's signature to - * the exchange. + * Create a request for a wallet's KYC UUID. * * @param label command label. - * @param expected_http_status expected HTTP status from exchange - * @param denom_ref reference to a command that identifies - * a denomination key (i.e. because it was used to - * withdraw a coin). - * @param bad_sig should we use a bogus signature? + * @param reserve_reference command with reserve private key to use (or NULL to create a fresh reserve key). + * @param threshold_balance balance amount to pass to the exchange + * @param expected_response_code expected HTTP status * @return the command */ struct TALER_TESTING_Command -TALER_TESTING_cmd_auditor_add_denom_sig (const char *label, - unsigned int expected_http_status, - const char *denom_ref, - bool bad_sig); - - -/* *** Generic trait logic for implementing traits ********* */ - -/** - * A trait. - */ -struct TALER_TESTING_Trait -{ - /** - * Index number associated with the trait. This gives the - * possibility to have _multiple_ traits on offer under the - * same name. - */ - unsigned int index; - - /** - * Trait type, for example "reserve-pub" or "coin-priv". - */ - const char *trait_name; - - /** - * Pointer to the piece of data to offer. - */ - const void *ptr; -}; - - -/** - * "end" trait. Because traits are offered into arrays, - * this type of trait is used to mark the end of such arrays; - * useful when iterating over those. - */ -struct TALER_TESTING_Trait -TALER_TESTING_trait_end (void); - - -/** - * Extract a trait. - * - * @param traits the array of all the traits. - * @param[out] ret where to store the result. - * @param trait type of the trait to extract. - * @param index index number of the trait to extract. - * @return #GNUNET_OK when the trait is found. - */ -int -TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, - const void **ret, - const char *trait, - unsigned int index); - - -/* ****** Specific traits supported by this component ******* */ - - -/** - * Obtain a bank transaction row value from @a cmd. - * - * @param cmd command to extract the number from. - * @param[out] row set to the number coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_bank_row (const struct TALER_TESTING_Command *cmd, - const uint64_t **row); - - -/** - * Offer bank transaction row trait. - * - * @param row number to offer. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_bank_row (const uint64_t *row); - - -/** - * Offer a reserve private key. - * - * @param index reserve priv's index number. - * @param reserve_priv reserve private key to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_reserve_priv ( - unsigned int index, - const struct TALER_ReservePrivateKeyP *reserve_priv); - - -/** - * Obtain a reserve private key from a @a cmd. - * - * @param cmd command to extract the reserve priv from. - * @param index reserve priv's index number. - * @param[out] reserve_priv set to the reserve priv. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_reserve_priv ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ReservePrivateKeyP **reserve_priv); - - -/** - * Offer a reserve public key. - * - * @param index reserve pubs's index number. - * @param reserve_pub reserve public key to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_reserve_pub ( - unsigned int index, - const struct TALER_ReservePublicKeyP *reserve_pub); - - -/** - * Obtain a reserve public key from a @a cmd. - * - * @param cmd command to extract the reserve pub from. - * @param index reserve pub's index number. - * @param[out] reserve_pub set to the reserve pub. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_reserve_pub ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ReservePublicKeyP **reserve_pub); - - -/** - * Offer a reserve history entry. - * - * @param index reserve pubs's index number. - * @param rh reserve history entry to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_reserve_history ( - unsigned int index, - const struct TALER_EXCHANGE_ReserveHistory *rh); - - -/** - * Obtain a reserve history entry from a @a cmd. - * - * @param cmd command to extract the reserve history from. - * @param index reserve history's index number. - * @param[out] rhp set to the reserve history. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_reserve_history ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_EXCHANGE_ReserveHistory **rhp); +TALER_TESTING_cmd_wallet_kyc_get (const char *label, + const char *reserve_reference, + const char *threshold_balance, + unsigned int expected_response_code); /** - * Make a trait for a exchange signature. + * Create a request for an account's KYC status. * - * @param index index number to associate to the offered exchange pub. - * @param exchange_sig exchange signature to offer with this trait. - * - * @return the trait. + * @param label command label. + * @param payment_target_reference command with a payment target to query + * @param expected_response_code expected HTTP status + * @return the command */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_exchange_sig ( - unsigned int index, - const struct TALER_ExchangeSignatureP *exchange_sig); +struct TALER_TESTING_Command +TALER_TESTING_cmd_check_kyc_get (const char *label, + const char *payment_target_reference, + unsigned int expected_response_code); /** - * Obtain a exchange signature (online sig) from a @a cmd. + * Create a KYC proof request. Only useful in conjunction with the OAuth2.0 + * logic, as it generates an OAuth2.0-specific request. * - * @param cmd command to extract trait from - * @param index index number of the exchange to obtain. - * @param[out] exchange_sig set to the offered exchange signature. - * @return #GNUNET_OK on success. + * @param label command label. + * @param payment_target_reference command with a payment target to query + * @param logic_section name of the KYC provider section + * in the exchange configuration for this proof + * @param code OAuth 2.0 code to use + * @param expected_response_code expected HTTP status + * @return the command */ -int -TALER_TESTING_get_trait_exchange_sig ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ExchangeSignatureP **exchange_sig); +struct TALER_TESTING_Command +TALER_TESTING_cmd_proof_kyc_oauth2 ( + const char *label, + const char *payment_target_reference, + const char *logic_section, + const char *code, + unsigned int expected_response_code); /** - * Make a trait for a exchange public key. - * - * @param index index number to associate to the offered exchange pub. - * @param exchange_pub exchange pub to offer with this trait. + * Starts a fake OAuth 2.0 service on @a port for testing + * KYC processes which also provides a @a birthdate in a response * - * @return the trait. + * @param label command label + * @param birthdate fixed birthdate, such as "2022-03-04", "2022-03-00", "2022-00-00" + * @param port the TCP port to listen on */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_exchange_pub ( - unsigned int index, - const struct TALER_ExchangePublicKeyP *exchange_pub); - +struct TALER_TESTING_Command +TALER_TESTING_cmd_oauth_with_birthdate (const char *label, + const char *birthdate, + uint16_t port); /** - * Obtain a exchange public key from a @a cmd. + * Starts a fake OAuth 2.0 service on @a port for testing + * KYC processes. * - * @param cmd command to extract trait from - * @param index index number of the exchange to obtain. - * @param[out] exchange_pub set to the offered exchange pub. - * @return #GNUNET_OK on success. + * @param label command label + * @param port the TCP port to listen on */ -int -TALER_TESTING_get_trait_exchange_pub ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ExchangePublicKeyP **exchange_pub); +#define TALER_TESTING_cmd_oauth(label, port) \ + TALER_TESTING_cmd_oauth_with_birthdate ((label), NULL, (port)) -/** - * Obtain location where a command stores a pointer to a process. - * - * @param cmd command to extract trait from. - * @param index which process to pick if @a cmd - * has multiple on offer. - * @param[out] processp set to the address of the pointer to the - * process. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_process (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct GNUNET_OS_Process ***processp); +/* ****************** P2P payment commands ****************** */ /** - * Offer location where a command stores a pointer to a process. + * Creates a purse with deposits. * - * @param index offered location index number, in case there are - * multiple on offer. - * @param processp process location to offer. - * @return the trait. + * @param label command label + * @param expected_http_status what HTTP status do we expect to get returned from the exchange + * @param contract_terms contract, JSON string + * @param upload_contract should we upload the contract + * @param purse_expiration how long until the purse expires + * @param ... NULL-terminated list of references to coins to be deposited + * @return the command */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_process (unsigned int index, - struct GNUNET_OS_Process **processp); - +struct TALER_TESTING_Command +TALER_TESTING_cmd_purse_create_with_deposit ( + const char *label, + unsigned int expected_http_status, + const char *contract_terms, + bool upload_contract, + struct GNUNET_TIME_Relative purse_expiration, + ...); -/** - * Offer coin private key. - * - * @param index index number to associate with offered coin priv. - * @param coin_priv coin private key to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_coin_priv ( - unsigned int index, - const struct TALER_CoinSpendPrivateKeyP *coin_priv); /** - * Obtain a coin private key from a @a cmd. + * Deletes a purse. * - * @param cmd command to extract trait from. - * @param index index of the coin priv to obtain. - * @param[out] coin_priv set to the private key of the coin. - * @return #GNUNET_OK on success. + * @param label command label + * @param expected_http_status what HTTP status do we expect to get returned from the exchange + * @param purse_cmd command that created the purse + * @return the command */ -int -TALER_TESTING_get_trait_coin_priv ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_CoinSpendPrivateKeyP **coin_priv); +struct TALER_TESTING_Command +TALER_TESTING_cmd_purse_delete ( + const char *label, + unsigned int expected_http_status, + const char *purse_cmd); /** - * Offer blinding key. + * Retrieve contract (also checks that the contract matches + * the upload command). * - * @param index index number to associate to the offered key. - * @param blinding_key blinding key to offer. - * @return the trait. + * @param label command label + * @param expected_http_status what HTTP status do we expect to get returned from the exchange + * @param for_merge true if for merge, false if for deposit + * @param contract_ref reference to a command providing us with the contract private key + * @return the command */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_blinding_key ( - unsigned int index, - const struct TALER_DenominationBlindingKeyP *blinding_key); +struct TALER_TESTING_Command +TALER_TESTING_cmd_contract_get ( + const char *label, + unsigned int expected_http_status, + bool for_merge, + const char *contract_ref); /** - * Obtain a blinding key from a @a cmd. + * Retrieve purse state by merge private key. * - * @param cmd command to extract trait from - * @param index which coin to pick if @a cmd has multiple on offer. - * @param[out] blinding_key set to the offered blinding key. - * @return #GNUNET_OK on success. + * @param label command label + * @param expected_http_status what HTTP status do we expect to get returned from the exchange + * @param merge_ref reference to a command providing us with the merge private key + * @param reserve_ref reference to a command providing us with a reserve private key; if NULL, we create a fresh reserve + * @return the command */ -int -TALER_TESTING_get_trait_blinding_key ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_DenominationBlindingKeyP **blinding_key); +struct TALER_TESTING_Command +TALER_TESTING_cmd_purse_merge ( + const char *label, + unsigned int expected_http_status, + const char *merge_ref, + const char *reserve_ref); /** - * Make a trait for a denomination public key. + * Retrieve purse state. * - * @param index index number to associate to the offered denom pub. - * @param denom_pub denom pub to offer with this trait. - * @return the trait. + * @param label command label + * @param expected_http_status what HTTP status do we expect to get returned from the exchange + * @param purse_ref reference to a command providing us with the purse private key + * @param expected_balance how much should be in the purse + * @param wait_for_merge true to wait for a merge event, otherwise wait for a deposit event + * @param timeout how long to wait + * @return the command */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_denom_pub ( - unsigned int index, - const struct TALER_EXCHANGE_DenomPublicKey *dpk); +struct TALER_TESTING_Command +TALER_TESTING_cmd_purse_poll ( + const char *label, + unsigned int expected_http_status, + const char *purse_ref, + const char *expected_balance, + bool wait_for_merge, + struct GNUNET_TIME_Relative timeout); /** - * Obtain a denomination public key from a @a cmd. + * Wait for the poll command to complete. * - * @param cmd command to extract trait from - * @param index index number of the denom to obtain. - * @param[out] denom_pub set to the offered denom pub. - * @return #GNUNET_OK on success. + * @param label command label + * @param timeout how long to wait at most + * @param poll_reference which poll command to wait for + * @return the command */ -int -TALER_TESTING_get_trait_denom_pub ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_EXCHANGE_DenomPublicKey **dpk); +struct TALER_TESTING_Command +TALER_TESTING_cmd_purse_poll_finish (const char *label, + struct GNUNET_TIME_Relative timeout, + const char *poll_reference); /** - * Obtain a denomination signature from a @a cmd. + * Creates a purse with reserve. * - * @param cmd command to extract the denom sig from. - * @param index index number associated with the denom sig. - * @param[out] denom_sig set to the offered signature. - * @return #GNUNET_OK on success. + * @param label command label + * @param expected_http_status what HTTP status do we expect to get returned from the exchange + * @param contract_terms contract, JSON string + * @param upload_contract should we upload the contract + * @param pay_purse_fee should we pay a fee to create the purse + * @param expiration when should the purse expire + * @param reserve_ref reference to reserve key, or NULL to create a new reserve + * @return the command */ -int -TALER_TESTING_get_trait_denom_sig ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_DenominationSignature **dpk); +struct TALER_TESTING_Command +TALER_TESTING_cmd_purse_create_with_reserve ( + const char *label, + unsigned int expected_http_status, + const char *contract_terms, + bool upload_contract, + bool pay_purse_fee, + struct GNUNET_TIME_Relative expiration, + const char *reserve_ref); /** - * Offer denom sig. + * Deposit coins into a purse. * - * @param index index number to associate to the signature on - * offer. - * @param denom_sig the denom sig on offer. - * @return the trait. + * @param label command label + * @param expected_http_status what HTTP status do we expect to get returned from the exchange + * @param min_age age restriction of the purse + * @param purse_ref reference to the purse + * @param ... NULL-terminated list of references to coins to be deposited + * @return the command */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_denom_sig ( - unsigned int index, - const struct TALER_DenominationSignature *sig); +struct TALER_TESTING_Command +TALER_TESTING_cmd_purse_deposit_coins ( + const char *label, + unsigned int expected_http_status, + uint8_t min_age, + const char *purse_ref, + ...); /** - * Offer number trait, 32-bit version. + * Setup AML officer. * - * @param index the number's index number. - * @param n number to offer. + * @param label command label + * @param ref_cmd command that previously created the + * officer, NULL to create one this time + * @param name full legal name of the officer to use + * @param is_active true to set the officer to active + * @param read_only true to restrict the officer to read-only + * @return the command */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_uint32 (unsigned int index, - const uint32_t *n); +struct TALER_TESTING_Command +TALER_TESTING_cmd_set_officer ( + const char *label, + const char *ref_cmd, + const char *name, + bool is_active, + bool read_only); /** - * Obtain a "number" value from @a cmd, 32-bit version. + * Make AML decision. * - * @param cmd command to extract the number from. - * @param index the number's index number. - * @param[out] n set to the number coming from @a cmd. - * @return #GNUNET_OK on success. + * @param label command label + * @param ref_officer command that previously created an + * officer + * @param ref_operation command that previously created an + * h_payto which to make an AML decision about + * @param new_threshold new threshold to set + * @param justification justification given for the decision + * @param new_state new AML state for the account + * @param kyc_requirement KYC requirement to impose + * @param expected_response expected HTTP return status + * @return the command */ -int -TALER_TESTING_get_trait_uint32 (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const uint32_t **n); +struct TALER_TESTING_Command +TALER_TESTING_cmd_take_aml_decision ( + const char *label, + const char *ref_officer, + const char *ref_operation, + const char *new_threshold, + const char *justification, + enum TALER_AmlDecisionState new_state, + const char *kyc_requirement, + unsigned int expected_response); /** - * Offer number trait, 64-bit version. + * Fetch AML decision. * - * @param index the number's index number. - * @param n number to offer. + * @param label command label + * @param ref_officer command that previously created an + * officer + * @param ref_operation command that previously created an + * h_payto which to make an AML decision about + * @param expected_http_status expected HTTP response status + * @return the command */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_uint64 (unsigned int index, - const uint64_t *n); +struct TALER_TESTING_Command +TALER_TESTING_cmd_check_aml_decision ( + const char *label, + const char *ref_officer, + const char *ref_operation, + unsigned int expected_http_status); /** - * Obtain a "number" value from @a cmd, 64-bit version. + * Fetch AML decisions. * - * @param cmd command to extract the number from. - * @param index the number's index number. - * @param[out] n set to the number coming from @a cmd. - * @return #GNUNET_OK on success. + * @param label command label + * @param ref_officer command that previously created an + * officer + * @param filter AML state to filter by + * @param expected_http_status expected HTTP response status + * @return the command */ -int -TALER_TESTING_get_trait_uint64 (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const uint64_t **n); - +struct TALER_TESTING_Command +TALER_TESTING_cmd_check_aml_decisions ( + const char *label, + const char *ref_officer, + enum TALER_AmlDecisionState filter, + unsigned int expected_http_status); -/** - * Offer number trait, 64-bit signed version. - * - * @param index the number's index number. - * @param n number to offer. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_int64 (unsigned int index, - const int64_t *n); +/* ****************** convenience functions ************** */ /** - * Obtain a "number" value from @a cmd, 64-bit signed version. + * Get exchange URL from interpreter. Convenience function. * - * @param cmd command to extract the number from. - * @param index the number's index number. - * @param[out] n set to the number coming from @a cmd. - * @return #GNUNET_OK on success. + * @param is interpreter state. + * @return the exchange URL, or NULL on error */ -int -TALER_TESTING_get_trait_int64 (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const int64_t **n); +const char * +TALER_TESTING_get_exchange_url ( + struct TALER_TESTING_Interpreter *is); /** - * Offer a number. + * Get exchange keys from interpreter. Convenience function. * - * @param index the number's index number. - * @param n the number to offer. - * @return #GNUNET_OK on success. + * @param is interpreter state. + * @return the exchange keys, or NULL on error */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_uint (unsigned int index, - const unsigned int *i); +struct TALER_EXCHANGE_Keys * +TALER_TESTING_get_keys ( + struct TALER_TESTING_Interpreter *is); -/** - * Obtain a number from @a cmd. - * - * @param cmd command to extract the number from. - * @param index the number's index number. - * @param[out] n set to the number coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_uint (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const unsigned int **n); +/* *** Generic trait logic for implementing traits ********* */ /** @@ -2655,579 +2504,234 @@ struct TALER_TESTING_FreshCoinData; /** - * Offer a _array_ of fresh coins. - * - * @param index which array of fresh coins to offer, - * if there are multiple on offer. Typically passed as - * zero. - * @param fresh_coins the array of fresh coins to offer - * @return the trait, - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_fresh_coins ( - unsigned int index, - const struct TALER_TESTING_FreshCoinData *fresh_coins); - - -/** - * Get a array of fresh coins. - * - * @param cmd command to extract the fresh coin from. - * @param index which array to pick if @a cmd has multiple - * on offer. - * @param[out] fresh_coins will point to the offered array. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_fresh_coins ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_TESTING_FreshCoinData **fresh_coins); - - -/** - * Obtain contract terms from @a cmd. - * - * @param cmd command to extract the contract terms from. - * @param index contract terms index number. - * @param[out] contract_terms where to write the contract - * terms. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_contract_terms (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **contract_terms); - - -/** - * Offer contract terms. - * - * @param index contract terms index number. - * @param contract_terms contract terms to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_contract_terms (unsigned int index, - const json_t *contract_terms); - - -/** - * Obtain wire details from @a cmd. - * - * @param cmd command to extract the wire details from. - * @param index index number associate with the wire details - * on offer; usually zero, as one command sticks to - * one bank account. - * @param[out] wire_details where to write the wire details. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_wire_details (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **wire_details); - - -/** - * Offer wire details in a trait. - * - * @param index index number associate with the wire details - * on offer; usually zero, as one command sticks to - * one bank account. - * @param wire_details wire details to offer. - * - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_wire_details (unsigned int index, - const json_t *wire_details); - - -/** - * Obtain serialized exchange keys from @a cmd. - * - * @param cmd command to extract the keys from. - * @param index index number associate with the keys on offer. - * @param[out] keys where to write the serialized keys. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_exchange_keys (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **keys); - - -/** - * Offer serialized keys in a trait. - * - * @param index index number associate with the serial keys - * on offer. - * @param keys serialized keys to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_exchange_keys (unsigned int index, - const json_t *keys); - - -/** - * Obtain json from @a cmd. - * - * @param cmd command to extract the json from. - * @param index index number associate with the json on offer. - * @param[out] json where to write the json. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_json (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const json_t **json); - - -/** - * Offer json in a trait. - * - * @param index index number associate with the json - * on offer. - * @param json json to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_json (unsigned int index, - const json_t *json); - - -/** - * Obtain a private key from a "merchant". Used e.g. to obtain - * a merchant's priv to sign a /track request. - * - * @param cmd command that is offering the key. - * @param index (typically zero) which key to return if there - * are multiple on offer. - * @param[out] priv set to the key coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_merchant_priv ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_MerchantPrivateKeyP **priv); - - -/** - * Offer private key of a merchant, typically done when CMD_1 needs it to - * sign a request. - * - * @param index (typically zero) which key to return if there are - * multiple on offer. - * @param priv which object should be offered. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_merchant_priv ( - unsigned int index, - const struct TALER_MerchantPrivateKeyP *priv); - - -/** - * Obtain a public key from a "merchant". Used e.g. to obtain - * a merchant's public key to use backend's API. - * - * @param cmd command offering the key. - * @param index (typically zero) which key to return if there - * are multiple on offer. - * @param[out] pub set to the key coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_merchant_pub ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_MerchantPublicKeyP **pub); - - -/** - * Offer public key. - * - * @param index (typically zero) which key to return if there - * are multiple on offer. NOTE: if one key is offered, it - * is mandatory to set this as zero. - * @param pub which object should be returned. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_merchant_pub ( - unsigned int index, - const struct TALER_MerchantPublicKeyP *pub); - - -/** - * Obtain a string from @a cmd. - * - * @param cmd command to extract the subject from. - * @param index index number associated with the transfer - * subject to offer. - * @param[out] s where to write the offered - * string. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_string ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **s); - - -/** - * Offer string subject. - * - * @param index index number associated with the transfer - * subject being offered. - * @param s string to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_string (unsigned int index, - const char *s); - - -/** - * Obtain a WTID value from @a cmd. - * - * @param cmd command to extract trait from - * @param index which WTID to pick if @a cmd has multiple on - * offer - * @param[out] wtid set to the wanted WTID. - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_get_trait_wtid ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_WireTransferIdentifierRawP **wtid); - - -/** - * Offer a WTID. - * - * @param index associate the WTID with this index. - * @param wtid pointer to the WTID to offer. - * @return the trait. + * A trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_wtid ( - unsigned int index, - const struct TALER_WireTransferIdentifierRawP *wtid); - - -/** - * Different types of URLs that appear in traits. - */ -enum TALER_TESTING_URL_Type { /** - * Category of last resort. Should not be used. - */ - TALER_TESTING_UT_UNDEFINED = 0, - - /** - * HTTP base URL of an exchange (API), as for example - * given in wire transfers subjects made by the aggregator. - */ - TALER_TESTING_UT_EXCHANGE_BASE_URL = 1, - - /** - * HTTP URL of the exchange's bank account at the bank. + * Index number associated with the trait. This gives the + * possibility to have _multiple_ traits on offer under the + * same name. */ - TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL = 2, + unsigned int index; /** - * A taler://-URL. + * Trait type, for example "reserve-pub" or "coin-priv". */ - TALER_TESTING_UT_TALER_URL = 3 -}; - - -/** - * Offer HTTP url in a trait. - * - * @param index which url is to be picked, - * in case multiple are offered. - * @param url the url to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_url (enum TALER_TESTING_URL_Type index, - const char *url); - - -/** - * Obtain a HTTP url from @a cmd. - * - * @param cmd command to extract the url from. - * @param index which url is to be picked, in case - * multiple are offered. - * @param[out] url where to write the url. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_url (const struct TALER_TESTING_Command *cmd, - enum TALER_TESTING_URL_Type index, - const char **url); - + const char *trait_name; -/** - * Used as the "index" in payto traits, to identify what kind of - * payto URL we are returning. - */ -enum TALER_TESTING_PaytoType -{ - /** - * We don't know / not credit or debit. - */ - TALER_TESTING_PT_NEUTRAL, - /** - * Credit side of a transaction. - */ - TALER_TESTING_PT_CREDIT, /** - * Debit side of a transaction. + * Pointer to the piece of data to offer. */ - TALER_TESTING_PT_DEBIT + const void *ptr; }; /** - * Offer a payto uri in a trait. - * - * @param pt which url is to be picked, - * in case multiple are offered. - * @param payto_uri the uri to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_payto (enum TALER_TESTING_PaytoType pt, - const char *payto_uri); - - -/** - * Obtain a PAYTO url from @a cmd. - * - * @param cmd command to extract the url from. - * @param pt which url is to be picked, in case - * multiple are offered. - * @param[out] url where to write the url. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_payto (const struct TALER_TESTING_Command *cmd, - enum TALER_TESTING_PaytoType pt, - const char **url); - - -/** - * Obtain a order id from @a cmd. - * - * @param cmd command to extract the order id from. - * @param index which order id is to be picked, in case - * multiple are offered. - * @param[out] order_id where to write the order id. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_order_id (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **order_id); - - -/** - * Offer order id in a trait. - * - * @param index which order id is to be offered, - * in case multiple are offered. - * @param order_id the order id to offer. - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_order_id (unsigned int index, - const char *order_id); - - -/** - * Obtain an amount from a @a cmd. - * - * @param cmd command to extract the amount from. - * @param index which amount to pick if @a cmd has multiple - * on offer - * @param[out] amount set to the amount. - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_get_trait_amount_obj (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_Amount **amount); - - -/** - * Offer amount. - * - * @param index which amount to offer, in case there are - * multiple available. - * @param amount the amount to offer. - * - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_amount_obj (unsigned int index, - const struct TALER_Amount *amount); - - -/** - * Offer a command in a trait. - * - * @param index always zero. Commands offering this - * kind of traits do not need this index. For - * example, a "meta" CMD returns always the - * CMD currently being executed. - * @param cmd wire details to offer. - * - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_cmd (unsigned int index, - const struct TALER_TESTING_Command *cmd); - - -/** - * Obtain a command from @a cmd. - * - * @param cmd command to extract the command from. - * @param index always zero. Commands offering this - * kind of traits do not need this index. For - * example, a "meta" CMD returns always the - * CMD currently being executed. - * @param[out] _cmd where to write the wire details. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_cmd (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct TALER_TESTING_Command **_cmd); - - -/** - * Obtain a uuid from @a cmd. - * - * @param cmd command to extract the uuid from. - * @param index which amount to pick if @a cmd has multiple - * on offer - * @param[out] uuid where to write the uuid. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_uuid (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct GNUNET_Uuid **uuid); - - -/** - * Offer a uuid in a trait. - * - * @param index which uuid to offer, in case there are - * multiple available. - * @param uuid the uuid to offer. - * - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_uuid (unsigned int index, - const struct GNUNET_Uuid *uuid); - - -/** - * Obtain a claim token from @a cmd. - * - * @param cmd command to extract the token from. - * @param index which amount to pick if @a cmd has multiple - * on offer - * @param[out] ct where to write the token. - * @return #GNUNET_OK on success. - */ -int -TALER_TESTING_get_trait_claim_token (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_ClaimTokenP **ct); - - -/** - * Offer a claim token in a trait. - * - * @param index which token to offer, in case there are - * multiple available. - * @param ct the token to offer. - * - * @return the trait. + * "end" trait. Because traits are offered into arrays, + * this type of trait is used to mark the end of such arrays; + * useful when iterating over those. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_claim_token (unsigned int index, - const struct TALER_ClaimTokenP *ct); +TALER_TESTING_trait_end (void); /** - * Obtain a absolute time from @a cmd. + * Extract a trait. * - * @param cmd command to extract trait from - * @param index which time stamp to pick if - * @a cmd has multiple on offer. - * @param[out] time set to the wanted WTID. - * @return #GNUNET_OK on success + * @param traits the array of all the traits. + * @param[out] ret where to store the result. + * @param trait type of the trait to extract. + * @param index index number of the trait to extract. + * @return #GNUNET_OK when the trait is found. */ -int -TALER_TESTING_get_trait_absolute_time ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_TIME_Absolute **time); +enum GNUNET_GenericReturnValue +TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, + const void **ret, + const char *trait, + unsigned int index); -/** - * Offer a absolute time. - * - * @param index associate the object with this index - * @param time which object should be returned - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_absolute_time ( - unsigned int index, - const struct GNUNET_TIME_Absolute *time); +/* ****** Specific traits supported by this component ******* */ /** - * Obtain a relative time from @a cmd. - * - * @param cmd command to extract trait from - * @param index which time to pick if - * @a cmd has multiple on offer. - * @param[out] time set to the wanted WTID. - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_get_trait_relative_time ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_TIME_Relative **time); - + * Create headers for a trait with name @a name for + * statically allocated data of type @a type. + */ +#define TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \ + enum GNUNET_GenericReturnValue \ + TALER_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + type **ret); \ + struct TALER_TESTING_Trait \ + TALER_TESTING_make_trait_ ## name ( \ + type * value); + + +/** + * Create C implementation for a trait with name @a name for statically + * allocated data of type @a type. + */ +#define TALER_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \ + enum GNUNET_GenericReturnValue \ + TALER_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + type **ret) \ + { \ + if (NULL == cmd->traits) return GNUNET_SYSERR; \ + return cmd->traits (cmd->cls, \ + (const void **) ret, \ + TALER_S (name), \ + 0); \ + } \ + struct TALER_TESTING_Trait \ + TALER_TESTING_make_trait_ ## name ( \ + type * value) \ + { \ + struct TALER_TESTING_Trait ret = { \ + .trait_name = TALER_S (name), \ + .ptr = (const void *) value \ + }; \ + return ret; \ + } + + +/** + * Create headers for a trait with name @a name for + * statically allocated data of type @a type. + */ +#define TALER_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \ + enum GNUNET_GenericReturnValue \ + TALER_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + unsigned int index, \ + type **ret); \ + struct TALER_TESTING_Trait \ + TALER_TESTING_make_trait_ ## name ( \ + unsigned int index, \ + type * value); + + +/** + * Create C implementation for a trait with name @a name for statically + * allocated data of type @a type. + */ +#define TALER_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \ + enum GNUNET_GenericReturnValue \ + TALER_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + unsigned int index, \ + type **ret) \ + { \ + if (NULL == cmd->traits) return GNUNET_SYSERR; \ + return cmd->traits (cmd->cls, \ + (const void **) ret, \ + TALER_S (name), \ + index); \ + } \ + struct TALER_TESTING_Trait \ + TALER_TESTING_make_trait_ ## name ( \ + unsigned int index, \ + type * value) \ + { \ + struct TALER_TESTING_Trait ret = { \ + .index = index, \ + .trait_name = TALER_S (name), \ + .ptr = (const void *) value \ + }; \ + return ret; \ + } + + +/** + * Call #op on all simple traits. + */ +#define TALER_TESTING_SIMPLE_TRAITS(op) \ + op (bank_row, const uint64_t) \ + op (officer_pub, const struct TALER_AmlOfficerPublicKeyP) \ + op (officer_priv, const struct TALER_AmlOfficerPrivateKeyP) \ + op (officer_name, const char) \ + op (aml_decision, enum TALER_AmlDecisionState) \ + op (aml_justification, const char) \ + op (auditor_priv, const struct TALER_AuditorPrivateKeyP) \ + op (auditor_pub, const struct TALER_AuditorPublicKeyP) \ + op (master_priv, const struct TALER_MasterPrivateKeyP) \ + op (master_pub, const struct TALER_MasterPublicKeyP) \ + op (purse_priv, const struct TALER_PurseContractPrivateKeyP) \ + op (purse_pub, const struct TALER_PurseContractPublicKeyP) \ + op (merge_priv, const struct TALER_PurseMergePrivateKeyP) \ + op (merge_pub, const struct TALER_PurseMergePublicKeyP) \ + op (contract_priv, const struct TALER_ContractDiffiePrivateP) \ + op (reserve_priv, const struct TALER_ReservePrivateKeyP) \ + op (reserve_sig, const struct TALER_ReserveSignatureP) \ + op (h_payto, const struct TALER_PaytoHashP) \ + op (planchet_secret, const struct TALER_PlanchetMasterSecretP) \ + op (refresh_secret, const struct TALER_RefreshMasterSecretP) \ + op (reserve_pub, const struct TALER_ReservePublicKeyP) \ + op (merchant_priv, const struct TALER_MerchantPrivateKeyP) \ + op (merchant_pub, const struct TALER_MerchantPublicKeyP) \ + op (merchant_sig, const struct TALER_MerchantSignatureP) \ + op (wtid, const struct TALER_WireTransferIdentifierRawP) \ + op (bank_auth_data, const struct TALER_BANK_AuthenticationData) \ + op (contract_terms, const json_t) \ + op (wire_details, const json_t) \ + op (exchange_url, const char) \ + op (auditor_url, const char) \ + op (exchange_bank_account_url, const char) \ + op (taler_uri, const char) \ + op (payto_uri, const char) \ + op (kyc_url, const char) \ + op (web_url, const char) \ + op (row, const uint64_t) \ + op (legi_requirement_row, const uint64_t) \ + op (array_length, const unsigned int) \ + op (credit_payto_uri, const char) \ + op (debit_payto_uri, const char) \ + op (order_id, const char) \ + op (amount, const struct TALER_Amount) \ + op (amount_with_fee, const struct TALER_Amount) \ + op (batch_cmds, struct TALER_TESTING_Command) \ + op (uuid, const struct GNUNET_Uuid) \ + op (fresh_coins, const struct TALER_TESTING_FreshCoinData *) \ + op (claim_token, const struct TALER_ClaimTokenP) \ + op (relative_time, const struct GNUNET_TIME_Relative) \ + op (fakebank, struct TALER_FAKEBANK_Handle) \ + op (keys, struct TALER_EXCHANGE_Keys) \ + op (process, struct GNUNET_OS_Process *) + + +/** + * Call #op on all indexed traits. + */ +#define TALER_TESTING_INDEXED_TRAITS(op) \ + op (denom_pub, const struct TALER_EXCHANGE_DenomPublicKey) \ + op (denom_sig, const struct TALER_DenominationSignature) \ + op (amounts, const struct TALER_Amount) \ + op (deposit_amount, const struct TALER_Amount) \ + op (deposit_fee_amount, const struct TALER_Amount) \ + op (age_commitment, const struct TALER_AgeCommitment) \ + op (age_commitment_proof, const struct TALER_AgeCommitmentProof) \ + op (h_age_commitment, const struct TALER_AgeCommitmentHash) \ + op (reserve_history, const struct TALER_EXCHANGE_ReserveHistoryEntry) \ + op (coin_history, const struct TALER_EXCHANGE_CoinHistoryEntry) \ + op (planchet_secrets, const struct TALER_PlanchetMasterSecretP) \ + op (exchange_wd_value, const struct TALER_ExchangeWithdrawValues) \ + op (coin_priv, const struct TALER_CoinSpendPrivateKeyP) \ + op (coin_pub, const struct TALER_CoinSpendPublicKeyP) \ + op (coin_sig, const struct TALER_CoinSpendSignatureP) \ + op (absolute_time, const struct GNUNET_TIME_Absolute) \ + op (timestamp, const struct GNUNET_TIME_Timestamp) \ + op (wire_deadline, const struct GNUNET_TIME_Timestamp) \ + op (refund_deadline, const struct GNUNET_TIME_Timestamp) \ + op (exchange_pub, const struct TALER_ExchangePublicKeyP) \ + op (exchange_sig, const struct TALER_ExchangeSignatureP) \ + op (blinding_key, const union GNUNET_CRYPTO_BlindingSecretP) \ + op (h_blinded_coin, const struct TALER_BlindedCoinHashP) + +TALER_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT) + +TALER_TESTING_INDEXED_TRAITS (TALER_TESTING_MAKE_DECL_INDEXED_TRAIT) -/** - * Offer a relative time. - * - * @param index associate the object with this index - * @param time which object should be returned - * @return the trait. - */ -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_relative_time ( - unsigned int index, - const struct GNUNET_TIME_Relative *time); #endif |