[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated (81ede40 -> 84d7b09)
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated (81ede40 -> 84d7b09) |
Date: |
Sat, 31 Oct 2020 00:50:54 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a change to branch master
in repository merchant.
from 81ede40 remove dead options
new 9a27496 properly detect if CONTRACT with same order ID already exists
as well
new e0a8668 remove bogus emtpy lines
new 1524388 do not force reset of bank in benchmark, allow skipping
instance creation
new 84d7b09 fix FIXME, get taler-merchant-benchmark to kind-of work in
ordinary mode
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../taler-merchant-httpd_private-post-orders.c | 25 ++++++-
.../taler-merchant-httpd_private-post-transfers.c | 6 ++
src/merchant-tools/taler-merchant-benchmark.c | 84 +++++++++++++++-------
src/testing/test_merchant_api.c | 2 -
src/testing/testing_api_cmd_get_transfers.c | 12 +++-
src/testing/testing_api_cmd_post_orders.c | 2 +-
src/testing/testing_api_cmd_post_transfers.c | 38 ++++++++--
7 files changed, 130 insertions(+), 39 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 8411420..bac98d4 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -218,6 +218,17 @@ execute_transaction (struct TMH_HandlerContext *hc,
GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+ qs = TMH_db->lookup_order_summary (TMH_db->cls,
+ hc->instance->settings.id,
+ order_id,
+ ×tamp,
+ &order_serial);
+ if (0 != qs)
+ {
+ /* order already exists. */
+ TMH_db->rollback (TMH_db->cls);
+ return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
+ }
/* Setup order */
qs = TMH_db->insert_order (TMH_db->cls,
hc->instance->settings.id,
@@ -226,11 +237,11 @@ execute_transaction (struct TMH_HandlerContext *hc,
pay_deadline,
claim_token,
order);
- /* qs == 0: order already exists. */
+ /* qs == 0: probably instance does not exist. */
if (qs <= 0)
{
TMH_db->rollback (TMH_db->cls);
- return qs;
+ return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
/* Migrate locks from UUIDs to new order: first release old locks */
for (unsigned int i = 0; i<uuids_length; i++)
@@ -508,6 +519,16 @@ execute_order (struct MHD_Connection *connection,
NULL);
}
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ /* should be: contract (!) with same order ID
+ already exists */
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_CONFLICT,
+
TALER_EC_PROPOSAL_STORE_DB_ERROR_ALREADY_EXISTS,
+ order_id);
+ }
+
/* If we have a product that has insufficient quantities,
generate the details for the response. */
if (PRODUCT_OOS_OFFSET >= qs)
diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c
b/src/backend/taler-merchant-httpd_private-post-transfers.c
index d12156f..92e3be3 100644
--- a/src/backend/taler-merchant-httpd_private-post-transfers.c
+++ b/src/backend/taler-merchant-httpd_private-post-transfers.c
@@ -1035,10 +1035,16 @@ fetch:
ptc->payto_uri,
&account_serial);
if (0 >= qs)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Bank account `%s' not configured for instance `%s'\n",
+ ptc->payto_uri,
+ ptc->hc->instance->settings.id);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_POST_TRANSFERS_ACCOUNT_NOT_FOUND,
ptc->payto_uri);
+ }
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/merchant-tools/taler-merchant-benchmark.c
b/src/merchant-tools/taler-merchant-benchmark.c
index 349de80..86c2d2b 100644
--- a/src/merchant-tools/taler-merchant-benchmark.c
+++ b/src/merchant-tools/taler-merchant-benchmark.c
@@ -36,6 +36,8 @@
#include <taler/taler_error_codes.h>
#include "taler_merchant_testing_lib.h"
+#define PAYTO_I1 "payto://x-taler-bank/localhost/42"
+
/**
* Maximum length of an amount (value plus currency string) needed by the test.
* We have a 32-bit and a 64-bit value (~48 characters), plus the currency,
plus
@@ -49,7 +51,7 @@
#define MAX_ORDER_LEN (MAX_AMOUNT_LEN * 4 + 2048)
-/* Error codes. */
+/* Error codes. */
enum PaymentGeneratorError
{
PG_SUCCESS = 0,
@@ -105,6 +107,11 @@ static unsigned int payments_number = 1;
*/
static unsigned int tracks_number = 1;
+/**
+ * Skip instance creation?
+ */
+static int skip_instance = 0;
+
/**
* Config filename to give to commands (like wirewatch).
*/
@@ -192,6 +199,12 @@ run (void *cls,
if (ordinary)
{
struct TALER_TESTING_Command ordinary_commands[] = {
+ TALER_TESTING_cmd_merchant_post_instances ("instance-create-default",
+ merchant_url,
+ "default",
+ PAYTO_I1,
+ "EUR",
+ MHD_HTTP_NO_CONTENT),
TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1",
CURRENCY_10_02,
&bc.exchange_auth,
@@ -209,7 +222,7 @@ run (void *cls,
TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1",
merchant_url,
MHD_HTTP_OK,
- "order-worth-5",
+ NULL, /* random order ID please
*/
GNUNET_TIME_UNIT_ZERO_ABS,
GNUNET_TIME_UNIT_FOREVER_ABS,
"EUR:5.0"),
@@ -222,7 +235,7 @@ run (void *cls,
CURRENCY_4_99,
NULL),
TALER_TESTING_cmd_rewind_ip ("rewind-payments",
- "create-reserve",
+ "create-reserve-1",
payments_number),
/* Next proposal-pay cycle will be used by /track CMDs
* and so it will not have to be looped over, only /track
@@ -246,12 +259,14 @@ run (void *cls,
TALER_TESTING_cmd_exec_aggregator ("aggregate-1",
cfg_filename),
+ TALER_TESTING_cmd_exec_transfer ("transfer-1",
+ cfg_filename),
TALER_TESTING_cmd_merchant_post_transfer (
"post-transfer-1",
&bc.exchange_auth,
bc.exchange_auth.wire_gateway_url,
merchant_url,
- "EUR:4.98", /* FIXME: check
amount! */
+ "EUR:4.98",
MHD_HTTP_OK,
"deposit-simple-2",
NULL),
@@ -259,7 +274,7 @@ run (void *cls,
merchant_url,
bc.user42_payto,
MHD_HTTP_OK,
- "post-transaction-1",
+ "post-transfer-1",
NULL),
TALER_TESTING_cmd_rewind_ip ("rewind-tracks",
"track-transfer-1",
@@ -268,13 +283,19 @@ run (void *cls,
};
TALER_TESTING_run (is,
- ordinary_commands);
+ &ordinary_commands[skip_instance]);
return;
}
if (corner) /* should never be 'false' here */
{
struct TALER_TESTING_Command corner_commands[] = {
+ TALER_TESTING_cmd_merchant_post_instances ("instance-create-default",
+ merchant_url,
+ "default",
+ PAYTO_I1,
+ "EUR",
+ MHD_HTTP_NO_CONTENT),
TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1",
CURRENCY_5_01,
&bc.exchange_auth,
@@ -334,6 +355,8 @@ run (void *cls,
NULL),
TALER_TESTING_cmd_exec_aggregator ("aggregate-twocoins",
cfg_filename),
+ TALER_TESTING_cmd_exec_transfer ("transfer-twocoins",
+ cfg_filename),
TALER_TESTING_cmd_rewind_ip ("rewind-twocoins",
"create-reserve-2",
twocoins_number),
@@ -341,7 +364,7 @@ run (void *cls,
};
TALER_TESTING_run (is,
- corner_commands);
+ &corner_commands[skip_instance]);
return;
}
}
@@ -373,10 +396,10 @@ int
main (int argc,
char *const *argv)
{
- char *loglev = "INFO";
+ char *loglev = NULL;
char *logfile = NULL;
- char *exchange_account;
- char *alt_instance_id;
+ char *exchange_account = NULL;
+ char *alt_instance_id = NULL;
struct GNUNET_OS_Process *bankd;
struct GNUNET_OS_Process *merchantd;
struct GNUNET_GETOPT_CommandLineOption *options;
@@ -385,16 +408,31 @@ main (int argc,
GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
GNUNET_GETOPT_option_help ("Runs benchmark logic against merchant backend.
"
"Must be used with either 'ordinary' or
'corner' sub-commands."),
+ GNUNET_GETOPT_option_string ('l',
+ "logfile",
+ "LF",
+ "will log to file LF",
+ &logfile),
+ GNUNET_GETOPT_option_loglevel (&loglev),
GNUNET_GETOPT_OPTION_END
};
struct GNUNET_GETOPT_CommandLineOption corner_options[] = {
- GNUNET_GETOPT_option_help ("Populate databases with corner case payments"),
+ GNUNET_GETOPT_option_string ('l',
+ "logfile",
+ "LF",
+ "will log to file LF",
+ &logfile),
GNUNET_GETOPT_option_loglevel (&loglev),
+ GNUNET_GETOPT_option_help ("Populate databases with corner case payments"),
GNUNET_GETOPT_option_uint ('u',
"unaggregated-number",
"UN",
"will generate UN unaggregated payments,
defaults to 1",
&unaggregated_number),
+ GNUNET_GETOPT_option_flag ('s',
+ "skip-instance",
+ "skip creating the backend default instance
(use if the instance already exists with the backend)",
+ &skip_instance),
GNUNET_GETOPT_option_uint ('t',
"two-coins",
"TC",
@@ -424,19 +462,19 @@ main (int argc,
" as they would get those far future ones"
" aggregated too.",
&alt_instance_id)),
+ GNUNET_GETOPT_OPTION_END
+ };
+ struct GNUNET_GETOPT_CommandLineOption ordinary_options[] = {
GNUNET_GETOPT_option_string ('l',
"logfile",
"LF",
"will log to file LF",
&logfile),
- GNUNET_GETOPT_OPTION_END
- };
- struct GNUNET_GETOPT_CommandLineOption ordinary_options[] = {
+ GNUNET_GETOPT_option_loglevel (&loglev),
GNUNET_GETOPT_option_cfgfile (&cfg_filename),
GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
GNUNET_GETOPT_option_help ("Generate Taler ordinary payments"
" to populate the databases"),
- GNUNET_GETOPT_option_loglevel (&loglev),
GNUNET_GETOPT_option_mandatory (
GNUNET_GETOPT_option_string ('e',
"exchange-account",
@@ -458,20 +496,11 @@ main (int argc,
"TN",
"will perform TN /track operations, defaults to
1",
&tracks_number),
- GNUNET_GETOPT_option_string ('l',
- "logfile",
- "LF",
- "will log to file LF",
- &logfile),
GNUNET_GETOPT_OPTION_END
};
const char *default_config_file;
default_config_file = GNUNET_OS_project_data_get ()->user_config_file;
- loglev = NULL;
- GNUNET_log_setup ("taler-merchant-benchmark",
- loglev,
- logfile);
options = root_options;
if (NULL != argv[1])
{
@@ -501,6 +530,9 @@ main (int argc,
if (0 == result)
return PG_SUCCESS;
}
+ GNUNET_log_setup ("taler-merchant-benchmark",
+ loglev,
+ logfile);
if ( (! ordinary) &&
(! corner) )
{
@@ -547,7 +579,7 @@ main (int argc,
}
if (GNUNET_OK !=
TALER_TESTING_prepare_bank (cfg_filename,
- GNUNET_YES,
+ GNUNET_NO,
exchange_account,
&bc))
{
@@ -573,7 +605,7 @@ main (int argc,
{
int result;
- result = TALER_TESTING_setup_with_exchange (run,
+ result = TALER_TESTING_setup_with_exchange (&run,
NULL,
cfg_filename);
terminate_process (merchantd);
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index f3dc709..2cb9caf 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -195,14 +195,12 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_TESTING_Command get_private_order_id[] = {
-
TALER_TESTING_cmd_merchant_post_instances ("instance-create-default",
merchant_url,
"default",
PAYTO_I1,
"EUR",
MHD_HTTP_NO_CONTENT),
-
TALER_TESTING_cmd_merchant_post_orders_no_claim ("create-proposal-4",
merchant_url,
MHD_HTTP_OK,
diff --git a/src/testing/testing_api_cmd_get_transfers.c
b/src/testing/testing_api_cmd_get_transfers.c
index 19e198a..3c0181c 100644
--- a/src/testing/testing_api_cmd_get_transfers.c
+++ b/src/testing/testing_api_cmd_get_transfers.c
@@ -124,6 +124,14 @@ get_transfers_cb (
transfer_cmd = TALER_TESTING_interpreter_lookup_command (
gts->is,
gts->transfers[i]);
+ if (NULL == transfer_cmd)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Command `%s' not found!\n",
+ gts->transfers[i]);
+ TALER_TESTING_interpreter_fail (gts->is);
+ return;
+ }
{
const struct TALER_WireTransferIdentifierRawP *wtid;
@@ -163,7 +171,9 @@ get_transfers_cb (
transfers[i].payto_uri))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Wire transfer payto uri does not match\n");
+ "Wire transfer payto uri does not match: %s != %s\n",
+ payto_uri,
+ transfers[i].payto_uri);
TALER_TESTING_interpreter_fail (gts->is);
return;
}
diff --git a/src/testing/testing_api_cmd_post_orders.c
b/src/testing/testing_api_cmd_post_orders.c
index b4a56ee..8ccfb00 100644
--- a/src/testing/testing_api_cmd_post_orders.c
+++ b/src/testing/testing_api_cmd_post_orders.c
@@ -629,7 +629,7 @@ mark_forgettable (void *cls,
/**
* Constructs the json for a POST order request.
*
- * @param order_id the name of the order to add.
+ * @param order_id the name of the order to add, can be NULL.
* @param refund_deadline the deadline for refunds on this order.
* @param pay_deadline the deadline for payment on this order.
* @param amount the amount this order is for.
diff --git a/src/testing/testing_api_cmd_post_transfers.c
b/src/testing/testing_api_cmd_post_transfers.c
index 5faba8e..1fa9dfc 100644
--- a/src/testing/testing_api_cmd_post_transfers.c
+++ b/src/testing/testing_api_cmd_post_transfers.c
@@ -59,6 +59,11 @@ struct PostTransfersState
*/
char *exchange_url;
+ /**
+ * Credit account of the merchant (set once @e found is set).
+ */
+ char *credit_account;
+
/**
* Payto URI to filter on.
*/
@@ -154,6 +159,11 @@ transfers_cb (void *cls,
{
pts->execution_time = execution_time;
pts->wire_fee = *wire_fee;
+ fprintf (stderr,
+ "FIXME");
+ json_dumpf (hr->reply,
+ stderr,
+ 0);
#if FIXME_WRITE_PROPPER_CHECK_OF_RETURNED_DATA_HERE
/* this code is some legacy logic that is close to what we
need but needs to be updated to the current API */
@@ -291,7 +301,8 @@ transfers_cb (void *cls,
default:
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unhandled HTTP status.\n");
+ "Unhandled HTTP status %d.\n",
+ hr->http_status);
}
TALER_TESTING_interpreter_next (pts->is);
}
@@ -316,7 +327,7 @@ post_transfers_traits (void *cls,
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_string (0, pts->credit_account),
TALER_TESTING_make_trait_amount_obj (0, &pts->credit_amount),
TALER_TESTING_make_trait_amount_obj (1, &pts->wire_fee),
TALER_TESTING_make_trait_string (1, pts->exchange_url),
@@ -368,11 +379,18 @@ debit_cb (
return GNUNET_OK;
}
GNUNET_assert (NULL != pts->exchange_url);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Bank transfer found, checking with merchant backend at %s
about %s from %s to %s with %s\n",
+ pts->merchant_url,
+ TALER_amount2s (&pts->credit_amount),
+ pts->payto_uri,
+ pts->exchange_url,
+ TALER_B2S (&pts->wtid));
pts->pth = TALER_MERCHANT_transfers_post (pts->is->ctx,
pts->merchant_url,
&pts->credit_amount,
&pts->wtid,
- pts->payto_uri,
+ pts->credit_account,
pts->exchange_url,
&transfers_cb,
pts);
@@ -387,15 +405,16 @@ debit_cb (
}
if (pts->found)
return GNUNET_OK;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Bank reports transfer of %s to %s\n",
+ TALER_amount2s (&details->amount),
+ details->credit_account_url);
if (0 != TALER_amount_cmp (&pts->credit_amount,
&details->amount))
return GNUNET_OK;
- if ( (NULL != pts->payto_uri) &&
- (0 != strcasecmp (pts->payto_uri,
- details->credit_account_url)) )
- return GNUNET_OK;
pts->found = true;
pts->wtid = details->wtid;
+ pts->credit_account = GNUNET_strdup (details->credit_account_url);
pts->exchange_url = GNUNET_strdup (details->exchange_base_url);
return GNUNET_OK;
}
@@ -417,6 +436,10 @@ post_transfers_run (void *cls,
struct PostTransfersState *pts = cls;
pts->is = is;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Looking for transfer of %s from %s at bank\n",
+ TALER_amount2s (&pts->credit_amount),
+ pts->payto_uri);
pts->dhh = TALER_BANK_debit_history (is->ctx,
&pts->auth,
UINT64_MAX,
@@ -456,6 +479,7 @@ post_transfers_cleanup (void *cls,
pts->deposits_length,
0);
GNUNET_free (pts->exchange_url);
+ GNUNET_free (pts->credit_account);
GNUNET_free (pts);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-merchant] branch master updated (81ede40 -> 84d7b09),
gnunet <=
- [taler-merchant] 03/04: do not force reset of bank in benchmark, allow skipping instance creation, gnunet, 2020/10/30
- [taler-merchant] 02/04: remove bogus emtpy lines, gnunet, 2020/10/30
- [taler-merchant] 01/04: properly detect if CONTRACT with same order ID already exists as well, gnunet, 2020/10/30
- [taler-merchant] 04/04: fix FIXME, get taler-merchant-benchmark to kind-of work in ordinary mode, gnunet, 2020/10/30