[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] branch master updated (73e2e5a -> 71e9b21)
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] branch master updated (73e2e5a -> 71e9b21) |
Date: |
Sun, 16 Jul 2017 22:44:13 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a change to branch master
in repository merchant.
from 73e2e5a making testcase pass to new "flagged as paid" policy
new 468eed8 > half testcase gone over for "assert vs fail" issue
new 71e9b21 indentating the code in order to avoid very long lines + #5092
The 2 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:
src/lib/test_merchant_api.c | 770 +++++++++++++++++++-------------------------
1 file changed, 337 insertions(+), 433 deletions(-)
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index df9edda..409a9a6 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -913,8 +913,8 @@ compare_admin_add_incoming_history (const struct
TALER_EXCHANGE_ReserveHistory *
return GNUNET_SYSERR;
}
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (cmd->details.admin_add_incoming.amount,
- &amount));
+ TALER_string_to_amount (cmd->details.admin_add_incoming.amount,
+ &amount));
if (0 != TALER_amount_cmp (&amount,
&h->amount))
{
@@ -1010,6 +1010,11 @@ reserve_status_cb (void *cls,
switch ((rel = &is->commands[i])->oc)
{
case OC_ADMIN_ADD_INCOMING:
+ /**
+ * If the command being iterated over filled a reserve AND
+ * it is the one referenced by the current "history command"
+ * ...
+ */
if ( ( (NULL != rel->label) &&
(0 == strcmp (cmd->details.reserve_status.reserve_reference,
rel->label) ) ) ||
@@ -1017,9 +1022,12 @@ reserve_status_cb (void *cls,
(0 == strcmp (cmd->details.reserve_status.reserve_reference,
rel->details.admin_add_incoming.reserve_reference) )
) )
{
- if (GNUNET_OK !=
- compare_admin_add_incoming_history (&history[j],
- rel))
+ /**
+ * ... then make sure the history element mentions a "deposit
+ * operation" on that reserve.
+ */
+ if (GNUNET_OK != compare_admin_add_incoming_history (&history[j],
+ rel))
{
GNUNET_break (0);
fail (is);
@@ -1029,12 +1037,20 @@ reserve_status_cb (void *cls,
}
break;
case OC_WITHDRAW_SIGN:
+ /**
+ * If the command being iterated over emptied a reserve AND
+ * it is the one referenced by the current "history command"
+ * ...
+ */
if (0 == strcmp (cmd->details.reserve_status.reserve_reference,
rel->details.reserve_withdraw.reserve_reference))
{
- if (GNUNET_OK !=
- compare_reserve_withdraw_history (&history[j],
- rel))
+ /**
+ * ... then make sure the history element mentions a "withdraw
+ * operation" on that reserve.
+ */
+ if (GNUNET_OK != compare_reserve_withdraw_history (&history[j],
+ rel))
{
GNUNET_break (0);
fail (is);
@@ -1104,8 +1120,6 @@ reserve_withdraw_cb (void *cls,
"Unexpected response code %u to command %s\n",
http_status,
cmd->label);
- json_dumpf (full_response, stderr, 0);
- GNUNET_break (0);
fail (is);
return;
}
@@ -1118,6 +1132,10 @@ reserve_withdraw_cb (void *cls,
fail (is);
return;
}
+ /**
+ * NOTE: this assert is OK on the second instance run because the
+ * interpreter is "cleaned" by cleanup_state()
+ */
GNUNET_assert (NULL == cmd->details.reserve_withdraw.sig.rsa_signature);
cmd->details.reserve_withdraw.sig.rsa_signature
= GNUNET_CRYPTO_rsa_signature_dup (sig->rsa_signature);
@@ -1135,7 +1153,7 @@ reserve_withdraw_cb (void *cls,
/**
- * Callback that works PUT /proposal's output.
+ * Callback that works POST /proposal's output.
*
* @param cls closure
* @param http_status HTTP response code, 200 indicates success;
@@ -1173,11 +1191,9 @@ proposal_cb (void *cls,
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "unexpected status code from /proposal: %u. Step %u\n",
+ "Unexpected status code from /proposal: %u. Step %u\n",
http_status,
is->ip);
- json_dumpf (obj, stderr, 0);
- GNUNET_break (0);
fail (is);
return;
}
@@ -1202,10 +1218,6 @@ refund_increase_cb (void *cls,
struct InterpreterState *is = cls;
struct Command *cmd = &is->commands[is->ip];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "/refund (increase) response object: %s\n",
- json_dumps (obj, JSON_INDENT (2)));
-
if (MHD_HTTP_OK != http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1290,17 +1302,10 @@ refund_lookup_cb (void *cls,
GNUNET_JSON_spec_end ()
};
- if (GNUNET_OK !=
- GNUNET_JSON_parse (elem,
- spec,
- &error_name,
- &error_line))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not parse GET /refund response\n");
- fail (is);
- return;
- }
+ GNUNET_assert (GNUNET_OK == GNUNET_JSON_parse (elem,
+ spec,
+ &error_name,
+ &error_line));
GNUNET_CRYPTO_hash (&coin_pub,
sizeof (struct TALER_CoinSpendPublicKeyP),
&h_coin_pub);
@@ -1313,11 +1318,9 @@ refund_lookup_cb (void *cls,
};
/* Retrieve coins used to pay, from OC_PAY command */
- GNUNET_assert (NULL !=
- (pay = find_command (is, cmd->details.refund_lookup.pay_ref)));
+ GNUNET_assert (NULL != (pay = find_command (is,
cmd->details.refund_lookup.pay_ref)));
icoin_refs = GNUNET_strdup (pay->details.pay.coin_ref);
- GNUNET_assert (NULL !=
- (icoin_ref = strtok (icoin_refs, ";")));
+ GNUNET_assert (NULL != (icoin_ref = strtok (icoin_refs, ";")));
TALER_amount_get_zero ("EUR", &acc);
do
{
@@ -1396,9 +1399,6 @@ pay_cb (void *cls,
"Unexpected response code %u to command %s\n",
http_status,
cmd->label);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Response was %s\n",
- json_dumps (obj, JSON_INDENT (2)));
fail (is);
return;
}
@@ -1410,20 +1410,11 @@ pay_cb (void *cls,
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
&cmd->details.pay.h_contract_terms),
GNUNET_JSON_spec_end ()
};
- if (GNUNET_OK !=
+ GNUNET_assert (GNUNET_OK ==
GNUNET_JSON_parse (obj,
spec,
&error_name,
- &error_line))
- {
- GNUNET_break_op (0);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Parser failed on %s:%u\n",
- error_name,
- error_line);
- fail (is);
- return;
- }
+ &error_line));
mr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
mr.purpose.size = htonl (sizeof (mr));
mr.h_contract_terms = cmd->details.pay.h_contract_terms;
@@ -1503,7 +1494,6 @@ track_transfer_cb (void *cls,
"Unexpected response code %u to command %s\n",
http_status,
cmd->label);
- json_dumpf (json, stderr, 0);
fail (is);
return;
}
@@ -1567,7 +1557,6 @@ track_transaction_cb (void *cls,
"Unexpected response code %u to command %s\n",
http_status,
cmd->label);
- json_dumpf (json, stderr, 0);
fail (is);
return;
}
@@ -1796,7 +1785,6 @@ cleanup_state (struct InterpreterState *is)
/**
* Run the main interpreter loop that performs exchange operations.
- *
* @param cls contains the `struct InterpreterState`
*/
static void
@@ -1817,8 +1805,8 @@ interpreter_run (void *cls)
tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
- fprintf (stderr,
- "Test aborted by shutdown request\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Test aborted by shutdown request\n");
fail (is);
return;
}
@@ -1829,55 +1817,54 @@ interpreter_run (void *cls)
cmd->oc);
switch (cmd->oc)
{
- case OC_END:
- result = GNUNET_OK;
- if (instance_idx + 1 == ninstances)
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- cleanup_state (is);
- is->ip = 0;
- instance_idx++;
- instance = instances[instance_idx];
- instance_priv = get_instance_priv (cfg, instance);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Switching instance: `%s'\n",
- instance);
- is->task = GNUNET_SCHEDULER_add_now (interpreter_run,
- is);
+ case OC_END:
+ result = GNUNET_OK;
+ if (instance_idx + 1 == ninstances)
+ {
+ GNUNET_SCHEDULER_shutdown ();
return;
+ }
+ cleanup_state (is);
+ is->ip = 0;
+ instance_idx++;
+ instance = instances[instance_idx];
+ instance_priv = get_instance_priv (cfg, instance);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Switching instance: `%s'\n",
+ instance);
+ is->task = GNUNET_SCHEDULER_add_now (interpreter_run,
+ is);
+ break;
case OC_PROPOSAL_LOOKUP:
{
const char *order_id;
GNUNET_assert (NULL != cmd->details.proposal_lookup.proposal_reference);
- ref = find_command (is, cmd->details.proposal_lookup.proposal_reference);
- GNUNET_assert (NULL != ref);
-
- order_id =
- json_string_value (json_object_get
(ref->details.proposal.contract_terms,
- "order_id"));
- GNUNET_assert (NULL !=
- (cmd->details.proposal_lookup.plo
- = TALER_MERCHANT_proposal_lookup (ctx,
- MERCHANT_URI,
- order_id,
- instance,
- proposal_lookup_cb,
- is)));
+ GNUNET_assert (NULL != (ref = find_command (is,
cmd->details.proposal_lookup.proposal_reference)));
+
+ order_id = json_string_value (json_object_get
(ref->details.proposal.contract_terms,
+ "order_id"));
+ if (NULL == (cmd->details.proposal_lookup.plo
+ = TALER_MERCHANT_proposal_lookup (ctx,
+ MERCHANT_URI,
+ order_id,
+ instance,
+ proposal_lookup_cb,
+ is)))
+ {
+ GNUNET_break (0);
+ fail (is);
+ }
}
-
- return;
+ break;
case OC_ADMIN_ADD_INCOMING:
if (NULL !=
cmd->details.admin_add_incoming.reserve_reference)
{
- ref = find_command (is,
- cmd->details.admin_add_incoming.reserve_reference);
- GNUNET_assert (NULL != ref);
+ GNUNET_assert (NULL != (ref
+ = find_command (is,
cmd->details.admin_add_incoming.reserve_reference)));
GNUNET_assert (OC_ADMIN_ADD_INCOMING == ref->oc);
cmd->details.admin_add_incoming.reserve_priv
= ref->details.admin_add_incoming.reserve_priv;
@@ -1892,45 +1879,19 @@ interpreter_run (void *cls)
}
GNUNET_CRYPTO_eddsa_key_get_public
(&cmd->details.admin_add_incoming.reserve_priv.eddsa_priv,
&reserve_pub.eddsa_pub);
- if (GNUNET_OK !=
- TALER_string_to_amount (cmd->details.admin_add_incoming.amount,
- &amount))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse amount `%s' at %u\n",
- cmd->details.admin_add_incoming.amount,
- is->ip);
- fail (is);
- return;
- }
-
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (cmd->details.admin_add_incoming.amount,
+ &amount));
execution_date = GNUNET_TIME_absolute_get ();
GNUNET_TIME_round_abs (&execution_date);
- sender_details = json_loads
(cmd->details.admin_add_incoming.sender_details,
- JSON_REJECT_DUPLICATES,
- NULL);
- if (NULL == sender_details)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse sender details `%s' at %u\n",
- cmd->details.admin_add_incoming.sender_details,
- is->ip);
- fail (is);
- return;
- }
- transfer_details = json_loads
(cmd->details.admin_add_incoming.transfer_details,
- JSON_REJECT_DUPLICATES,
- NULL);
-
- if (NULL == transfer_details)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse transfer details `%s' at %u\n",
- cmd->details.admin_add_incoming.transfer_details,
- is->ip);
- fail (is);
- return;
- }
+ GNUNET_assert (NULL != (sender_details
+ = json_loads (cmd->details.admin_add_incoming.sender_details,
+ JSON_REJECT_DUPLICATES,
+ NULL)));
+ GNUNET_assert (NULL != (transfer_details
+ = json_loads (cmd->details.admin_add_incoming.transfer_details,
+ JSON_REJECT_DUPLICATES,
+ NULL)));
cmd->details.admin_add_incoming.aih
= TALER_EXCHANGE_admin_add_incoming (exchange,
@@ -1948,56 +1909,40 @@ interpreter_run (void *cls)
{
GNUNET_break (0);
fail (is);
- return;
}
- return;
+ break;
case OC_WITHDRAW_STATUS:
GNUNET_assert (NULL !=
cmd->details.reserve_status.reserve_reference);
- ref = find_command (is,
- cmd->details.reserve_status.reserve_reference);
- GNUNET_assert (NULL != ref);
+ GNUNET_assert (NULL != (ref = find_command
+ (is,
+ cmd->details.reserve_status.reserve_reference)));
GNUNET_assert (OC_ADMIN_ADD_INCOMING == ref->oc);
GNUNET_CRYPTO_eddsa_key_get_public
(&ref->details.admin_add_incoming.reserve_priv.eddsa_priv,
&reserve_pub.eddsa_pub);
- cmd->details.reserve_status.wsh
- = TALER_EXCHANGE_reserve_status (exchange,
- &reserve_pub,
- &reserve_status_cb,
- is);
- return;
- case OC_WITHDRAW_SIGN:
- GNUNET_assert (NULL !=
- cmd->details.reserve_withdraw.reserve_reference);
- ref = find_command (is,
- cmd->details.reserve_withdraw.reserve_reference);
- GNUNET_assert (NULL != ref);
- GNUNET_assert (OC_ADMIN_ADD_INCOMING == ref->oc);
- if (NULL != cmd->details.reserve_withdraw.amount)
- {
- if (GNUNET_OK !=
- TALER_string_to_amount (cmd->details.reserve_withdraw.amount,
- &amount))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse amount `%s' at %u\n",
- cmd->details.reserve_withdraw.amount,
- is->ip);
- fail (is);
- return;
- }
- cmd->details.reserve_withdraw.pk = find_pk (is->keys,
- &amount);
- }
- if (NULL == cmd->details.reserve_withdraw.pk)
+ if (NULL == (cmd->details.reserve_status.wsh
+ = TALER_EXCHANGE_reserve_status (exchange,
+ &reserve_pub,
+ &reserve_status_cb,
+ is)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to determine denomination key at %u\n",
- is->ip);
+ GNUNET_break (0);
fail (is);
- return;
}
-
+ break;
+ case OC_WITHDRAW_SIGN:
+ GNUNET_assert (NULL != cmd->details.reserve_withdraw.reserve_reference);
+ GNUNET_assert (NULL != (ref = find_command
+ (is,
+ cmd->details.reserve_withdraw.reserve_reference)));
+ GNUNET_assert (OC_ADMIN_ADD_INCOMING == ref->oc);
+ GNUNET_assert (NULL != cmd->details.reserve_withdraw.amount);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (cmd->details.reserve_withdraw.amount,
+ &amount));
+ GNUNET_assert (NULL != (cmd->details.reserve_withdraw.pk
+ = find_pk (is->keys,
+ &amount)));
/* create coin's private key */
{
struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
@@ -2013,28 +1958,28 @@ interpreter_run (void *cls)
sizeof
(cmd->details.reserve_withdraw.blinding_key));
cmd->details.reserve_withdraw.wsh
- = TALER_EXCHANGE_reserve_withdraw (exchange,
- cmd->details.reserve_withdraw.pk,
-
&ref->details.admin_add_incoming.reserve_priv,
-
&cmd->details.reserve_withdraw.coin_priv,
-
&cmd->details.reserve_withdraw.blinding_key,
- &reserve_withdraw_cb,
- is);
+ = TALER_EXCHANGE_reserve_withdraw
+ (exchange,
+ cmd->details.reserve_withdraw.pk,
+ &ref->details.admin_add_incoming.reserve_priv,
+ &cmd->details.reserve_withdraw.coin_priv,
+ &cmd->details.reserve_withdraw.blinding_key,
+ &reserve_withdraw_cb,
+ is);
if (NULL == cmd->details.reserve_withdraw.wsh)
{
GNUNET_break (0);
fail (is);
- return;
}
- return;
+ break;
case OC_PROPOSAL:
{
json_t *order;
json_error_t error;
- order = json_loads (cmd->details.proposal.order,
- JSON_REJECT_DUPLICATES,
- &error);
+ GNUNET_assert (NULL != (order = json_loads (cmd->details.proposal.order,
+ JSON_REJECT_DUPLICATES,
+ &error)));
if (NULL != instance)
{
json_t *merchant;
@@ -2047,31 +1992,18 @@ interpreter_run (void *cls)
"merchant",
merchant);
}
- if (NULL == order)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse the order `%s' at command #%u: %s at %u\n",
- cmd->details.proposal.order,
- is->ip,
- error.text,
- (unsigned int) error.column);
- fail (is);
- return;
- }
- cmd->details.proposal.po
- = TALER_MERCHANT_order_put (ctx,
- MERCHANT_URI,
- order,
- &proposal_cb,
- is);
+ cmd->details.proposal.po = TALER_MERCHANT_order_put (ctx,
+ MERCHANT_URI,
+ order,
+ &proposal_cb,
+ is);
json_decref (order);
if (NULL == cmd->details.proposal.po)
{
GNUNET_break (0);
fail (is);
- return;
}
- return;
+ break;
}
case OC_PAY:
{
@@ -2093,9 +2025,9 @@ interpreter_run (void *cls)
unsigned int error_line;
/* get proposal */
- ref = find_command (is,
- cmd->details.pay.contract_ref);
- GNUNET_assert (NULL != ref);
+ GNUNET_assert (NULL != (ref = find_command
+ (is,
+ cmd->details.pay.contract_ref)));
merchant_sig = ref->details.proposal.merchant_sig;
GNUNET_assert (NULL != ref->details.proposal.contract_terms);
{
@@ -2123,14 +2055,18 @@ interpreter_run (void *cls)
"Parser failed on %s:%u\n",
error_name,
error_line);
+ /**
+ * Let's use fail() here, as the proposal might be broken
+ * because of backend's fault.
+ */
fail (is);
return;
}
cmd->details.pay.merchant_pub = merchant_pub;
}
- /* strtok loop here */
+ /* strtok loop here */
coins = GNUNET_strdup (cmd->details.pay.coin_ref);
- GNUNET_break (NULL != (token = strtok (coins, ";")));
+ GNUNET_assert (NULL != (token = strtok (coins, ";")));
pc = GNUNET_new (struct TALER_MERCHANT_PayCoin);
icoin = pc;
npc = 1;
@@ -2138,9 +2074,8 @@ interpreter_run (void *cls)
{
const struct Command *coin_ref;
- coin_ref = find_command (is,
- token);
- GNUNET_assert (NULL != ref);
+ GNUNET_assert (coin_ref = find_command (is,
+ token));
switch (coin_ref->oc)
{
case OC_WITHDRAW_SIGN:
@@ -2153,29 +2088,12 @@ interpreter_run (void *cls)
GNUNET_assert (0);
}
- if (GNUNET_OK !=
- TALER_string_to_amount (cmd->details.pay.amount_without_fee,
- &icoin->amount_without_fee))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse amount `%s' at %u\n",
- cmd->details.pay.amount_without_fee,
- is->ip);
- fail (is);
- return;
- }
-
- if (GNUNET_OK !=
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (cmd->details.pay.amount_without_fee,
+ &icoin->amount_without_fee));
+ GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (cmd->details.pay.amount_with_fee,
- &icoin->amount_with_fee))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse amount `%s' at %u\n",
- cmd->details.pay.amount_with_fee,
- is->ip);
- fail (is);
- return;
- }
+ &icoin->amount_with_fee));
token = strtok (NULL, ";");
if (NULL == token)
break;
@@ -2184,39 +2102,37 @@ interpreter_run (void *cls)
} while (1);
icoin->next = NULL;
-
- cmd->details.pay.ph
- = TALER_MERCHANT_pay_wallet (ctx,
- MERCHANT_URI,
- instance,
- &ref->details.proposal.hash,
- &total_amount,
- &max_fee,
- &merchant_pub,
- &merchant_sig,
- timestamp,
- refund_deadline,
- pay_deadline,
- &h_wire,
- EXCHANGE_URI,
- order_id,
- npc /* num_coins */,
- pc /* coins */,
- &pay_cb,
- is);
+ cmd->details.pay.ph = TALER_MERCHANT_pay_wallet
+ (ctx,
+ MERCHANT_URI,
+ instance,
+ &ref->details.proposal.hash,
+ &total_amount,
+ &max_fee,
+ &merchant_pub,
+ &merchant_sig,
+ timestamp,
+ refund_deadline,
+ pay_deadline,
+ &h_wire,
+ EXCHANGE_URI,
+ order_id,
+ npc /* num_coins */,
+ pc /* coins */,
+ &pay_cb,
+ is);
}
if (NULL == cmd->details.pay.ph)
{
GNUNET_break (0);
fail (is);
- return;
}
- return;
+ break;
case OC_RUN_AGGREGATOR:
{
const struct GNUNET_DISK_FileHandle *pr;
- cmd->details.run_aggregator.aggregator_proc
+ GNUNET_assert (NULL != (cmd->details.run_aggregator.aggregator_proc
= GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
@@ -2224,40 +2140,26 @@ interpreter_run (void *cls)
"taler-exchange-aggregator",
"-c", "test_merchant_api.conf",
"-t", /* exit when done */
- NULL);
- if (NULL == cmd->details.run_aggregator.aggregator_proc)
- {
- GNUNET_break (0);
- fail (is);
- return;
- }
+ NULL)));
pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
cmd->details.run_aggregator.child_death_task
= GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
pr,
&maint_child_death, is);
- return;
}
+ break;
case OC_CHECK_BANK_TRANSFER:
{
- if (GNUNET_OK !=
- TALER_string_to_amount (cmd->details.check_bank_transfer.amount,
- &amount))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse amount `%s' at %u\n",
- cmd->details.reserve_withdraw.amount,
- is->ip);
- fail (is);
- return;
- }
- if (GNUNET_OK !=
- TALER_FAKEBANK_check (fakebank,
- &amount,
- cmd->details.check_bank_transfer.account_debit,
-
cmd->details.check_bank_transfer.account_credit,
- EXCHANGE_URI,
- &cmd->details.check_bank_transfer.subject))
+ GNUNET_assert (GNUNET_OK == TALER_string_to_amount
+ (cmd->details.check_bank_transfer.amount,
+ &amount));
+ if (GNUNET_OK != TALER_FAKEBANK_check
+ (fakebank,
+ &amount,
+ cmd->details.check_bank_transfer.account_debit,
+ cmd->details.check_bank_transfer.account_credit,
+ EXCHANGE_URI,
+ &cmd->details.check_bank_transfer.subject))
{
GNUNET_break (0);
fail (is);
@@ -2283,102 +2185,107 @@ interpreter_run (void *cls)
struct TALER_WireTransferIdentifierRawP wtid;
const char *subject;
- ref = find_command (is,
- cmd->details.track_transfer.check_bank_ref);
- GNUNET_assert (NULL != ref);
+ GNUNET_assert (NULL != ( ref = find_command
+ (is,
+ cmd->details.track_transfer.check_bank_ref)));
subject = ref->details.check_bank_transfer.subject;
- GNUNET_assert (GNUNET_OK ==
- GNUNET_STRINGS_string_to_data (subject,
- strlen (subject),
- &wtid,
- sizeof (wtid)));
- cmd->details.track_transfer.tdo
- = TALER_MERCHANT_track_transfer (ctx,
- MERCHANT_URI,
- instance,
- &wtid,
- EXCHANGE_URI,
- &track_transfer_cb,
- is);
- return;
+ GNUNET_assert (GNUNET_OK == GNUNET_STRINGS_string_to_data (subject,
+ strlen (subject),
+ &wtid,
+ sizeof (wtid)));
+ if (NULL == (cmd->details.track_transfer.tdo
+ = TALER_MERCHANT_track_transfer (ctx,
+ MERCHANT_URI,
+ instance,
+ &wtid,
+ EXCHANGE_URI,
+ &track_transfer_cb,
+ is)))
+ {
+ GNUNET_break (0);
+ fail (is);
+ }
}
+ return;
case OC_TRACK_TRANSACTION:
{
const struct Command *proposal_ref;
const char *order_id;
- ref = find_command (is,
- cmd->details.track_transaction.pay_ref);
- GNUNET_assert (NULL != ref);
- proposal_ref = find_command (is,
- ref->details.pay.contract_ref);
- order_id = json_string_value (json_object_get
(proposal_ref->details.proposal.contract_terms,
- "order_id"));
- cmd->details.track_transaction.tth =
- TALER_MERCHANT_track_transaction (ctx,
- MERCHANT_URI,
- instance,
- order_id,
- &track_transaction_cb,
- is);
- }
+ GNUNET_assert(NULL != (ref = find_command
+ (is,
+ cmd->details.track_transaction.pay_ref)));
+ GNUNET_assert (NULL != (proposal_ref = find_command
+ (is,
+ ref->details.pay.contract_ref)));
+ order_id = json_string_value
+ (json_object_get (proposal_ref->details.proposal.contract_terms,
+ "order_id"));
+
+ if (NULL == (cmd->details.track_transaction.tth
+ = TALER_MERCHANT_track_transaction (ctx,
+ MERCHANT_URI,
+ instance,
+ order_id,
+ &track_transaction_cb,
+ is)))
+ {
+ GNUNET_break (0);
+ fail (is);
+ }
return;
+ }
case OC_HISTORY:
-
- if (NULL ==
- (cmd->details.history.ho = TALER_MERCHANT_history (ctx,
- MERCHANT_URI,
- instance,
-
cmd->details.history.start,
-
cmd->details.history.nrows,
-
cmd->details.history.date,
- &history_cb,
- is)))
+ if (NULL == (cmd->details.history.ho
+ = TALER_MERCHANT_history (ctx,
+ MERCHANT_URI,
+ instance,
+ cmd->details.history.start,
+ cmd->details.history.nrows,
+ cmd->details.history.date,
+ &history_cb,
+ is)))
{
+ GNUNET_break (0);
fail (is);
- return;
}
break;
case OC_REFUND_INCREASE:
{
struct TALER_Amount refund_amount;
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (cmd->details.refund_increase.refund_amount,
- &refund_amount));
- if (NULL ==
- (cmd->details.refund_increase.rio =
- TALER_MERCHANT_refund_increase (ctx,
- MERCHANT_URI,
-
cmd->details.refund_increase.order_id,
- &refund_amount,
- cmd->details.refund_increase.reason,
- instance,
- refund_increase_cb,
- is)))
+ GNUNET_assert (GNUNET_OK == TALER_string_to_amount
+ (cmd->details.refund_increase.refund_amount,
+ &refund_amount));
+ if (NULL == (cmd->details.refund_increase.rio
+ = TALER_MERCHANT_refund_increase
+ (ctx,
+ MERCHANT_URI,
+ cmd->details.refund_increase.order_id,
+ &refund_amount,
+ cmd->details.refund_increase.reason,
+ instance,
+ refund_increase_cb,
+ is)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not issue a /refund increase request\n");
+ GNUNET_break (0);
fail (is);
- return;
}
break;
}
case OC_REFUND_LOOKUP:
{
- if (NULL ==
- (cmd->details.refund_lookup.rlo =
- TALER_MERCHANT_refund_lookup (ctx,
- MERCHANT_URI,
- cmd->details.refund_lookup.order_id,
- instance,
- refund_lookup_cb,
- is)))
+ if (NULL == (cmd->details.refund_lookup.rlo
+ = TALER_MERCHANT_refund_lookup
+ (ctx,
+ MERCHANT_URI,
+ cmd->details.refund_lookup.order_id,
+ instance,
+ refund_lookup_cb,
+ is)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not issue a /refund lookup request\n");
+ GNUNET_break (0);
fail (is);
- return;
}
break;
}
@@ -2453,12 +2360,7 @@ do_shutdown (void *cls)
}
TALER_FAKEBANK_stop (fakebank);
fakebank = NULL;
-
- /**
- * WARNING: hangs when attempting to drop tables.
- */
db->drop_tables (db->cls);
-
TALER_MERCHANTDB_plugin_unload (db);
GNUNET_CONFIGURATION_destroy (cfg);
}
@@ -2498,7 +2400,7 @@ cert_cb (void *cls,
"Certificate callback invoked, starting interpreter\n");
is->keys = keys;
is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
- is);
+ is);
}
@@ -2512,11 +2414,12 @@ sighandler_child_death ()
static char c;
int old_errno = errno; /* back-up errno */
- GNUNET_break (1 ==
- GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle
- (sigpipe, GNUNET_DISK_PIPE_END_WRITE),
- &c, sizeof (c)));
- errno = old_errno; /* restore errno */
+ GNUNET_break (1 == GNUNET_DISK_file_write
+ (GNUNET_DISK_pipe_handle (sigpipe,
+ GNUNET_DISK_PIPE_END_WRITE),
+ &c,
+ sizeof (c)));
+ errno = old_errno; /* restore errno */
}
/**
@@ -2788,15 +2691,15 @@ run (void *cls)
is = GNUNET_new (struct InterpreterState);
is->commands = commands;
- ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
- &rc);
- GNUNET_assert (NULL != ctx);
+ GNUNET_assert (ctx = GNUNET_CURL_init
+ (&GNUNET_CURL_gnunet_scheduler_reschedule,
+ &rc));
rc = GNUNET_CURL_gnunet_rc_create (ctx);
- exchange = TALER_EXCHANGE_connect (ctx,
- EXCHANGE_URI,
- &cert_cb, is,
- TALER_EXCHANGE_OPTION_END);
- GNUNET_assert (NULL != exchange);
+ GNUNET_assert (NULL != (exchange
+ = TALER_EXCHANGE_connect (ctx,
+ EXCHANGE_URI,
+ &cert_cb, is,
+ TALER_EXCHANGE_OPTION_END)));
timeout_task
= GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 150),
@@ -2829,21 +2732,21 @@ main (int argc,
"DEBUG",
NULL);
cfg = GNUNET_CONFIGURATION_create ();
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load
+ (cfg,
+ "test_merchant_api.conf"));
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONFIGURATION_load (cfg,
- "test_merchant_api.conf"));
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "merchant",
- "INSTANCES",
- &_instances));
- fprintf (stderr,
- "Found instances `%s'\n",
- _instances);
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "merchant",
+ "INSTANCES",
+ &_instances));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Found instances `%s'\n",
+ _instances);
GNUNET_break (NULL != (token = strtok (_instances, " ")));
GNUNET_array_append (instances,
- ninstances,
- GNUNET_strdup (token));
+ ninstances,
+ GNUNET_strdup (token));
while (NULL != (token = strtok (NULL, " ")))
GNUNET_array_append (instances,
ninstances,
@@ -2864,53 +2767,53 @@ main (int argc,
GNUNET_CONFIGURATION_destroy (cfg);
return 77;
}
- proc = GNUNET_OS_start_process (GNUNET_NO,
- GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-exchange-keyup",
- "taler-exchange-keyup",
- "-c", "test_merchant_api.conf",
- NULL);
- if (NULL == proc)
+ if (NULL == (proc = GNUNET_OS_start_process
+ (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-exchange-keyup",
+ "taler-exchange-keyup",
+ "-c", "test_merchant_api.conf",
+ NULL)))
{
- fprintf (stderr,
- "Failed to run taler-exchange-keyup. Check your PATH.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to run taler-exchange-keyup. Check your PATH.\n");
return 77;
}
GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc);
- proc = GNUNET_OS_start_process (GNUNET_NO,
- GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-exchange-dbinit",
- "taler-exchange-dbinit",
- "-c", "test_merchant_api.conf",
- "-r",
- NULL);
- if (NULL == proc)
+ if (NULL == (proc = GNUNET_OS_start_process
+ (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-exchange-dbinit",
+ "taler-exchange-dbinit",
+ "-c", "test_merchant_api.conf",
+ "-r",
+ NULL)))
{
- fprintf (stderr,
- "Failed to run taler-exchange-dbinit. Check your PATH.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to run taler-exchange-dbinit. Check your PATH.\n");
return 77;
}
GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc);
- exchanged = GNUNET_OS_start_process (GNUNET_NO,
- GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-exchange-httpd",
- "taler-exchange-httpd",
- "-c", "test_merchant_api.conf",
- NULL);
- if (NULL == exchanged)
+ if (NULL == (exchanged = GNUNET_OS_start_process
+ (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-exchange-httpd",
+ "taler-exchange-httpd",
+ "-c", "test_merchant_api.conf",
+ NULL)))
{
- fprintf (stderr,
- "Failed to run taler-exchange-httpd. Check your PATH.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to run taler-exchange-httpd. Check your PATH.\n");
return 77;
}
/* give child time to start and bind against the socket */
- fprintf (stderr,
- "Waiting for taler-exchange-httpd to be ready\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Waiting for taler-exchange-httpd to be ready\n");
cnt = 0;
do
{
@@ -2919,8 +2822,8 @@ main (int argc,
cnt++;
if (cnt > 60)
{
- fprintf (stderr,
- "\nFailed to start taler-exchange-httpd\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "\nFailed to start taler-exchange-httpd\n");
GNUNET_OS_process_kill (exchanged,
SIGKILL);
GNUNET_OS_process_wait (exchanged);
@@ -2930,18 +2833,18 @@ main (int argc,
}
while (0 != system ("wget -q -t 1 -T 1 " EXCHANGE_URI "keys -o /dev/null -O
/dev/null"));
fprintf (stderr, "\n");
- merchantd = GNUNET_OS_start_process (GNUNET_NO,
- GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-merchant-httpd",
- "taler-merchant-httpd",
- "-c", "test_merchant_api.conf",
- "-L", "DEBUG",
- NULL);
- if (NULL == merchantd)
+ if (NULL == (merchantd = GNUNET_OS_start_process
+ (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-merchant-httpd",
+ "taler-merchant-httpd",
+ "-c", "test_merchant_api.conf",
+ "-L", "DEBUG",
+ NULL)))
{
- fprintf (stderr,
- "Failed to run taler-merchant-httpd. Check your PATH.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to run taler-merchant-httpd. Check your PATH.\n");
GNUNET_OS_process_kill (exchanged,
SIGKILL);
GNUNET_OS_process_wait (exchanged);
@@ -2949,8 +2852,8 @@ main (int argc,
return 77;
}
/* give child time to start and bind against the socket */
- fprintf (stderr,
- "Waiting for taler-merchant-httpd to be ready\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Waiting for taler-merchant-httpd to be ready\n");
cnt = 0;
do
{
@@ -2959,8 +2862,8 @@ main (int argc,
cnt++;
if (cnt > 60)
{
- fprintf (stderr,
- "\nFailed to start taler-merchant-httpd\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "\nFailed to start taler-merchant-httpd\n");
GNUNET_OS_process_kill (merchantd,
SIGKILL);
GNUNET_OS_process_wait (merchantd);
@@ -2976,23 +2879,24 @@ main (int argc,
fprintf (stderr, "\n");
result = GNUNET_SYSERR;
- sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO);
- GNUNET_assert (NULL != sigpipe);
- shc_chld = GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD,
- &sighandler_child_death);
+ GNUNET_assert (NULL != (sigpipe = GNUNET_DISK_pipe
+ (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO)));
+ shc_chld = GNUNET_SIGNAL_handler_install
+ (GNUNET_SIGCHLD,
+ &sighandler_child_death);
GNUNET_SCHEDULER_run (&run, NULL);
GNUNET_SIGNAL_handler_uninstall (shc_chld);
shc_chld = NULL;
GNUNET_DISK_pipe_close (sigpipe);
GNUNET_OS_process_kill (merchantd,
- SIGTERM);
+ SIGTERM);
GNUNET_OS_process_wait (merchantd);
GNUNET_OS_process_destroy (merchantd);
GNUNET_OS_process_kill (exchanged,
- SIGTERM);
+ SIGTERM);
GNUNET_OS_process_wait (exchanged);
GNUNET_OS_process_destroy (exchanged);
if (77 == result)
-return 77;
+ return 77;
return (GNUNET_OK == result) ? 0 : 1;
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-merchant] branch master updated (73e2e5a -> 71e9b21),
gnunet <=