exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

taler_testing_lib.h (93502B)


      1 /*
      2   This file is part of TALER
      3   (C) 2018-2025 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify
      6   it under the terms of the GNU General Public License as
      7   published by the Free Software Foundation; either version 3, or
      8   (at your option) any later version.
      9 
     10   TALER is distributed in the hope that it will be useful, but
     11   WITHOUT ANY WARRANTY; without even the implied warranty of
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13   GNU General Public License for more details.
     14 
     15   You should have received a copy of the GNU General Public
     16   License along with TALER; see the file COPYING.  If not, see
     17   <http://www.gnu.org/licenses/>
     18 */
     19 
     20 /**
     21  * @file include/taler/taler_testing_lib.h
     22  * @brief API for writing an interpreter to test Taler components
     23  *        This library is not thread-safe, all APIs must only be used from a single thread.
     24  *        This library calls abort() if it runs out of memory. Be aware of these limitations.
     25  * @author Christian Grothoff <christian@grothoff.org>
     26  * @author Marcello Stanisci
     27  * @author Özgür Kesim
     28  */
     29 #ifndef TALER_TESTING_LIB_H
     30 #define TALER_TESTING_LIB_H
     31 
     32 #include <microhttpd.h>
     33 #include <gnunet/gnunet_json_lib.h>
     34 #include <taler/taler_json_lib.h>
     35 #include <taler/taler_auditor_service.h>
     36 #include <taler/taler_bank_service.h>
     37 /**
     38  * To get access to testing relevant API's
     39  */
     40 #define TALER_TESTING_EXPORTS_DANGEROUS 1
     41 #include <taler/taler_exchange_service.h>  /* UNNECESSARY? */
     42 #include <taler/taler_fakebank_lib.h>
     43 
     44 
     45 /* ********************* Helper functions ********************* */
     46 
     47 /**
     48  * Print failing line number and trigger shutdown.  Useful
     49  * quite any time after the command "run" method has been called.
     50  */
     51 #define TALER_TESTING_FAIL(is) \
     52         do \
     53         { \
     54           GNUNET_break (0); \
     55           TALER_TESTING_interpreter_fail (is); \
     56           return; \
     57         } while (0)
     58 
     59 
     60 /**
     61  * Log an error message about us receiving an unexpected HTTP
     62  * status code at the current command and fail the test.
     63  *
     64  * @param is interpreter to fail
     65  * @param status unexpected HTTP status code received
     66  * @param expected expected HTTP status code
     67  */
     68 #define TALER_TESTING_unexpected_status(is,status,expected)             \
     69         do {                                                                  \
     70           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                                \
     71                       "Unexpected response code %u (expected: %u) to command %s in %s:%u\n", \
     72                       status,                                                 \
     73                       expected,                                               \
     74                       TALER_TESTING_interpreter_get_current_label (is),       \
     75                       __FILE__,                                               \
     76                       __LINE__);                                              \
     77           TALER_TESTING_interpreter_fail (is);                                \
     78         } while (0)
     79 
     80 /**
     81  * Log an error message about us receiving an unexpected HTTP
     82  * status code at the current command and fail the test and print the response
     83  * body (expected as json).
     84  *
     85  * @param is interpreter to fail
     86  * @param status unexpected HTTP status code received
     87  * @param expected expected HTTP status code
     88  * @param body received JSON-reply
     89  */
     90 #define TALER_TESTING_unexpected_status_with_body(is,status,expected,body) \
     91         do {                                                                  \
     92           char *tmp = json_dumps (body, JSON_INDENT (2));                     \
     93           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                                \
     94                       "Unexpected response code %u (expected: %u) to "        \
     95                       "command %s in %s:%u\nwith body:\n>>%s<<\n",            \
     96                       status,                                                 \
     97                       expected,                                               \
     98                       TALER_TESTING_interpreter_get_current_label (is),       \
     99                       __FILE__,                                               \
    100                       __LINE__,                                               \
    101                       tmp);                                                   \
    102           GNUNET_free (tmp);                                                  \
    103           TALER_TESTING_interpreter_fail (is);                                \
    104         } while (0)
    105 
    106 
    107 /**
    108  * Log an error message about a command not having
    109  * run to completion.
    110  *
    111  * @param is interpreter
    112  * @param label command label of the incomplete command
    113  */
    114 #define TALER_TESTING_command_incomplete(is,label)                      \
    115         do {                                                                  \
    116           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                                \
    117                       "Command %s (%s:%u) did not complete (at %s)\n",        \
    118                       label,                                                  \
    119                       __FILE__,                                               \
    120                       __LINE__,                                               \
    121                       TALER_TESTING_interpreter_get_current_label (is));      \
    122         } while (0)
    123 
    124 
    125 /**
    126  * Age restriction mask for the exchange under test.
    127  * Set by TALER_TESTING_run_with_fakebank() when AGE_RESTRICTION_ENABLED
    128  * is set in the [exchange] config section.
    129  */
    130 extern struct TALER_AgeMask TALER_testing_age_restriction_mask;
    131 
    132 
    133 /**
    134  * Common credentials used in a test.
    135  */
    136 struct TALER_TESTING_Credentials
    137 {
    138   /**
    139    * Bank authentication details for the exchange bank
    140    * account.
    141    */
    142   struct TALER_BANK_AuthenticationData ba;
    143 
    144   /**
    145    * Bank authentication details for the admin bank
    146    * account.
    147    */
    148   struct TALER_BANK_AuthenticationData ba_admin;
    149 
    150   /**
    151    * Configuration file data.
    152    */
    153   struct GNUNET_CONFIGURATION_Handle *cfg;
    154 
    155   /**
    156    * Base URL of the exchange.
    157    */
    158   char *exchange_url;
    159 
    160   /**
    161    * Base URL of the auditor.
    162    */
    163   char *auditor_url;
    164 
    165   /**
    166    * RFC 8905 URI of the exchange.
    167    */
    168   struct TALER_FullPayto exchange_payto;
    169 
    170   /**
    171    * RFC 8905 URI of a user.
    172    */
    173   struct TALER_FullPayto user42_payto;
    174 
    175   /**
    176    * RFC 8905 URI of a user.
    177    */
    178   struct TALER_FullPayto user43_payto;
    179 
    180   /**
    181    * RFC 8905 URI of a user.
    182    */
    183   struct TALER_FullPayto user44_payto;
    184 };
    185 
    186 
    187 /**
    188  * What type of bank are we using?
    189  */
    190 enum TALER_TESTING_BankSystem
    191 {
    192   TALER_TESTING_BS_FAKEBANK = 1,
    193   TALER_TESTING_BS_IBAN = 2
    194 };
    195 
    196 
    197 /**
    198  * Obtain bank credentials for a given @a cfg_file using
    199  * @a exchange_account_section as the basis for the
    200  * exchange account.
    201  *
    202  * @param cfg_file name of configuration to parse
    203  * @param exchange_account_section configuration section name for the exchange account to use
    204  * @param bs type of bank to use
    205  * @param[out] ua where to write user account details
    206  *         and other credentials
    207  */
    208 enum GNUNET_GenericReturnValue
    209 TALER_TESTING_get_credentials (
    210   const char *cfg_file,
    211   const char *exchange_account_section,
    212   enum TALER_TESTING_BankSystem bs,
    213   struct TALER_TESTING_Credentials *ua);
    214 
    215 
    216 /**
    217  * Allocate and return a piece of wire-details.  Combines
    218  * a @a payto -URL and adds some salt to create the JSON.
    219  *
    220  * @param fpayto payto://-URL to encapsulate
    221  * @return JSON describing the account, including the
    222  *         payto://-URL of the account, must be manually decref'd
    223  */
    224 json_t *
    225 TALER_TESTING_make_wire_details (const struct TALER_FullPayto fpayto);
    226 
    227 
    228 /**
    229  * Remove files from previous runs
    230  *
    231  * @param cls NULL
    232  * @param cfg configuration
    233  * @return #GNUNET_OK on success
    234  */
    235 enum GNUNET_GenericReturnValue
    236 TALER_TESTING_cleanup_files_cfg (void *cls,
    237                                  const struct GNUNET_CONFIGURATION_Handle *cfg);
    238 
    239 
    240 /**
    241  * Find denomination key matching the given amount.
    242  *
    243  * @param keys array of keys to search
    244  * @param amount coin value to look for
    245  * @param age_restricted must the denomination be age restricted?
    246  * @return NULL if no matching key was found
    247  */
    248 const struct TALER_EXCHANGE_DenomPublicKey *
    249 TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,
    250                        const struct TALER_Amount *amount,
    251                        bool age_restricted);
    252 
    253 
    254 /**
    255  * Test port in URL string for availability.
    256  *
    257  * @param url URL to extract port from, 80 is default
    258  * @return #GNUNET_OK if the port is free
    259  */
    260 enum GNUNET_GenericReturnValue
    261 TALER_TESTING_url_port_free (const char *url);
    262 
    263 
    264 /* ******************* Generic interpreter logic ************ */
    265 
    266 /**
    267  * Global state of the interpreter, used by a command
    268  * to access information about other commands.
    269  */
    270 struct TALER_TESTING_Interpreter;
    271 
    272 
    273 /**
    274  * A command to be run by the interpreter.
    275  */
    276 struct TALER_TESTING_Command
    277 {
    278 
    279   /**
    280    * Closure for all commands with command-specific context
    281    * information.
    282    */
    283   void *cls;
    284 
    285   /**
    286    * Label for the command.
    287    */
    288   const char *label;
    289 
    290   /**
    291    * Variable name for the command, NULL for none.
    292    */
    293   const char *name;
    294 
    295   /**
    296    * Runs the command.  Note that upon return, the interpreter
    297    * will not automatically run the next command, as the command
    298    * may continue asynchronously in other scheduler tasks.  Thus,
    299    * the command must ensure to eventually call
    300    * #TALER_TESTING_interpreter_next() or
    301    * #TALER_TESTING_interpreter_fail().
    302    *
    303    * @param cls closure
    304    * @param cmd command being run
    305    * @param is interpreter state
    306    */
    307   void
    308   (*run)(void *cls,
    309          const struct TALER_TESTING_Command *cmd,
    310          struct TALER_TESTING_Interpreter *is);
    311 
    312 
    313   /**
    314    * Clean up after the command.  Run during forced termination
    315    * (CTRL-C) or test failure or test success.
    316    *
    317    * @param cls closure
    318    * @param cmd command being cleaned up
    319    */
    320   void
    321   (*cleanup)(void *cls,
    322              const struct TALER_TESTING_Command *cmd);
    323 
    324   /**
    325    * Extract information from a command that is useful for other
    326    * commands.
    327    *
    328    * @param cls closure
    329    * @param[out] ret result (could be anything)
    330    * @param trait name of the trait
    331    * @param index index number of the object to extract.
    332    * @return #GNUNET_OK on success
    333    */
    334   enum GNUNET_GenericReturnValue
    335   (*traits)(void *cls,
    336             const void **ret,
    337             const char *trait,
    338             unsigned int index);
    339 
    340   /**
    341    * When did the execution of this command start?
    342    */
    343   struct GNUNET_TIME_Absolute start_time;
    344 
    345   /**
    346    * When did the execution of this command finish?
    347    */
    348   struct GNUNET_TIME_Absolute finish_time;
    349 
    350   /**
    351    * When did we start the last request of this command?
    352    * Delta to @e finish_time gives the latency for the last
    353    * successful request.
    354    */
    355   struct GNUNET_TIME_Absolute last_req_time;
    356 
    357   /**
    358    * How often did we try to execute this command? (In case
    359    * it is a request that is repated.)
    360    */
    361   unsigned int num_tries;
    362 
    363 };
    364 
    365 
    366 /**
    367  * Lookup command by label.
    368  *
    369  * @param is interpreter state.
    370  * @param label label of the command to lookup.
    371  * @return the command, if it is found, or NULL.
    372  */
    373 const struct TALER_TESTING_Command *
    374 TALER_TESTING_interpreter_lookup_command (
    375   struct TALER_TESTING_Interpreter *is,
    376   const char *label);
    377 
    378 
    379 /**
    380  * Get command from hash map by variable name.
    381  *
    382  * @param is interpreter state.
    383  * @param name name of the variable to get command by
    384  * @return the command, if it is found, or NULL.
    385  */
    386 const struct TALER_TESTING_Command *
    387 TALER_TESTING_interpreter_get_command (
    388   struct TALER_TESTING_Interpreter *is,
    389   const char *name);
    390 
    391 
    392 /**
    393  * Update the last request time of the current command
    394  * to the current time.
    395  *
    396  * @param[in,out] is interpreter state where to show
    397  *       that we are doing something
    398  */
    399 void
    400 TALER_TESTING_touch_cmd (struct TALER_TESTING_Interpreter *is);
    401 
    402 
    403 /**
    404  * Increment the 'num_tries' counter for the current
    405  * command.
    406  *
    407  * @param[in,out] is interpreter state where to
    408  *   increment the counter
    409  */
    410 void
    411 TALER_TESTING_inc_tries (struct TALER_TESTING_Interpreter *is);
    412 
    413 
    414 /**
    415  * Obtain CURL context for the main loop.
    416  *
    417  * @param is interpreter state.
    418  * @return CURL execution context.
    419  */
    420 struct GNUNET_CURL_Context *
    421 TALER_TESTING_interpreter_get_context (struct TALER_TESTING_Interpreter *is);
    422 
    423 
    424 /**
    425  * Obtain label of the command being now run.
    426  *
    427  * @param is interpreter state.
    428  * @return the label.
    429  */
    430 const char *
    431 TALER_TESTING_interpreter_get_current_label (
    432   struct TALER_TESTING_Interpreter *is);
    433 
    434 
    435 /**
    436  * Current command is done, run the next one.
    437  *
    438  * @param is interpreter state.
    439  */
    440 void
    441 TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is);
    442 
    443 /**
    444  * Current command failed, clean up and fail the test case.
    445  *
    446  * @param is interpreter state.
    447  */
    448 void
    449 TALER_TESTING_interpreter_fail (struct TALER_TESTING_Interpreter *is);
    450 
    451 
    452 /**
    453  * Make the instruction pointer point to @a target_label
    454  * only if @a counter is greater than zero.
    455  *
    456  * @param label command label
    457  * @param target_label label of the new instruction pointer's destination after the jump;
    458  *                     must be before the current instruction
    459  * @param counter counts how many times the rewinding is to happen.
    460  */
    461 struct TALER_TESTING_Command
    462 TALER_TESTING_cmd_rewind_ip (const char *label,
    463                              const char *target_label,
    464                              unsigned int counter);
    465 
    466 
    467 /**
    468  * Wait until we receive SIGCHLD signal.
    469  * Then obtain the process trait of the current
    470  * command, wait on the the zombie and continue
    471  * with the next command.
    472  *
    473  * @param is interpreter state.
    474  */
    475 void
    476 TALER_TESTING_wait_for_sigchld (struct TALER_TESTING_Interpreter *is);
    477 
    478 
    479 /**
    480  * Schedule the first CMD in the CMDs array.
    481  *
    482  * @param is interpreter state.
    483  * @param commands array of all the commands to execute.
    484  */
    485 void
    486 TALER_TESTING_run (struct TALER_TESTING_Interpreter *is,
    487                    struct TALER_TESTING_Command *commands);
    488 
    489 
    490 /**
    491  * Run the testsuite.  Note, CMDs are copied into
    492  * the interpreter state because they are _usually_
    493  * defined into the "run" method that returns after
    494  * having scheduled the test interpreter.
    495  *
    496  * @param is the interpreter state
    497  * @param commands the list of command to execute
    498  * @param timeout how long to wait
    499  */
    500 void
    501 TALER_TESTING_run2 (struct TALER_TESTING_Interpreter *is,
    502                     struct TALER_TESTING_Command *commands,
    503                     struct GNUNET_TIME_Relative timeout);
    504 
    505 
    506 /**
    507  * The function that contains the array of all the CMDs to run,
    508  * which is then on charge to call some fashion of
    509  * TALER_TESTING_run*.  In all the test cases, this function is
    510  * always the GNUnet-ish "run" method.
    511  *
    512  * @param cls closure.
    513  * @param is interpreter state.
    514  */
    515 typedef void
    516 (*TALER_TESTING_Main)(void *cls,
    517                       struct TALER_TESTING_Interpreter *is);
    518 
    519 
    520 /**
    521  * Run Taler testing loop.  Starts the GNUnet SCHEDULER (event loop).
    522  *
    523  * @param main_cb main function to run
    524  * @param main_cb_cls closure for @a main_cb
    525  */
    526 enum GNUNET_GenericReturnValue
    527 TALER_TESTING_loop (TALER_TESTING_Main main_cb,
    528                     void *main_cb_cls);
    529 
    530 
    531 /**
    532  * Convenience function to run a test.
    533  *
    534  * @param argv command-line arguments given
    535  * @param loglevel log level to use
    536  * @param cfg_file configuration file to use
    537  * @param exchange_account_section configuration section
    538  *   with exchange bank account to use
    539  * @param bs bank system to use
    540  * @param[in,out] cred global credentials to initialize
    541  * @param main_cb main test function to run
    542  * @param main_cb_cls closure for @a main_cb
    543  * @return 0 on success, 77 on setup trouble, non-zero process status code otherwise
    544  */
    545 int
    546 TALER_TESTING_main (char *const *argv,
    547                     const char *loglevel,
    548                     const char *cfg_file,
    549                     const char *exchange_account_section,
    550                     enum TALER_TESTING_BankSystem bs,
    551                     struct TALER_TESTING_Credentials *cred,
    552                     TALER_TESTING_Main main_cb,
    553                     void *main_cb_cls);
    554 
    555 
    556 /**
    557  * Callback over commands of an interpreter.
    558  *
    559  * @param cls closure
    560  * @param cmd a command to process
    561  */
    562 typedef void
    563 (*TALER_TESTING_CommandIterator)(
    564   void *cls,
    565   const struct TALER_TESTING_Command *cmd);
    566 
    567 
    568 /**
    569  * Iterates over all of the top-level commands of an
    570  * interpreter.
    571  *
    572  * @param[in] is interpreter to iterate over
    573  * @param asc true in execution order, false for reverse execution order
    574  * @param cb function to call on each command
    575  * @param cb_cls closure for cb
    576  */
    577 void
    578 TALER_TESTING_iterate (struct TALER_TESTING_Interpreter *is,
    579                        bool asc,
    580                        TALER_TESTING_CommandIterator cb,
    581                        void *cb_cls);
    582 
    583 
    584 /**
    585  * Look for substring in a programs' name.
    586  *
    587  * @param prog program's name to look into
    588  * @param marker chunk to find in @a prog
    589  * @return true if @a marker is in @a prog
    590  */
    591 bool
    592 TALER_TESTING_has_in_name (const char *prog,
    593                            const char *marker);
    594 
    595 
    596 /**
    597  * Wait for an HTTPD service to have started. Waits for at
    598  * most 10s, after that returns 77 to indicate an error.
    599  *
    600  * @param base_url what URL should we expect the exchange
    601  *        to be running at
    602  * @return 0 on success
    603  */
    604 int
    605 TALER_TESTING_wait_httpd_ready (const char *base_url);
    606 
    607 
    608 /**
    609  * Parse reference to a coin.
    610  *
    611  * @param coin_reference of format $LABEL['#' $INDEX]?
    612  * @param[out] cref where we return a copy of $LABEL
    613  * @param[out] idx where we set $INDEX
    614  * @return #GNUNET_SYSERR if $INDEX is present but not numeric
    615  */
    616 enum GNUNET_GenericReturnValue
    617 TALER_TESTING_parse_coin_reference (
    618   const char *coin_reference,
    619   char **cref,
    620   unsigned int *idx);
    621 
    622 
    623 /* ************** Specific interpreter commands ************ */
    624 
    625 
    626 /**
    627  * Create command array terminator.
    628  *
    629  * @return a end-command.
    630  */
    631 struct TALER_TESTING_Command
    632 TALER_TESTING_cmd_end (void);
    633 
    634 
    635 /**
    636  * Set variable to command as side-effect of
    637  * running a command.
    638  *
    639  * @param name name of the variable to set
    640  * @param cmd command to set to variable when run
    641  * @return modified command
    642  */
    643 struct TALER_TESTING_Command
    644 TALER_TESTING_cmd_set_var (const char *name,
    645                            struct TALER_TESTING_Command cmd);
    646 
    647 
    648 /**
    649  * Update interpreter @a is variable state due to execution of @a cmd.
    650  *
    651  * @param[in,out] is interpreter to update
    652  * @param[in,out] cmd command that we are executing and that
    653  *   needs to be checked for side-effects on the variable state
    654  */
    655 void
    656 TALER_TESTING_update_variables_ (
    657   struct TALER_TESTING_Interpreter *is,
    658   struct TALER_TESTING_Command *cmd);
    659 
    660 
    661 /**
    662  * Launch GNU Taler setup.
    663  *
    664  * @param label command label.
    665  * @param config_file configuration file to use
    666  * @param ... NULL-terminated (const char *) arguments to pass to taler-benchmark-setup.sh
    667  * @return the command.
    668  */
    669 struct TALER_TESTING_Command
    670 TALER_TESTING_cmd_system_start (
    671   const char *label,
    672   const char *config_file,
    673   ...);
    674 
    675 
    676 /**
    677  * Connects to the exchange.
    678  *
    679  * @param label command label
    680  * @param cfg configuration to use
    681  * @param last_keys_ref reference to command with prior /keys response, NULL for none
    682  * @param wait_for_keys block until we got /keys
    683  * @param load_private_key obtain private key from file indicated in @a cfg
    684  * @return the command.
    685  */
    686 struct TALER_TESTING_Command
    687 TALER_TESTING_cmd_get_exchange (
    688   const char *label,
    689   const struct GNUNET_CONFIGURATION_Handle *cfg,
    690   const char *last_keys_ref,
    691   bool wait_for_keys,
    692   bool load_private_key);
    693 
    694 
    695 /**
    696  * Connects to the auditor.
    697  *
    698  * @param label command label
    699  * @param cfg configuration to use
    700  * @param load_auditor_keys obtain auditor keys from file indicated in @a cfg
    701  * @return the command.
    702  */
    703 struct TALER_TESTING_Command
    704 TALER_TESTING_cmd_get_auditor (
    705   const char *label,
    706   const struct GNUNET_CONFIGURATION_Handle *cfg,
    707   bool load_auditor_keys);
    708 
    709 
    710 /**
    711  * Runs the Fakebank in-process by guessing / extracting the portnumber
    712  * from the base URL.
    713  *
    714  * @param label command label
    715  * @param cfg configuration to use
    716  * @param exchange_account_section configuration section
    717  *   to use to determine bank account of the exchange
    718  * @return the command.
    719  */
    720 struct TALER_TESTING_Command
    721 TALER_TESTING_cmd_run_fakebank (
    722   const char *label,
    723   const struct GNUNET_CONFIGURATION_Handle *cfg,
    724   const char *exchange_account_section);
    725 
    726 
    727 /**
    728  * Command to modify authorization header used in the CURL context.
    729  * This will destroy the existing CURL context and create a fresh
    730  * one. The command will fail (badly) if the existing CURL context
    731  * still has active HTTP requests associated with it.
    732  *
    733  * @param label command label.
    734  * @param auth_token auth token to use henceforth, can be NULL
    735  * @return the command.
    736  */
    737 struct TALER_TESTING_Command
    738 TALER_TESTING_cmd_set_authorization (const char *label,
    739                                      const char *auth_token);
    740 
    741 
    742 /**
    743  * Make a credit "history" CMD.
    744  *
    745  * @param label command label.
    746  * @param auth login data to use
    747  * @param start_row_reference reference to a command that can
    748  *        offer a row identifier, to be used as the starting row
    749  *        to accept in the result.
    750  * @param num_results how many rows we want in the result,
    751  *        and ascending/descending call
    752  * @return the command.
    753  */
    754 struct TALER_TESTING_Command
    755 TALER_TESTING_cmd_bank_credits (
    756   const char *label,
    757   const struct TALER_BANK_AuthenticationData *auth,
    758   const char *start_row_reference,
    759   long long num_results);
    760 
    761 
    762 /**
    763  * Make an account access token request CMD.
    764  *
    765  * @param label command label.
    766  * @param auth login data to use
    767  * @param account_name account name to request access token for
    768  * @param scope requested token scope
    769  * @param refreshable true if the token should be refreshable
    770  * @param duration how long should the token be valid
    771  * @param expected_http_status expected server response code
    772  * @return the command.
    773  */
    774 struct TALER_TESTING_Command
    775 TALER_TESTING_cmd_bank_account_token (
    776   const char *label,
    777   const struct TALER_BANK_AuthenticationData *auth,
    778   const char *account_name,
    779   enum TALER_BANK_TokenScope scope,
    780   bool refreshable,
    781   struct GNUNET_TIME_Relative duration,
    782   unsigned int expected_http_status);
    783 
    784 
    785 /**
    786  * Make a debit "history" CMD.
    787  *
    788  * @param label command label.
    789  * @param auth authentication data
    790  * @param start_row_reference reference to a command that can
    791  *        offer a row identifier, to be used as the starting row
    792  *        to accept in the result.
    793  * @param num_results how many rows we want in the result.
    794  * @return the command.
    795  */
    796 struct TALER_TESTING_Command
    797 TALER_TESTING_cmd_bank_debits (const char *label,
    798                                const struct TALER_BANK_AuthenticationData *auth,
    799                                const char *start_row_reference,
    800                                long long num_results);
    801 
    802 
    803 /**
    804  * Create transfer command.
    805  *
    806  * @param label command label
    807  * @param amount amount to transfer
    808  * @param auth authentication data to use
    809  * @param payto_debit_account which account to withdraw money from
    810  * @param payto_credit_account which account receives money
    811  * @param wtid wire transfer identifier to use
    812  * @param exchange_base_url exchange URL to use
    813  * @return the command.
    814  */
    815 struct TALER_TESTING_Command
    816 TALER_TESTING_cmd_transfer (const char *label,
    817                             const char *amount,
    818                             const struct TALER_BANK_AuthenticationData *auth,
    819                             const struct TALER_FullPayto payto_debit_account,
    820                             const struct TALER_FullPayto payto_credit_account,
    821                             const struct TALER_WireTransferIdentifierRawP *wtid,
    822                             const char *exchange_base_url);
    823 
    824 
    825 /**
    826  * Modify a transfer command to enable retries when the reserve is not yet
    827  * full or we get other transient errors from the bank.
    828  *
    829  * @param cmd a fakebank transfer command
    830  * @return the command with retries enabled
    831  */
    832 struct TALER_TESTING_Command
    833 TALER_TESTING_cmd_transfer_retry (struct TALER_TESTING_Command cmd);
    834 
    835 
    836 /**
    837  * Make the "exec-auditor" CMD.
    838  *
    839  * @param label command label.
    840  * @param config_filename configuration filename.
    841  * @return the command.
    842  */
    843 struct TALER_TESTING_Command
    844 TALER_TESTING_cmd_exec_auditor (const char *label,
    845                                 const char *config_filename);
    846 
    847 
    848 /**
    849  * Make the "exec-auditor-dbinit" CMD. Always run with the "-r" option.
    850  *
    851  * @param label command label.
    852  * @param config_filename configuration filename.
    853  * @return the command.
    854  */
    855 struct TALER_TESTING_Command
    856 TALER_TESTING_cmd_exec_auditor_dbinit (const char *label,
    857                                        const char *config_filename);
    858 
    859 
    860 /**
    861  * Create a "deposit-confirmation" command.
    862  *
    863  * @param label command label.
    864  * @param deposit_reference reference to any operation that can
    865  *        provide a coin.
    866  * @param num_coins number of coins expected in the batch deposit
    867  * @param amount_without_fee deposited amount without the fee
    868  * @param expected_response_code expected HTTP response code.
    869  * @return the command.
    870  */
    871 struct TALER_TESTING_Command
    872 TALER_TESTING_cmd_deposit_confirmation (
    873   const char *label,
    874   const char *deposit_reference,
    875   unsigned int num_coins,
    876   const char *amount_without_fee,
    877   unsigned int expected_response_code);
    878 
    879 
    880 /**
    881  * Modify a deposit confirmation command to enable retries when we get
    882  * transient errors from the auditor.
    883  *
    884  * @param cmd a deposit confirmation command
    885  * @return the command with retries enabled
    886  */
    887 struct TALER_TESTING_Command
    888 TALER_TESTING_cmd_deposit_confirmation_with_retry (
    889   struct TALER_TESTING_Command cmd);
    890 
    891 
    892 /**
    893  * Create command that does a wire transfer using
    894  * /admin/add-incoming to establish a reserve.
    895  *
    896  * @param label command label.
    897  * @param amount amount to transfer.
    898  * @param auth authentication data
    899  * @param payto_debit_account which account sends money.
    900  * @return the command.
    901  */
    902 struct TALER_TESTING_Command
    903 TALER_TESTING_cmd_admin_add_incoming (
    904   const char *label,
    905   const char *amount,
    906   const struct TALER_BANK_AuthenticationData *auth,
    907   const struct TALER_FullPayto payto_debit_account);
    908 
    909 
    910 /**
    911  * Create command that does a wire transfer using
    912  * /admin/add-kycauth to establish an account private key.
    913  *
    914  * @param label command label.
    915  * @param amount amount to transfer.
    916  * @param auth authentication data
    917  * @param payto_debit_account which account sends money.
    918  * @param account_ref reference to command with account
    919  *    private key to use; NULL to create a fresh key pair
    920  * @return the command.
    921  */
    922 struct TALER_TESTING_Command
    923 TALER_TESTING_cmd_admin_add_kycauth (
    924   const char *label,
    925   const char *amount,
    926   const struct TALER_BANK_AuthenticationData *auth,
    927   const struct TALER_FullPayto payto_debit_account,
    928   const char *account_ref);
    929 
    930 
    931 /**
    932  * Create "fakebank transfer" CMD, letting the caller specify
    933  * a reference to a command that can offer a reserve private key.
    934  * This private key will then be used to construct the subject line
    935  * of the wire transfer.
    936  *
    937  * @param label command label.
    938  * @param amount the amount to transfer.
    939  * @param payto_debit_account which account sends money.
    940  * @param auth authentication data
    941  * @param ref reference to a command that can offer a reserve
    942  *        private key or public key.
    943  * @param http_status expected HTTP status
    944  * @return the command.
    945  */
    946 struct TALER_TESTING_Command
    947 TALER_TESTING_cmd_admin_add_incoming_with_ref (
    948   const char *label,
    949   const char *amount,
    950   const struct TALER_BANK_AuthenticationData *auth,
    951   const struct TALER_FullPayto payto_debit_account,
    952   const char *ref,
    953   unsigned int http_status);
    954 
    955 
    956 /**
    957  * Modify a fakebank transfer command to enable retries when the
    958  * reserve is not yet full or we get other transient errors from
    959  * the fakebank.
    960  *
    961  * @param cmd a fakebank transfer command
    962  * @return the command with retries enabled
    963  */
    964 struct TALER_TESTING_Command
    965 TALER_TESTING_cmd_admin_add_incoming_retry (struct TALER_TESTING_Command cmd);
    966 
    967 
    968 /**
    969  * Make a "wirewatch" CMD.
    970  *
    971  * @param label command label.
    972  * @param config_filename configuration filename.
    973  * @return the command.
    974  */
    975 struct TALER_TESTING_Command
    976 TALER_TESTING_cmd_exec_wirewatch (const char *label,
    977                                   const char *config_filename);
    978 
    979 
    980 /**
    981  * Make a "wirewatch" CMD.
    982  *
    983  * @param label command label.
    984  * @param config_filename configuration filename.
    985  * @param account_section section to run wirewatch against
    986  * @return the command.
    987  */
    988 struct TALER_TESTING_Command
    989 TALER_TESTING_cmd_exec_wirewatch2 (const char *label,
    990                                    const char *config_filename,
    991                                    const char *account_section);
    992 
    993 
    994 /**
    995  * Request URL via "wget".
    996  *
    997  * @param label command label.
    998  * @param url URL to fetch
    999  * @return the command.
   1000  */
   1001 struct TALER_TESTING_Command
   1002 TALER_TESTING_cmd_exec_wget (const char *label,
   1003                              const char *url);
   1004 
   1005 
   1006 /**
   1007  * Make a "expire" CMD.
   1008  *
   1009  * @param label command label.
   1010  * @param config_filename configuration filename.
   1011  * @return the command.
   1012  */
   1013 struct TALER_TESTING_Command
   1014 TALER_TESTING_cmd_exec_expire (const char *label,
   1015                                const char *config_filename);
   1016 
   1017 
   1018 /**
   1019  * Make a "router" CMD.
   1020  *
   1021  * @param label command label.
   1022  * @param config_filename configuration filename.
   1023  * @return the command.
   1024  */
   1025 struct TALER_TESTING_Command
   1026 TALER_TESTING_cmd_exec_router (const char *label,
   1027                                const char *config_filename);
   1028 
   1029 
   1030 /**
   1031  * Run a "taler-exchange-aggregator" CMD.
   1032  *
   1033  * @param label command label.
   1034  * @param config_filename configuration file for the
   1035  *                        aggregator to use.
   1036  * @return the command.
   1037  */
   1038 struct TALER_TESTING_Command
   1039 TALER_TESTING_cmd_exec_aggregator (const char *label,
   1040                                    const char *config_filename);
   1041 
   1042 
   1043 /**
   1044  * Run a "taler-auditor-offline" CMD.
   1045  *
   1046  * @param label command label.
   1047  * @param config_filename configuration file for the
   1048  *                        aggregator to use.
   1049  * @return the command.
   1050  */
   1051 struct TALER_TESTING_Command
   1052 TALER_TESTING_cmd_exec_auditor_offline (const char *label,
   1053                                         const char *config_filename);
   1054 
   1055 
   1056 /**
   1057  * Make a "aggregator" CMD and do not disable KYC checks.
   1058  *
   1059  * @param label command label.
   1060  * @param config_filename configuration file for the
   1061  *                        aggregator to use.
   1062  * @return the command.
   1063  */
   1064 struct TALER_TESTING_Command
   1065 TALER_TESTING_cmd_exec_aggregator_with_kyc (const char *label,
   1066                                             const char *config_filename);
   1067 
   1068 
   1069 /**
   1070  * Make a "closer" CMD.  Note that it is right now not supported to run the
   1071  * closer to close multiple reserves in combination with a subsequent reserve
   1072  * status call, as we cannot generate the traits necessary for multiple closed
   1073  * reserves.  You can work around this by using multiple closer commands, one
   1074  * per reserve that is being closed.
   1075  *
   1076  * @param label command label.
   1077  * @param config_filename configuration file for the
   1078  *                        closer to use.
   1079  * @param expected_amount amount we expect to see wired from a @a expected_reserve_ref
   1080  * @param expected_fee closing fee we expect to see
   1081  * @param expected_reserve_ref reference to a reserve we expect the closer to drain;
   1082  *          NULL if we do not expect the closer to do anything
   1083  * @return the command.
   1084  */
   1085 struct TALER_TESTING_Command
   1086 TALER_TESTING_cmd_exec_closer (
   1087   const char *label,
   1088   const char *config_filename,
   1089   const char *expected_amount,
   1090   const char *expected_fee,
   1091   const char *expected_reserve_ref);
   1092 
   1093 
   1094 /**
   1095  * Make a "transfer" CMD.
   1096  *
   1097  * @param label command label.
   1098  * @param config_filename configuration file for the
   1099  *                        transfer to use.
   1100  * @return the command.
   1101  */
   1102 struct TALER_TESTING_Command
   1103 TALER_TESTING_cmd_exec_transfer (const char *label,
   1104                                  const char *config_filename);
   1105 
   1106 
   1107 /**
   1108  * Create a withdraw command, letting the caller specify
   1109  * the desired amount as string.
   1110  *
   1111  * @param label command label.
   1112  * @param reserve_reference command providing us with a reserve to withdraw from
   1113  * @param amount how much we withdraw.
   1114  * @param age if > 0, age restriction applies
   1115  * @param expected_response_code which HTTP response code
   1116  *        we expect from the exchange.
   1117  * @return the withdraw command to be executed by the interpreter.
   1118  */
   1119 struct TALER_TESTING_Command
   1120 TALER_TESTING_cmd_withdraw_amount (
   1121   const char *label,
   1122   const char *reserve_reference,
   1123   const char *amount,
   1124   uint8_t age,
   1125   unsigned int expected_response_code);
   1126 
   1127 
   1128 /**
   1129  * Create a batch withdraw command, letting the caller specify
   1130  * the desired amounts as string.  Takes a variable, non-empty
   1131  * list of the denomination amounts via VARARGS.
   1132  * Takes a variable, non-empty list of the denomination amounts via VARARGS,
   1133  * similar to #TALER_TESTING_cmd_withdraw_amount(), just using a batch
   1134  * withdraw.
   1135  *
   1136  * @param label command label.
   1137  * @param reserve_reference command providing us with a reserve to withdraw from
   1138  * @param expected_response_code which HTTP response code
   1139  *        we expect from the exchange.
   1140  * @param amount how much we withdraw for the first coin
   1141  * @param ... NULL-terminated list of additional amounts to withdraw (one per coin)
   1142  * @return the withdraw command to be executed by the interpreter.
   1143  */
   1144 struct TALER_TESTING_Command
   1145 TALER_TESTING_cmd_batch_withdraw (
   1146   const char *label,
   1147   const char *reserve_reference,
   1148   unsigned int expected_response_code,
   1149   const char *amount,
   1150   ...);
   1151 
   1152 
   1153 /**
   1154  * Create an withdraw command with age proof, letting the caller specify
   1155  * the maximum agend and desired amounts as string.  Takes a variable,
   1156  * non-empty list of the denomination amounts via VARARGS, similar to
   1157  * #TALER_TESTING_cmd_withdraw_amount(), just using a batch withdraw.
   1158  *
   1159  * @param label command label.
   1160  * @param reserve_reference command providing us with a reserve to withdraw from
   1161  * @param max_age maximum allowed age, same for each coin
   1162  * @param expected_response_code which HTTP response code
   1163  *        we expect from the exchange.
   1164  * @param amount how much we withdraw for the first coin
   1165  * @param ... NULL-terminated list of additional amounts to withdraw (one per coin)
   1166  * @return the withdraw command to be executed by the interpreter.
   1167  */
   1168 struct TALER_TESTING_Command
   1169 TALER_TESTING_cmd_withdraw_with_age_proof (
   1170   const char *label,
   1171   const char *reserve_reference,
   1172   uint8_t max_age,
   1173   unsigned int expected_response_code,
   1174   const char *amount,
   1175   ...);
   1176 
   1177 
   1178 /**
   1179  * Create a "withdraw-reveal" command, in case of a withdraw with age proof.
   1180  *
   1181  * @param label command label.
   1182  * @param age_withdraw_reference reference to a "age-withdraw" command.
   1183  * @param expected_response_code expected HTTP response code.
   1184  * @return the command.
   1185  */
   1186 struct TALER_TESTING_Command
   1187 TALER_TESTING_cmd_withdraw_reveal_age_proof (
   1188   const char *label,
   1189   const char *age_withdraw_reference,
   1190   unsigned int expected_response_code);
   1191 
   1192 /**
   1193  * Create a withdraw command, letting the caller specify
   1194  * the desired amount as string and also reusing an existing
   1195  * coin private key in the process (violating the specification,
   1196  * which will result in an error when spending the coin!).
   1197  *
   1198  * Note that in case of CS denominations, the blinding seed
   1199  * will still differ!
   1200  *
   1201  * @param label command label.
   1202  * @param reserve_reference command providing us with a reserve to withdraw from
   1203  * @param amount how much we withdraw.
   1204  * @param age if > 0, age restriction applies.
   1205  * @param coin_ref reference to (withdraw/reveal) command of a coin
   1206  *        from which we should reuse the private key
   1207  * @param expected_response_code which HTTP response code
   1208  *        we expect from the exchange.
   1209  * @return the withdraw command to be executed by the interpreter.
   1210  */
   1211 struct TALER_TESTING_Command
   1212 TALER_TESTING_cmd_withdraw_amount_reuse_key (
   1213   const char *label,
   1214   const char *reserve_reference,
   1215   const char *amount,
   1216   uint8_t age,
   1217   const char *coin_ref,
   1218   unsigned int expected_response_code);
   1219 
   1220 
   1221 /**
   1222  * Create a withdraw command, letting the caller specify
   1223  * the desired amount as string and also reusing an existing
   1224  * coin private key _and_ blinding seed in the process
   1225  * (violating the specification, which will result in an error
   1226  * when spending the coin!).
   1227  *
   1228  * @param label command label.
   1229  * @param reserve_reference command providing us with a reserve to withdraw from
   1230  * @param amount how much we withdraw.
   1231  * @param age if > 0, age restriction applies.
   1232  * @param coin_ref reference to (withdraw/reveal) command of a coin
   1233  *        from which we should reuse the private key
   1234  * @param expected_response_code which HTTP response code
   1235  *        we expect from the exchange.
   1236  * @return the withdraw command to be executed by the interpreter.
   1237  */
   1238 struct TALER_TESTING_Command
   1239 TALER_TESTING_cmd_withdraw_amount_reuse_all_secrets (
   1240   const char *label,
   1241   const char *reserve_reference,
   1242   const char *amount,
   1243   uint8_t age,
   1244   const char *coin_ref,
   1245   unsigned int expected_response_code);
   1246 
   1247 
   1248 /**
   1249  * Create withdraw command, letting the caller specify the
   1250  * amount by a denomination key.
   1251  *
   1252  * @param label command label.
   1253  * @param reserve_reference reference to the reserve to withdraw
   1254  *        from; will provide reserve priv to sign the request.
   1255  * @param dk denomination public key.
   1256  * @param expected_response_code expected HTTP response code.
   1257  * @return the command.
   1258  */
   1259 struct TALER_TESTING_Command
   1260 TALER_TESTING_cmd_withdraw_denomination (
   1261   const char *label,
   1262   const char *reserve_reference,
   1263   const struct TALER_EXCHANGE_DenomPublicKey *dk,
   1264   unsigned int expected_response_code);
   1265 
   1266 
   1267 /**
   1268  * Modify a withdraw command to enable retries when the
   1269  * reserve is not yet full or we get other transient
   1270  * errors from the exchange.
   1271  *
   1272  * @param cmd a withdraw command
   1273  * @return the command with retries enabled
   1274  */
   1275 struct TALER_TESTING_Command
   1276 TALER_TESTING_cmd_withdraw_with_retry (struct TALER_TESTING_Command cmd);
   1277 
   1278 
   1279 /**
   1280  * Create a GET "reserves" command.
   1281  *
   1282  * @param label the command label.
   1283  * @param reserve_reference reference to the reserve to check.
   1284  * @param expected_balance expected balance for the reserve.
   1285  * @param expected_response_code expected HTTP response code.
   1286  * @return the command.
   1287  */
   1288 struct TALER_TESTING_Command
   1289 TALER_TESTING_cmd_status (const char *label,
   1290                           const char *reserve_reference,
   1291                           const char *expected_balance,
   1292                           unsigned int expected_response_code);
   1293 
   1294 
   1295 /**
   1296  * Create a GET "reserves" command with a @a timeout.
   1297  *
   1298  * @param label the command label.
   1299  * @param reserve_reference reference to the reserve to check.
   1300  * @param expected_balance expected balance for the reserve.
   1301  * @param timeout how long to long-poll for the reserve to exist.
   1302  * @param expected_response_code expected HTTP response code.
   1303  * @return the command.
   1304  */
   1305 struct TALER_TESTING_Command
   1306 TALER_TESTING_cmd_reserve_poll (const char *label,
   1307                                 const char *reserve_reference,
   1308                                 const char *expected_balance,
   1309                                 struct GNUNET_TIME_Relative timeout,
   1310                                 unsigned int expected_response_code);
   1311 
   1312 
   1313 /**
   1314  * Wait for #TALER_TESTING_cmd_reserve_poll() to finish.
   1315  * Fail if it did not conclude by the timeout.
   1316  *
   1317  * @param label our label
   1318  * @param timeout how long to give the long poll to finish
   1319  * @param poll_reference reference to a #TALER_TESTING_cmd_reserve_poll() command
   1320  * @return the command.
   1321  */
   1322 struct TALER_TESTING_Command
   1323 TALER_TESTING_cmd_reserve_poll_finish (const char *label,
   1324                                        struct GNUNET_TIME_Relative timeout,
   1325                                        const char *poll_reference);
   1326 
   1327 
   1328 /**
   1329  * Create a GET "/reserves/$RID/history" command.
   1330  *
   1331  * @param label the command label.
   1332  * @param reserve_reference reference to the reserve to check.
   1333  * @param expected_balance expected balance for the reserve.
   1334  * @param expected_response_code expected HTTP response code.
   1335  * @return the command.
   1336  */
   1337 struct TALER_TESTING_Command
   1338 TALER_TESTING_cmd_reserve_history (
   1339   const char *label,
   1340   const char *reserve_reference,
   1341   const char *expected_balance,
   1342   unsigned int expected_response_code);
   1343 
   1344 
   1345 /**
   1346  * Create a GET "/coins/$COIN_PUB/history" command.
   1347  *
   1348  * @param label the command label.
   1349  * @param coin_reference reference to the coin to check.
   1350  * @param expected_balance expected balance for the coin.
   1351  * @param expected_response_code expected HTTP response code.
   1352  * @return the command.
   1353  */
   1354 struct TALER_TESTING_Command
   1355 TALER_TESTING_cmd_coin_history (
   1356   const char *label,
   1357   const char *coin_reference,
   1358   const char *expected_balance,
   1359   unsigned int expected_response_code);
   1360 
   1361 
   1362 /**
   1363  * Create a POST "/reserves/$RID/open" command.
   1364  *
   1365  * @param label the command label.
   1366  * @param reserve_reference reference to the reserve to open.
   1367  * @param reserve_pay amount to pay from the reserve balance
   1368  * @param expiration_time how long into the future should the reserve remain open
   1369  * @param min_purses minimum number of purses to allow
   1370  * @param expected_response_code expected HTTP response code.
   1371  * @param ... NULL terminated list of pairs of coin references and amounts
   1372  * @return the command.
   1373  */
   1374 struct TALER_TESTING_Command
   1375 TALER_TESTING_cmd_reserve_open (
   1376   const char *label,
   1377   const char *reserve_reference,
   1378   const char *reserve_pay,
   1379   struct GNUNET_TIME_Relative expiration_time,
   1380   uint32_t min_purses,
   1381   unsigned int expected_response_code,
   1382   ...);
   1383 
   1384 
   1385 /**
   1386  * Create a GET "/reserves/$RID/attest" command.
   1387  *
   1388  * @param label the command label.
   1389  * @param reserve_reference reference to the reserve to get attestable attributes of.
   1390  * @param expected_response_code expected HTTP response code.
   1391  * @param ... NULL-terminated list of attributes expected
   1392  * @return the command.
   1393  */
   1394 struct TALER_TESTING_Command
   1395 TALER_TESTING_cmd_reserve_get_attestable (
   1396   const char *label,
   1397   const char *reserve_reference,
   1398   unsigned int expected_response_code,
   1399   ...);
   1400 
   1401 
   1402 /**
   1403  * Create a POST "/reserves/$RID/attest" command.
   1404  *
   1405  * @param label the command label.
   1406  * @param reserve_reference reference to the reserve to get attests for
   1407  * @param expected_response_code expected HTTP response code.
   1408  * @param ... NULL-terminated list of attributes that should be attested
   1409  * @return the command.
   1410  */
   1411 struct TALER_TESTING_Command
   1412 TALER_TESTING_cmd_reserve_attest (
   1413   const char *label,
   1414   const char *reserve_reference,
   1415   unsigned int expected_response_code,
   1416   ...);
   1417 
   1418 
   1419 /**
   1420  * Create a POST "/reserves/$RID/close" command.
   1421  *
   1422  * @param label the command label.
   1423  * @param reserve_reference reference to the reserve to close.
   1424  * @param target_account where to wire funds remaining, can be NULL
   1425  * @param expected_response_code expected HTTP response code.
   1426  * @return the command.
   1427  */
   1428 struct TALER_TESTING_Command
   1429 TALER_TESTING_cmd_reserve_close (
   1430   const char *label,
   1431   const char *reserve_reference,
   1432   struct TALER_FullPayto target_account,
   1433   unsigned int expected_response_code);
   1434 
   1435 
   1436 /**
   1437  * Create a "deposit" command.
   1438  *
   1439  * @param label command label.
   1440  * @param coin_reference reference to any operation that can
   1441  *        provide a coin.
   1442  * @param coin_index if @a withdraw_reference offers an array of
   1443  *        coins, this parameter selects which one in that array.
   1444  *        This value is currently ignored, as only one-coin
   1445  *        withdrawals are implemented.
   1446  * @param target_account_payto target account for the "deposit"
   1447  *        request.
   1448  * @param contract_terms contract terms to be signed over by the
   1449  *        coin.
   1450  * @param refund_deadline refund deadline, zero means 'no refunds'.
   1451  * @param amount how much is going to be deposited.
   1452  * @param expected_response_code expected HTTP response code.
   1453  * @return the command.
   1454  */
   1455 struct TALER_TESTING_Command
   1456 TALER_TESTING_cmd_deposit (
   1457   const char *label,
   1458   const char *coin_reference,
   1459   unsigned int coin_index,
   1460   const struct TALER_FullPayto target_account_payto,
   1461   const char *contract_terms,
   1462   struct GNUNET_TIME_Relative refund_deadline,
   1463   const char *amount,
   1464   unsigned int expected_response_code);
   1465 
   1466 /**
   1467  * Create a "deposit" command that references an existing merchant key.
   1468  *
   1469  * @param label command label.
   1470  * @param coin_reference reference to any operation that can
   1471  *        provide a coin.
   1472  * @param coin_index if @a withdraw_reference offers an array of
   1473  *        coins, this parameter selects which one in that array.
   1474  *        This value is currently ignored, as only one-coin
   1475  *        withdrawals are implemented.
   1476  * @param target_account_payto target account for the "deposit"
   1477  *        request.
   1478  * @param contract_terms contract terms to be signed over by the
   1479  *        coin.
   1480  * @param refund_deadline refund deadline, zero means 'no refunds'.
   1481  *        Note, if time were absolute, then it would have come
   1482  *        one day and disrupt tests meaning.
   1483  * @param amount how much is going to be deposited.
   1484  * @param expected_response_code expected HTTP response code.
   1485  * @param merchant_priv_reference reference to another operation
   1486  *        that has a merchant private key trait
   1487  *
   1488  * @return the command.
   1489  */
   1490 struct TALER_TESTING_Command
   1491 TALER_TESTING_cmd_deposit_with_ref (
   1492   const char *label,
   1493   const char *coin_reference,
   1494   unsigned int coin_index,
   1495   const struct TALER_FullPayto target_account_payto,
   1496   const char *contract_terms,
   1497   struct GNUNET_TIME_Relative refund_deadline,
   1498   const char *amount,
   1499   unsigned int expected_response_code,
   1500   const char *merchant_priv_reference);
   1501 
   1502 /**
   1503  * Modify a deposit command to enable retries when we get transient
   1504  * errors from the exchange.
   1505  *
   1506  * @param cmd a deposit command
   1507  * @return the command with retries enabled
   1508  */
   1509 struct TALER_TESTING_Command
   1510 TALER_TESTING_cmd_deposit_with_retry (struct TALER_TESTING_Command cmd);
   1511 
   1512 
   1513 /**
   1514  * Create a "deposit" command that repeats an existing
   1515  * deposit command.
   1516  *
   1517  * @param label command label.
   1518  * @param deposit_reference which deposit command should we repeat
   1519  * @param expected_response_code expected HTTP response code.
   1520  * @return the command.
   1521  */
   1522 struct TALER_TESTING_Command
   1523 TALER_TESTING_cmd_deposit_replay (const char *label,
   1524                                   const char *deposit_reference,
   1525                                   unsigned int expected_response_code);
   1526 
   1527 
   1528 /**
   1529  * Create a "batch deposit" command.
   1530  *
   1531  * @param label command label.
   1532  * @param target_account_payto target account for the "deposit"
   1533  *        request.
   1534  * @param contract_terms contract terms to be signed over by the
   1535  *        coin.
   1536  * @param refund_deadline refund deadline, zero means 'no refunds'.
   1537  * @param expected_response_code expected HTTP response code.
   1538  * @param ... NULL-terminated list with an even number of
   1539  *            strings that alternate referring to coins
   1540  *            (possibly with index using label#index notation)
   1541  *            and the amount of that coin to deposit
   1542  * @return the command.
   1543  */
   1544 struct TALER_TESTING_Command
   1545 TALER_TESTING_cmd_batch_deposit (
   1546   const char *label,
   1547   const struct TALER_FullPayto target_account_payto,
   1548   const char *contract_terms,
   1549   struct GNUNET_TIME_Relative refund_deadline,
   1550   unsigned int expected_response_code,
   1551   ...);
   1552 
   1553 
   1554 /**
   1555  * Create a "refresh melt" command.
   1556  *
   1557  * @param label command label.
   1558  * @param coin_reference reference to a command
   1559  *        that will provide a coin to refresh.
   1560  * @param expected_response_code expected HTTP code.
   1561  * @param ... NULL-terminated list of amounts to be melted
   1562  * @return the command.
   1563  */
   1564 struct TALER_TESTING_Command
   1565 TALER_TESTING_cmd_melt (const char *label,
   1566                         const char *coin_reference,
   1567                         unsigned int expected_response_code,
   1568                         ...);
   1569 
   1570 
   1571 /**
   1572  * Create a "refresh melt" CMD that does TWO /refresh/melt
   1573  * requests.  This was needed to test the replay of a valid melt
   1574  * request, see #5312.
   1575  *
   1576  * @param label command label
   1577  * @param coin_reference reference to a command that will provide
   1578  *        a coin to refresh
   1579  * @param expected_response_code expected HTTP code
   1580  * @param ... NULL-terminated list of amounts to be melted
   1581  * @return the command.
   1582  */
   1583 struct TALER_TESTING_Command
   1584 TALER_TESTING_cmd_melt_double (const char *label,
   1585                                const char *coin_reference,
   1586                                unsigned int expected_response_code,
   1587                                ...);
   1588 
   1589 
   1590 /**
   1591  * Modify a "refresh melt" command to enable retries.
   1592  *
   1593  * @param cmd command
   1594  * @return modified command.
   1595  */
   1596 struct TALER_TESTING_Command
   1597 TALER_TESTING_cmd_melt_with_retry (struct TALER_TESTING_Command cmd);
   1598 
   1599 
   1600 /**
   1601  * Create a "refresh reveal" command.
   1602  *
   1603  * @param label command label.
   1604  * @param melt_reference reference to a "refresh melt" command.
   1605  * @param expected_response_code expected HTTP response code.
   1606  * @return the command.
   1607  */
   1608 struct TALER_TESTING_Command
   1609 TALER_TESTING_cmd_melt_reveal (const char *label,
   1610                                const char *melt_reference,
   1611                                unsigned int expected_response_code);
   1612 
   1613 
   1614 /**
   1615  * Modify a "refresh reveal" command to enable retries.
   1616  *
   1617  * @param cmd command
   1618  * @return modified command.
   1619  */
   1620 struct TALER_TESTING_Command
   1621 TALER_TESTING_cmd_melt_reveal_with_retry (struct TALER_TESTING_Command cmd);
   1622 
   1623 
   1624 /**
   1625  * Create a "track transaction" command.
   1626  *
   1627  * @param label the command label.
   1628  * @param transaction_reference reference to a deposit operation,
   1629  *        will be used to get the input data for the track.
   1630  * @param coin_index index of the coin involved in the transaction.
   1631  * @param expected_response_code expected HTTP response code.
   1632  * @param bank_transfer_reference reference to a command that
   1633  *        can offer a WTID so as to check that against what WTID
   1634  *        the tracked operation has.  Set as NULL if not needed.
   1635  * @return the command.
   1636  */
   1637 struct TALER_TESTING_Command
   1638 TALER_TESTING_cmd_deposits_get (const char *label,
   1639                                 const char *transaction_reference,
   1640                                 unsigned int coin_index,
   1641                                 unsigned int expected_response_code,
   1642                                 const char *bank_transfer_reference);
   1643 
   1644 /**
   1645  * Make a "track transfer" CMD where no "expected"-arguments,
   1646  * except the HTTP response code, are given.  The best use case
   1647  * is when what matters to check is the HTTP response code, e.g.
   1648  * when a bogus WTID was passed.
   1649  *
   1650  * @param label the command label
   1651  * @param wtid_reference reference to any command which can provide
   1652  *        a wtid.  If NULL is given, then a all zeroed WTID is
   1653  *        used that will at 99.9999% probability NOT match any
   1654  *        existing WTID known to the exchange.
   1655  * @param expected_response_code expected HTTP response code.
   1656  * @return the command.
   1657  */
   1658 struct TALER_TESTING_Command
   1659 TALER_TESTING_cmd_track_transfer_empty (const char *label,
   1660                                         const char *wtid_reference,
   1661                                         unsigned int expected_response_code);
   1662 
   1663 
   1664 /**
   1665  * Make a "track transfer" command, specifying which amount and
   1666  * wire fee are expected.
   1667  *
   1668  * @param label the command label.
   1669  * @param wtid_reference reference to any command which can provide
   1670  *        a wtid.  Will be the one tracked.
   1671  * @param expected_response_code expected HTTP response code.
   1672  * @param expected_total_amount how much money we expect being moved
   1673  *        with this wire-transfer.
   1674  * @param expected_wire_fee expected wire fee.
   1675  * @return the command
   1676  */
   1677 struct TALER_TESTING_Command
   1678 TALER_TESTING_cmd_track_transfer (const char *label,
   1679                                   const char *wtid_reference,
   1680                                   unsigned int expected_response_code,
   1681                                   const char *expected_total_amount,
   1682                                   const char *expected_wire_fee);
   1683 
   1684 
   1685 /**
   1686  * Make a "bank check" CMD.  It checks whether a particular wire transfer from
   1687  * the exchange (debit) has been made or not.
   1688  *
   1689  * @param label the command label.
   1690  * @param exchange_base_url base url of the exchange involved in
   1691  *        the wire transfer.
   1692  * @param amount the amount expected to be transferred.
   1693  * @param debit_payto the account that gave money.
   1694  * @param credit_payto the account that received money.
   1695  * @return the command
   1696  */
   1697 struct TALER_TESTING_Command
   1698 TALER_TESTING_cmd_check_bank_transfer (
   1699   const char *label,
   1700   const char *exchange_base_url,
   1701   const char *amount,
   1702   const struct TALER_FullPayto debit_payto,
   1703   const struct TALER_FullPayto credit_payto);
   1704 
   1705 
   1706 /**
   1707  * Make a "bank check" CMD.  It checks whether a particular wire transfer to
   1708  * the exchange (credit) has been made or not.
   1709  *
   1710  * @param label the command label.
   1711  * @param amount the amount expected to be transferred.
   1712  * @param debit_payto the account that gave money.
   1713  * @param credit_payto the account that received money.
   1714  * @param reserve_pub_ref command that provides the reserve public key to expect
   1715  * @return the command
   1716  */
   1717 struct TALER_TESTING_Command
   1718 TALER_TESTING_cmd_check_bank_admin_transfer (
   1719   const char *label,
   1720   const char *amount,
   1721   const struct TALER_FullPayto debit_payto,
   1722   const struct TALER_FullPayto credit_payto,
   1723   const char *reserve_pub_ref);
   1724 
   1725 
   1726 /**
   1727  * Define a "bank check" CMD that takes the input
   1728  * data from another CMD that offers it.
   1729  *
   1730  * @param label command label.
   1731  * @param deposit_reference reference to a CMD that is
   1732  *        able to provide the "check bank transfer" operation
   1733  *        input data.
   1734  *
   1735  * @return the command.
   1736  */
   1737 struct TALER_TESTING_Command
   1738 TALER_TESTING_cmd_check_bank_transfer_with_ref (
   1739   const char *label,
   1740   const char *deposit_reference);
   1741 
   1742 
   1743 /**
   1744  * Checks whether all the wire transfers got "checked"
   1745  * by the "bank check" CMD.
   1746  *
   1747  * @param label command label.
   1748  *
   1749  * @return the command
   1750  */
   1751 struct TALER_TESTING_Command
   1752 TALER_TESTING_cmd_check_bank_empty (const char *label);
   1753 
   1754 
   1755 /**
   1756  * Create a "refund" command, allow to specify refund transaction
   1757  * id.  Mainly used to create conflicting requests.
   1758  *
   1759  * @param label command label.
   1760  * @param expected_response_code expected HTTP status code.
   1761  * @param refund_amount the amount to ask a refund for.
   1762  * @param coin_reference reference to a command that can
   1763  *        provide a coin to be refunded.
   1764  * @param refund_transaction_id transaction id to use
   1765  *        in the request.
   1766  * @return the command.
   1767  */
   1768 struct TALER_TESTING_Command
   1769 TALER_TESTING_cmd_refund_with_id (const char *label,
   1770                                   unsigned int expected_response_code,
   1771                                   const char *refund_amount,
   1772                                   const char *coin_reference,
   1773                                   uint64_t refund_transaction_id);
   1774 
   1775 
   1776 /**
   1777  * Create a "refund" command.
   1778  *
   1779  * @param label command label.
   1780  * @param expected_response_code expected HTTP status code.
   1781  * @param refund_amount the amount to ask a refund for.
   1782  * @param coin_reference reference to a command that can
   1783  *        provide a coin to be refunded.
   1784  * @return the command.
   1785  */
   1786 struct TALER_TESTING_Command
   1787 TALER_TESTING_cmd_refund (const char *label,
   1788                           unsigned int expected_response_code,
   1789                           const char *refund_amount,
   1790                           const char *coin_reference);
   1791 
   1792 
   1793 /**
   1794  * Make a "recoup" command.
   1795  *
   1796  * @param label the command label
   1797  * @param expected_response_code expected HTTP status code
   1798  * @param coin_reference reference to any command which
   1799  *        offers a coin and reserve private key.  May specify
   1800  *        the index of the coin using "$LABEL#$INDEX" syntax.
   1801  *        Here, $INDEX must be a non-negative number.
   1802  * @param amount how much do we expect to recoup, NULL for nothing
   1803  * @return the command.
   1804  */
   1805 struct TALER_TESTING_Command
   1806 TALER_TESTING_cmd_recoup (const char *label,
   1807                           unsigned int expected_response_code,
   1808                           const char *coin_reference,
   1809                           const char *amount);
   1810 
   1811 
   1812 /**
   1813  * Make a "recoup-refresh" command.
   1814  *
   1815  * @param label the command label
   1816  * @param expected_response_code expected HTTP status code
   1817  * @param coin_reference reference to any command which
   1818  *        offers a coin and reserve private key.  May specify
   1819  *        the index of the coin using "$LABEL#$INDEX" syntax.
   1820  *        Here, $INDEX must be a non-negative number.
   1821  * @param melt_reference label of the melt operation
   1822  * @param amount how much do we expect to recoup, NULL for nothing
   1823  * @return the command.
   1824  */
   1825 struct TALER_TESTING_Command
   1826 TALER_TESTING_cmd_recoup_refresh (const char *label,
   1827                                   unsigned int expected_response_code,
   1828                                   const char *coin_reference,
   1829                                   const char *melt_reference,
   1830                                   const char *amount);
   1831 
   1832 
   1833 /**
   1834  * Make a "revoke" command.
   1835  *
   1836  * @param label the command label.
   1837  * @param expected_response_code expected HTTP status code.
   1838  * @param coin_reference reference to a CMD that will offer the
   1839  *        denomination to revoke.
   1840  * @param config_filename configuration file name.
   1841  * @return the command.
   1842  */
   1843 struct TALER_TESTING_Command
   1844 TALER_TESTING_cmd_revoke (const char *label,
   1845                           unsigned int expected_response_code,
   1846                           const char *coin_reference,
   1847                           const char *config_filename);
   1848 
   1849 
   1850 /**
   1851  * Create a "signal" CMD.
   1852  *
   1853  * @param label command label.
   1854  * @param process handle to the process to signal.
   1855  * @param signal signal to send.
   1856  *
   1857  * @return the command.
   1858  */
   1859 struct TALER_TESTING_Command
   1860 TALER_TESTING_cmd_signal (const char *label,
   1861                           struct GNUNET_Process *process,
   1862                           int signal);
   1863 
   1864 
   1865 /**
   1866  * Sleep for @a duration_s seconds.
   1867  *
   1868  * @param label command label.
   1869  * @param duration_s number of seconds to sleep
   1870  * @return the command.
   1871  */
   1872 struct TALER_TESTING_Command
   1873 TALER_TESTING_cmd_sleep (const char *label,
   1874                          unsigned int duration_s);
   1875 
   1876 
   1877 /**
   1878  * This CMD simply tries to connect via HTTP to the
   1879  * service addressed by @a url.  It attempts 10 times
   1880  * before giving up and make the test fail.
   1881  *
   1882  * @param label label for the command.
   1883  * @param url complete URL to connect to.
   1884  */
   1885 struct TALER_TESTING_Command
   1886 TALER_TESTING_cmd_wait_service (const char *label,
   1887                                 const char *url);
   1888 
   1889 /**
   1890  * Create a "batch" command.  Such command takes a
   1891  * end_CMD-terminated array of CMDs and executed them.
   1892  * Once it hits the end CMD, it passes the control
   1893  * to the next top-level CMD, regardless of it being
   1894  * another batch or ordinary CMD.
   1895  *
   1896  * @param label the command label.
   1897  * @param batch array of CMDs to execute.
   1898  *
   1899  * @return the command.
   1900  */
   1901 struct TALER_TESTING_Command
   1902 TALER_TESTING_cmd_batch (const char *label,
   1903                          struct TALER_TESTING_Command *batch);
   1904 
   1905 
   1906 /**
   1907  * Test if this command is a batch command.
   1908  *
   1909  * @return false if not, true if it is a batch command
   1910  */
   1911 bool
   1912 TALER_TESTING_cmd_is_batch (const struct TALER_TESTING_Command *cmd);
   1913 
   1914 
   1915 /**
   1916  * Advance internal pointer to next command.
   1917  *
   1918  * @param is interpreter state.
   1919  * @param[in,out] cls closure of the batch
   1920  * @return true to advance IP in parent
   1921  */
   1922 bool
   1923 TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is,
   1924                               void *cls);
   1925 
   1926 
   1927 /**
   1928  * Obtain what command the batch is at.
   1929  *
   1930  * @return cmd current batch command
   1931  */
   1932 struct TALER_TESTING_Command *
   1933 TALER_TESTING_cmd_batch_get_current (const struct TALER_TESTING_Command *cmd);
   1934 
   1935 
   1936 /**
   1937  * Set what command the batch should be at.
   1938  *
   1939  * @param cmd current batch command
   1940  * @param new_ip where to move the IP
   1941  */
   1942 void
   1943 TALER_TESTING_cmd_batch_set_current (const struct TALER_TESTING_Command *cmd,
   1944                                      unsigned int new_ip);
   1945 
   1946 
   1947 /**
   1948  * Make the "insert-deposit" CMD.
   1949  *
   1950  * @param label command label.
   1951  * @param db_cfg configuration to talk to the DB
   1952  * @param merchant_name Human-readable name of the merchant.
   1953  * @param merchant_account merchant's account name (NOT a payto:// URI)
   1954  * @param exchange_timestamp when did the exchange receive the deposit
   1955  * @param wire_deadline point in time where the aggregator should have
   1956  *        wired money to the merchant.
   1957  * @param amount_with_fee amount to deposit (inclusive of deposit fee)
   1958  * @param deposit_fee deposit fee
   1959  * @return the command.
   1960  */
   1961 struct TALER_TESTING_Command
   1962 TALER_TESTING_cmd_insert_deposit (
   1963   const char *label,
   1964   const struct GNUNET_CONFIGURATION_Handle *db_cfg,
   1965   const char *merchant_name,
   1966   const char *merchant_account,
   1967   struct GNUNET_TIME_Timestamp exchange_timestamp,
   1968   struct GNUNET_TIME_Relative wire_deadline,
   1969   const char *amount_with_fee,
   1970   const char *deposit_fee);
   1971 
   1972 
   1973 /**
   1974  * Performance counter.
   1975  */
   1976 struct TALER_TESTING_Timer
   1977 {
   1978   /**
   1979    * For which type of commands.
   1980    */
   1981   const char *prefix;
   1982 
   1983   /**
   1984    * Total time spend in all commands of this type.
   1985    */
   1986   struct GNUNET_TIME_Relative total_duration;
   1987 
   1988   /**
   1989    * Total time spend waiting for the *successful* execution
   1990    * in all commands of this type.
   1991    */
   1992   struct GNUNET_TIME_Relative success_latency;
   1993 
   1994   /**
   1995    * Number of commands summed up.
   1996    */
   1997   unsigned int num_commands;
   1998 
   1999   /**
   2000    * Number of retries summed up.
   2001    */
   2002   unsigned int num_retries;
   2003 };
   2004 
   2005 
   2006 /**
   2007  * Obtain performance data from the interpreter.
   2008  *
   2009  * @param[in,out] timers what commands (by label) to obtain runtimes for
   2010  * @return the command
   2011  */
   2012 struct TALER_TESTING_Command
   2013 TALER_TESTING_cmd_stat (struct TALER_TESTING_Timer *timers);
   2014 
   2015 
   2016 /**
   2017  * Add the auditor to the exchange's list of auditors.
   2018  * The information about the auditor is taken from the
   2019  * "[auditor]" section in the configuration file.
   2020  *
   2021  * @param label command label.
   2022  * @param expected_http_status expected HTTP status from exchange
   2023  * @param bad_sig should we use a bogus signature?
   2024  * @return the command
   2025  */
   2026 struct TALER_TESTING_Command
   2027 TALER_TESTING_cmd_auditor_add (const char *label,
   2028                                unsigned int expected_http_status,
   2029                                bool bad_sig);
   2030 
   2031 
   2032 /**
   2033  * Remove the auditor from the exchange's list of auditors.
   2034  * The information about the auditor is taken from the
   2035  * "[auditor]" section in the configuration file.
   2036  *
   2037  * @param label command label.
   2038  * @param expected_http_status expected HTTP status from exchange
   2039  * @param bad_sig should we use a bogus signature?
   2040  * @return the command
   2041  */
   2042 struct TALER_TESTING_Command
   2043 TALER_TESTING_cmd_auditor_del (const char *label,
   2044                                unsigned int expected_http_status,
   2045                                bool bad_sig);
   2046 
   2047 
   2048 /**
   2049  * Add affirmation that the auditor is auditing the given
   2050  * denomination.
   2051  * The information about the auditor is taken from the
   2052  * "[auditor]" section in the configuration file.
   2053  *
   2054  * @param label command label.
   2055  * @param expected_http_status expected HTTP status from exchange
   2056  * @param denom_ref reference to a command identifying a denomination key
   2057  * @param bad_sig should we use a bogus signature?
   2058  * @return the command
   2059  */
   2060 struct TALER_TESTING_Command
   2061 TALER_TESTING_cmd_auditor_add_denom_sig (const char *label,
   2062                                          unsigned int expected_http_status,
   2063                                          const char *denom_ref,
   2064                                          bool bad_sig);
   2065 
   2066 
   2067 /**
   2068  * Add statement about wire fees of the exchange. This is always
   2069  * done for a few hours around the current time (for the test).
   2070  *
   2071  * @param label command label.
   2072  * @param wire_method wire method to set wire fees for
   2073  * @param wire_fee the wire fee to affirm
   2074  * @param closing_fee the closing fee to affirm
   2075  * @param expected_http_status expected HTTP status from exchange
   2076  * @param bad_sig should we use a bogus signature?
   2077  * @return the command
   2078  */
   2079 struct TALER_TESTING_Command
   2080 TALER_TESTING_cmd_set_wire_fee (const char *label,
   2081                                 const char *wire_method,
   2082                                 const char *wire_fee,
   2083                                 const char *closing_fee,
   2084                                 unsigned int expected_http_status,
   2085                                 bool bad_sig);
   2086 
   2087 
   2088 /**
   2089  * Add the given payto-URI bank account to the list of bank
   2090  * accounts used by the exchange.
   2091  *
   2092  * @param label command label.
   2093  * @param payto_uri URI identifying the bank account
   2094  * @param expected_http_status expected HTTP status from exchange
   2095  * @param bad_sig should we use a bogus signature?
   2096  * @return the command
   2097  */
   2098 struct TALER_TESTING_Command
   2099 TALER_TESTING_cmd_wire_add (const char *label,
   2100                             const struct TALER_FullPayto payto_uri,
   2101                             unsigned int expected_http_status,
   2102                             bool bad_sig);
   2103 
   2104 
   2105 /**
   2106  * Remove the given payto-URI bank account from the list of bank
   2107  * accounts used by the exchange.
   2108  *
   2109  * @param label command label.
   2110  * @param payto_uri URI identifying the bank account
   2111  * @param expected_http_status expected HTTP status from exchange
   2112  * @param bad_sig should we use a bogus signature?
   2113  * @return the command
   2114  */
   2115 struct TALER_TESTING_Command
   2116 TALER_TESTING_cmd_wire_del (const char *label,
   2117                             const struct TALER_FullPayto payto_uri,
   2118                             unsigned int expected_http_status,
   2119                             bool bad_sig);
   2120 
   2121 /**
   2122  * Sign all exchange denomination and online signing keys
   2123  * with the "offline" key and provide those signatures to
   2124  * the exchange. (Downloads the keys, makes the signature
   2125  * and uploads the result, all in one.)
   2126  *
   2127  * @param label command label.
   2128  * @param config_filename configuration filename.
   2129  * @return the command
   2130  */
   2131 struct TALER_TESTING_Command
   2132 TALER_TESTING_cmd_exec_offline_sign_keys (const char *label,
   2133                                           const char *config_filename);
   2134 
   2135 
   2136 /**
   2137  * Sign a wire fee structure.
   2138  *
   2139  * @param label command label.
   2140  * @param config_filename configuration filename.
   2141  * @param wire_fee the wire fee to affirm (for the current year)
   2142  * @param closing_fee the closing fee to affirm (for the current year)
   2143  * @return the command
   2144  */
   2145 struct TALER_TESTING_Command
   2146 TALER_TESTING_cmd_exec_offline_sign_fees (const char *label,
   2147                                           const char *config_filename,
   2148                                           const char *wire_fee,
   2149                                           const char *closing_fee);
   2150 
   2151 
   2152 /**
   2153  * Sign global fee structure.
   2154  *
   2155  * @param label command label.
   2156  * @param config_filename configuration filename.
   2157  * @param history_fee the history fee to charge (for the current year)
   2158  * @param account_fee the account fee to charge (for the current year)
   2159  * @param purse_fee the purse fee to charge (for the current year)
   2160  * @param purse_timeout when do purses time out
   2161  * @param history_expiration when does an account history expire
   2162  * @param num_purses number of (free) active purses per account
   2163  * @return the command
   2164  */
   2165 struct TALER_TESTING_Command
   2166 TALER_TESTING_cmd_exec_offline_sign_global_fees (
   2167   const char *label,
   2168   const char *config_filename,
   2169   const char *history_fee,
   2170   const char *account_fee,
   2171   const char *purse_fee,
   2172   struct GNUNET_TIME_Relative purse_timeout,
   2173   struct GNUNET_TIME_Relative history_expiration,
   2174   unsigned int num_purses);
   2175 
   2176 
   2177 /**
   2178  * Revoke an exchange denomination key.
   2179  *
   2180  * @param label command label.
   2181  * @param expected_response_code expected HTTP status from exchange
   2182  * @param bad_sig should we use a bogus signature?
   2183  * @param denom_ref reference to a command that identifies
   2184  *        a denomination key (i.e. because it was used to
   2185  *        withdraw a coin).
   2186  * @return the command
   2187  */
   2188 struct TALER_TESTING_Command
   2189 TALER_TESTING_cmd_revoke_denom_key (
   2190   const char *label,
   2191   unsigned int expected_response_code,
   2192   bool bad_sig,
   2193   const char *denom_ref);
   2194 
   2195 
   2196 /**
   2197  * Revoke an exchange online signing key.
   2198  *
   2199  * @param label command label.
   2200  * @param expected_response_code expected HTTP status from exchange
   2201  * @param bad_sig should we use a bogus signature?
   2202  * @param signkey_ref reference to a command that identifies
   2203  *        a signing key (i.e. because it was used to
   2204  *        sign a deposit confirmation).
   2205  * @return the command
   2206  */
   2207 struct TALER_TESTING_Command
   2208 TALER_TESTING_cmd_revoke_sign_key (
   2209   const char *label,
   2210   unsigned int expected_response_code,
   2211   bool bad_sig,
   2212   const char *signkey_ref);
   2213 
   2214 
   2215 /**
   2216  * Create a request for a wallet's KYC UUID.
   2217  *
   2218  * @param label command label.
   2219  * @param reserve_reference command with reserve private key to use (or NULL to create a fresh reserve key).
   2220  * @param threshold_balance balance amount to pass to the exchange
   2221  * @param expected_response_code expected HTTP status
   2222  * @return the command
   2223  */
   2224 struct TALER_TESTING_Command
   2225 TALER_TESTING_cmd_wallet_kyc_get (
   2226   const char *label,
   2227   const char *reserve_reference,
   2228   const char *threshold_balance,
   2229   unsigned int expected_response_code);
   2230 
   2231 
   2232 /**
   2233  * Create a request for an account's KYC status.
   2234  *
   2235  * @param label command label.
   2236  * @param payment_target_reference command with a payment target to query
   2237  * @param account_reference command with account private key to query
   2238  * @param lpt target for long polling
   2239  * @param expected_response_code expected HTTP status
   2240  * @return the command
   2241  */
   2242 struct TALER_TESTING_Command
   2243 TALER_TESTING_cmd_check_kyc_get (
   2244   const char *label,
   2245   const char *payment_target_reference,
   2246   const char *account_reference,
   2247   enum TALER_EXCHANGE_KycLongPollTarget lpt,
   2248   unsigned int expected_response_code);
   2249 
   2250 
   2251 /**
   2252  * Create a request for detailed account KYC information.
   2253  *
   2254  * @param label command label.
   2255  * @param kyc_check_reference command with account access token trait to use
   2256  * @param expected_response_code expected HTTP status
   2257  * @return the command
   2258  */
   2259 struct TALER_TESTING_Command
   2260 TALER_TESTING_cmd_get_kyc_info (
   2261   const char *label,
   2262   const char *kyc_check_reference,
   2263   unsigned int expected_response_code);
   2264 
   2265 
   2266 /**
   2267  * Start external KYC process.
   2268  *
   2269  * @param label command label.
   2270  * @param kyc_info_reference command with requirement information about the KYC process
   2271  * @param requirement_index index of the KYC requirement to trigger the KYC start for
   2272  * @param expected_response_code expected HTTP status
   2273  * @return the command
   2274  */
   2275 struct TALER_TESTING_Command
   2276 TALER_TESTING_cmd_post_kyc_start (
   2277   const char *label,
   2278   const char *kyc_info_reference,
   2279   unsigned int requirement_index,
   2280   unsigned int expected_response_code);
   2281 
   2282 
   2283 /**
   2284  * Upload KYC data for a FORM requirement.
   2285  *
   2286  * @param label command label.
   2287  * @param kyc_info_reference command with requirement information about the KYC process
   2288  * @param requirement_index index of the KYC requirement to upload KYC data for
   2289  * @param form_data_content_type content type of @a form_data
   2290  * @param form_data form data to upload
   2291  * @param expected_response_code expected HTTP status
   2292  * @return the command
   2293  */
   2294 struct TALER_TESTING_Command
   2295 TALER_TESTING_cmd_post_kyc_form (
   2296   const char *label,
   2297   const char *kyc_info_reference,
   2298   unsigned int requirement_index,
   2299   const char *form_data_content_type,
   2300   const char *form_data,
   2301   unsigned int expected_response_code);
   2302 
   2303 
   2304 /**
   2305  * Create a KYC proof request. Only useful in conjunction with the OAuth2.0
   2306  * logic, as it generates an OAuth2.0-specific request.
   2307  *
   2308  * @param label command label.
   2309  * @param payment_target_reference command with a payment target to query
   2310  * @param logic_section name of the KYC provider section
   2311  *         in the exchange configuration for this proof
   2312  * @param code OAuth 2.0 code to use
   2313  * @param expected_response_code expected HTTP status
   2314  * @return the command
   2315  */
   2316 struct TALER_TESTING_Command
   2317 TALER_TESTING_cmd_proof_kyc_oauth2 (
   2318   const char *label,
   2319   const char *payment_target_reference,
   2320   const char *logic_section,
   2321   const char *code,
   2322   unsigned int expected_response_code);
   2323 
   2324 
   2325 /**
   2326  * Starts a fake OAuth 2.0 service on @a port for testing
   2327  * KYC processes which also provides a @a birthdate in a response
   2328  *
   2329  * @param label command label
   2330  * @param birthdate fixed birthdate, such as "2022-03-04", "2022-03-00", "2022-00-00"
   2331  * @param port the TCP port to listen on
   2332  */
   2333 struct TALER_TESTING_Command
   2334 TALER_TESTING_cmd_oauth_with_birthdate (const char *label,
   2335                                         const char *birthdate,
   2336                                         uint16_t port);
   2337 
   2338 /**
   2339  * Starts a fake OAuth 2.0 service on @a port for testing
   2340  * KYC processes.
   2341  *
   2342  * @param label command label
   2343  * @param port the TCP port to listen on
   2344  */
   2345 #define TALER_TESTING_cmd_oauth(label, port) \
   2346         TALER_TESTING_cmd_oauth_with_birthdate ((label), NULL, (port))
   2347 
   2348 
   2349 /* ****************** P2P payment commands ****************** */
   2350 
   2351 
   2352 /**
   2353  * Creates a purse with deposits.
   2354  *
   2355  * @param label command label
   2356  * @param expected_http_status what HTTP status do we expect to get returned from the exchange
   2357  * @param contract_terms contract, JSON string
   2358  * @param upload_contract should we upload the contract
   2359  * @param purse_expiration how long until the purse expires
   2360  * @param ... NULL-terminated list of references to coins to be deposited
   2361  * @return the command
   2362  */
   2363 struct TALER_TESTING_Command
   2364 TALER_TESTING_cmd_purse_create_with_deposit (
   2365   const char *label,
   2366   unsigned int expected_http_status,
   2367   const char *contract_terms,
   2368   bool upload_contract,
   2369   struct GNUNET_TIME_Relative purse_expiration,
   2370   ...);
   2371 
   2372 
   2373 /**
   2374  * Deletes a purse.
   2375  *
   2376  * @param label command label
   2377  * @param expected_http_status what HTTP status do we expect to get returned from the exchange
   2378  * @param purse_cmd command that created the purse
   2379  * @return the command
   2380  */
   2381 struct TALER_TESTING_Command
   2382 TALER_TESTING_cmd_purse_delete (
   2383   const char *label,
   2384   unsigned int expected_http_status,
   2385   const char *purse_cmd);
   2386 
   2387 
   2388 /**
   2389  * Retrieve contract (also checks that the contract matches
   2390  * the upload command).
   2391  *
   2392  * @param label command label
   2393  * @param expected_http_status what HTTP status do we expect to get returned from the exchange
   2394  * @param for_merge true if for merge, false if for deposit
   2395  * @param contract_ref reference to a command providing us with the contract private key
   2396  * @return the command
   2397  */
   2398 struct TALER_TESTING_Command
   2399 TALER_TESTING_cmd_contract_get (
   2400   const char *label,
   2401   unsigned int expected_http_status,
   2402   bool for_merge,
   2403   const char *contract_ref);
   2404 
   2405 
   2406 /**
   2407  * Retrieve purse state by merge private key.
   2408  *
   2409  * @param label command label
   2410  * @param expected_http_status what HTTP status do we expect to get returned from the exchange
   2411  * @param merge_ref reference to a command providing us with the merge private key
   2412  * @param reserve_ref reference to a command providing us with a reserve private key; if NULL, we create a fresh reserve
   2413  * @return the command
   2414  */
   2415 struct TALER_TESTING_Command
   2416 TALER_TESTING_cmd_purse_merge (
   2417   const char *label,
   2418   unsigned int expected_http_status,
   2419   const char *merge_ref,
   2420   const char *reserve_ref);
   2421 
   2422 
   2423 /**
   2424  * Retrieve purse state.
   2425  *
   2426  * @param label command label
   2427  * @param expected_http_status what HTTP status do we expect to get returned from the exchange
   2428  * @param purse_ref reference to a command providing us with the purse private key
   2429  * @param expected_balance how much should be in the purse
   2430  * @param wait_for_merge true to wait for a merge event, otherwise wait for a deposit event
   2431  * @param timeout how long to wait
   2432  * @return the command
   2433  */
   2434 struct TALER_TESTING_Command
   2435 TALER_TESTING_cmd_purse_poll (
   2436   const char *label,
   2437   unsigned int expected_http_status,
   2438   const char *purse_ref,
   2439   const char *expected_balance,
   2440   bool wait_for_merge,
   2441   struct GNUNET_TIME_Relative timeout);
   2442 
   2443 
   2444 /**
   2445  * Wait for the poll command to complete.
   2446  *
   2447  * @param label command label
   2448  * @param timeout how long to wait at most
   2449  * @param poll_reference which poll command to wait for
   2450  * @return the command
   2451  */
   2452 struct TALER_TESTING_Command
   2453 TALER_TESTING_cmd_purse_poll_finish (const char *label,
   2454                                      struct GNUNET_TIME_Relative timeout,
   2455                                      const char *poll_reference);
   2456 
   2457 
   2458 /**
   2459  * Creates a purse with reserve.
   2460  *
   2461  * @param label command label
   2462  * @param expected_http_status what HTTP status do we expect to get returned from the exchange
   2463  * @param contract_terms contract, JSON string
   2464  * @param upload_contract should we upload the contract
   2465  * @param pay_purse_fee should we pay a fee to create the purse
   2466  * @param expiration when should the purse expire
   2467  * @param reserve_ref reference to reserve key, or NULL to create a new reserve
   2468  * @return the command
   2469  */
   2470 struct TALER_TESTING_Command
   2471 TALER_TESTING_cmd_purse_create_with_reserve (
   2472   const char *label,
   2473   unsigned int expected_http_status,
   2474   const char *contract_terms,
   2475   bool upload_contract,
   2476   bool pay_purse_fee,
   2477   struct GNUNET_TIME_Relative expiration,
   2478   const char *reserve_ref);
   2479 
   2480 
   2481 /**
   2482  * Deposit coins into a purse.
   2483  *
   2484  * @param label command label
   2485  * @param expected_http_status what HTTP status do we expect to get returned from the exchange
   2486  * @param min_age age restriction of the purse
   2487  * @param purse_ref reference to the purse
   2488  * @param ... NULL-terminated list of references to coins to be deposited
   2489  * @return the command
   2490  */
   2491 struct TALER_TESTING_Command
   2492 TALER_TESTING_cmd_purse_deposit_coins (
   2493   const char *label,
   2494   unsigned int expected_http_status,
   2495   uint8_t min_age,
   2496   const char *purse_ref,
   2497   ...);
   2498 
   2499 
   2500 /**
   2501  * Setup AML officer.
   2502  *
   2503  * @param label command label
   2504  * @param ref_cmd command that previously created the
   2505  *       officer, NULL to create one this time
   2506  * @param name full legal name of the officer to use
   2507  * @param is_active true to set the officer to active
   2508  * @param read_only true to restrict the officer to read-only
   2509  * @return the command
   2510  */
   2511 struct TALER_TESTING_Command
   2512 TALER_TESTING_cmd_set_officer (
   2513   const char *label,
   2514   const char *ref_cmd,
   2515   const char *name,
   2516   bool is_active,
   2517   bool read_only);
   2518 
   2519 
   2520 /**
   2521  * Make AML decision.
   2522  *
   2523  * @param label command label
   2524  * @param ref_officer command that previously created an
   2525  *       officer
   2526  * @param ref_operation command that previously created an
   2527  *       h_payto which to make an AML decision about
   2528  * @param keep_investigating true to keep investigating
   2529  * @param expiration_delay how long should the @a new_rules apply
   2530  * @param successor_measure measure to trigger on @a expiration_delay
   2531  * @param new_rules JSON with new rules for the account
   2532  * @param properties properties to set for the account
   2533  * @param justification justification given for the decision
   2534  * @param expected_response expected HTTP return status
   2535  * @return the command
   2536  */
   2537 struct TALER_TESTING_Command
   2538 TALER_TESTING_cmd_take_aml_decision (
   2539   const char *label,
   2540   const char *ref_officer,
   2541   const char *ref_operation,
   2542   bool keep_investigating,
   2543   struct GNUNET_TIME_Relative expiration_delay,
   2544   const char *successor_measure,
   2545   const char *new_rules,
   2546   const char *properties,
   2547   const char *justification,
   2548   unsigned int expected_response);
   2549 
   2550 
   2551 /**
   2552  * Lookup active legitimization measure for a particular account.
   2553  *
   2554  * @param label command label
   2555  * @param ref_officer command that previously created an
   2556  *       officer
   2557  * @param ref_operation command that previously created an
   2558  *       h_payto which to make an AML decision about
   2559  * @param expected_response expected HTTP return status
   2560  * @param expected_measures legitimization measure we expect to find, NULL if none
   2561  * @return the command
   2562  */
   2563 struct TALER_TESTING_Command
   2564 TALER_TESTING_cmd_get_active_legitimization_measures (
   2565   const char *label,
   2566   const char *ref_officer,
   2567   const char *ref_operation,
   2568   unsigned int expected_response,
   2569   const char *expected_measures);
   2570 
   2571 
   2572 /**
   2573  * Fetch and check AML decision.
   2574  *
   2575  * @param label command label
   2576  * @param ref_officer command that previously created an
   2577  *       officer
   2578  * @param ref_operation command that previously created an
   2579  *       h_payto which to make an AML decision about;
   2580  *       If it has also a justification trait,
   2581  *       we check that this is the current justification
   2582  *       for the latest AML decision.
   2583  * @param expected_http_status expected HTTP response status
   2584  * @return the command
   2585  */
   2586 struct TALER_TESTING_Command
   2587 TALER_TESTING_cmd_check_aml_decisions (
   2588   const char *label,
   2589   const char *ref_officer,
   2590   const char *ref_operation,
   2591   unsigned int expected_http_status);
   2592 
   2593 
   2594 /* ****************** convenience functions ************** */
   2595 
   2596 /**
   2597  * Get exchange URL from interpreter. Convenience function.
   2598  *
   2599  * @param is interpreter state.
   2600  * @return the exchange URL, or NULL on error
   2601  */
   2602 const char *
   2603 TALER_TESTING_get_exchange_url (
   2604   struct TALER_TESTING_Interpreter *is);
   2605 
   2606 
   2607 /**
   2608  * Get exchange keys from interpreter. Convenience function.
   2609  *
   2610  * @param is interpreter state.
   2611  * @return the exchange keys, or NULL on error
   2612  */
   2613 struct TALER_EXCHANGE_Keys *
   2614 TALER_TESTING_get_keys (
   2615   struct TALER_TESTING_Interpreter *is);
   2616 
   2617 
   2618 /* *** Generic trait logic for implementing traits ********* */
   2619 
   2620 
   2621 /**
   2622  * Opaque handle to fresh coins generated during refresh.
   2623  * Details are internal to the refresh logic.
   2624  */
   2625 struct TALER_TESTING_FreshCoinData;
   2626 
   2627 
   2628 /**
   2629  * A trait.
   2630  */
   2631 struct TALER_TESTING_Trait
   2632 {
   2633   /**
   2634    * Index number associated with the trait.  This gives the
   2635    * possibility to have _multiple_ traits on offer under the
   2636    * same name.
   2637    */
   2638   unsigned int index;
   2639 
   2640   /**
   2641    * Trait type, for example "reserve-pub" or "coin-priv".
   2642    */
   2643   const char *trait_name;
   2644 
   2645   /**
   2646    * Pointer to the piece of data to offer.
   2647    */
   2648   const void *ptr;
   2649 };
   2650 
   2651 
   2652 /**
   2653  * "end" trait.  Because traits are offered into arrays,
   2654  * this type of trait is used to mark the end of such arrays;
   2655  * useful when iterating over those.
   2656  */
   2657 struct TALER_TESTING_Trait
   2658 TALER_TESTING_trait_end (void);
   2659 
   2660 
   2661 /**
   2662  * Extract a trait.
   2663  *
   2664  * @param traits the array of all the traits.
   2665  * @param[out] ret where to store the result.
   2666  * @param trait type of the trait to extract.
   2667  * @param index index number of the trait to extract.
   2668  * @return #GNUNET_OK when the trait is found.
   2669  */
   2670 enum GNUNET_GenericReturnValue
   2671 TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
   2672                          const void **ret,
   2673                          const char *trait,
   2674                          unsigned int index);
   2675 
   2676 
   2677 /* ****** Specific traits supported by this component ******* */
   2678 
   2679 
   2680 /**
   2681  * Create headers for a trait with name @a name for
   2682  * statically allocated data of type @a type.
   2683  */
   2684 #define TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type)   \
   2685         enum GNUNET_GenericReturnValue                          \
   2686         TALER_TESTING_get_trait_ ## name (                    \
   2687           const struct TALER_TESTING_Command *cmd,              \
   2688           type * *ret);                                          \
   2689         struct TALER_TESTING_Trait                              \
   2690         TALER_TESTING_make_trait_ ## name (                   \
   2691           type * value);
   2692 
   2693 
   2694 /**
   2695  * Create C implementation for a trait with name @a name for statically
   2696  * allocated data of type @a type.
   2697  */
   2698 #define TALER_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type)  \
   2699         enum GNUNET_GenericReturnValue                         \
   2700         TALER_TESTING_get_trait_ ## name (                   \
   2701           const struct TALER_TESTING_Command *cmd,             \
   2702           type * *ret)                                          \
   2703         {                                                      \
   2704           if (NULL == cmd->traits) return GNUNET_SYSERR;       \
   2705           return cmd->traits (cmd->cls,                        \
   2706                               (const void **) ret,             \
   2707                               TALER_S (name),                  \
   2708                               0);                              \
   2709         }                                                      \
   2710         struct TALER_TESTING_Trait                             \
   2711         TALER_TESTING_make_trait_ ## name (                  \
   2712           type * value)                                        \
   2713         {                                                      \
   2714           struct TALER_TESTING_Trait ret = {                   \
   2715             .trait_name = TALER_S (name),                      \
   2716             .ptr = (const void *) value                        \
   2717           };                                                   \
   2718           return ret;                                          \
   2719         }
   2720 
   2721 
   2722 /**
   2723  * Create headers for a trait with name @a name for
   2724  * statically allocated data of type @a type.
   2725  */
   2726 #define TALER_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type)  \
   2727         enum GNUNET_GenericReturnValue                          \
   2728         TALER_TESTING_get_trait_ ## name (                    \
   2729           const struct TALER_TESTING_Command *cmd,              \
   2730           unsigned int index,                                   \
   2731           type * *ret);                                          \
   2732         struct TALER_TESTING_Trait                              \
   2733         TALER_TESTING_make_trait_ ## name (                   \
   2734           unsigned int index,                                   \
   2735           type * value);
   2736 
   2737 
   2738 /**
   2739  * Create C implementation for a trait with name @a name for statically
   2740  * allocated data of type @a type.
   2741  */
   2742 #define TALER_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \
   2743         enum GNUNET_GenericReturnValue                         \
   2744         TALER_TESTING_get_trait_ ## name (                   \
   2745           const struct TALER_TESTING_Command *cmd,             \
   2746           unsigned int index,                                  \
   2747           type * *ret)                                          \
   2748         {                                                      \
   2749           if (NULL == cmd->traits) return GNUNET_SYSERR;       \
   2750           return cmd->traits (cmd->cls,                        \
   2751                               (const void **) ret,             \
   2752                               TALER_S (name),                  \
   2753                               index);                          \
   2754         }                                                      \
   2755         struct TALER_TESTING_Trait                             \
   2756         TALER_TESTING_make_trait_ ## name (                  \
   2757           unsigned int index,                                  \
   2758           type * value)                                        \
   2759         {                                                      \
   2760           struct TALER_TESTING_Trait ret = {                   \
   2761             .index = index,                                    \
   2762             .trait_name = TALER_S (name),                      \
   2763             .ptr = (const void *) value                        \
   2764           };                                                   \
   2765           return ret;                                          \
   2766         }
   2767 
   2768 
   2769 /**
   2770  * Call #op on all simple traits.
   2771  */
   2772 #define TALER_TESTING_SIMPLE_TRAITS(op) \
   2773         op (bank_row, const uint64_t)                                    \
   2774         op (access_token, const char)                                    \
   2775         op (officer_pub, const struct TALER_AmlOfficerPublicKeyP)        \
   2776         op (officer_priv, const struct TALER_AmlOfficerPrivateKeyP)      \
   2777         op (officer_name, const char)                                    \
   2778         op (aml_justification, const char)                               \
   2779         op (auditor_priv, const struct TALER_AuditorPrivateKeyP)         \
   2780         op (auditor_pub, const struct TALER_AuditorPublicKeyP)           \
   2781         op (master_priv, const struct TALER_MasterPrivateKeyP)           \
   2782         op (master_pub, const struct TALER_MasterPublicKeyP)             \
   2783         op (purse_priv, const struct TALER_PurseContractPrivateKeyP)     \
   2784         op (purse_pub, const struct TALER_PurseContractPublicKeyP)       \
   2785         op (merge_priv, const struct TALER_PurseMergePrivateKeyP)        \
   2786         op (merge_pub, const struct TALER_PurseMergePublicKeyP)          \
   2787         op (contract_priv, const struct TALER_ContractDiffiePrivateP)    \
   2788         op (reserve_priv, const struct TALER_ReservePrivateKeyP)         \
   2789         op (reserve_sig, const struct TALER_ReserveSignatureP)           \
   2790         op (h_full_payto, const struct TALER_FullPaytoHashP)             \
   2791         op (h_normalized_payto, const struct TALER_NormalizedPaytoHashP) \
   2792         op (account_access_token, const struct TALER_AccountAccessTokenP) \
   2793         op (account_priv, const union TALER_AccountPrivateKeyP)          \
   2794         op (account_pub, const union TALER_AccountPublicKeyP)            \
   2795         op (planchet_secret, const struct TALER_PlanchetMasterSecretP)   \
   2796         op (withdraw_seed, const struct TALER_WithdrawMasterSeedP)       \
   2797         op (blinding_seed, const struct TALER_BlindingMasterSeedP)       \
   2798         op (withdraw_commitment, const struct TALER_HashBlindedPlanchetsP)       \
   2799         op (kappa_seed, const struct TALER_KappaWithdrawMasterSeedP)     \
   2800         op (refresh_seed, const struct TALER_PublicRefreshMasterSeedP)     \
   2801         op (reserve_pub, const struct TALER_ReservePublicKeyP)           \
   2802         op (merchant_priv, const struct TALER_MerchantPrivateKeyP)       \
   2803         op (merchant_pub, const struct TALER_MerchantPublicKeyP)         \
   2804         op (merchant_sig, const struct TALER_MerchantSignatureP)         \
   2805         op (wtid, const struct TALER_WireTransferIdentifierRawP)         \
   2806         op (bank_auth_data, const struct TALER_BANK_AuthenticationData)  \
   2807         op (contract_terms, const json_t)                                \
   2808         op (wire_details, const json_t)                                  \
   2809         op (exchange_url, const char)                                    \
   2810         op (auditor_url, const char)                                     \
   2811         op (exchange_bank_account_url, const char)                       \
   2812         op (taler_uri, const char)                                       \
   2813         op (full_payto_uri, const struct TALER_FullPayto)                \
   2814         op (normalized_payto_uri, const struct TALER_NormalizedPayto)    \
   2815         op (kyc_url, const char)                                         \
   2816         op (web_url, const char)                                         \
   2817         op (row, const uint64_t)                                         \
   2818         op (legi_requirement_row, const uint64_t)                        \
   2819         op (array_length, const unsigned int)                            \
   2820         op (credit_payto_uri, const struct TALER_FullPayto)              \
   2821         op (debit_payto_uri, const struct TALER_FullPayto)               \
   2822         op (order_id, const char)                                        \
   2823         op (amount, const struct TALER_Amount)                           \
   2824         op (amount_with_fee, const struct TALER_Amount)                  \
   2825         op (batch_cmds, struct TALER_TESTING_Command)                    \
   2826         op (uuid, const struct GNUNET_Uuid)                              \
   2827         op (fresh_coins, const struct TALER_TESTING_FreshCoinData *)     \
   2828         op (claim_token, const struct TALER_ClaimTokenP)                 \
   2829         op (relative_time, const struct GNUNET_TIME_Relative)            \
   2830         op (fakebank, struct TALER_FAKEBANK_Handle)                      \
   2831         op (keys, struct TALER_EXCHANGE_Keys)                            \
   2832         op (process, struct GNUNET_Process *)
   2833 
   2834 
   2835 /**
   2836  * Call #op on all indexed traits.
   2837  */
   2838 #define TALER_TESTING_INDEXED_TRAITS(op)                                      \
   2839         op (denom_pub, const struct TALER_EXCHANGE_DenomPublicKey)            \
   2840         op (denom_sig, const struct TALER_DenominationSignature)              \
   2841         op (amounts, const struct TALER_Amount)                               \
   2842         op (deposit_amount, const struct TALER_Amount)                        \
   2843         op (kyc_id, const char)                                               \
   2844         op (deposit_fee_amount, const struct TALER_Amount)                    \
   2845         op (age_commitment, const struct TALER_AgeCommitment)                 \
   2846         op (age_commitment_proof, const struct TALER_AgeCommitmentProof)      \
   2847         op (h_age_commitment, const struct TALER_AgeCommitmentHashP)           \
   2848         op (coin_history, const struct TALER_EXCHANGE_CoinHistoryEntry)       \
   2849         op (planchet_secrets, const struct TALER_PlanchetMasterSecretP)       \
   2850         op (kappa_seeds, const struct TALER_KappaWithdrawMasterSeedP)         \
   2851         op (exchange_blinding_values, const struct TALER_ExchangeBlindingValues)     \
   2852         op (coin_priv, const struct TALER_CoinSpendPrivateKeyP)               \
   2853         op (coin_pub, const struct TALER_CoinSpendPublicKeyP)                 \
   2854         op (coin_sig, const struct TALER_CoinSpendSignatureP)                 \
   2855         op (absolute_time, const struct GNUNET_TIME_Absolute)                 \
   2856         op (timestamp, const struct GNUNET_TIME_Timestamp)                    \
   2857         op (wire_deadline, const struct GNUNET_TIME_Timestamp)                \
   2858         op (refund_deadline, const struct GNUNET_TIME_Timestamp)              \
   2859         op (exchange_pub, const struct TALER_ExchangePublicKeyP)              \
   2860         op (exchange_sig, const struct TALER_ExchangeSignatureP)              \
   2861         op (reserve_history, const struct TALER_EXCHANGE_ReserveHistoryEntry) \
   2862         op (blinding_key, const union GNUNET_CRYPTO_BlindingSecretP)          \
   2863         op (h_blinded_coin, const struct TALER_BlindedCoinHashP)
   2864 
   2865 TALER_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT)
   2866 
   2867 TALER_TESTING_INDEXED_TRAITS (TALER_TESTING_MAKE_DECL_INDEXED_TRAIT)
   2868 
   2869 
   2870 #endif