diff options
| author | Christian Grothoff <christian@grothoff.org> | 2021-05-20 12:31:27 +0200 | 
|---|---|---|
| committer | Christian Grothoff <christian@grothoff.org> | 2021-05-20 12:31:27 +0200 | 
| commit | 4741f4ea02148ed1dede88affd83edd9a96e2680 (patch) | |
| tree | bde9d1f98715cbd73ce4394545abd6e0252b6180 /src/testing | |
| parent | 259a180bb68bbc084cdb2f89887ecd165960f1f5 (diff) | |
implement duplicate reserve_pub detection in fakebank, add test (fails in pybank), for #6863
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/test_bank_api.c | 5 | ||||
| -rw-r--r-- | src/testing/test_exchange_api.c | 18 | ||||
| -rw-r--r-- | src/testing/testing_api_cmd_bank_admin_add_incoming.c | 51 | 
3 files changed, 35 insertions, 39 deletions
| diff --git a/src/testing/test_bank_api.c b/src/testing/test_bank_api.c index 7069e44f..98f97cd4 100644 --- a/src/testing/test_bank_api.c +++ b/src/testing/test_bank_api.c @@ -87,6 +87,11 @@ run (void *cls,                                              "KUDOS:5.01",                                              &bc.exchange_auth,                                              bc.user42_payto), +      TALER_TESTING_cmd_admin_add_incoming_with_ref ("credit-1-fail", +                                                     "KUDOS:2.01", +                                                     &bc.exchange_auth, +                                                     bc.user42_payto, +                                                     "credit-1"),        TALER_TESTING_cmd_sleep ("Waiting 4s for 'credit-1' to settle",                                 4),        TALER_TESTING_cmd_bank_credits ("history-1c", diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index 18f7237b..008eefb2 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -121,9 +121,9 @@ run (void *cls,       * Move money to the exchange's bank account.       */      CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1", -                              "EUR:4.01"), +                              "EUR:6.02"),      TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1", -                                                 "EUR:4.01", +                                                 "EUR:6.02",                                                   bc.user42_payto,                                                   bc.exchange_payto,                                                   "create-reserve-1"), @@ -133,20 +133,6 @@ run (void *cls,       */      CMD_EXEC_WIREWATCH ("wirewatch-1"),      /** -     * Do another transfer to the same reserve -     */ -    TALER_TESTING_cmd_admin_add_incoming_with_ref ("create-reserve-1.2", -                                                   "EUR:2.01", -                                                   &bc.exchange_auth, -                                                   bc.user42_payto, -                                                   "create-reserve-1"), -    TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1.2", -                                                 "EUR:2.01", -                                                 bc.user42_payto, -                                                 bc.exchange_payto, -                                                 "create-reserve-1.2"), -    CMD_EXEC_WIREWATCH ("wirewatch-1.2"), -    /**       * Withdraw EUR:5.       */      TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", diff --git a/src/testing/testing_api_cmd_bank_admin_add_incoming.c b/src/testing/testing_api_cmd_bank_admin_add_incoming.c index e467063a..aaa447fe 100644 --- a/src/testing/testing_api_cmd_bank_admin_add_incoming.c +++ b/src/testing/testing_api_cmd_bank_admin_add_incoming.c @@ -148,6 +148,11 @@ struct AdminAddIncomingState     * enable retries? If so, how often should we still retry?     */    unsigned int do_retry; + +  /** +   * Expected HTTP status code. +   */ +  unsigned int expected_http_status;  }; @@ -215,6 +220,13 @@ confirmation_cb (void *cls,    switch (http_status)    {    case MHD_HTTP_OK: +    if (fts->expected_http_status != +        MHD_HTTP_OK) +    { +      GNUNET_break (0); +      TALER_TESTING_interpreter_fail (is); +      return; +    }      fts->serial_id = serial_id;      fts->timestamp = timestamp;      TALER_TESTING_interpreter_next (is); @@ -233,6 +245,16 @@ confirmation_cb (void *cls,        break;      }      break; +  case MHD_HTTP_CONFLICT: +    if (fts->expected_http_status != +        MHD_HTTP_CONFLICT) +    { +      GNUNET_break (0); +      TALER_TESTING_interpreter_fail (is); +      return; +    } +    TALER_TESTING_interpreter_next (is); +    return;    default:      if (0 != fts->do_retry)      { @@ -405,6 +427,10 @@ admin_add_incoming_traits (void *cls,                             unsigned int index)  {    struct AdminAddIncomingState *fts = cls; + +  if (MHD_HTTP_OK != +      fts->expected_http_status) +    return GNUNET_NO; /* requests that failed generate no history */    if (fts->reserve_priv_known)    {      struct TALER_TESTING_Trait traits[] = { @@ -479,6 +505,7 @@ make_fts (const char *amount,    fts->exchange_credit_url = auth->wire_gateway_url;    fts->payto_debit_account = payto_debit_account;    fts->auth = *auth; +  fts->expected_http_status = MHD_HTTP_OK;    if (GNUNET_OK !=        TALER_string_to_amount (amount,                                &fts->amount)) @@ -515,15 +542,6 @@ make_command (const char *label,  } -/** - * Create admin/add-incoming command. - * - * @param label command label. - * @param amount amount to transfer. - * @param payto_debit_account which account sends money. - * @param auth authentication data - * @return the command. - */  struct TALER_TESTING_Command  TALER_TESTING_cmd_admin_add_incoming (const char *label,                                        const char *amount, @@ -538,20 +556,6 @@ TALER_TESTING_cmd_admin_add_incoming (const char *label,  } -/** - * Create "/admin/add-incoming" CMD, letting the caller specify - * a reference to a command that can offer a reserve private key. - * This private key will then be used to construct the subject line - * of the wire transfer. - * - * @param label command label. - * @param amount the amount to transfer. - * @param payto_debit_account which account sends money - * @param auth authentication data - * @param ref reference to a command that can offer a reserve - *        private key or public key. - * @return the command. - */  struct TALER_TESTING_Command  TALER_TESTING_cmd_admin_add_incoming_with_ref    (const char *label, @@ -566,6 +570,7 @@ TALER_TESTING_cmd_admin_add_incoming_with_ref                    auth,                    payto_debit_account);    fts->reserve_reference = ref; +  fts->expected_http_status = MHD_HTTP_CONFLICT;    return make_command (label,                         fts);  } | 
