diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-01-29 18:11:58 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-01-29 18:11:58 +0100 |
commit | 38b8097d94f794287c0dea3fbbe1f80cac46a69f (patch) | |
tree | 5617ccd57ec630794fb766ed8527549400fa38e5 | |
parent | 719854d4879b54d27552bbbfc9f66a20eb8dd2cc (diff) |
allow permutations in order of reserves returned to still count as acceptable
-rw-r--r-- | src/testing/testing_api_cmd_get_reserves.c | 111 |
1 files changed, 66 insertions, 45 deletions
diff --git a/src/testing/testing_api_cmd_get_reserves.c b/src/testing/testing_api_cmd_get_reserves.c index 22e0e1cd..f673d70b 100644 --- a/src/testing/testing_api_cmd_get_reserves.c +++ b/src/testing/testing_api_cmd_get_reserves.c @@ -74,6 +74,8 @@ get_reserves_cb (void *cls, { /* FIXME, deeper checks should be implemented here. */ struct GetReservesState *grs = cls; + bool matched[reserves_length]; + bool fail = false; grs->rgh = NULL; if (grs->http_status != hr->http_status) @@ -97,60 +99,79 @@ get_reserves_cb (void *cls, return; } // FIXME: check if the data returned matches that from the POST / PATCH + memset (matched, 0, sizeof (matched)); for (unsigned int i = 0; i < reserves_length; ++i) - { - const struct TALER_TESTING_Command *reserve_cmd; - - reserve_cmd = TALER_TESTING_interpreter_lookup_command ( - grs->is, - grs->reserves[i]); + for (unsigned int j = 0; j < reserves_length; ++j) { - const struct TALER_ReservePublicKeyP *reserve_pub; + const struct TALER_TESTING_Command *reserve_cmd; + bool match = true; - if (GNUNET_OK != - TALER_TESTING_get_trait_reserve_pub (reserve_cmd, - 0, - &reserve_pub)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Could not fetch reserve public key\n"); - TALER_TESTING_interpreter_fail (grs->is); - return; - } - if (0 != GNUNET_memcmp (&reserves[i].reserve_pub, - reserve_pub)) + reserve_cmd = TALER_TESTING_interpreter_lookup_command ( + grs->is, + grs->reserves[j]); { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Reserve public key does not match\n"); - TALER_TESTING_interpreter_fail (grs->is); - return; - } - } - { - const struct TALER_Amount *initial; + const struct TALER_ReservePublicKeyP *reserve_pub; - if (GNUNET_OK != - TALER_TESTING_get_trait_amount_obj (reserve_cmd, - 0, - &initial)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Could not fetch reserve initial balance\n"); - TALER_TESTING_interpreter_fail (grs->is); - return; + if (GNUNET_OK != + TALER_TESTING_get_trait_reserve_pub (reserve_cmd, + 0, + &reserve_pub)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch reserve public key\n"); + TALER_TESTING_interpreter_fail (grs->is); + return; + } + if (0 != GNUNET_memcmp (&reserves[i].reserve_pub, + reserve_pub)) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Reserve public key does not match, got %s\n", + TALER_B2S (&reserves[i].reserve_pub)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Reserve public key does not match, expected %s\n", + TALER_B2S (reserve_pub)); + match = false; + } } - if ((GNUNET_OK != TALER_amount_cmp_currency ( - &reserves[i].merchant_initial_amount, - initial)) || - (0 != TALER_amount_cmp (&reserves[i].merchant_initial_amount, - initial))) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Reserve initial amount does not match\n"); - TALER_TESTING_interpreter_fail (grs->is); - return; + const struct TALER_Amount *initial; + + if (GNUNET_OK != + TALER_TESTING_get_trait_amount_obj (reserve_cmd, + 0, + &initial)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch reserve initial balance\n"); + TALER_TESTING_interpreter_fail (grs->is); + return; + } + if ((GNUNET_OK != + TALER_amount_cmp_currency (&reserves[i].merchant_initial_amount, + initial)) || + (0 != TALER_amount_cmp (&reserves[i].merchant_initial_amount, + initial))) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Reserve initial amount does not match, got %s\n", + TALER_amount2s (&reserves[i].merchant_initial_amount)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Reserve initial amount does not match, wanted %s\n", + TALER_amount2s (initial)); + match = false; + } } + if (match) + matched[i] = true; } + for (unsigned int i = 0; i < reserves_length; ++i) + if (! matched[i]) + fail = true; + if (fail) + { + TALER_TESTING_interpreter_fail (grs->is); + return; } break; default: |