diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-05-19 15:14:12 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-05-19 15:14:12 +0200 |
commit | 8c0719db1f153106ea69a7224694f4a39394707a (patch) | |
tree | 32adefda8fa1327929f17d390332778e62d110e2 /src/testing/testing_api_cmd_post_transfers.c | |
parent | 83afcc2e6ab7e4be1b62614445087e4df22b83f7 (diff) |
add test for #6876, and minor fixes
Diffstat (limited to 'src/testing/testing_api_cmd_post_transfers.c')
-rw-r--r-- | src/testing/testing_api_cmd_post_transfers.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/testing/testing_api_cmd_post_transfers.c b/src/testing/testing_api_cmd_post_transfers.c index e78af34e..35c425a3 100644 --- a/src/testing/testing_api_cmd_post_transfers.c +++ b/src/testing/testing_api_cmd_post_transfers.c @@ -310,6 +310,8 @@ transfers_cb (void *cls, break; case MHD_HTTP_NOT_FOUND: break; + case MHD_HTTP_GATEWAY_TIMEOUT: + break; default: GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -356,6 +358,34 @@ post_transfers_traits (void *cls, /** + * Run the "POST /transfers" CMD. First, get the bank history to find + * the wtid. + * + * @param cls closure. + * @param cmd command being run now. + * @param is interpreter state. + */ +static void +post_transfers_run2 (void *cls, + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is) +{ + struct PostTransfersState *pts = cls; + + pts->is = is; + pts->pth = TALER_MERCHANT_transfers_post (pts->is->ctx, + pts->merchant_url, + &pts->credit_amount, + &pts->wtid, + pts->credit_account, + pts->exchange_url, + &transfers_cb, + pts); + GNUNET_assert (NULL != pts->pth); +} + + +/** * Callbacks of this type are used to serve the result of asking * the bank for the debit transaction history. * @@ -407,6 +437,7 @@ debit_cb ( pts->exchange_url, &transfers_cb, pts); + GNUNET_assert (NULL != pts->pth); return GNUNET_OK; } if (MHD_HTTP_OK != http_status) @@ -544,6 +575,54 @@ TALER_TESTING_cmd_merchant_post_transfer ( } +struct TALER_TESTING_Command +TALER_TESTING_cmd_merchant_post_transfer2 ( + const char *label, + const char *merchant_url, + const char *payto_uri, + const char *credit_amount, + const char *wtid, + const char *exchange_url, + unsigned int http_code) +{ + struct PostTransfersState *pts; + + pts = GNUNET_new (struct PostTransfersState); + pts->merchant_url = merchant_url; + pts->credit_account = GNUNET_strdup (payto_uri); + pts->exchange_url = GNUNET_strdup (exchange_url); + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (credit_amount, + &pts->credit_amount)); + if (NULL == wtid) + { + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, + &pts->wtid, + sizeof (pts->wtid)); + } + else + { + GNUNET_assert (GNUNET_OK == + GNUNET_STRINGS_string_to_data (wtid, + strlen (wtid), + &pts->wtid, + sizeof (pts->wtid))); + } + pts->http_status = http_code; + { + struct TALER_TESTING_Command cmd = { + .cls = pts, + .label = label, + .run = &post_transfers_run2, + .cleanup = &post_transfers_cleanup, + .traits = &post_transfers_traits + }; + + return cmd; + } +} + + void TALER_TESTING_cmd_merchant_post_transfer_set_serial ( struct TALER_TESTING_Command *cmd, |