diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-06-18 13:47:32 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-06-18 14:19:12 +0200 |
commit | 0159d1a0e89e918bc60849b8742642ede72cf02d (patch) | |
tree | f10c832d2e53b7f0d8c177be0680177a8c4a4b17 | |
parent | 64d9a74739c8a2b8da5b21fcce69a85dbb81923f (diff) |
fix misc style bugs and one real one
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 19 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 4 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_proposal.c | 35 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_tip-query.c | 3 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transaction.c | 3 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transfer.c | 2 | ||||
-rw-r--r-- | src/lib/merchant_api_tip_pickup.c | 4 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_history.c | 48 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_pay.c | 96 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_proposal.c | 14 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_refund.c | 14 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_tip.c | 45 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_track.c | 4 |
13 files changed, 150 insertions, 141 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 50b80cd6..a1397ed3 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -224,6 +224,9 @@ url_handler (void *cls, { "/", MHD_HTTP_METHOD_GET, "text/plain", "Hello, I'm a merchant's Taler backend. This HTTP server is not for humans.\n", 0, &TMH_MHD_handler_static_response, MHD_HTTP_OK }, + { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", + NULL, 0, + &TMH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, { "/public/pay", MHD_HTTP_METHOD_POST, "application/json", NULL, 0, &MH_handler_pay, MHD_HTTP_OK }, @@ -693,7 +696,7 @@ wireformat_iterator_cb (void *cls, struct TALER_WIRE_Plugin *plugin; json_t *j; enum TALER_ErrorCode ec; - struct GNUNET_HashCode h_wire; + struct GNUNET_HashCode jh_wire; char *wire_file_mode; if (0 != strncasecmp (section, @@ -893,7 +896,7 @@ wireformat_iterator_cb (void *cls, if (GNUNET_OK != TALER_JSON_merchant_wire_signature_hash (j, - &h_wire)) + &jh_wire)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to hash wire input\n"); @@ -925,7 +928,7 @@ wireformat_iterator_cb (void *cls, wm); wm->j_wire = j; - wm->h_wire = h_wire; + wm->h_wire = jh_wire; } @@ -993,7 +996,7 @@ instances_iterator_cb (void *cls, &mi->tip_exchange)) { char *tip_reserves; - struct GNUNET_CRYPTO_EddsaPrivateKey *pk; + struct GNUNET_CRYPTO_EddsaPrivateKey *tip_pk; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (iic->config, @@ -1010,8 +1013,8 @@ instances_iterator_cb (void *cls, iic->ret = GNUNET_SYSERR; return; } - pk = GNUNET_CRYPTO_eddsa_key_create_from_file (tip_reserves); - if (NULL == pk) + tip_pk = GNUNET_CRYPTO_eddsa_key_create_from_file (tip_reserves); + if (NULL == tip_pk) { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, section, @@ -1024,8 +1027,8 @@ instances_iterator_cb (void *cls, iic->ret = GNUNET_SYSERR; return; } - mi->tip_reserve.eddsa_priv = *pk; - GNUNET_free (pk); + mi->tip_reserve.eddsa_priv = *tip_pk; + GNUNET_free (tip_pk); GNUNET_free (tip_reserves); } diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c index 2764a0c5..227497f2 100644 --- a/src/backend/taler-merchant-httpd_pay.c +++ b/src/backend/taler-merchant-httpd_pay.c @@ -1657,7 +1657,7 @@ parse_pay (struct MHD_Connection *connection, { struct DepositConfirmation *dc = &pc->dc[coins_index]; const char *exchange_url; - struct GNUNET_JSON_Specification spec[] = { + struct GNUNET_JSON_Specification ispec[] = { TALER_JSON_spec_denomination_public_key ("denom_pub", &dc->denom), TALER_JSON_spec_amount ("contribution", @@ -1675,7 +1675,7 @@ parse_pay (struct MHD_Connection *connection, res = TMH_PARSE_json_data (connection, coin, - spec); + ispec); if (GNUNET_YES != res) { GNUNET_JSON_parse_free (spec); diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c index a65bf46c..31a0b29d 100644 --- a/src/backend/taler-merchant-httpd_proposal.c +++ b/src/backend/taler-merchant-httpd_proposal.c @@ -63,7 +63,6 @@ check_products (json_t *products) { size_t index; json_t *value; - int res; if (! json_is_array (products)) { @@ -74,6 +73,7 @@ check_products (json_t *products) const char *description; const char *error_name; unsigned int error_line; + int res; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("description", &description), /* FIXME: there are other fields in the product specification @@ -322,9 +322,9 @@ proposal_put (struct MHD_Connection *connection, /* The frontend either fully specifieds the "merchant" field, * or just gives the backend the "instance" name and lets it * fill out. */ - struct MerchantInstance *mi = TMH_lookup_instance (instance); + struct MerchantInstance *my_mi = TMH_lookup_instance (instance); - if (NULL == mi) + if (NULL == my_mi) { TALER_LOG_WARNING ("Does 'default' instance exist?\n"); return TMH_RESPONSE_reply_not_found @@ -344,29 +344,27 @@ proposal_put (struct MHD_Connection *connection, const char *mj = NULL; const char *ma = NULL; json_t *locations; - json_t *locj; - json_t *loca; - json_t *merchant; char *label; + json_t *jmerchant; - merchant = json_object (); - json_object_set_new (merchant, + jmerchant = json_object (); + json_object_set_new (jmerchant, "name", - json_string (mi->name)); - json_object_set_new (merchant, + json_string (my_mi->name)); + json_object_set_new (jmerchant, "instance", json_string (instance)); - json_object_set_new (order, - "merchant", - merchant); locations = json_object_get (order, "locations"); if (NULL != locations) { + json_t *loca; + json_t *locj; + /* Handle merchant address */ GNUNET_assert (0 < GNUNET_asprintf (&label, "%s-address", - mi->id)); + my_mi->id)); loca = json_object_get (default_locations, label); if (NULL != loca) @@ -376,7 +374,7 @@ proposal_put (struct MHD_Connection *connection, json_object_set_new (locations, ma, loca); - json_object_set_new (merchant, + json_object_set_new (jmerchant, "address", json_string (ma)); } @@ -385,7 +383,7 @@ proposal_put (struct MHD_Connection *connection, /* Handle merchant jurisdiction */ GNUNET_assert (0 < GNUNET_asprintf (&label, "%s-jurisdiction", - mi->id)); + my_mi->id)); locj = json_object_get (default_locations, label); if (NULL != locj) @@ -411,8 +409,11 @@ proposal_put (struct MHD_Connection *connection, } GNUNET_free (label); } /* have locations */ + json_object_set_new (order, + "merchant", + jmerchant); } /* needed to synthesize merchant info */ - } /* scope of 'mi' */ + } /* scope of 'my_mi' */ /* extract fields we need to sign separately */ res = TMH_PARSE_json_data (connection, diff --git a/src/backend/taler-merchant-httpd_tip-query.c b/src/backend/taler-merchant-httpd_tip-query.c index b63f3d2f..2b90b795 100644 --- a/src/backend/taler-merchant-httpd_tip-query.c +++ b/src/backend/taler-merchant-httpd_tip-query.c @@ -136,7 +136,6 @@ MH_handler_tip_query (struct TMH_RequestHandler *rh, size_t *upload_data_size) { struct TipQueryContext *tqc; - int res; struct MerchantInstance *mi; if (NULL == *connection_cls) @@ -153,6 +152,8 @@ MH_handler_tip_query (struct TMH_RequestHandler *rh, if (0 != tqc->ctr.response_code) { + int res; + /* We are *done* processing the request, just queue the response (!) */ if (UINT_MAX == tqc->ctr.response_code) { diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c index b4b361d4..14ac127a 100644 --- a/src/backend/taler-merchant-httpd_track-transaction.c +++ b/src/backend/taler-merchant-httpd_track-transaction.c @@ -1049,7 +1049,6 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, struct TrackTransactionContext *tctx; const char *order_id; const char *instance; - int ret; enum GNUNET_DB_QueryStatus qs; struct GNUNET_HashCode h_instance; struct json_t *contract_terms; @@ -1070,6 +1069,8 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, if (0 != tctx->response_code) { + int ret; + /* We are *done* processing the request, just queue the response (!) */ if (UINT_MAX == tctx->response_code) { diff --git a/src/backend/taler-merchant-httpd_track-transfer.c b/src/backend/taler-merchant-httpd_track-transfer.c index 80a22da5..54810037 100644 --- a/src/backend/taler-merchant-httpd_track-transfer.c +++ b/src/backend/taler-merchant-httpd_track-transfer.c @@ -728,7 +728,7 @@ wire_transfer_cb (void *cls, } /* Response is consistent with the /deposit we made, remember it for future reference */ - for (unsigned int i=0;i<MAX_RETRIES;i++) + for (unsigned int r=0;r<MAX_RETRIES;r++) { db->preflight (db->cls); qs = db->store_coin_to_transfer (db->cls, diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c index d3d0f669..63b0e59d 100644 --- a/src/lib/merchant_api_tip_pickup.c +++ b/src/lib/merchant_api_tip_pickup.c @@ -118,14 +118,14 @@ check_ok (struct TALER_MERCHANT_TipPickupOperation *tpo, { json_t *pj = json_array_get (ja, i); - struct GNUNET_JSON_Specification spec[] = { + struct GNUNET_JSON_Specification ispec[] = { GNUNET_JSON_spec_fixed_auto ("reserve_sig", &reserve_sigs[i]), GNUNET_JSON_spec_end() }; if (GNUNET_OK != GNUNET_JSON_parse (pj, - spec, + ispec, NULL, NULL)) { GNUNET_break_op (0); diff --git a/src/lib/testing_api_cmd_history.c b/src/lib/testing_api_cmd_history.c index 2c60af7e..68c1e257 100644 --- a/src/lib/testing_api_cmd_history.c +++ b/src/lib/testing_api_cmd_history.c @@ -160,7 +160,6 @@ history_cb (void *cls, enum TALER_ErrorCode ec, const json_t *json) { - struct HistoryState *hs = cls; unsigned int nresult; struct GNUNET_TIME_Absolute last_timestamp; @@ -176,7 +175,7 @@ history_cb (void *cls, { /* 0 was caused intentionally by the tests, * move on without further checking. */ - TALER_TESTING_interpreter_next (hs->is); + TALER_TESTING_interpreter_next (hs->is); return; } @@ -192,32 +191,34 @@ history_cb (void *cls, } last_timestamp = GNUNET_TIME_absolute_get (); - last_timestamp = GNUNET_TIME_absolute_add - (last_timestamp, GNUNET_TIME_UNIT_DAYS); - json_t *entry; - json_t *timestamp; - size_t index; - json_array_foreach (json, index, entry) + last_timestamp = GNUNET_TIME_absolute_add (last_timestamp, + GNUNET_TIME_UNIT_DAYS); { - timestamp = json_object_get (entry, "timestamp"); - if (GNUNET_OK != parse_abs_time (timestamp, &entry_timestamp)) - TALER_TESTING_FAIL (hs->is); - - if (last_timestamp.abs_value_us < entry_timestamp.abs_value_us) + json_t *entry; + size_t index; + json_array_foreach (json, index, entry) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "History entries are NOT" - " sorted from younger to older\n"); - TALER_TESTING_interpreter_fail (hs->is); - return; + json_t *timestamp; + + timestamp = json_object_get (entry, "timestamp"); + if (GNUNET_OK != parse_abs_time (timestamp, &entry_timestamp)) + TALER_TESTING_FAIL (hs->is); + + if (last_timestamp.abs_value_us < entry_timestamp.abs_value_us) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "History entries are NOT" + " sorted from younger to older\n"); + TALER_TESTING_interpreter_fail (hs->is); + return; + } + last_timestamp = entry_timestamp; } - - last_timestamp = entry_timestamp; } - TALER_TESTING_interpreter_next (hs->is); } + /** * Free the state for a "history" CMD, and possibly cancel * any pending operation thereof. @@ -240,6 +241,7 @@ history_cleanup (void *cls, GNUNET_free (hs); } + /** * Run a "history" CMD. * @@ -253,7 +255,7 @@ history_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct HistoryState *hs = cls; - + hs->is = is; if (0 == hs->time.abs_value_us) { @@ -341,7 +343,7 @@ cmd_history2 (const char *label, .run = &history_run, .cleanup = &history_cleanup }; - + return cmd; } diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c index 15e0adac..b3a0e18d 100644 --- a/src/lib/testing_api_cmd_pay.c +++ b/src/lib/testing_api_cmd_pay.c @@ -138,7 +138,7 @@ struct CheckPaymentState */ struct PayAgainState { - + /** * Expected HTTP response code. */ @@ -298,7 +298,7 @@ check_payment_cleanup (void *cls, "Command `%s' was not terminated\n", TALER_TESTING_interpreter_get_current_label ( cps->is)); - TALER_MERCHANT_check_payment_cancel (cps->cpo); + TALER_MERCHANT_check_payment_cancel (cps->cpo); } GNUNET_free (cps); } @@ -394,7 +394,7 @@ check_payment_run (void *cls, check_payment_cb, cps); - GNUNET_assert (NULL != cps->cpo); + GNUNET_assert (NULL != cps->cpo); } /** @@ -484,8 +484,8 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc, "%u", &ci)) { - GNUNET_break (0); - return GNUNET_SYSERR; + GNUNET_break (0); + return GNUNET_SYSERR; } } @@ -499,38 +499,39 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc, } GNUNET_array_grow (*pc, - *npc, - (*npc) + 1); - - icoin = &(*pc)[(*npc)-1]; - - const struct TALER_CoinSpendPrivateKeyP *coin_priv; - const struct TALER_DenominationSignature *denom_sig; - const struct TALER_Amount *denom_value; - const struct TALER_EXCHANGE_DenomPublicKey *denom_pub; + *npc, + (*npc) + 1); - GNUNET_assert - (GNUNET_OK == TALER_TESTING_get_trait_coin_priv - (coin_cmd, 0, &coin_priv)); - - GNUNET_assert - (GNUNET_OK == TALER_TESTING_get_trait_denom_pub - (coin_cmd, 0, &denom_pub)); + icoin = &((*pc)[(*npc)-1]); - GNUNET_assert - (GNUNET_OK == TALER_TESTING_get_trait_denom_sig - (coin_cmd, 0, &denom_sig)); - - GNUNET_assert - (GNUNET_OK == TALER_TESTING_get_trait_amount_obj - (coin_cmd, 0, &denom_value)); - - icoin->coin_priv = *coin_priv; - icoin->denom_pub = denom_pub->key; - icoin->denom_sig = *denom_sig; - icoin->denom_value = *denom_value; - icoin->amount_with_fee = *denom_value; - + { + const struct TALER_CoinSpendPrivateKeyP *coin_priv; + const struct TALER_DenominationSignature *denom_sig; + const struct TALER_Amount *denom_value; + const struct TALER_EXCHANGE_DenomPublicKey *denom_pub; + + GNUNET_assert + (GNUNET_OK == TALER_TESTING_get_trait_coin_priv + (coin_cmd, 0, &coin_priv)); + + GNUNET_assert + (GNUNET_OK == TALER_TESTING_get_trait_denom_pub + (coin_cmd, 0, &denom_pub)); + + GNUNET_assert + (GNUNET_OK == TALER_TESTING_get_trait_denom_sig + (coin_cmd, 0, &denom_sig)); + + GNUNET_assert + (GNUNET_OK == TALER_TESTING_get_trait_amount_obj + (coin_cmd, 0, &denom_value)); + + icoin->coin_priv = *coin_priv; + icoin->denom_pub = denom_pub->key; + icoin->denom_sig = *denom_sig; + icoin->denom_value = *denom_value; + icoin->amount_with_fee = *denom_value; + } GNUNET_assert (NULL != (dpk = TALER_TESTING_find_pk (is->keys, &icoin->denom_value))); @@ -541,11 +542,12 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc, GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_url - (coin_cmd, 0, &icoin->exchange_url)); + (coin_cmd, 0, &icoin->exchange_url)); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (refund_fee, &icoin->refund_fee)); + } return GNUNET_OK; @@ -577,7 +579,6 @@ pay_cb (void *cls, const char *error_name; unsigned int error_line; const struct GNUNET_CRYPTO_EddsaPublicKey *merchant_pub; - const struct TALER_TESTING_Command *proposal_cmd; ps->po = NULL; if (ps->http_status != http_status) @@ -601,6 +602,7 @@ pay_cb (void *cls, &ps->h_contract_terms), GNUNET_JSON_spec_end () }; + const struct TALER_TESTING_Command *proposal_cmd; GNUNET_assert (GNUNET_OK == GNUNET_JSON_parse ( obj, spec, @@ -890,7 +892,7 @@ pay_run (void *cls, { struct PayState *ps = cls; - + ps->is = is; if (NULL == (ps->po = _pay_run (ps->merchant_url, ps->coin_reference, @@ -1087,7 +1089,7 @@ pay_abort_run (void *cls, const struct TALER_TESTING_Command *cmd, struct TALER_TESTING_Interpreter *is) { - + struct PayAbortState *pas = cls; const struct TALER_TESTING_Command *pay_cmd; @@ -1096,13 +1098,13 @@ pay_abort_run (void *cls, const char *amount_with_fee; const char *amount_without_fee; const char *refund_fee; - + pas->is = is; pay_cmd = TALER_TESTING_interpreter_lookup_command (is, pas->pay_reference); if (NULL == pay_cmd) TALER_TESTING_FAIL (is); - + if (GNUNET_OK != TALER_TESTING_get_trait_proposal_reference (pay_cmd, 0, &proposal_reference)) TALER_TESTING_FAIL (is); @@ -1202,7 +1204,7 @@ TALER_TESTING_cmd_pay_abort (const char *label, .cleanup = &pay_abort_cleanup, .traits = &pay_abort_traits }; - + return cmd; } @@ -1307,13 +1309,13 @@ pay_again_run (void *cls, const char *proposal_reference; const char *amount_with_fee; const char *amount_without_fee; - + pas->is = is; pay_cmd = TALER_TESTING_interpreter_lookup_command (is, pas->pay_reference); if (NULL == pay_cmd) TALER_TESTING_FAIL (is); - + if (GNUNET_OK != TALER_TESTING_get_trait_proposal_reference (pay_cmd, 0, &proposal_reference)) TALER_TESTING_FAIL (is); @@ -1401,7 +1403,7 @@ TALER_TESTING_cmd_pay_again (const char *label, .run = &pay_again_run, .cleanup = &pay_again_cleanup }; - + return cmd; } @@ -1515,9 +1517,9 @@ pay_abort_refund_run (void *cls, (abort_cmd, 0, &refund_entry)) TALER_TESTING_FAIL (is); - GNUNET_assert (GNUNET_OK == TALER_string_to_amount + GNUNET_assert (GNUNET_OK == TALER_string_to_amount (pars->refund_amount, &refund_amount)); - GNUNET_assert (GNUNET_OK == TALER_string_to_amount + GNUNET_assert (GNUNET_OK == TALER_string_to_amount (pars->refund_fee, &refund_fee)); pars->rh = TALER_EXCHANGE_refund2 diff --git a/src/lib/testing_api_cmd_proposal.c b/src/lib/testing_api_cmd_proposal.c index bceecc17..71a02061 100644 --- a/src/lib/testing_api_cmd_proposal.c +++ b/src/lib/testing_api_cmd_proposal.c @@ -176,12 +176,11 @@ proposal_traits (void *cls, MAKE_TRAIT_NONCE (&ps->nonce), TALER_TESTING_trait_end () }; - + return TALER_TESTING_get_trait (traits, ret, trait, index); - return GNUNET_SYSERR; } @@ -350,7 +349,7 @@ proposal_run (void *cls, // human error here. GNUNET_break (0); fprintf (stderr, "%s\n", error.text); - TALER_TESTING_interpreter_fail (is); + TALER_TESTING_interpreter_fail (is); return; } @@ -360,7 +359,7 @@ proposal_run (void *cls, struct GNUNET_TIME_Absolute now; char *order_id; - now = GNUNET_TIME_absolute_get (); + now = GNUNET_TIME_absolute_get (); order_id = GNUNET_STRINGS_data_to_string_alloc (&now.abs_value_us, @@ -541,7 +540,6 @@ proposal_lookup_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct ProposalLookupState *pls = cls; - const struct TALER_TESTING_Command *proposal_cmd; const char *order_id; const struct GNUNET_CRYPTO_EddsaPublicKey *nonce; /* Only used if we do NOT use the nonce from traits. */ @@ -561,6 +559,8 @@ proposal_lookup_run (void *cls, } else { + const struct TALER_TESTING_Command *proposal_cmd; + proposal_cmd = TALER_TESTING_interpreter_lookup_command (is, pls->proposal_reference); @@ -569,7 +569,7 @@ proposal_lookup_run (void *cls, if (GNUNET_OK != GET_TRAIT_NONCE (proposal_cmd, &nonce)) - TALER_TESTING_FAIL (is); + TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_order_id (proposal_cmd, 0, &order_id)) @@ -607,7 +607,7 @@ TALER_TESTING_cmd_proposal_lookup const char *order_id) { struct ProposalLookupState *pls; - + pls = GNUNET_new (struct ProposalLookupState); pls->http_status = http_status; pls->proposal_reference = proposal_reference; diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c index c8b825a6..bc96175a 100644 --- a/src/lib/testing_api_cmd_refund.c +++ b/src/lib/testing_api_cmd_refund.c @@ -275,7 +275,6 @@ refund_lookup_cb (void *cls, char *coin_reference_dup; const char *icoin_reference; const struct TALER_TESTING_Command *pay_cmd; - const struct TALER_TESTING_Command *icoin_cmd; const struct TALER_TESTING_Command *increase_cmd; const char *refund_amount; struct TALER_Amount acc; @@ -344,6 +343,7 @@ refund_lookup_cb (void *cls, struct TALER_CoinSpendPublicKeyP icoin_pub; struct GNUNET_HashCode h_icoin_pub; struct TALER_Amount *iamount; + const struct TALER_TESTING_Command *icoin_cmd; if ( NULL == ( icoin_cmd = TALER_TESTING_interpreter_lookup_command @@ -351,7 +351,7 @@ refund_lookup_cb (void *cls, { GNUNET_break (0); TALER_LOG_ERROR ("Bad reference `%s'\n", - icoin_reference); + icoin_reference); TALER_TESTING_interpreter_fail (rls->is); return; } @@ -362,11 +362,11 @@ refund_lookup_cb (void *cls, GNUNET_break (0); TALER_LOG_ERROR ("Command `%s' failed to give coin" " priv trait\n", - icoin_reference); + icoin_reference); TALER_TESTING_interpreter_fail (rls->is); return; } - + GNUNET_CRYPTO_eddsa_key_get_public (&icoin_priv->eddsa_priv, &icoin_pub.eddsa_pub); GNUNET_CRYPTO_hash (&icoin_pub, @@ -386,7 +386,7 @@ refund_lookup_cb (void *cls, } GNUNET_free (coin_reference_dup); - + if (NULL != (increase_cmd = TALER_TESTING_interpreter_lookup_command (rls->is, rls->increase_reference))) @@ -443,7 +443,7 @@ refund_lookup_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct RefundLookupState *rls = cls; - + rls->is = is; rls->rlo = TALER_MERCHANT_refund_lookup (is->ctx, rls->merchant_url, @@ -472,7 +472,7 @@ refund_increase_traits (void *cls, unsigned int index) { struct RefundIncreaseState *ris = cls; - + struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_amount (0, ris->refund_amount), TALER_TESTING_trait_end () diff --git a/src/lib/testing_api_cmd_tip.c b/src/lib/testing_api_cmd_tip.c index 44043670..cc51ff07 100644 --- a/src/lib/testing_api_cmd_tip.c +++ b/src/lib/testing_api_cmd_tip.c @@ -88,7 +88,7 @@ struct TipPickupState * How many coins are involved in the tipping operation. */ unsigned int num_coins; - + /** * The array of denomination keys, in the same order of @a * amounts. @@ -176,7 +176,7 @@ struct TipQueryState */ struct TipAuthorizeState { - + /** * Merchant base URL. */ @@ -255,7 +255,7 @@ tip_authorize_cb (void *cls, struct GNUNET_TIME_Absolute tip_expiration, const char *exchange_url) { - struct TipAuthorizeState *tas = cls; + struct TipAuthorizeState *tas = cls; tas->tao = NULL; if (tas->http_status != http_status) @@ -321,7 +321,6 @@ tip_authorize_traits (void *cls, unsigned int index) { struct TipAuthorizeState *tas = cls; - struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_tip_id (0, &tas->tip_id), TALER_TESTING_trait_end (), @@ -331,9 +330,9 @@ tip_authorize_traits (void *cls, ret, trait, index); - return GNUNET_SYSERR; } + /** * Runs the /tip-authorize CMD * @@ -347,7 +346,7 @@ tip_authorize_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct TipAuthorizeState *tas = cls; - struct TALER_Amount amount; + struct TALER_Amount amount; tas->is = is; if (GNUNET_OK != TALER_string_to_amount (tas->amount, @@ -461,7 +460,7 @@ TALER_TESTING_cmd_tip_authorize_with_ec .cleanup = &tip_authorize_cleanup, .traits = &tip_authorize_traits }; - + return cmd; } @@ -508,7 +507,7 @@ TALER_TESTING_cmd_tip_authorize (const char *label, .cleanup = &tip_authorize_cleanup, .traits = &tip_authorize_traits }; - + return cmd; } @@ -627,7 +626,7 @@ tip_query_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct TipQueryState *tqs = cls; - + tqs->is = is; tqs->tqo = TALER_MERCHANT_tip_query (is->ctx, tqs->merchant_url, @@ -681,7 +680,7 @@ TALER_TESTING_cmd_tip_query_with_amounts .run = &tip_query_run, .cleanup = &tip_query_cleanup }; - + return cmd; } @@ -715,7 +714,7 @@ TALER_TESTING_cmd_tip_query (const char *label, .run = &tip_query_run, .cleanup = &tip_query_cleanup }; - + return cmd; } @@ -740,7 +739,7 @@ struct WithdrawHandle */ unsigned int off; - + /** * Internal state of the "pickup" CMD. */ @@ -748,7 +747,7 @@ struct WithdrawHandle }; /** - * This callback handles the response of a withdraw operation + * This callback handles the response of a withdraw operation * from the exchange, that is the final step in getting the tip. * * @param cls closure, a `struct WithdrawHandle *` @@ -935,8 +934,8 @@ tip_pickup_run (void *cls, if ( NULL == /* looking for "parent" tip-pickup command */ ( replay_cmd = TALER_TESTING_interpreter_lookup_command (is, tps->replay_reference)) ) - TALER_TESTING_FAIL (is); - + TALER_TESTING_FAIL (is); + if (GNUNET_OK != TALER_TESTING_get_trait_uint (replay_cmd, 0, &np)) TALER_TESTING_FAIL (is); @@ -975,7 +974,7 @@ tip_pickup_run (void *cls, if (NULL == tps->dks[i]) TALER_TESTING_FAIL (is); - TALER_planchet_setup_random (&tps->psa[i]); + TALER_planchet_setup_random (&tps->psa[i]); } else { @@ -994,9 +993,9 @@ tip_pickup_run (void *cls, if (GNUNET_OK != TALER_planchet_prepare (&tps->dks[i]->key, &tps->psa[i], &planchets[i])) - TALER_TESTING_FAIL (is); + TALER_TESTING_FAIL (is); } - + if (GNUNET_OK != TALER_TESTING_get_trait_tip_id (authorize_cmd, 0, &tip_id)) TALER_TESTING_FAIL (is); @@ -1061,7 +1060,7 @@ tip_pickup_traits (void *cls, struct TipPickupState *tps = cls; #define NUM_TRAITS (tps->num_coins * 5) + 2 struct TALER_TESTING_Trait traits[NUM_TRAITS]; - + for (unsigned int i=0; i<tps->num_coins; i++) { traits[i] = TALER_TESTING_make_trait_planchet_secrets @@ -1090,9 +1089,9 @@ tip_pickup_traits (void *cls, ret, trait, index); - return GNUNET_SYSERR; } + /** * Define a /tip-pickup CMD, equipped with the expected error * code. @@ -1134,7 +1133,7 @@ TALER_TESTING_cmd_tip_pickup_with_ec .cleanup = &tip_pickup_cleanup, .traits = &tip_pickup_traits }; - + return cmd; } @@ -1173,7 +1172,7 @@ TALER_TESTING_cmd_tip_pickup .cleanup = &tip_pickup_cleanup, .traits = &tip_pickup_traits }; - + return cmd; } @@ -1201,7 +1200,7 @@ TALER_TESTING_cmd_tip_authorize_fake (const char *label) .cleanup = &tip_authorize_cleanup, .traits = &tip_authorize_traits }; - + return cmd; } diff --git a/src/lib/testing_api_cmd_track.c b/src/lib/testing_api_cmd_track.c index c6169c67..9cd4803b 100644 --- a/src/lib/testing_api_cmd_track.c +++ b/src/lib/testing_api_cmd_track.c @@ -137,8 +137,6 @@ track_transaction_cb (void *cls, const json_t *json) { struct TrackTransactionState *tts = cls; - json_t *wtid_str; - json_t *exchange_url; tts->tth = NULL; if (tts->http_status != http_status) @@ -160,6 +158,8 @@ track_transaction_cb (void *cls, /* Only storing first element's wtid, as this works around * the disability of the real bank to provide a "bank check" * CMD as the fakebank does. */ + json_t *wtid_str; + json_t *exchange_url; if (NULL == (wtid_str = json_object_get (json_array_get (json, 0), "wtid"))) |