diff options
author | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-03 18:23:46 -0400 |
---|---|---|
committer | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-03 18:23:46 -0400 |
commit | 33d332a637d77524f140a20c0b636177276224a9 (patch) | |
tree | a0aa460e89e7379c6fd83ba19229bec54779c7d8 /src/testing | |
parent | c4dc3bf39183559ddcfeafba65ef3d8635bc13fe (diff) | |
download | merchant-33d332a637d77524f140a20c0b636177276224a9.tar.gz merchant-33d332a637d77524f140a20c0b636177276224a9.tar.bz2 merchant-33d332a637d77524f140a20c0b636177276224a9.zip |
test GET /private/transfers
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/test_merchant_api.c | 8 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_get_transfers.c | 124 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_post_transfers.c | 46 |
3 files changed, 171 insertions, 7 deletions
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index eb3e7def..02a70f33 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -383,12 +383,18 @@ run (void *cls, merchant_payto), TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-1", &bc.exchange_auth, - "payto://x-taler-bank/localhost/3", + PAYTO_I1, merchant_url, "EUR:4.98", MHD_HTTP_OK, "deposit-simple", NULL), + TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-1", + merchant_url, + PAYTO_I1, + MHD_HTTP_OK, + "post-transfer-1", + NULL), TALER_TESTING_cmd_merchant_delete_order ("delete-order-1", merchant_url, "1", diff --git a/src/testing/testing_api_cmd_get_transfers.c b/src/testing/testing_api_cmd_get_transfers.c index d0efa13a..34889e88 100644 --- a/src/testing/testing_api_cmd_get_transfers.c +++ b/src/testing/testing_api_cmd_get_transfers.c @@ -117,9 +117,127 @@ get_transfers_cb ( TALER_TESTING_interpreter_fail (gts->is); return; } - // { - // FIXME: check that list of returned transactions matches our expectations! - // } + for (unsigned int i = 0; i < transfers_length; ++i) + { + const struct TALER_TESTING_Command *transfer_cmd; + + transfer_cmd = TALER_TESTING_interpreter_lookup_command ( + gts->is, + gts->transfers[i]); + { + const struct TALER_WireTransferIdentifierRawP *wtid; + + if (GNUNET_OK != + TALER_TESTING_get_trait_wtid (transfer_cmd, + 0, + &wtid)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch wire transfer id\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + if (0 != GNUNET_memcmp (wtid, + &transfers[i].wtid)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Wire transfer id does not match\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + } + { + const char *payto_uri; + + if (GNUNET_OK != + TALER_TESTING_get_trait_string (transfer_cmd, + 0, + &payto_uri)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch wire transfer payto uri\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + if (0 != strcmp (payto_uri, + transfers[i].payto_uri)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Wire transfer payto uri does not match\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + } + { + const struct TALER_Amount *credit_amount; + + if (GNUNET_OK != + TALER_TESTING_get_trait_amount_obj (transfer_cmd, + 0, + &credit_amount)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch wire transfer credit amount\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + if ((GNUNET_OK != TALER_amount_cmp_currency (credit_amount, + &transfers[i].credit_amount)) + || + (0 != TALER_amount_cmp (credit_amount, + &transfers[i].credit_amount))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Wire transfer credit amount does not match\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + } + { + const char *exchange_url; + + if (GNUNET_OK != + TALER_TESTING_get_trait_string (transfer_cmd, + 1, + &exchange_url)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch wire transfer exchange url\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + if (0 != strcmp (exchange_url, + transfers[i].exchange_url)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Wire transfer exchange url does not match\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + } + { + const struct GNUNET_TIME_Absolute *execution_time; + + if (GNUNET_OK != + TALER_TESTING_get_trait_absolute_time (transfer_cmd, + 0, + &execution_time)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch wire transfer execution time\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + if (execution_time->abs_value_us != + transfers[i].execution_time.abs_value_us) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Wire transfer execution time does not match\n"); + TALER_TESTING_interpreter_fail (gts->is); + return; + } + } + } break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/testing/testing_api_cmd_post_transfers.c b/src/testing/testing_api_cmd_post_transfers.c index 768b76a4..100ea32d 100644 --- a/src/testing/testing_api_cmd_post_transfers.c +++ b/src/testing/testing_api_cmd_post_transfers.c @@ -98,6 +98,11 @@ struct PostTransfersState * Set to true once @e wtid and @e exchange_url are initialized. */ bool found; + + /** + * When the exchange executed the transfer. + */ + struct GNUNET_TIME_Absolute execution_time; }; @@ -142,9 +147,10 @@ transfers_cb (void *cls, { case MHD_HTTP_OK: { - /* - struct TALER_Amount total; + // struct TALER_Amount total; + pts->execution_time = execution_time; + /* if (0 > TALER_amount_subtract (&total, total_amount, @@ -284,6 +290,39 @@ transfers_cb (void *cls, /** + * Offers information from the POST /transfers CMD state to other + * commands. + * + * @param cls closure + * @param ret[out] result (could be anything) + * @param trait name of the trait + * @param index index number of the object to extract. + * @return #GNUNET_OK on success + */ +static int +post_transfers_traits (void *cls, + const void **ret, + const char *trait, + unsigned int index) +{ + struct PostTransfersState *pts = cls; + struct TALER_TESTING_Trait traits[] = { + TALER_TESTING_make_trait_wtid (0, &pts->wtid), + TALER_TESTING_make_trait_string (0, pts->payto_uri), + TALER_TESTING_make_trait_amount_obj (0, &pts->credit_amount), + TALER_TESTING_make_trait_string (1, pts->exchange_url), + TALER_TESTING_make_trait_absolute_time (0, &pts->execution_time), + TALER_TESTING_trait_end (), + }; + + return TALER_TESTING_get_trait (traits, + ret, + trait, + index); +} + + +/** * Callbacks of this type are used to serve the result of asking * the bank for the debit transaction history. * @@ -468,7 +507,8 @@ TALER_TESTING_cmd_merchant_post_transfer ( .cls = pts, .label = label, .run = &post_transfers_run, - .cleanup = &post_transfers_cleanup + .cleanup = &post_transfers_cleanup, + .traits = &post_transfers_traits }; return cmd; |