diff options
Diffstat (limited to 'src/testing')
37 files changed, 480 insertions, 1128 deletions
| diff --git a/src/testing/taler-unified-setup.sh b/src/testing/taler-unified-setup.sh index a52aebff..1ddc3316 100755 --- a/src/testing/taler-unified-setup.sh +++ b/src/testing/taler-unified-setup.sh @@ -29,19 +29,21 @@ set -eu  # Exit, with status code "skip" (no 'real' failure)  function exit_skip() { -    echo " SKIP: " "$@" +    echo " SKIP: " "$@" >&2      exit 77  }  # Exit, with error message (hard failure)  function exit_fail() { -    echo " FAIL: " "$@" +    echo " FAIL: " "$@" >&2      exit 1  }  # Cleanup to run whenever we exit  function cleanup()  { +    echo "Taler unified setup terminating!" >&2 +      for n in $(jobs -p)      do          kill $n 2> /dev/null || true @@ -53,6 +55,7 @@ function cleanup()  # Install cleanup handler (except for kill -9)  trap cleanup EXIT +WAIT_FOR_SIGNAL=0  START_AUDITOR=0  START_BACKUP=0  START_EXCHANGE=0 @@ -71,7 +74,7 @@ LOGLEVEL="DEBUG"  DEFAULT_SLEEP="0.2"  # Parse command-line options -while getopts ':abc:d:efghl:mnr:stu:vw' OPTION; do +while getopts ':abc:d:efghl:mnr:stu:vwW' OPTION; do      case "$OPTION" in          a)              START_AUDITOR="1" @@ -82,7 +85,7 @@ while getopts ':abc:d:efghl:mnr:stu:vw' OPTION; do          c)              CONF_ORIG="$OPTARG"              ;; -        c) +        d)              WIRE_DOMAIN="$OPTARG"              ;;          e) @@ -142,6 +145,9 @@ while getopts ':abc:d:efghl:mnr:stu:vw' OPTION; do          w)              START_WIREWATCH="1"              ;; +        W) +            WAIT_FOR_SIGNAL="1" +            ;;          ?)          exit_fail "Unrecognized command line option"          ;; @@ -201,22 +207,40 @@ register_sandbox_account() {        demobank \        delete \        --bank-account "$1" &> /dev/null || true -    libeufin-cli sandbox \ -      demobank \ -      register --name "$3" + +    MAYBE_IBAN="${4:-}" +    if test -n "$MAYBE_IBAN"; then +      libeufin-cli sandbox \ +        demobank \ +        register --name "$3" --iban "$MAYBE_IBAN" +    else +      libeufin-cli sandbox \ +        demobank \ +        register --name "$3" +    fi +      unset LIBEUFIN_SANDBOX_USERNAME      unset LIBEUFIN_SANDBOX_PASSWORD  } -BANK_PORT=$(taler-config -c "$CONF" -s "BANK" -o "HTTP_PORT") -if [ "1" = "$START_NEXUS" ] +if [[ "1" = "$START_NEXUS" || "1" = "$START_FAKEBANK" ]]  then -    NEXUS_PORT="$BANK_PORT" -    SANDBOX_PORT="1$BANK_PORT" +    BANK_PORT=$(taler-config -c "$CONF" -s "BANK" -o "HTTP_PORT") +    if [ "1" = "$START_NEXUS" ] +    then +        NEXUS_PORT="$BANK_PORT" +        SANDBOX_PORT="1$BANK_PORT" +    else +        NEXUS_PORT="0" +        SANDBOX_PORT="1$BANK_PORT" +    fi  else -    NEXUS_PORT="0" -    SANDBOX_PORT="1$BANK_PORT" +    if [ "1" = "$START_SANDBOX" ] +    then +        BANK_PORT=$(taler-config -c "$CONF" -s "BANK" -o "HTTP_PORT") +        SANDBOX_PORT="$BANK_PORT" +    fi  fi  if [ "1" = "$START_SANDBOX" ] @@ -256,7 +280,11 @@ then      fi      echo "OK"      echo -n "Register Sandbox users ..." -    register_sandbox_account fortytwo x "Forty Two" +    # The specified IBAN and name must match the ones hard-coded into +    # the C helper for the add-incoming call.  Without this value, +    # Sandbox  won't find the target account to debit along a /add-incoming +    # call. +    register_sandbox_account fortytwo x "User42" FR7630006000011234567890189      register_sandbox_account fortythree x "Forty Three"      register_sandbox_account exchange x "Exchange Company"      register_sandbox_account tor x "Tor Project" @@ -610,7 +638,7 @@ then      if [ "1" != "$OK" ]      then          cat "$LAST_RESPONSE" -        exit_skip "Failed to setup exchange keys, check secmod logs" +        exit_fail "Failed to setup exchange keys, check secmod logs"      fi      rm "$LAST_RESPONSE"      echo " OK" @@ -662,7 +690,7 @@ then      if [ "1" != "$OK" ]      then          cat "$LAST_RESPONSE" -        exit_skip " Failed to setup keys" +        exit_fail " Failed to setup keys"      fi      rm "$LAST_RESPONSE"      echo " OK" @@ -681,7 +709,17 @@ fi  # Signal caller that we are ready.  echo "<<READY>>" -# Wait until caller stops us. -read +if [ "1" = "$WAIT_FOR_SIGNAL" ] +then +    while true +    do +        sleep 0.1 +    done +else +    # Wait until caller stops us. +    read +fi + +echo "Taler unified setup terminating!" >&2  exit 0 diff --git a/src/testing/test_auditor_api_version.c b/src/testing/test_auditor_api_version.c index 252369fa..dcd542ad 100644 --- a/src/testing/test_auditor_api_version.c +++ b/src/testing/test_auditor_api_version.c @@ -41,7 +41,7 @@   */  #define CONFIG_FILE "test_auditor_api-rsa.conf" -static struct TALER_AUDITOR_Handle *ah; +static struct TALER_AUDITOR_GetConfigHandle *ah;  static struct GNUNET_CURL_Context *ctx; @@ -62,7 +62,11 @@ do_shutdown (void *cls)      GNUNET_SCHEDULER_cancel (tt);      tt = NULL;    } -  TALER_AUDITOR_disconnect (ah); +  if (NULL != ah) +  { +    TALER_AUDITOR_get_config_cancel (ah); +    ah = NULL; +  }    GNUNET_CURL_fini (ctx);    GNUNET_CURL_gnunet_rc_destroy (rc);  } @@ -82,20 +86,16 @@ do_timeout (void *cls)   * Function called with information about the auditor.   *   * @param cls closure - * @param hr http response details - * @param vi basic information about the auditor - * @param compat protocol compatibility information + * @param vr response details   */  static void  version_cb (void *cls, -            const struct TALER_AUDITOR_HttpResponse *hr, -            const struct TALER_AUDITOR_VersionInformation *vi, -            enum TALER_AUDITOR_VersionCompatibility compat) +            const struct TALER_AUDITOR_ConfigResponse *vr)  {    (void) cls; -  (void) hr; -  if ( (NULL != vi) && -       (TALER_AUDITOR_VC_MATCH == compat) ) +  ah = NULL; +  if ( (MHD_HTTP_OK == vr->hr.http_status) && +       (TALER_AUDITOR_VC_MATCH == vr->details.ok.compat) )      global_ret = 0;    else      global_ret = 2; @@ -118,10 +118,10 @@ run (void *cls)    ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,                            &rc);    rc = GNUNET_CURL_gnunet_rc_create (ctx); -  ah = TALER_AUDITOR_connect (ctx, -                              auditor_url, -                              &version_cb, -                              NULL); +  ah = TALER_AUDITOR_get_config (ctx, +                                 auditor_url, +                                 &version_cb, +                                 NULL);    GNUNET_SCHEDULER_add_shutdown (&do_shutdown,                                   NULL);    tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, diff --git a/src/testing/test_bank_api.c b/src/testing/test_bank_api.c index a2afdf06..e197b152 100644 --- a/src/testing/test_bank_api.c +++ b/src/testing/test_bank_api.c @@ -142,8 +142,8 @@ run (void *cls,          "fetch-transactions-at-nexus",          "exchange", /* from taler-nexus-prepare */          "x", /* from taler-nexus-prepare */ -        "http://localhost:5001", -        "my-bank-account") /* from taler-nexus-prepare */ +        "http://localhost:8082", +        "exchange-nexus") /* from taler-nexus-prepare */        : TALER_TESTING_cmd_sleep ("nop",                                   0),        TALER_TESTING_cmd_bank_debits ("history-2b", diff --git a/src/testing/test_exchange_api.conf b/src/testing/test_exchange_api.conf index 9ed12412..b7f8c5c6 100644 --- a/src/testing/test_exchange_api.conf +++ b/src/testing/test_exchange_api.conf @@ -11,7 +11,7 @@ CURRENCY_ROUND_UNIT = EUR:0.01  [auditor]  BASE_URL = "http://localhost:8083/"  PORT = 8083 -PUBLIC_KEY = SA7JVMCW3MMN7SYAWJ9AB0BGJDX6MP3PNN2JWQ3T8233MDSQC7Z0 +PUBLIC_KEY = T0XJ9QZ59YDN7QG3RE40SB2HY7W0ASR1EKF4WZDGZ1G159RSQC80  TINY_AMOUNT = EUR:0.01  [auditordb-postgres] diff --git a/src/testing/test_exchange_api_home/taler/auditor/offline-keys/auditor.priv b/src/testing/test_exchange_api_home/taler/auditor/offline-keys/auditor.priv new file mode 100644 index 00000000..7e712e48 --- /dev/null +++ b/src/testing/test_exchange_api_home/taler/auditor/offline-keys/auditor.priv @@ -0,0 +1 @@ +G,U{~#r-H
\ No newline at end of file diff --git a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c index c6a1516e..5c7b76a3 100644 --- a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c +++ b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c @@ -1,6 +1,6 @@  /*    This file is part of TALER -  Copyright (C) 2018, 2021 Taler Systems SA +  Copyright (C) 2018-2023 Taler Systems SA    TALER is free software; you can redistribute it and/or modify it    under the terms of the GNU General Public License as published by @@ -132,13 +132,15 @@ do_retry (void *cls)   * to check if the response code is acceptable.   *   * @param cls closure. - * @param hr HTTP response details + * @param dcr response details   */  static void -deposit_confirmation_cb (void *cls, -                         const struct TALER_AUDITOR_HttpResponse *hr) +deposit_confirmation_cb ( +  void *cls, +  const struct TALER_AUDITOR_DepositConfirmationResponse *dcr)  {    struct DepositConfirmationState *dcs = cls; +  const struct TALER_AUDITOR_HttpResponse *hr = &dcr->hr;    dcs->dc = NULL;    if (dcs->expected_response_code != hr->http_status) @@ -208,7 +210,7 @@ deposit_confirmation_run (void *cls,    const struct TALER_CoinSpendPrivateKeyP *coin_priv;    const struct TALER_EXCHANGE_Keys *keys;    const struct TALER_EXCHANGE_SigningPublicKey *spk; -  struct TALER_AUDITOR_Handle *auditor; +  const char *auditor_url;    struct TALER_EXCHANGE_Handle *exchange      = TALER_TESTING_get_exchange (is); @@ -229,9 +231,14 @@ deposit_confirmation_run (void *cls,        TALER_TESTING_interpreter_fail (is);        return;      } -    GNUNET_assert (GNUNET_OK == -                   TALER_TESTING_get_trait_auditor (auditor_cmd, -                                                    &auditor)); +    if (GNUNET_OK != +        TALER_TESTING_get_trait_auditor_url (auditor_cmd, +                                             &auditor_url)) +    { +      GNUNET_break (0); +      TALER_TESTING_interpreter_fail (is); +      return; +    }    }    deposit_cmd      = TALER_TESTING_interpreter_lookup_command (is, @@ -317,25 +324,27 @@ deposit_confirmation_run (void *cls,      if (GNUNET_TIME_absolute_is_zero (refund_deadline.abs_time))        refund_deadline = timestamp;    } -  dcs->dc = TALER_AUDITOR_deposit_confirmation (auditor, -                                                &h_wire, -                                                &no_h_policy, -                                                &h_contract_terms, -                                                *exchange_timestamp, -                                                *wire_deadline, -                                                refund_deadline, -                                                &amount_without_fee, -                                                &coin_pub, -                                                &merchant_pub, -                                                exchange_pub, -                                                exchange_sig, -                                                &keys->master_pub, -                                                spk->valid_from, -                                                spk->valid_until, -                                                spk->valid_legal, -                                                &spk->master_sig, -                                                &deposit_confirmation_cb, -                                                dcs); +  dcs->dc = TALER_AUDITOR_deposit_confirmation ( +    TALER_TESTING_interpreter_get_context (is), +    auditor_url, +    &h_wire, +    &no_h_policy, +    &h_contract_terms, +    *exchange_timestamp, +    *wire_deadline, +    refund_deadline, +    &amount_without_fee, +    &coin_pub, +    &merchant_pub, +    exchange_pub, +    exchange_sig, +    &keys->master_pub, +    spk->valid_from, +    spk->valid_until, +    spk->valid_legal, +    &spk->master_sig, +    &deposit_confirmation_cb, +    dcs);    if (NULL == dcs->dc)    { diff --git a/src/testing/testing_api_cmd_auditor_exchanges.c b/src/testing/testing_api_cmd_auditor_exchanges.c index 070b6409..aa9a1bfb 100644 --- a/src/testing/testing_api_cmd_auditor_exchanges.c +++ b/src/testing/testing_api_cmd_auditor_exchanges.c @@ -1,6 +1,6 @@  /*    This file is part of TALER -  Copyright (C) 2018 Taler Systems SA +  Copyright (C) 2018-2023 Taler Systems SA    TALER is free software; you can redistribute it and/or modify it    under the terms of the GNU General Public License as published by @@ -127,11 +127,10 @@ do_retry (void *cls)   */  static void  exchanges_cb (void *cls, -              const struct TALER_AUDITOR_HttpResponse *hr, -              unsigned int num_exchanges, -              const struct TALER_AUDITOR_ExchangeInfo *ei) +              const struct TALER_AUDITOR_ListExchangesResponse *ler)  {    struct ExchangesState *es = cls; +  const struct TALER_AUDITOR_HttpResponse *hr = &ler->hr;    es->leh = NULL;    if (es->expected_response_code != hr->http_status) @@ -164,24 +163,30 @@ exchanges_cb (void *cls,                                       hr->http_status);      return;    } +  if (MHD_HTTP_OK != hr->http_status) +  { +    TALER_TESTING_interpreter_next (es->is); +    return; +  }    if (NULL != es->exchange_url)    { -    unsigned int found = GNUNET_NO; +    bool found = false; +    unsigned int num_exchanges = ler->details.ok.num_exchanges; +    const struct TALER_AUDITOR_ExchangeInfo *ei = ler->details.ok.ei;      for (unsigned int i = 0;           i<num_exchanges;           i++)        if (0 == strcmp (es->exchange_url,                         ei[i].exchange_url)) -        found = GNUNET_YES; -    if (GNUNET_NO == found) +        found = true; +    if (! found)      {        TALER_LOG_ERROR ("Exchange '%s' doesn't exist at this auditor\n",                         es->exchange_url);        TALER_TESTING_interpreter_fail (es->is);        return;      } -      TALER_LOG_DEBUG ("Exchange '%s' exists at this auditor!\n",                       es->exchange_url);    } @@ -203,7 +208,7 @@ exchanges_run (void *cls,  {    struct ExchangesState *es = cls;    const struct TALER_TESTING_Command *auditor_cmd; -  struct TALER_AUDITOR_Handle *auditor; +  const char *auditor_url;    (void) cmd;    auditor_cmd = TALER_TESTING_interpreter_get_command (is, @@ -214,15 +219,20 @@ exchanges_run (void *cls,      TALER_TESTING_interpreter_fail (is);      return;    } -  GNUNET_assert (GNUNET_OK == -                 TALER_TESTING_get_trait_auditor (auditor_cmd, -                                                  &auditor)); - +  if (GNUNET_OK != +      TALER_TESTING_get_trait_auditor_url (auditor_cmd, +                                           &auditor_url)) +  { +    GNUNET_break (0); +    TALER_TESTING_interpreter_fail (is); +    return; +  }    es->is = is; -  es->leh = TALER_AUDITOR_list_exchanges (auditor, -                                          &exchanges_cb, -                                          es); - +  es->leh = TALER_AUDITOR_list_exchanges ( +    TALER_TESTING_interpreter_get_context (is), +    auditor_url, +    &exchanges_cb, +    es);    if (NULL == es->leh)    {      GNUNET_break (0); @@ -287,14 +297,6 @@ exchanges_traits (void *cls,  } -/** - * Create a "list exchanges" command. - * - * @param label command label. - * @param auditor auditor connection. - * @param expected_response_code expected HTTP response code. - * @return the command. - */  struct TALER_TESTING_Command  TALER_TESTING_cmd_exchanges (const char *label,                               unsigned int expected_response_code) @@ -318,16 +320,6 @@ TALER_TESTING_cmd_exchanges (const char *label,  } -/** - * Create a "list exchanges" command and check whether - * a particular exchange belongs to the returned bundle. - * - * @param label command label. - * @param expected_response_code expected HTTP response code. - * @param exchange_url URL of the exchange supposed to - *  be included in the response. - * @return the command. - */  struct TALER_TESTING_Command  TALER_TESTING_cmd_exchanges_with_url (const char *label,                                        unsigned int expected_response_code, diff --git a/src/testing/testing_api_cmd_bank_history_credit.c b/src/testing/testing_api_cmd_bank_history_credit.c index 286d0631..f2fb70e0 100644 --- a/src/testing/testing_api_cmd_bank_history_credit.c +++ b/src/testing/testing_api_cmd_bank_history_credit.c @@ -288,8 +288,7 @@ command_cb (void *cls,   * to be allocated, and the second to actually populate every   * element.   * - * @param is interpreter state (supposedly having the - *        current CMD pointing at a "history" CMD). + * @param hs history state   * @param[out] rh history array to initialize.   * @return number of entries in @a rh.   */ diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c index 6a05071a..0a4fbd25 100644 --- a/src/testing/testing_api_cmd_batch_deposit.c +++ b/src/testing/testing_api_cmd_batch_deposit.c @@ -251,12 +251,15 @@ batch_deposit_run (void *cls,                                   &wire_salt),      GNUNET_JSON_spec_end ()    }; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url +    = TALER_TESTING_get_exchange_url (is);    (void) cmd; -  if (NULL == exchange) +  if (NULL == exchange_url) +  { +    GNUNET_break (0);      return; +  }    memset (cdds,            0,            sizeof (cdds)); @@ -383,13 +386,16 @@ batch_deposit_run (void *cls,        .refund_deadline = ds->refund_deadline      }; -    ds->dh = TALER_EXCHANGE_batch_deposit (exchange, -                                           &dcd, -                                           ds->num_coins, -                                           cdds, -                                           &batch_deposit_cb, -                                           ds, -                                           &ec); +    ds->dh = TALER_EXCHANGE_batch_deposit ( +      TALER_TESTING_interpreter_get_context (is), +      exchange_url, +      TALER_TESTING_get_keys (is), +      &dcd, +      ds->num_coins, +      cdds, +      &batch_deposit_cb, +      ds, +      &ec);    }    if (NULL == ds->dh)    { diff --git a/src/testing/testing_api_cmd_contract_get.c b/src/testing/testing_api_cmd_contract_get.c index adde3ed2..902ec4a4 100644 --- a/src/testing/testing_api_cmd_contract_get.c +++ b/src/testing/testing_api_cmd_contract_get.c @@ -190,13 +190,16 @@ get_run (void *cls,    struct ContractGetState *ds = cls;    const struct TALER_ContractDiffiePrivateP *contract_priv;    const struct TALER_TESTING_Command *ref; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url;    (void) cmd; -  if (NULL == exchange) -    return;    ds->is = is; +  exchange_url = TALER_TESTING_get_exchange_url (is); +  if (NULL == exchange_url) +  { +    GNUNET_break (0); +    return; +  }    ref = TALER_TESTING_interpreter_lookup_command (ds->is,                                                    ds->contract_ref);    GNUNET_assert (NULL != ref); @@ -210,7 +213,8 @@ get_run (void *cls,    }    ds->contract_priv = *contract_priv;    ds->dh = TALER_EXCHANGE_contract_get ( -    exchange, +    TALER_TESTING_interpreter_get_context (is), +    exchange_url,      contract_priv,      &get_cb,      ds); diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c index 3d5c00ab..f2a3a269 100644 --- a/src/testing/testing_api_cmd_deposit.c +++ b/src/testing/testing_api_cmd_deposit.c @@ -98,7 +98,7 @@ struct DepositState    /**     * Deposit handle while operation is running.     */ -  struct TALER_EXCHANGE_DepositHandle *dh; +  struct TALER_EXCHANGE_BatchDepositHandle *dh;    /**     * Timestamp of the /deposit operation in the wallet (contract signing time). @@ -215,7 +215,7 @@ do_retry (void *cls)   */  static void  deposit_cb (void *cls, -            const struct TALER_EXCHANGE_DepositResult *dr) +            const struct TALER_EXCHANGE_BatchDepositResult *dr)  {    struct DepositState *ds = cls; @@ -254,10 +254,11 @@ deposit_cb (void *cls,    }    if (MHD_HTTP_OK == dr->hr.http_status)    { +    GNUNET_assert (1 == dr->details.ok.num_signatures);      ds->deposit_succeeded = GNUNET_YES;      ds->exchange_timestamp = dr->details.ok.deposit_timestamp;      ds->exchange_pub = *dr->details.ok.exchange_pub; -    ds->exchange_sig = *dr->details.ok.exchange_sig; +    ds->exchange_sig = dr->details.ok.exchange_sigs[0];    }    TALER_TESTING_interpreter_next (ds->is);  } @@ -296,12 +297,15 @@ deposit_run (void *cls,                                   &wire_salt),      GNUNET_JSON_spec_end ()    }; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url +    = TALER_TESTING_get_exchange_url (is);    (void) cmd; -  if (NULL == exchange) +  if (NULL == exchange_url) +  { +    GNUNET_break (0);      return; +  }    ds->is = is;    if (NULL != ds->deposit_reference)    { @@ -469,12 +473,16 @@ deposit_run (void *cls,        .refund_deadline = ds->refund_deadline      }; -    ds->dh = TALER_EXCHANGE_deposit (exchange, -                                     &dcd, -                                     &cdd, -                                     &deposit_cb, -                                     ds, -                                     &ec); +    ds->dh = TALER_EXCHANGE_batch_deposit ( +      TALER_TESTING_interpreter_get_context (is), +      exchange_url, +      TALER_TESTING_get_keys (is), +      &dcd, +      1, +      &cdd, +      &deposit_cb, +      ds, +      &ec);    }    if (NULL == ds->dh)    { @@ -505,7 +513,7 @@ deposit_cleanup (void *cls,    {      TALER_TESTING_command_incomplete (ds->is,                                        cmd->label); -    TALER_EXCHANGE_deposit_cancel (ds->dh); +    TALER_EXCHANGE_batch_deposit_cancel (ds->dh);      ds->dh = NULL;    }    if (NULL != ds->retry_task) diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 972a85b7..165af9b1 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -198,12 +198,8 @@ track_transaction_run (void *cls,    struct TALER_MerchantWireHashP h_wire_details;    struct TALER_PrivateContractHashP h_contract_terms;    const struct TALER_MerchantPrivateKeyP *merchant_priv; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is);    tts->cmd = cmd; -  if (NULL == exchange) -    return;    tts->is = is;    transaction_cmd      = TALER_TESTING_interpreter_lookup_command (tts->is, @@ -275,14 +271,17 @@ track_transaction_run (void *cls,      return;    } -  tts->tth = TALER_EXCHANGE_deposits_get (exchange, -                                          merchant_priv, -                                          &h_wire_details, -                                          &h_contract_terms, -                                          &coin_pub, -                                          GNUNET_TIME_UNIT_ZERO, -                                          &deposit_wtid_cb, -                                          tts); +  tts->tth = TALER_EXCHANGE_deposits_get ( +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is), +    merchant_priv, +    &h_wire_details, +    &h_contract_terms, +    &coin_pub, +    GNUNET_TIME_UNIT_ZERO, +    &deposit_wtid_cb, +    tts);    GNUNET_assert (NULL != tts->tth);  } diff --git a/src/testing/testing_api_cmd_get_auditor.c b/src/testing/testing_api_cmd_get_auditor.c index 42c887da..e1ae8ba5 100644 --- a/src/testing/testing_api_cmd_get_auditor.c +++ b/src/testing/testing_api_cmd_get_auditor.c @@ -49,9 +49,9 @@ struct GetAuditorState    struct TALER_TESTING_Interpreter *is;    /** -   * Auditor handle we produced. +   * Auditor handle used to get the configuration.     */ -  struct TALER_AUDITOR_Handle *auditor; +  struct TALER_AUDITOR_GetConfigHandle *auditor;    /**     * URL of the auditor. @@ -70,23 +70,28 @@ struct GetAuditorState   * Function called with information about the auditor.   *   * @param cls closure - * @param hr HTTP response data - * @param vi basic information about the auditor - * @param compat protocol compatibility information + * @param vr response data   */  static void  version_cb (    void *cls, -  const struct TALER_AUDITOR_HttpResponse *hr, -  const struct TALER_AUDITOR_VersionInformation *vi, -  enum TALER_AUDITOR_VersionCompatibility compat) +  const struct TALER_AUDITOR_ConfigResponse *vr)  {    struct GetAuditorState *gas = cls; -  if (MHD_HTTP_OK != hr->http_status) +  gas->auditor = NULL; +  if (MHD_HTTP_OK != vr->hr.http_status)    {      TALER_TESTING_unexpected_status (gas->is, -                                     hr->http_status); +                                     vr->hr.http_status); +    return; +  } +  if ( (NULL != gas->priv_file) && +       (0 != GNUNET_memcmp (&gas->auditor_pub, +                            &vr->details.ok.vi.auditor_pub)) ) +  { +    GNUNET_break (0); +    TALER_TESTING_interpreter_fail (gas->is);      return;    }    TALER_TESTING_interpreter_next (gas->is); @@ -130,10 +135,10 @@ get_auditor_run (void *cls,    }    gas->is = is;    gas->auditor -    = TALER_AUDITOR_connect (TALER_TESTING_interpreter_get_context (is), -                             gas->auditor_url, -                             &version_cb, -                             gas); +    = TALER_AUDITOR_get_config (TALER_TESTING_interpreter_get_context (is), +                                gas->auditor_url, +                                &version_cb, +                                gas);    if (NULL == gas->auditor)    {      GNUNET_break (0); @@ -157,7 +162,8 @@ get_auditor_cleanup (void *cls,    if (NULL != gas->auditor)    { -    TALER_AUDITOR_disconnect (gas->auditor); +    GNUNET_break (0); +    TALER_AUDITOR_get_config_cancel (gas->auditor);      gas->auditor = NULL;    }    GNUNET_free (gas->priv_file); @@ -186,7 +192,6 @@ get_auditor_traits (void *cls,    struct TALER_TESTING_Trait traits[] = {      TALER_TESTING_make_trait_auditor_priv (&gas->auditor_priv),      TALER_TESTING_make_trait_auditor_pub (&gas->auditor_pub), -    TALER_TESTING_make_trait_auditor (gas->auditor),      TALER_TESTING_make_trait_auditor_url (gas->auditor_url),      TALER_TESTING_trait_end ()    }; diff --git a/src/testing/testing_api_cmd_get_exchange.c b/src/testing/testing_api_cmd_get_exchange.c index 2fc8ba77..2822616c 100644 --- a/src/testing/testing_api_cmd_get_exchange.c +++ b/src/testing/testing_api_cmd_get_exchange.c @@ -189,7 +189,7 @@ get_exchange_traits (void *cls,  {    struct GetExchangeState *ges = cls;    unsigned int off = (NULL == ges->master_priv_file) ? 1 : 0; -  const struct TALER_EXCHANGE_Keys *keys +  struct TALER_EXCHANGE_Keys *keys      = TALER_EXCHANGE_get_keys (ges->exchange);    if (NULL != keys) @@ -198,6 +198,7 @@ get_exchange_traits (void *cls,        TALER_TESTING_make_trait_master_priv (&ges->master_priv),        TALER_TESTING_make_trait_master_pub (&keys->master_pub),        TALER_TESTING_make_trait_exchange (ges->exchange), +      TALER_TESTING_make_trait_keys (keys),        TALER_TESTING_make_trait_exchange_url (ges->exchange_url),        TALER_TESTING_trait_end ()      }; diff --git a/src/testing/testing_api_cmd_kyc_proof.c b/src/testing/testing_api_cmd_kyc_proof.c index 291378d9..c0fe7495 100644 --- a/src/testing/testing_api_cmd_kyc_proof.c +++ b/src/testing/testing_api_cmd_kyc_proof.c @@ -127,13 +127,16 @@ proof_kyc_run (void *cls,    const struct TALER_TESTING_Command *res_cmd;    const struct TALER_PaytoHashP *h_payto;    char *uargs; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url;    (void) cmd; -  if (NULL == exchange) -    return;    kps->is = is; +  exchange_url = TALER_TESTING_get_exchange_url (is); +  if (NULL == exchange_url) +  { +    GNUNET_break (0); +    return; +  }    res_cmd = TALER_TESTING_interpreter_lookup_command (      kps->is,      kps->payment_target_reference); @@ -157,12 +160,14 @@ proof_kyc_run (void *cls,      GNUNET_asprintf (&uargs,                       "&code=%s",                       kps->code); -  kps->kph = TALER_EXCHANGE_kyc_proof (exchange, -                                       h_payto, -                                       kps->logic, -                                       uargs, -                                       &proof_kyc_cb, -                                       kps); +  kps->kph = TALER_EXCHANGE_kyc_proof ( +    TALER_TESTING_interpreter_get_context (is), +    exchange_url, +    h_payto, +    kps->logic, +    uargs, +    &proof_kyc_cb, +    kps);    GNUNET_free (uargs);    GNUNET_assert (NULL != kps->kph);  } diff --git a/src/testing/testing_api_cmd_kyc_wallet_get.c b/src/testing/testing_api_cmd_kyc_wallet_get.c index 5f6eaeb4..fa6edab2 100644 --- a/src/testing/testing_api_cmd_kyc_wallet_get.c +++ b/src/testing/testing_api_cmd_kyc_wallet_get.c @@ -147,13 +147,16 @@ wallet_kyc_run (void *cls,                  struct TALER_TESTING_Interpreter *is)  {    struct KycWalletGetState *kwg = cls; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url;    kwg->cmd = cmd; -  if (NULL == exchange) -    return;    kwg->is = is; +  exchange_url = TALER_TESTING_get_exchange_url (is); +  if (NULL == exchange_url) +  { +    GNUNET_break (0); +    return; +  }    if (NULL != kwg->reserve_reference)    {      const struct TALER_TESTING_Command *res_cmd; @@ -185,13 +188,15 @@ wallet_kyc_run (void *cls,    GNUNET_CRYPTO_eddsa_key_get_public (&kwg->reserve_priv.eddsa_priv,                                        &kwg->reserve_pub.eddsa_pub);    kwg->reserve_payto_uri -    = TALER_reserve_make_payto (TALER_EXCHANGE_get_base_url (exchange), +    = TALER_reserve_make_payto (exchange_url,                                  &kwg->reserve_pub); -  kwg->kwh = TALER_EXCHANGE_kyc_wallet (exchange, -                                        &kwg->reserve_priv, -                                        &kwg->balance, -                                        &wallet_kyc_cb, -                                        kwg); +  kwg->kwh = TALER_EXCHANGE_kyc_wallet ( +    TALER_TESTING_interpreter_get_context (is), +    exchange_url, +    &kwg->reserve_priv, +    &kwg->balance, +    &wallet_kyc_cb, +    kwg);    GNUNET_assert (NULL != kwg->kwh);  } diff --git a/src/testing/testing_api_cmd_purse_create_deposit.c b/src/testing/testing_api_cmd_purse_create_deposit.c index 2f13849d..36dbfbff 100644 --- a/src/testing/testing_api_cmd_purse_create_deposit.c +++ b/src/testing/testing_api_cmd_purse_create_deposit.c @@ -189,12 +189,8 @@ deposit_run (void *cls,  {    struct PurseCreateDepositState *ds = cls;    struct TALER_EXCHANGE_PurseDeposit deposits[ds->num_coin_references]; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is);    (void) cmd; -  if (NULL == exchange) -    return;    ds->is = is;    for (unsigned int i = 0; i<ds->num_coin_references; i++)    { @@ -259,7 +255,9 @@ deposit_run (void *cls,                     "pay_deadline",                     GNUNET_JSON_from_timestamp (ds->purse_expiration)));    ds->dh = TALER_EXCHANGE_purse_create_with_deposit ( -    exchange, +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is),      &ds->purse_priv,      &ds->merge_priv,      &ds->contract_priv, diff --git a/src/testing/testing_api_cmd_purse_delete.c b/src/testing/testing_api_cmd_purse_delete.c index 758524ae..f6b7d573 100644 --- a/src/testing/testing_api_cmd_purse_delete.c +++ b/src/testing/testing_api_cmd_purse_delete.c @@ -97,12 +97,15 @@ purse_delete_run (void *cls,    struct PurseDeleteState *pds = cls;    const struct TALER_PurseContractPrivateKeyP *purse_priv;    const struct TALER_TESTING_Command *ref; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url;    (void) cmd; -  if (NULL == exchange) +  exchange_url = TALER_TESTING_get_exchange_url (is); +  if (NULL == exchange_url) +  { +    GNUNET_break (0);      return; +  }    ref = TALER_TESTING_interpreter_lookup_command (is,                                                    pds->purse_cmd);    if (NULL == ref) @@ -121,7 +124,8 @@ purse_delete_run (void *cls,    }    pds->is = is;    pds->pdh = TALER_EXCHANGE_purse_delete ( -    exchange, +    TALER_TESTING_interpreter_get_context (is), +    exchange_url,      purse_priv,      &purse_delete_cb,      pds); diff --git a/src/testing/testing_api_cmd_purse_deposit.c b/src/testing/testing_api_cmd_purse_deposit.c index fb1d5155..8bddc53a 100644 --- a/src/testing/testing_api_cmd_purse_deposit.c +++ b/src/testing/testing_api_cmd_purse_deposit.c @@ -259,11 +259,7 @@ deposit_run (void *cls,    struct TALER_EXCHANGE_PurseDeposit deposits[ds->num_coin_references];    const struct TALER_PurseContractPublicKeyP *purse_pub;    const struct TALER_TESTING_Command *purse_cmd; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); -  if (NULL == exchange) -    return;    (void) cmd;    ds->is = is;    purse_cmd = TALER_TESTING_interpreter_lookup_command (is, @@ -321,7 +317,9 @@ deposit_run (void *cls,    }    ds->dh = TALER_EXCHANGE_purse_deposit ( -    exchange, +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is),      NULL, /* FIXME #7271: WADs support: purse exchange URL */      &ds->purse_pub,      ds->min_age, diff --git a/src/testing/testing_api_cmd_purse_get.c b/src/testing/testing_api_cmd_purse_get.c index 235ae63c..d5246660 100644 --- a/src/testing/testing_api_cmd_purse_get.c +++ b/src/testing/testing_api_cmd_purse_get.c @@ -183,11 +183,7 @@ status_run (void *cls,  {    struct StatusState *ss = cls;    const struct TALER_TESTING_Command *create_purse; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); -  if (NULL == exchange) -    return;    ss->is = is;    create_purse      = TALER_TESTING_interpreter_lookup_command (is, @@ -202,12 +198,15 @@ status_run (void *cls,      TALER_TESTING_interpreter_fail (is);      return;    } -  ss->pgh = TALER_EXCHANGE_purse_get (exchange, -                                      ss->purse_pub, -                                      ss->timeout, -                                      ss->wait_for_merge, -                                      &purse_status_cb, -                                      ss); +  ss->pgh = TALER_EXCHANGE_purse_get ( +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is), +    ss->purse_pub, +    ss->timeout, +    ss->wait_for_merge, +    &purse_status_cb, +    ss);    if (! GNUNET_TIME_relative_is_zero (ss->timeout))    {      TALER_TESTING_interpreter_next (is); diff --git a/src/testing/testing_api_cmd_purse_merge.c b/src/testing/testing_api_cmd_purse_merge.c index 8f4f6b3c..503ef162 100644 --- a/src/testing/testing_api_cmd_purse_merge.c +++ b/src/testing/testing_api_cmd_purse_merge.c @@ -201,12 +201,8 @@ merge_run (void *cls,    const struct TALER_PurseMergePrivateKeyP *merge_priv;    const json_t *ct;    const struct TALER_TESTING_Command *ref; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is);    (void) cmd; -  if (NULL == exchange) -    return;    ds->is = is;    ref = TALER_TESTING_interpreter_lookup_command (ds->is,                                                    ds->merge_ref); @@ -322,7 +318,9 @@ merge_run (void *cls,                                        &ds->merge_pub.eddsa_pub);    ds->merge_timestamp = GNUNET_TIME_timestamp_get ();    ds->dh = TALER_EXCHANGE_account_merge ( -    exchange, +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is),      NULL, /* no wad */      &ds->reserve_priv,      &ds->purse_pub, diff --git a/src/testing/testing_api_cmd_recoup.c b/src/testing/testing_api_cmd_recoup.c index 9483b158..263a3303 100644 --- a/src/testing/testing_api_cmd_recoup.c +++ b/src/testing/testing_api_cmd_recoup.c @@ -182,11 +182,7 @@ recoup_run (void *cls,    char *cref;    unsigned int idx;    const struct TALER_ExchangeWithdrawValues *ewv; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); -  if (NULL == exchange) -    return;    ps->is = is;    if (GNUNET_OK !=        TALER_TESTING_parse_coin_reference ( @@ -259,13 +255,16 @@ recoup_run (void *cls,    GNUNET_log (GNUNET_ERROR_TYPE_INFO,                "Trying to recoup denomination '%s'\n",                TALER_B2S (&denom_pub->h_key)); -  ps->ph = TALER_EXCHANGE_recoup (exchange, -                                  denom_pub, -                                  coin_sig, -                                  ewv, -                                  planchet, -                                  &recoup_cb, -                                  ps); +  ps->ph = TALER_EXCHANGE_recoup ( +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is), +    denom_pub, +    coin_sig, +    ewv, +    planchet, +    &recoup_cb, +    ps);    GNUNET_assert (NULL != ps->ph);  } diff --git a/src/testing/testing_api_cmd_recoup_refresh.c b/src/testing/testing_api_cmd_recoup_refresh.c index 1c7456c7..7de5b96d 100644 --- a/src/testing/testing_api_cmd_recoup_refresh.c +++ b/src/testing/testing_api_cmd_recoup_refresh.c @@ -184,11 +184,7 @@ recoup_refresh_run (void *cls,    const struct TALER_ExchangeWithdrawValues *ewv;    char *cref;    unsigned int idx; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); -  if (NULL == exchange) -    return;    rrs->is = is;    if (GNUNET_OK !=        TALER_TESTING_parse_coin_reference ( @@ -273,15 +269,18 @@ recoup_refresh_run (void *cls,    GNUNET_log (GNUNET_ERROR_TYPE_INFO,                "Trying to recoup_refresh denomination '%s'\n",                TALER_B2S (&denom_pub->h_key)); -  rrs->ph = TALER_EXCHANGE_recoup_refresh (exchange, -                                           denom_pub, -                                           coin_sig, -                                           ewv, -                                           rplanchet, -                                           planchet, -                                           idx, -                                           &recoup_refresh_cb, -                                           rrs); +  rrs->ph = TALER_EXCHANGE_recoup_refresh ( +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is), +    denom_pub, +    coin_sig, +    ewv, +    rplanchet, +    planchet, +    idx, +    &recoup_refresh_cb, +    rrs);    GNUNET_assert (NULL != rrs->ph);  } diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c index a15e8dbc..dfaf31fd 100644 --- a/src/testing/testing_api_cmd_refresh.c +++ b/src/testing/testing_api_cmd_refresh.c @@ -496,12 +496,8 @@ refresh_reveal_run (void *cls,    struct RefreshRevealState *rrs = cls;    struct RefreshMeltState *rms;    const struct TALER_TESTING_Command *melt_cmd; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is);    rrs->cmd = cmd; -  if (NULL == exchange) -    return;    rrs->is = is;    melt_cmd = TALER_TESTING_interpreter_lookup_command (is,                                                         rrs->melt_reference); @@ -518,14 +514,16 @@ refresh_reveal_run (void *cls,      for (unsigned int i = 0; i<rms->num_fresh_coins; i++)        alg_values[i] = rms->mbds[i].alg_value; -    rrs->rrh = TALER_EXCHANGE_refreshes_reveal (exchange, -                                                &rms->rms, -                                                &rms->refresh_data, -                                                rms->num_fresh_coins, -                                                alg_values, -                                                rms->noreveal_index, -                                                &reveal_cb, -                                                rrs); +    rrs->rrh = TALER_EXCHANGE_refreshes_reveal ( +      TALER_TESTING_interpreter_get_context (is), +      TALER_TESTING_get_exchange_url (is), +      &rms->rms, +      &rms->refresh_data, +      rms->num_fresh_coins, +      alg_values, +      rms->noreveal_index, +      &reveal_cb, +      rrs);    }    if (NULL == rrs->rrh)    { @@ -783,13 +781,16 @@ refresh_link_run (void *cls,    const struct TALER_TESTING_Command *reveal_cmd;    const struct TALER_TESTING_Command *melt_cmd;    const struct TALER_TESTING_Command *coin_cmd; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url;    rls->cmd = cmd; -  if (NULL == exchange) -    return;    rls->is = is; +  exchange_url = TALER_TESTING_get_exchange_url (is); +  if (NULL == exchange_url) +  { +    GNUNET_break (0); +    return; +  }    reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,                                                           rls->reveal_reference);    if (NULL == reveal_cmd) @@ -832,11 +833,13 @@ refresh_link_run (void *cls,    }    /* finally, use private key from withdraw sign command */ -  rls->rlh = TALER_EXCHANGE_link (exchange, -                                  coin_priv, -                                  rms->refresh_data.melt_age_commitment_proof, -                                  &link_cb, -                                  rls); +  rls->rlh = TALER_EXCHANGE_link ( +    TALER_TESTING_interpreter_get_context (is), +    exchange_url, +    coin_priv, +    rms->refresh_data.melt_age_commitment_proof, +    &link_cb, +    rls);    if (NULL == rls->rlh)    { @@ -908,12 +911,8 @@ melt_cb (void *cls,  {    struct RefreshMeltState *rms = cls;    const struct TALER_EXCHANGE_HttpResponse *hr = &mr->hr; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (rms->is);    rms->rmh = NULL; -  if (NULL == exchange) -    return;    if (rms->expected_response_code != hr->http_status)    {      if (0 != rms->do_retry) @@ -973,11 +972,14 @@ melt_cb (void *cls,    {      TALER_LOG_DEBUG ("Doubling the melt (%s)\n",                       rms->cmd->label); -    rms->rmh = TALER_EXCHANGE_melt (exchange, -                                    &rms->rms, -                                    &rms->refresh_data, -                                    &melt_cb, -                                    rms); +    rms->rmh = TALER_EXCHANGE_melt ( +      TALER_TESTING_interpreter_get_context (rms->is), +      TALER_TESTING_get_exchange_url (rms->is), +      TALER_TESTING_get_keys (rms->is), +      &rms->rms, +      &rms->refresh_data, +      &melt_cb, +      rms);      rms->double_melt = false;      return;    } @@ -1149,11 +1151,14 @@ melt_run (void *cls,      GNUNET_assert (age_restricted ==                     (NULL != age_commitment_proof)); -    rms->rmh = TALER_EXCHANGE_melt (exchange, -                                    &rms->rms, -                                    &rms->refresh_data, -                                    &melt_cb, -                                    rms); +    rms->rmh = TALER_EXCHANGE_melt ( +      TALER_TESTING_interpreter_get_context (is), +      TALER_TESTING_get_exchange_url (is), +      TALER_TESTING_get_keys (is), +      &rms->rms, +      &rms->refresh_data, +      &melt_cb, +      rms);      if (NULL == rms->rmh)      { diff --git a/src/testing/testing_api_cmd_refund.c b/src/testing/testing_api_cmd_refund.c index a3ebd2e8..b8ce85f9 100644 --- a/src/testing/testing_api_cmd_refund.c +++ b/src/testing/testing_api_cmd_refund.c @@ -54,11 +54,6 @@ struct RefundState    uint64_t refund_transaction_id;    /** -   * Connection to the exchange. -   */ -  struct TALER_EXCHANGE_Handle *exchange; - -  /**     * Handle to the refund operation.     */    struct TALER_EXCHANGE_RefundHandle *rh; @@ -116,9 +111,6 @@ refund_run (void *cls,    const struct TALER_MerchantPrivateKeyP *merchant_priv;    const struct TALER_TESTING_Command *coin_cmd; -  rs->exchange = TALER_TESTING_get_exchange (is); -  if (NULL == rs->exchange) -    return;    rs->is = is;    if (GNUNET_OK !=        TALER_string_to_amount (rs->refund_amount, @@ -172,14 +164,17 @@ refund_run (void *cls,      TALER_TESTING_interpreter_fail (is);      return;    } -  rs->rh = TALER_EXCHANGE_refund (rs->exchange, -                                  &refund_amount, -                                  &h_contract_terms, -                                  &coin, -                                  rs->refund_transaction_id, -                                  merchant_priv, -                                  &refund_cb, -                                  rs); +  rs->rh = TALER_EXCHANGE_refund ( +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is), +    &refund_amount, +    &h_contract_terms, +    &coin, +    rs->refund_transaction_id, +    merchant_priv, +    &refund_cb, +    rs);    GNUNET_assert (NULL != rs->rh);  } diff --git a/src/testing/testing_api_cmd_reserve_attest.c b/src/testing/testing_api_cmd_reserve_attest.c index 77166d2b..64b15a10 100644 --- a/src/testing/testing_api_cmd_reserve_attest.c +++ b/src/testing/testing_api_cmd_reserve_attest.c @@ -152,12 +152,15 @@ attest_run (void *cls,  {    struct AttestState *ss = cls;    const struct TALER_TESTING_Command *create_reserve; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url; -  if (NULL == exchange) -    return;    ss->is = is; +  exchange_url = TALER_TESTING_get_exchange_url (is); +  if (NULL == exchange_url) +  { +    GNUNET_break (0); +    return; +  }    create_reserve      = TALER_TESTING_interpreter_lookup_command (is,                                                  ss->reserve_reference); @@ -179,12 +182,14 @@ attest_run (void *cls,    }    GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,                                        &ss->reserve_pub.eddsa_pub); -  ss->rsh = TALER_EXCHANGE_reserves_attest (exchange, -                                            ss->reserve_priv, -                                            ss->attrs_len, -                                            ss->attrs, -                                            &reserve_attest_cb, -                                            ss); +  ss->rsh = TALER_EXCHANGE_reserves_attest ( +    TALER_TESTING_interpreter_get_context (is), +    exchange_url, +    ss->reserve_priv, +    ss->attrs_len, +    ss->attrs, +    &reserve_attest_cb, +    ss);  } diff --git a/src/testing/testing_api_cmd_reserve_close.c b/src/testing/testing_api_cmd_reserve_close.c index b2929f16..8e272f54 100644 --- a/src/testing/testing_api_cmd_reserve_close.c +++ b/src/testing/testing_api_cmd_reserve_close.c @@ -142,11 +142,7 @@ close_run (void *cls,  {    struct CloseState *ss = cls;    const struct TALER_TESTING_Command *create_reserve; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); -  if (NULL == exchange) -    return;    ss->is = is;    create_reserve      = TALER_TESTING_interpreter_lookup_command (is, @@ -169,11 +165,13 @@ close_run (void *cls,    }    GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,                                        &ss->reserve_pub.eddsa_pub); -  ss->rsh = TALER_EXCHANGE_reserves_close (exchange, -                                           ss->reserve_priv, -                                           ss->target_account, -                                           &reserve_close_cb, -                                           ss); +  ss->rsh = TALER_EXCHANGE_reserves_close ( +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    ss->reserve_priv, +    ss->target_account, +    &reserve_close_cb, +    ss);  } diff --git a/src/testing/testing_api_cmd_reserve_get.c b/src/testing/testing_api_cmd_reserve_get.c index a4345940..9a938cf8 100644 --- a/src/testing/testing_api_cmd_reserve_get.c +++ b/src/testing/testing_api_cmd_reserve_get.c @@ -178,12 +178,15 @@ status_run (void *cls,  {    struct StatusState *ss = cls;    const struct TALER_TESTING_Command *create_reserve; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url; -  if (NULL == exchange) -    return;    ss->is = is; +  exchange_url = TALER_TESTING_get_exchange_url (is); +  if (NULL == exchange_url) +  { +    GNUNET_break (0); +    return; +  }    create_reserve      = TALER_TESTING_interpreter_lookup_command (is,                                                  ss->reserve_reference); @@ -197,11 +200,13 @@ status_run (void *cls,      TALER_TESTING_interpreter_fail (is);      return;    } -  ss->rsh = TALER_EXCHANGE_reserves_get (exchange, -                                         ss->reserve_pubp, -                                         ss->timeout, -                                         &reserve_status_cb, -                                         ss); +  ss->rsh = TALER_EXCHANGE_reserves_get ( +    TALER_TESTING_interpreter_get_context (is), +    exchange_url, +    ss->reserve_pubp, +    ss->timeout, +    &reserve_status_cb, +    ss);    if (! GNUNET_TIME_relative_is_zero (ss->timeout))    {      TALER_TESTING_interpreter_next (is); diff --git a/src/testing/testing_api_cmd_reserve_get_attestable.c b/src/testing/testing_api_cmd_reserve_get_attestable.c index 75783e04..ed1eb135 100644 --- a/src/testing/testing_api_cmd_reserve_get_attestable.c +++ b/src/testing/testing_api_cmd_reserve_get_attestable.c @@ -125,12 +125,15 @@ get_attestable_run (void *cls,    const struct TALER_TESTING_Command *ref_reserve;    const struct TALER_ReservePrivateKeyP *reserve_priv;    const struct TALER_ReservePublicKeyP *reserve_pub; -  struct TALER_EXCHANGE_Handle *exchange -    = TALER_TESTING_get_exchange (is); +  const char *exchange_url; -  if (NULL == exchange) -    return;    ss->is = is; +  exchange_url = TALER_TESTING_get_exchange_url (is); +  if (NULL == exchange_url) +  { +    GNUNET_break (0); +    return; +  }    ref_reserve      = TALER_TESTING_interpreter_lookup_command (is,                                                  ss->reserve_reference); @@ -162,10 +165,12 @@ get_attestable_run (void *cls,      }      ss->reserve_pub = *reserve_pub;    } -  ss->rgah = TALER_EXCHANGE_reserves_get_attestable (exchange, -                                                     &ss->reserve_pub, -                                                     &reserve_get_attestable_cb, -                                                     ss); +  ss->rgah = TALER_EXCHANGE_reserves_get_attestable ( +    TALER_TESTING_interpreter_get_context (is), +    exchange_url, +    &ss->reserve_pub, +    &reserve_get_attestable_cb, +    ss);  } diff --git a/src/testing/testing_api_cmd_reserve_history.c b/src/testing/testing_api_cmd_reserve_history.c index e9cc11a6..6e68bbe2 100644 --- a/src/testing/testing_api_cmd_reserve_history.c +++ b/src/testing/testing_api_cmd_reserve_history.c @@ -369,10 +369,13 @@ history_run (void *cls,    }    GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,                                        &ss->reserve_pub.eddsa_pub); -  ss->rsh = TALER_EXCHANGE_reserves_history (exchange, -                                             ss->reserve_priv, -                                             &reserve_history_cb, -                                             ss); +  ss->rsh = TALER_EXCHANGE_reserves_history ( +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is), +    ss->reserve_priv, +    &reserve_history_cb, +    ss);  } diff --git a/src/testing/testing_api_cmd_reserve_open.c b/src/testing/testing_api_cmd_reserve_open.c index 6a6247b8..a78662c3 100644 --- a/src/testing/testing_api_cmd_reserve_open.c +++ b/src/testing/testing_api_cmd_reserve_open.c @@ -256,7 +256,9 @@ open_run (void *cls,      cpi->h_denom_pub = denom_pub->h_key;    }    ss->rsh = TALER_EXCHANGE_reserves_open ( -    exchange, +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is),      ss->reserve_priv,      &ss->reserve_pay,      ss->cpl, diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c index 79530803..7a356c23 100644 --- a/src/testing/testing_api_cmd_reserve_purse.c +++ b/src/testing/testing_api_cmd_reserve_purse.c @@ -245,7 +245,9 @@ purse_run (void *cls,                     GNUNET_JSON_from_timestamp (ds->purse_expiration)));    ds->merge_timestamp = GNUNET_TIME_timestamp_get ();    ds->dh = TALER_EXCHANGE_purse_create_with_merge ( -    exchange, +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is),      &ds->reserve_priv,      &ds->purse_priv,      &ds->merge_priv, diff --git a/src/testing/testing_api_cmd_reserve_status.c b/src/testing/testing_api_cmd_reserve_status.c index 7e7b45cd..2da1bf74 100644 --- a/src/testing/testing_api_cmd_reserve_status.c +++ b/src/testing/testing_api_cmd_reserve_status.c @@ -341,10 +341,13 @@ status_run (void *cls,    }    GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,                                        &ss->reserve_pub.eddsa_pub); -  ss->rsh = TALER_EXCHANGE_reserves_status (exchange, -                                            ss->reserve_priv, -                                            &reserve_status_cb, -                                            ss); +  ss->rsh = TALER_EXCHANGE_reserves_status ( +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is), +    ss->reserve_priv, +    &reserve_status_cb, +    ss);  } diff --git a/src/testing/testing_api_cmd_transfer_get.c b/src/testing/testing_api_cmd_transfer_get.c index 10fe48c2..37fe736b 100644 --- a/src/testing/testing_api_cmd_transfer_get.c +++ b/src/testing/testing_api_cmd_transfer_get.c @@ -345,10 +345,13 @@ track_transfer_run (void *cls,      }      GNUNET_assert (NULL != wtid_ptr);    } -  tts->tth = TALER_EXCHANGE_transfers_get (exchange, -                                           wtid_ptr, -                                           &track_transfer_cb, -                                           tts); +  tts->tth = TALER_EXCHANGE_transfers_get ( +    TALER_TESTING_interpreter_get_context (is), +    TALER_TESTING_get_exchange_url (is), +    TALER_TESTING_get_keys (is), +    wtid_ptr, +    &track_transfer_cb, +    tts);    GNUNET_assert (NULL != tts->tth);  } diff --git a/src/testing/testing_api_helpers_exchange.c b/src/testing/testing_api_helpers_exchange.c deleted file mode 100644 index 1444f154..00000000 --- a/src/testing/testing_api_helpers_exchange.c +++ /dev/null @@ -1,796 +0,0 @@ -/* -  This file is part of TALER -  Copyright (C) 2018-2020 Taler Systems SA - -  TALER is free software; you can redistribute it and/or modify -  it under the terms of the GNU General Public License as -  published by the Free Software Foundation; either version 3, or -  (at your option) any later version. - -  TALER is distributed in the hope that it will be useful, but -  WITHOUT ANY WARRANTY; without even the implied warranty of -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -  GNU General Public License for more details. - -  You should have received a copy of the GNU General Public -  License along with TALER; see the file COPYING.  If not, see -  <http://www.gnu.org/licenses/> -*/ - -/** - * @file testing/testing_api_helpers_exchange.c - * @brief helper functions - * @author Christian Grothoff - * @author Marcello Stanisci - */ -#include "platform.h" -#include "taler_json_lib.h" -#include <gnunet/gnunet_curl_lib.h> -#include "taler_signatures.h" -#include "taler_extensions.h" -#include "taler_testing_lib.h" - -/** - * Run multiple taler-exchange-httpd processes in - * parallel using GNU parallel? - */ -#define GNU_PARALLEL 0 - - -void -TALER_TESTING_cleanup_files (const char *config_name) -{ -  if (GNUNET_OK != -      GNUNET_CONFIGURATION_parse_and_run (config_name, -                                          &TALER_TESTING_cleanup_files_cfg, -                                          NULL)) -    exit (77); -} - - -enum GNUNET_GenericReturnValue -TALER_TESTING_run_auditor_exchange (const char *config_filename, -                                    const char *exchange_master_pub, -                                    const char *exchange_base_url, -                                    int do_remove) -{ -  struct GNUNET_OS_Process *proc; -  enum GNUNET_OS_ProcessStatusType type; -  unsigned long code; - -  TALER_LOG_DEBUG ("Add exchange (%s,%s) to the auditor\n", -                   exchange_base_url, -                   exchange_master_pub); - -  proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, -                                  NULL, NULL, NULL, -                                  "taler-auditor-exchange", -                                  "taler-auditor-exchange", -                                  "-c", config_filename, -                                  "-u", exchange_base_url, -                                  "-m", exchange_master_pub, -                                  (GNUNET_YES == do_remove) -                                  ? "-r" -                                  : NULL, -                                  NULL); -  if (NULL == proc) -  { -    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -                "Failed to run `taler-auditor-exchange`, is your PATH correct?\n"); -    return GNUNET_SYSERR; -  } -  GNUNET_assert (GNUNET_OK == -                 GNUNET_OS_process_wait_status (proc, -                                                &type, -                                                &code)); -  GNUNET_OS_process_destroy (proc); -  if ( (0 != code) || -       (GNUNET_OS_PROCESS_EXITED != type) ) -  { -    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -                "taler-auditor-exchange terminated with error (%d/%d)\n", -                (int) type, -                (int) code); -    return GNUNET_SYSERR; -  } -  return GNUNET_OK; -} - - -enum GNUNET_GenericReturnValue -TALER_TESTING_exchange_db_reset (const char *config_filename) -{ -  struct GNUNET_OS_Process *proc; -  enum GNUNET_OS_ProcessStatusType type; -  unsigned long code; - -  proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, -                                  NULL, NULL, NULL, -                                  "taler-exchange-dbinit", -                                  "taler-exchange-dbinit", -                                  "-c", config_filename, -                                  "-L", "WARNING", -                                  "-r", -                                  NULL); -  if (NULL == proc) -  { -    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -                "Failed to run `taler-exchange-dbinit`, is your PATH correct?\n"); -    return GNUNET_NO; -  } -  if (GNUNET_SYSERR == -      GNUNET_OS_process_wait_status (proc, -                                     &type, -                                     &code)) -  { -    GNUNET_break (0); -    GNUNET_OS_process_destroy (proc); -    return GNUNET_SYSERR; -  } -  GNUNET_OS_process_destroy (proc); -  if ( (type == GNUNET_OS_PROCESS_EXITED) && -       (0 != code) ) -  { -    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -                "Failed to setup (exchange) database, exit code %d\n", -                (int) code); -    return GNUNET_NO; -  } -  if ( (type != GNUNET_OS_PROCESS_EXITED) || -       (0 != code) ) -  { -    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -                "Unexpected error (%d/%d) running `taler-exchange-dbinit'!\n", -                (int) type, -                (int) code); -    return GNUNET_SYSERR; -  } -  return GNUNET_OK; -} - - -enum GNUNET_GenericReturnValue -TALER_TESTING_auditor_db_reset (const char *config_filename) -{ -  struct GNUNET_OS_Process *proc; -  enum GNUNET_OS_ProcessStatusType type; -  unsigned long code; - -  proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, -                                  NULL, NULL, NULL, -                                  "taler-auditor-dbinit", -                                  "taler-auditor-dbinit", -                                  "-c", config_filename, -                                  "-R", -                                  NULL); -  if (NULL == proc) -  { -    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -                "Failed to run `taler-auditor-dbinit`, is your PATH correct?\n"); -    return GNUNET_NO; -  } -  if (GNUNET_SYSERR == -      GNUNET_OS_process_wait_status (proc, -                                     &type, -                                     &code)) -  { -    GNUNET_break (0); -    GNUNET_OS_process_destroy (proc); -    return GNUNET_SYSERR; -  } -  GNUNET_OS_process_destroy (proc); -  if ( (type == GNUNET_OS_PROCESS_EXITED) && -       (0 != code) ) -  { -    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -                "Failed to setup (auditor) database, exit code %d\n", -                (int) code); -    return GNUNET_NO; -  } -  if ( (type != GNUNET_OS_PROCESS_EXITED) || -       (0 != code) ) -  { -    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -                "Unexpected error (%d/%d) running `taler-auditor-dbinit'!\n", -                (int) type, -                (int) code); -    return GNUNET_SYSERR; -  } -  return GNUNET_OK; -} - - -/** - * Type of closure for - * #sign_keys_for_exchange. - */ -struct SignInfo -{ -  /** -   * Members will be set to the exchange configuration. -   */ -  struct TALER_TESTING_ExchangeConfiguration *ec; - -  /** -   * Name of the configuration file to use. -   */ -  const char *config_filename; - -  /** -   * Did we reset the database? -   */ -  int db_reset; -}; - - -/** - * Sign the keys for an exchange given configuration @a cfg. - * The information to be signed must be in a file "auditor.in". - * - * @param[in,out] cls a `struct SignInfo` with further parameters - * @param cfg configuration to use - * @return #GNUNET_OK on success - */ -static enum GNUNET_GenericReturnValue -sign_keys_for_exchange (void *cls, -                        const struct GNUNET_CONFIGURATION_Handle *cfg) -{ -  struct SignInfo *si = cls; -  char *exchange_master_pub; -  int ret; - -  /* Load the extensions */ -  if (GNUNET_OK != TALER_extensions_init (cfg)) -  { -    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -                "couldn't load extensions"); -    return GNUNET_SYSERR; -  } - -  if (GNUNET_OK != -      GNUNET_CONFIGURATION_get_value_string (cfg, -                                             "exchange", -                                             "BASE_URL", -                                             &si->ec->exchange_url)) -  { -    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, -                               "exchange", -                               "BASE_URL"); -    si->ec->exchange_url = NULL; -    return GNUNET_NO; -  } -  if (GNUNET_OK != -      GNUNET_CONFIGURATION_get_value_string (cfg, -                                             "auditor", -                                             "BASE_URL", -                                             &si->ec->auditor_url)) -  { -    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, -                               "auditor", -                               "BASE_URL"); -    GNUNET_free (si->ec->exchange_url); -    si->ec->exchange_url = NULL; -    si->ec->auditor_url = NULL; -    return GNUNET_SYSERR; -  } -  if (GNUNET_OK != -      GNUNET_CONFIGURATION_get_value_string (cfg, -                                             "exchange", -                                             "MASTER_PUBLIC_KEY", -                                             &exchange_master_pub)) -  { -    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, -                               "exchange", -                               "MASTER_PUBLIC_KEY"); -    ret = GNUNET_SYSERR; -    goto fail; -  } -  if ( (GNUNET_OK != -        TALER_TESTING_run_auditor_exchange (si->config_filename, -                                            exchange_master_pub, -                                            si->ec->exchange_url, -                                            GNUNET_NO)) && -       (GNUNET_YES == si->db_reset) ) -  { -    ret = GNUNET_NO; -    goto fail; -  } -  GNUNET_free (exchange_master_pub); -  return GNUNET_OK; -fail: -  GNUNET_free (si->ec->exchange_url); -  GNUNET_free (si->ec->auditor_url); -  si->ec->exchange_url = NULL; -  si->ec->auditor_url = NULL; -  return ret; -} - - -enum GNUNET_GenericReturnValue -TALER_TESTING_prepare_exchange (const char *config_filename, -                                int reset_db, -                                struct TALER_TESTING_ExchangeConfiguration *ec) -{ -  struct SignInfo si = { -    .config_filename = config_filename, -    .ec = ec, -    .db_reset = reset_db -  }; - -  if (GNUNET_YES == reset_db) -  { -    if (GNUNET_OK != -        TALER_TESTING_exchange_db_reset (config_filename)) -      return GNUNET_NO; -    if (GNUNET_OK != -        TALER_TESTING_auditor_db_reset (config_filename)) -      return GNUNET_NO; -  } -  if (GNUNET_OK != -      GNUNET_CONFIGURATION_parse_and_run (config_filename, -                                          &sign_keys_for_exchange, -                                          &si)) -    return GNUNET_NO; -  return GNUNET_OK; -} - - -int -TALER_TESTING_wait_exchange_ready (const char *base_url) -{ -  char *wget_cmd; -  unsigned int iter; - -  GNUNET_asprintf (&wget_cmd, -                   "wget -q -t 1 -T 1 %sseed -o /dev/null -O /dev/null", -                   base_url); // make sure ends with '/' -  /* give child time to start and bind against the socket */ -  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, -              "Waiting for `taler-exchange-httpd` service to be ready (check with: %s)\n", -              wget_cmd); -  iter = 0; -  do -  { -    if (10 == iter) -    { -      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, -                  "Failed to launch `taler-exchange-httpd` service (or `wget')\n"); -      GNUNET_free (wget_cmd); -      return 77; -    } -    sleep (1); -    iter++; -  } -  while (0 != system (wget_cmd)); -  GNUNET_free (wget_cmd); -  return 0; -} - - -/** - * Wait for the auditor to have started. Waits for at - * most 10s, after that returns 77 to indicate an error. - * - * @param base_url what URL should we expect the auditor - *        to be running at - * @return 0 on success - */ -int -TALER_TESTING_wait_auditor_ready (const char *base_url) -{ -  char *wget_cmd; -  unsigned int iter; - -  GNUNET_asprintf (&wget_cmd, -                   "wget -q -t 1 -T 1 %sversion -o /dev/null -O /dev/null", -                   base_url); // make sure ends with '/' -  /* give child time to start and bind against the socket */ -  fprintf (stderr, -           "Waiting for `taler-auditor-httpd' to be ready at %s\n", -           base_url); -  iter = 0; -  do -  { -    if (10 == iter) -    { -      fprintf (stderr, -               "Failed to launch `taler-auditor-httpd' (or `wget')\n"); -      GNUNET_free (wget_cmd); -      return 77; -    } -    fprintf (stderr, ".\n"); -    sleep (1); -    iter++; -  } -  while (0 != system (wget_cmd)); -  GNUNET_free (wget_cmd); -  return 0; -} - - -enum GNUNET_GenericReturnValue -TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, -                                   void *main_cb_cls, -                                   const char *config_file) -{ -  struct TALER_TESTING_SetupContext setup_ctx = { -    .config_filename = config_file, -    .main_cb = main_cb, -    .main_cb_cls = main_cb_cls -  }; -  enum GNUNET_GenericReturnValue result; - -  result = -    GNUNET_CONFIGURATION_parse_and_run (config_file, -                                        &TALER_TESTING_setup_with_exchange_cfg, -                                        &setup_ctx); -  if (GNUNET_OK != result) -    return result; -  return GNUNET_OK; -} - - -/** - * Stop taler-exchange-crypto helpers. - * - * @param[in] helpers the process handles. - */ -static void -stop_helpers (struct GNUNET_OS_Process *helpers[3]) -{ -  for (unsigned int i = 0; i<3; i++) -  { -    if (NULL == helpers[i]) -      continue; -    GNUNET_break (0 == -                  GNUNET_OS_process_kill (helpers[i], -                                          SIGTERM)); -    GNUNET_break (GNUNET_OK == -                  GNUNET_OS_process_wait (helpers[i])); -    GNUNET_OS_process_destroy (helpers[i]); -  } -} - - -/** - * Start taler-exchange-crypto helpers. - * - * @param config_filename configuration file to use - * @param[out] helpers where to store the process handles. - */ -static enum GNUNET_GenericReturnValue -start_helpers (const char *config_filename, -               struct GNUNET_OS_Process *helpers[3]) -{ -  char *dir; -  const struct GNUNET_OS_ProjectData *pd; - -  pd = GNUNET_OS_project_data_get (); -  GNUNET_OS_init (TALER_project_data_default ()); -  dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); -  GNUNET_OS_init (pd); -  if (NULL == dir) -  { -    GNUNET_break (0); -    return GNUNET_SYSERR; -  } -  { -    char *fn; - -    GNUNET_asprintf (&fn, -                     "%s/%s", -                     dir, -                     "taler-exchange-secmod-eddsa"); -    helpers[0] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, -                                          NULL, NULL, NULL, -                                          fn, -                                          "taler-exchange-secmod-eddsa", -                                          "-c", config_filename, -                                          "-L", "INFO", -                                          NULL); -    GNUNET_free (fn); -  } -  { -    char *fn; - -    GNUNET_asprintf (&fn, -                     "%s/%s", -                     dir, -                     "taler-exchange-secmod-rsa"); -    helpers[1] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, -                                          NULL, NULL, NULL, -                                          fn, -                                          "taler-exchange-secmod-rsa", -                                          "-c", config_filename, -                                          "-L", "INFO", -                                          NULL); -    GNUNET_free (fn); -  } -  { -    char *fn; - -    GNUNET_asprintf (&fn, -                     "%s/%s", -                     dir, -                     "taler-exchange-secmod-cs"); -    helpers[2] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, -                                          NULL, NULL, NULL, -                                          fn, -                                          "taler-exchange-secmod-cs", -                                          "-c", config_filename, -                                          "-L", "INFO", -                                          NULL); -    GNUNET_free (fn); -  } -  GNUNET_free (dir); -  if ( (NULL == helpers[0]) || -       (NULL == helpers[1]) || -       (NULL == helpers[2]) ) -  { -    stop_helpers (helpers); -    return GNUNET_SYSERR; -  } -  return GNUNET_OK; -} - - -enum GNUNET_GenericReturnValue -TALER_TESTING_setup_with_exchange_cfg ( -  void *cls, -  const struct GNUNET_CONFIGURATION_Handle *cfg) -{ -  const struct TALER_TESTING_SetupContext *setup_ctx = cls; -  struct GNUNET_OS_Process *exchanged; -  struct GNUNET_OS_Process *helpers[3]; -  unsigned long long port; -  char *serve; -  char *base_url; -  int result; - -  if (GNUNET_OK != -      GNUNET_CONFIGURATION_get_value_string (cfg, -                                             "exchange", -                                             "SERVE", -                                             &serve)) -  { -    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, -                               "exchange", -                               "SERVE"); -    return GNUNET_NO; -  } - -  if (0 == strcmp ("tcp", -                   serve)) -  { -    if (GNUNET_OK != -        GNUNET_CONFIGURATION_get_value_number (cfg, -                                               "exchange", -                                               "PORT", -                                               &port)) -    { -      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, -                                 "exchange", -                                 "PORT"); -      GNUNET_free (serve); -      return GNUNET_NO; -    } - -    if (GNUNET_OK != -        GNUNET_NETWORK_test_port_free (IPPROTO_TCP, -                                       (uint16_t) port)) -    { -      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, -                  "Required port %llu not available, skipping.\n", -                  port); -      GNUNET_free (serve); -      return GNUNET_NO; -    } -  } -  GNUNET_free (serve); -  if (GNUNET_OK != -      start_helpers (setup_ctx->config_filename, -                     helpers)) -  { -    GNUNET_break (0); -    return 77; -  } -  exchanged = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, -                                       NULL, NULL, NULL, -#if GNU_PARALLEL -                                       "parallel", -#endif -                                       "taler-exchange-httpd", -                                       "taler-exchange-httpd", -                                       "-L", "INFO", -                                       "-a", /* some tests may need timetravel */ -                                       "-c", setup_ctx->config_filename, -#if GNU_PARALLEL -                                       "-r", -                                       ":::", -                                       "-", -                                       "-", -                                       "-", -                                       "-", -#endif -                                       NULL); -  if (NULL == exchanged) -  { -    GNUNET_break (0); -    stop_helpers (helpers); -    return 77; -  } -  if (GNUNET_OK != -      GNUNET_CONFIGURATION_get_value_string (cfg, -                                             "exchange", -                                             "BASE_URL", -                                             &base_url)) -  { -    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, -                               "exchange", -                               "BASE_URL"); -    stop_helpers (helpers); -    return GNUNET_NO; -  } - -  if (0 != TALER_TESTING_wait_exchange_ready (base_url)) -  { -    GNUNET_free (base_url); -    stop_helpers (helpers); -    GNUNET_break (0 == -                  GNUNET_OS_process_kill (exchanged, -                                          SIGTERM)); -#if GNU_PARALLEL -    /* GNU Parallel kills on 2nd SIGTERM, need to give it a -       chance to process the 1st signal first... */ -    sleep (1); -    GNUNET_break (0 == -                  GNUNET_OS_process_kill (exchanged, -                                          SIGTERM)); -#endif -    GNUNET_break (GNUNET_OK == -                  GNUNET_OS_process_wait (exchanged)); -    GNUNET_OS_process_destroy (exchanged); -    return 77; -  } -  GNUNET_free (base_url); - -  /* NOTE: this call blocks.  */ -  result = TALER_TESTING_setup (setup_ctx->main_cb, -                                setup_ctx->main_cb_cls, -                                cfg, -                                exchanged, -                                GNUNET_YES); -  GNUNET_break (0 == -                GNUNET_OS_process_kill (exchanged, -                                        SIGTERM)); -#if GNU_PARALLEL -  /* GNU Parallel kills on 2nd SIGTERM, need to give it a -     chance to process the 1st signal first... */ -  sleep (1); -  GNUNET_break (0 == -                GNUNET_OS_process_kill (exchanged, -                                        SIGTERM)); -#endif -  GNUNET_break (GNUNET_OK == -                GNUNET_OS_process_wait (exchanged)); -  GNUNET_OS_process_destroy (exchanged); -  stop_helpers (helpers); -  return result; -} - - -enum GNUNET_GenericReturnValue -TALER_TESTING_setup_with_auditor_and_exchange_cfg ( -  void *cls, -  const struct GNUNET_CONFIGURATION_Handle *cfg) -{ -  const struct TALER_TESTING_SetupContext *setup_ctx = cls; -  struct GNUNET_OS_Process *auditord; -  unsigned long long port; -  char *serve; -  char *base_url; -  int result; - -  if (GNUNET_OK != -      GNUNET_CONFIGURATION_get_value_string (cfg, -                                             "auditor", -                                             "SERVE", -                                             &serve)) -  { -    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, -                               "auditor", -                               "SERVE"); -    return GNUNET_NO; -  } - -  if (0 == strcmp ("tcp", serve)) -  { -    if (GNUNET_OK != -        GNUNET_CONFIGURATION_get_value_number (cfg, -                                               "auditor", -                                               "PORT", -                                               &port)) -    { -      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, -                                 "auditor", -                                 "PORT"); -      GNUNET_free (serve); -      return GNUNET_NO; -    } - -    if (GNUNET_OK != -        GNUNET_NETWORK_test_port_free (IPPROTO_TCP, -                                       (uint16_t) port)) -    { -      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, -                  "Required port %llu not available, skipping.\n", -                  port); -      GNUNET_free (serve); -      return GNUNET_NO; -    } -  } -  GNUNET_free (serve); -  auditord = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, -                                      NULL, NULL, NULL, -                                      "taler-auditor-httpd", -                                      "taler-auditor-httpd", -                                      "-c", setup_ctx->config_filename, -                                      NULL); - -  if (GNUNET_OK != -      GNUNET_CONFIGURATION_get_value_string (cfg, -                                             "auditor", -                                             "BASE_URL", -                                             &base_url)) -  { -    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, -                               "auditor", -                               "BASE_URL"); -    return GNUNET_NO; -  } - -  if (0 != TALER_TESTING_wait_auditor_ready (base_url)) -  { -    GNUNET_free (base_url); -    GNUNET_break (0 == -                  GNUNET_OS_process_kill (auditord, -                                          SIGTERM)); -    GNUNET_break (GNUNET_OK == -                  GNUNET_OS_process_wait (auditord)); -    GNUNET_OS_process_destroy (auditord); -    return 77; -  } -  GNUNET_free (base_url); - -  /* NOTE: this call blocks.  */ -  result = TALER_TESTING_setup_with_exchange_cfg ((void *) setup_ctx, -                                                  cfg); -  GNUNET_break (0 == -                GNUNET_OS_process_kill (auditord, -                                        SIGTERM)); -  GNUNET_break (GNUNET_OK == -                GNUNET_OS_process_wait (auditord)); -  GNUNET_OS_process_destroy (auditord); -  return result; -} - - -enum GNUNET_GenericReturnValue -TALER_TESTING_setup_with_auditor_and_exchange (TALER_TESTING_Main main_cb, -                                               void *main_cb_cls, -                                               const char *config_file) -{ -  struct TALER_TESTING_SetupContext setup_ctx = { -    .config_filename = config_file, -    .main_cb = main_cb, -    .main_cb_cls = main_cb_cls -  }; - -  return GNUNET_CONFIGURATION_parse_and_run ( -    config_file, -    &TALER_TESTING_setup_with_auditor_and_exchange_cfg, -    &setup_ctx); -} - - -/* end of testing_api_helpers_exchange.c */ diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index ea6b805b..411e47c4 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c @@ -385,7 +385,7 @@ do_timeout (void *cls)   *   * @param cls the `struct TALER_TESTING_Interpreter *`   * @param type type of the process - * @param exit_code status code of the process + * @param code status code of the process   */  static void  maint_child_death (void *cls, diff --git a/src/testing/testing_api_traits.c b/src/testing/testing_api_traits.c index d84e2c37..d00a8d8c 100644 --- a/src/testing/testing_api_traits.c +++ b/src/testing/testing_api_traits.c @@ -102,4 +102,59 @@ TALER_TESTING_get_exchange (struct TALER_TESTING_Interpreter *is)  } +const char * +TALER_TESTING_get_exchange_url (struct TALER_TESTING_Interpreter *is) +{ +  const char *exchange_url; +  const struct TALER_TESTING_Command *exchange_cmd; + +  exchange_cmd +    = TALER_TESTING_interpreter_get_command (is, +                                             "exchange"); +  if (NULL == exchange_cmd) +  { +    GNUNET_break (0); +    TALER_TESTING_interpreter_fail (is); +    return NULL; +  } +  if (GNUNET_OK != +      TALER_TESTING_get_trait_exchange_url (exchange_cmd, +                                            &exchange_url)) +  { +    GNUNET_break (0); +    TALER_TESTING_interpreter_fail (is); +    return NULL; +  } +  return exchange_url; +} + + +struct TALER_EXCHANGE_Keys * +TALER_TESTING_get_keys ( +  struct TALER_TESTING_Interpreter *is) +{ +  struct TALER_EXCHANGE_Keys *keys; +  const struct TALER_TESTING_Command *exchange_cmd; + +  exchange_cmd +    = TALER_TESTING_interpreter_get_command (is, +                                             "exchange"); +  if (NULL == exchange_cmd) +  { +    GNUNET_break (0); +    TALER_TESTING_interpreter_fail (is); +    return NULL; +  } +  if (GNUNET_OK != +      TALER_TESTING_get_trait_keys (exchange_cmd, +                                    &keys)) +  { +    GNUNET_break (0); +    TALER_TESTING_interpreter_fail (is); +    return NULL; +  } +  return keys; +} + +  /* end of testing_api_traits.c */ | 
