diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-10-22 18:26:39 +0200 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-10-22 18:26:39 +0200 |
commit | 0f12281ca51a9d49ef59c35c89a4370e74b7931c (patch) | |
tree | 85e6828f3ab26d576c129471f30b692edc57f67a /src | |
parent | 4617cba31344f4650bfe40583c47cb91adc15fad (diff) | |
download | merchant-0f12281ca51a9d49ef59c35c89a4370e74b7931c.tar.gz merchant-0f12281ca51a9d49ef59c35c89a4370e74b7931c.tar.bz2 merchant-0f12281ca51a9d49ef59c35c89a4370e74b7931c.zip |
receiver->instance. test passed
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 24 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 4 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transaction.c | 20 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transfer.c | 12 | ||||
-rw-r--r-- | src/include/taler_merchant_service.h | 16 | ||||
-rw-r--r-- | src/lib/merchant_api_pay.c | 16 | ||||
-rw-r--r-- | src/lib/merchant_api_track_transaction.c | 8 | ||||
-rw-r--r-- | src/lib/merchant_api_track_transfer.c | 8 | ||||
-rw-r--r-- | src/lib/test_merchant_api.c | 42 | ||||
-rw-r--r-- | src/lib/test_merchant_api.conf | 6 |
10 files changed, 78 insertions, 78 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index b5b289da..b02436d1 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -575,19 +575,19 @@ instances_iterator_cb (void *cls, struct MerchantInstance * TMH_lookup_instance (const char *name) { - struct GNUNET_HashCode h_receiver; + struct GNUNET_HashCode h_instance; GNUNET_CRYPTO_hash (name, strlen (name), - &h_receiver); + &h_instance); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for by-id key %s of '%s' in hashmap\n", - GNUNET_h2s (&h_receiver), + GNUNET_h2s (&h_instance), name); /* We're fine if that returns NULL, the calling routine knows how to handle that */ return GNUNET_CONTAINER_multihashmap_get (by_id_map, - &h_receiver); + &h_instance); } @@ -596,10 +596,10 @@ TMH_lookup_instance (const char *name) * * @param json the JSON to inspect; it is not required to * comply with any particular format. It will only be checked - * if the field "receiver" is there. + * if the field "instance" is there. * @return a pointer to a #struct MerchantInstance. This will be * the 'default' merchant if the frontend did not specif any - * "receiver" field. The user should not care to free the returned + * "instance" field. The user should not care to free the returned * value, as it is taken from a global array that will be freed * by the general shutdown routine. NULL if the frontend specified * a wrong instance @@ -607,14 +607,14 @@ TMH_lookup_instance (const char *name) struct MerchantInstance * get_instance (struct json_t *json) { - struct json_t *receiver; - const char *receiver_str; + struct json_t *instance; + const char *instance_str; - if (NULL == (receiver = json_object_get (json, "receiver"))) - receiver_str = "default"; + if (NULL == (instance = json_object_get (json, "instance"))) + instance_str = "default"; else - receiver_str = json_string_value (receiver); - return TMH_lookup_instance (receiver_str); + instance_str = json_string_value (instance); + return TMH_lookup_instance (instance_str); } diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c index 7d94a91b..3feceb50 100644 --- a/src/backend/taler-merchant-httpd_pay.c +++ b/src/backend/taler-merchant-httpd_pay.c @@ -243,7 +243,7 @@ struct PayContext int transaction_exits; /** - * Instance of the payment's receiver (in JSON format) + * Instance of the payment's instance (in JSON format) */ struct MerchantInstance *mi; @@ -981,7 +981,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, "Unknown instance given"); } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "The receiver for this deposit is '%s', whose bank details are '%s'\n", + "The instance for this deposit is '%s', whose bank details are '%s'\n", pc->mi->id, json_dumps (pc->mi->j_wire, JSON_COMPACT)); diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c index a76ef56c..93d3d0be 100644 --- a/src/backend/taler-merchant-httpd_track-transaction.c +++ b/src/backend/taler-merchant-httpd_track-transaction.c @@ -831,9 +831,9 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, struct TrackTransactionContext *tctx; unsigned long long transaction_id; const char *str; - const char *receiver; + const char *instance; int ret; - struct GNUNET_HashCode h_receiver; + struct GNUNET_HashCode h_instance; if (NULL == *connection_cls) { @@ -885,16 +885,16 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, return TMH_RESPONSE_reply_arg_missing (connection, TALER_EC_PARAMETER_MISSING, "id"); - receiver = MHD_lookup_connection_value (connection, + instance = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, - "receiver" /* FIXME: rename to 'instance' */); - if (NULL == receiver) - receiver = "default"; - GNUNET_CRYPTO_hash (receiver, - strlen (receiver), - &h_receiver); + "instance" /* FIXME: rename to 'instance' */); + if (NULL == instance) + instance = "default"; + GNUNET_CRYPTO_hash (instance, + strlen (instance), + &h_instance); tctx->mi = GNUNET_CONTAINER_multihashmap_get (by_id_map, - &h_receiver); + &h_instance); if (NULL == tctx->mi) return TMH_RESPONSE_reply_not_found (connection, TALER_EC_TRACK_TRANSACTION_INSTANCE_UNKNOWN, diff --git a/src/backend/taler-merchant-httpd_track-transfer.c b/src/backend/taler-merchant-httpd_track-transfer.c index 1909092e..ec771fac 100644 --- a/src/backend/taler-merchant-httpd_track-transfer.c +++ b/src/backend/taler-merchant-httpd_track-transfer.c @@ -508,7 +508,7 @@ MH_handler_track_transfer (struct TMH_RequestHandler *rh, struct TrackTransferContext *rctx; const char *str; const char *uri; - const char *receiver_str; + const char *instance_str; int ret; if (NULL == *connection_cls) @@ -564,12 +564,12 @@ MH_handler_track_transfer (struct TMH_RequestHandler *rh, "exchange"); rctx->uri = GNUNET_strdup (uri); - receiver_str = MHD_lookup_connection_value (connection, + instance_str = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, - "receiver" /* FIXME: instance */); - if (NULL == receiver_str) - receiver_str = "default"; - rctx->mi = TMH_lookup_instance (receiver_str); + "instance" /* FIXME: instance */); + if (NULL == instance_str) + instance_str = "default"; + rctx->mi = TMH_lookup_instance (instance_str); if (NULL == rctx->mi) return TMH_RESPONSE_reply_not_found (connection, TALER_EC_TRACK_TRANSFER_INSTANCE_UNKNOWN, diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index b3b42c4b..eaf85caf 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -166,7 +166,7 @@ struct TALER_MERCHANT_PayCoin * * @param ctx execution context * @param merchant_uri base URI of the merchant - * @param receiver which merchant instance will receive this payment + * @param instance which merchant instance will receive this payment * @param h_wire hash of the merchant’s account details * @param h_contract hash of the contact of the merchant with the customer * @param transaction_id transaction id for the transaction between merchant and customer @@ -188,7 +188,7 @@ struct TALER_MERCHANT_PayCoin struct TALER_MERCHANT_Pay * TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, const char *merchant_uri, - const char *receiver, + const char *instance, const struct GNUNET_HashCode *h_contract, uint64_t transaction_id, const struct TALER_Amount *amount, @@ -258,7 +258,7 @@ struct TALER_MERCHANT_PaidCoin * * @param ctx execution context * @param merchant_uri base URI of the merchant - * @param receiver which merchant instance will receive this payment + * @param instance which merchant instance will receive this payment * @param h_contract hash of the contact of the merchant with the customer * @param amount total value of the contract to be paid to the merchant * @param max_fee maximum fee covered by the merchant (according to the contract) @@ -279,7 +279,7 @@ struct TALER_MERCHANT_PaidCoin struct TALER_MERCHANT_Pay * TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx, const char *merchant_uri, - const char *receiver, + const char *instance, const struct GNUNET_HashCode *h_contract, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, @@ -348,7 +348,7 @@ typedef void * * @param ctx execution context * @param backend_uri base URI of the backend - * @param receiver which merchant instance is going to be tracked + * @param instance which merchant instance is going to be tracked * @param wtid base32 string indicating a wtid * @param exchange base URL of the exchange in charge of returning the wanted information * @param track_transfer_cb the callback to call when a reply for this request is available @@ -358,7 +358,7 @@ typedef void struct TALER_MERCHANT_TrackTransferHandle * TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx, const char *backend_uri, - const char *receiver, + const char *instance, const struct TALER_WireTransferIdentifierRawP *wtid, const char *exchange_uri, TALER_MERCHANT_TrackTransferCallback track_transfer_cb, @@ -462,7 +462,7 @@ typedef void * * @param ctx execution context * @param backend_uri base URI of the backend - * @param receiver which merchant instance is going to be tracked + * @param instance which merchant instance is going to be tracked * @param transaction_id which transaction should we trace * @param track_transaction_cb the callback to call when a reply for this request is available * @param track_transaction_cb_cls closure for @a track_transaction_cb @@ -471,7 +471,7 @@ typedef void struct TALER_MERCHANT_TrackTransactionHandle * TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx, const char *backend_uri, - const char *receiver, + const char *instance, uint64_t transaction_id, TALER_MERCHANT_TrackTransactionCallback track_transaction_cb, void *track_transaction_cb_cls); diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c index 821534a7..0c06326a 100644 --- a/src/lib/merchant_api_pay.c +++ b/src/lib/merchant_api_pay.c @@ -252,7 +252,7 @@ handle_pay_finished (void *cls, * * @param ctx the execution loop context * @param merchant_uri base URI of the merchant's backend - * @param receiver which merchant instance will receive this payment + * @param instance which merchant instance will receive this payment * @param h_wire hash of the merchant’s account details * @param h_contract hash of the contact of the merchant with the customer * @param transaction_id transaction id for the transaction between merchant and customer @@ -278,7 +278,7 @@ handle_pay_finished (void *cls, struct TALER_MERCHANT_Pay * TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, const char *merchant_uri, - const char *receiver, + const char *instance, const struct GNUNET_HashCode *h_contract, uint64_t transaction_id, const struct TALER_Amount *amount, @@ -346,7 +346,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, } return TALER_MERCHANT_pay_frontend (ctx, merchant_uri, - receiver, + instance, h_contract, amount, max_fee, @@ -372,7 +372,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, * * @param ctx the execution loop context * @param merchant_uri base URI of the merchant's backend - * @param receiver which merchant instance will receive this payment + * @param instance which merchant instance will receive this payment * @param h_contract hash of the contact of the merchant with the customer * @param timestamp timestamp when the contract was finalized, must match approximately the current time of the merchant * @param transaction_id transaction id for the transaction between merchant and customer @@ -392,7 +392,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, struct TALER_MERCHANT_Pay * TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx, const char *merchant_uri, - const char *receiver, + const char *instance, const struct GNUNET_HashCode *h_contract, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, @@ -578,10 +578,10 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx, "max_fee", TALER_JSON_from_amount (max_fee), "amount", TALER_JSON_from_amount (amount), "merchant_sig", GNUNET_JSON_from_data_auto (merchant_sig)); - if (NULL != receiver) + if (NULL != instance) json_object_set_new (pay_obj, - "receiver", - json_string (receiver)); + "instance", + json_string (instance)); if (0 != wire_transfer_deadline.abs_value_us) { diff --git a/src/lib/merchant_api_track_transaction.c b/src/lib/merchant_api_track_transaction.c index c42b1128..4aed3c68 100644 --- a/src/lib/merchant_api_track_transaction.c +++ b/src/lib/merchant_api_track_transaction.c @@ -232,7 +232,7 @@ handle_track_transaction_finished (void *cls, * * @param ctx execution context * @param backend_uri base URI of the backend - * @param receiver which merchant instance is going to be tracked + * @param instance which merchant instance is going to be tracked * @param transaction_id which transaction should we trace * @param track_transaction_cb the callback to call when a reply for this request is available * @param track_transaction_cb_cls closure for @a track_transaction_cb @@ -241,7 +241,7 @@ handle_track_transaction_finished (void *cls, struct TALER_MERCHANT_TrackTransactionHandle * TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx, const char *backend_uri, - const char *receiver, + const char *instance, uint64_t transaction_id, TALER_MERCHANT_TrackTransactionCallback track_transaction_cb, void *track_transaction_cb_cls) @@ -254,10 +254,10 @@ TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx, tdo->cb = track_transaction_cb; tdo->cb_cls = track_transaction_cb_cls; GNUNET_asprintf (&tdo->url, - "%s/track/transaction?id=%llu&receiver=%s", + "%s/track/transaction?id=%llu&instance=%s", backend_uri, (unsigned long long) transaction_id, - receiver); + instance); eh = curl_easy_init (); GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, diff --git a/src/lib/merchant_api_track_transfer.c b/src/lib/merchant_api_track_transfer.c index 0c1b3af9..e7a1fdc3 100644 --- a/src/lib/merchant_api_track_transfer.c +++ b/src/lib/merchant_api_track_transfer.c @@ -215,7 +215,7 @@ handle_track_transfer_finished (void *cls, * * @param ctx execution context * @param backend_uri base URI of the backend - * @param receiver which merchant instance is going to be tracked + * @param instance which merchant instance is going to be tracked * @param wtid base32 string indicating a wtid * @param exchange base URL of the exchange in charge of returning the wanted information * @param track_transfer_cb the callback to call when a reply for this request is available @@ -225,7 +225,7 @@ handle_track_transfer_finished (void *cls, struct TALER_MERCHANT_TrackTransferHandle * TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx, const char *backend_uri, - const char *receiver, + const char *instance, const struct TALER_WireTransferIdentifierRawP *wtid, const char *exchange_uri, TALER_MERCHANT_TrackTransferCallback track_transfer_cb, @@ -243,11 +243,11 @@ TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx, tdo->cb_cls = track_transfer_cb_cls; /* TODO: do we need to escape 'exchange_uri' here? */ GNUNET_asprintf (&tdo->url, - "%s/track/transfer?wtid=%s&exchange=%s&receiver=%s", + "%s/track/transfer?wtid=%s&exchange=%s&instance=%s", backend_uri, wtid_str, exchange_uri, - receiver); + instance); GNUNET_free (wtid_str); eh = curl_easy_init (); GNUNET_assert (CURLE_OK == diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c index b81678a4..26d52bd0 100644 --- a/src/lib/test_merchant_api.c +++ b/src/lib/test_merchant_api.c @@ -66,24 +66,24 @@ static struct TALER_EXCHANGE_Handle *exchange; static struct GNUNET_CURL_Context *ctx; /** - * Array of receivers to test against + * Array of instances to test against */ static char **instances; /** * How many merchant instances this test runs */ -unsigned int nreceiver = 0; +unsigned int ninstances = 0; /** - * Current receiver + * Current instance */ -static char *receiver; +static char *instance; /** - * Current receiver being tested + * Current instance being tested */ -unsigned int receiver_idx = 0; +unsigned int instance_idx = 0; /** * Task run on timeout. @@ -648,7 +648,7 @@ get_new_contracts (struct Command *cmds) \"products\":\ [ {\"description\":\"ice cream\", \"value\":\"{EUR:5}\"} ]\ }", - receiver_idx + d); + instance_idx + d); } } @@ -763,7 +763,7 @@ history_cb (void *cls, return; } nelements = json_array_size (json); - if (nelements != (cmd->details.history.nresult * (receiver_idx + 1))) + if (nelements != (cmd->details.history.nresult * (instance_idx + 1))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get as many history entries as expected\n"); @@ -1461,17 +1461,17 @@ interpreter_run (void *cls) { case OC_END: result = GNUNET_OK; - if (receiver_idx + 1 == nreceiver) + if (instance_idx + 1 == ninstances) { GNUNET_SCHEDULER_shutdown (); return; } is->ip = 0; - receiver_idx++; - receiver = instances[receiver_idx]; + instance_idx++; + instance = instances[instance_idx]; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Switching instance: '%s'\n", - receiver); + instance); /*get_new_contracts(is->commands);*/ is->task = GNUNET_SCHEDULER_add_now (interpreter_run, is); @@ -1640,10 +1640,10 @@ interpreter_run (void *cls) proposal = json_loads (cmd->details.contract.proposal, JSON_REJECT_DUPLICATES, &error); - if (NULL != receiver) + if (NULL != instance) json_object_set_new (proposal, - "receiver", - json_string (receiver)); + "instance", + json_string (instance)); if (NULL == proposal) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1773,7 +1773,7 @@ interpreter_run (void *cls) cmd->details.pay.ph = TALER_MERCHANT_pay_wallet (ctx, MERCHANT_URI, - receiver, + instance, &h_contract, transaction_id, &total_amount, @@ -1870,7 +1870,7 @@ interpreter_run (void *cls) cmd->details.track_transfer.tdo = TALER_MERCHANT_track_transfer (ctx, MERCHANT_URI, - receiver, + instance, &ref->details.check_bank_transfer.wtid, EXCHANGE_URI, &track_transfer_cb, @@ -1884,7 +1884,7 @@ interpreter_run (void *cls) cmd->details.track_transaction.tth = TALER_MERCHANT_track_transaction (ctx, MERCHANT_URI, - receiver, /* got it NULL, right now */ + instance, /* got it NULL, right now */ ref->details.pay.transaction_id, &track_transaction_cb, is); @@ -2454,12 +2454,12 @@ main (int argc, "INSTANCES", &_instances)); GNUNET_break (NULL != (token = strtok (_instances, " "))); - GNUNET_array_append (instances, nreceiver, token); + GNUNET_array_append (instances, ninstances, token); while (NULL != (token = strtok (NULL, " "))) - GNUNET_array_append(instances, nreceiver, token); + GNUNET_array_append(instances, ninstances, token); - receiver = instances[receiver_idx]; + instance = instances[instance_idx]; db = TALER_MERCHANTDB_plugin_load (cfg); if (NULL == db) { diff --git a/src/lib/test_merchant_api.conf b/src/lib/test_merchant_api.conf index 80f49b3d..c05530f0 100644 --- a/src/lib/test_merchant_api.conf +++ b/src/lib/test_merchant_api.conf @@ -33,9 +33,9 @@ DB = postgres # Which wireformat do we use? WIREFORMAT = test -# This option is a list of receivers which are to be used -# during the tests. 'default' receiver should explicitly be given. -# The receiver "token" X must match the corresponding substring in +# This option is a list of instances which are to be used +# during the tests. 'default' instance should explicitly be given. +# The instance "token" X must match the corresponding substring in # section like X-wireformat and merchant-instance-X INSTANCES = tor default |