From 6a46b13e80659cbc9917b46f74d21b4f4aaf6c3b Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 20 Mar 2020 14:01:59 +0530 Subject: make recoup idempotent and simplify response --- src/testing/test_auditor_api.c | 2 -- src/testing/test_exchange_api.c | 3 --- src/testing/test_exchange_api_revocation.c | 16 ++++++++------ src/testing/testing_api_cmd_recoup.c | 35 +----------------------------- 4 files changed, 10 insertions(+), 46 deletions(-) (limited to 'src/testing') diff --git a/src/testing/test_auditor_api.c b/src/testing/test_auditor_api.c index eea676bd4..97934f1d1 100644 --- a/src/testing/test_auditor_api.c +++ b/src/testing/test_auditor_api.c @@ -409,7 +409,6 @@ run (void *cls, TALER_TESTING_cmd_recoup ("recoup-1", MHD_HTTP_OK, "recoup-withdraw-coin-1", - "EUR:5", NULL), /** * Re-withdraw from this reserve @@ -469,7 +468,6 @@ run (void *cls, TALER_TESTING_cmd_recoup ("recoup-2", MHD_HTTP_OK, "recoup-withdraw-coin-2a", - "EUR:0.5", NULL), TALER_TESTING_cmd_end () }; diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index 0913688a3..e62223303 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -587,7 +587,6 @@ run (void *cls, TALER_TESTING_cmd_recoup ("recoup-1", MHD_HTTP_OK, "recoup-withdraw-coin-1", - "EUR:5", NULL), /* Check the money is back with the reserve */ TALER_TESTING_cmd_status ("recoup-reserve-status-1", @@ -682,12 +681,10 @@ run (void *cls, TALER_TESTING_cmd_recoup ("recoup-2", MHD_HTTP_OK, "recoup-withdraw-coin-2a", - "EUR:0.5", NULL), TALER_TESTING_cmd_recoup ("recoup-2b", MHD_HTTP_CONFLICT, "recoup-withdraw-coin-2a", - "EUR:0.5", NULL), TALER_TESTING_cmd_deposit ("recoup-deposit-revoked", "recoup-withdraw-coin-2b", diff --git a/src/testing/test_exchange_api_revocation.c b/src/testing/test_exchange_api_revocation.c index 467b93e9a..05ec06b16 100644 --- a/src/testing/test_exchange_api_revocation.c +++ b/src/testing/test_exchange_api_revocation.c @@ -117,27 +117,31 @@ run (void *cls, TALER_TESTING_cmd_recoup ("recoup-1a", MHD_HTTP_OK, "refresh-reveal-1#0", - "EUR:1", "refresh-melt-1"), TALER_TESTING_cmd_recoup ("recoup-1b", MHD_HTTP_OK, "refresh-reveal-1#1", - "EUR:1", "refresh-melt-1"), TALER_TESTING_cmd_recoup ("recoup-1c", MHD_HTTP_OK, "refresh-reveal-1#2", - "EUR:1", + "refresh-melt-1"), + /* Repeat recoup to test idempotency */ + TALER_TESTING_cmd_recoup ("recoup-1c", + MHD_HTTP_OK, + "refresh-reveal-1#2", + "refresh-melt-1"), + TALER_TESTING_cmd_recoup ("recoup-1c", + MHD_HTTP_OK, + "refresh-reveal-1#2", "refresh-melt-1"), TALER_TESTING_cmd_recoup ("recoup-1c", MHD_HTTP_OK, "refresh-reveal-1#2", - "EUR:1", "refresh-melt-1"), TALER_TESTING_cmd_recoup ("recoup-1c", MHD_HTTP_OK, "refresh-reveal-1#2", - "EUR:1", "refresh-melt-1"), /* Now we have EUR:3.83 EUR back after 3x EUR:1 in recoups */ /* Melt original coin AGAIN, but only create one 0.1 EUR coin; @@ -168,14 +172,12 @@ run (void *cls, TALER_TESTING_cmd_recoup ("recoup-2", MHD_HTTP_OK, "refresh-reveal-2", - "EUR:0.1", "refresh-melt-2"), /* Due to recoup, original coin is now at EUR:3.79 */ /* Refund original (now zombie) coin to reserve */ TALER_TESTING_cmd_recoup ("recoup-3", MHD_HTTP_OK, "withdraw-revocation-coin-1", - "EUR:3.79", NULL), /* Check the money is back with the reserve */ TALER_TESTING_cmd_status ("recoup-reserve-status-1", diff --git a/src/testing/testing_api_cmd_recoup.c b/src/testing/testing_api_cmd_recoup.c index add54b87f..b0012f82d 100644 --- a/src/testing/testing_api_cmd_recoup.c +++ b/src/testing/testing_api_cmd_recoup.c @@ -86,11 +86,6 @@ struct RecoupState */ struct TALER_TESTING_Interpreter *is; - /** - * Amount expected to be paid back. - */ - const char *amount; - /** * Handle to the ongoing operation. */ @@ -157,9 +152,6 @@ parse_coin_reference (const char *coin_reference, * @param cls closure * @param http_status HTTP response code. * @param ec taler-specific error code. - * @param amount amount the exchange will wire back for this coin. - * @param timestamp what time did the exchange receive the - * /recoup request * @param reserve_pub public key of the reserve receiving the recoup, NULL if refreshed or on error * @param old_coin_pub public key of the dirty coin, NULL if not refreshed or on error * @param full_response raw response from the exchange. @@ -168,8 +160,6 @@ static void recoup_cb (void *cls, unsigned int http_status, enum TALER_ErrorCode ec, - const struct TALER_Amount *amount, - struct GNUNET_TIME_Absolute timestamp, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_CoinSpendPublicKeyP *old_coin_pub, const json_t *full_response) @@ -219,28 +209,7 @@ recoup_cb (void *cls, switch (http_status) { case MHD_HTTP_OK: - /* first, check amount */ - { - struct TALER_Amount expected_amount; - - if (GNUNET_OK != - TALER_string_to_amount (ps->amount, &expected_amount)) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - if (0 != TALER_amount_cmp (amount, &expected_amount)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Total amount mismatch to command %s\n", - cmd->label); - json_dumpf (full_response, stderr, 0); - TALER_TESTING_interpreter_fail (is); - return; - } - } - /* now, check old_coin_pub or reserve_pub, respectively */ + /* check old_coin_pub or reserve_pub, respectively */ if (NULL != ps->melt_reference) { const struct TALER_TESTING_Command *melt_cmd; @@ -559,7 +528,6 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_recoup (const char *label, unsigned int expected_response_code, const char *coin_reference, - const char *amount, const char *melt_reference) { struct RecoupState *ps; @@ -567,7 +535,6 @@ TALER_TESTING_cmd_recoup (const char *label, ps = GNUNET_new (struct RecoupState); ps->expected_response_code = expected_response_code; ps->coin_reference = coin_reference; - ps->amount = amount; ps->melt_reference = melt_reference; { struct TALER_TESTING_Command cmd = { -- cgit v1.2.3