From 46aa711262566b7a8f358cbe684c64ed526a5edb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 25 Apr 2020 22:32:36 +0200 Subject: misc bugfixes --- .../taler-merchant-httpd_private-get-products-ID.c | 13 +++--- ...aler-merchant-httpd_private-patch-products-ID.c | 26 +++++------ .../taler-merchant-httpd_private-post-products.c | 14 +++--- src/backenddb/merchant-0001.sql | 4 +- src/backenddb/plugin_merchantdb_postgres.c | 22 ++++------ src/include/taler_merchant_service.h | 14 +++--- src/include/taler_merchant_testing_lib.h | 10 ++--- src/include/taler_merchantdb_plugin.h | 2 +- src/lib/merchant_api_get_product.c | 50 +++++++++++++++------- src/lib/merchant_api_patch_product.c | 11 ++--- src/lib/merchant_api_post_products.c | 9 ++-- src/testing/test_merchant_api.c | 4 ++ src/testing/testing_api_cmd_get_product.c | 4 +- src/testing/testing_api_cmd_patch_product.c | 12 +++--- src/testing/testing_api_cmd_post_instances.c | 5 ++- src/testing/testing_api_cmd_post_products.c | 15 ++++--- 16 files changed, 121 insertions(+), 94 deletions(-) (limited to 'src') diff --git a/src/backend/taler-merchant-httpd_private-get-products-ID.c b/src/backend/taler-merchant-httpd_private-get-products-ID.c index 57b3182c..611de7e8 100644 --- a/src/backend/taler-merchant-httpd_private-get-products-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-products-ID.c @@ -57,9 +57,8 @@ TMH_private_get_products_ID (const struct TMH_RequestHandler *rh, json_t *reply; reply = json_pack ( - "{s:s, s:o, s:s, s:o, s:o," - " s:I, s:I, s:I, s:o, s:o," - " s:o}", + "{s:s, s:s, s:o, s:o, s:I," + " s:I, s:I, s:o, s:o, s:o}", "description", pd.description, "unit", @@ -68,11 +67,11 @@ TMH_private_get_products_ID (const struct TMH_RequestHandler *rh, TALER_JSON_from_amount (&pd.price), "taxes", pd.taxes, - /* end of first group of 5 */ - "total_stocked", - (UINT64_MAX == pd.total_stocked) + "total_stock", + (UINT64_MAX == pd.total_stock) ? (json_int_t) -1 - : (json_int_t) pd.total_stocked, + : (json_int_t) pd.total_stock, + /* end of first group of 5 */ "total_sold", (json_int_t) pd.total_sold, "total_lost", diff --git a/src/backend/taler-merchant-httpd_private-patch-products-ID.c b/src/backend/taler-merchant-httpd_private-patch-products-ID.c index 6ffc73fd..be7f52e7 100644 --- a/src/backend/taler-merchant-httpd_private-patch-products-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-products-ID.c @@ -86,16 +86,16 @@ determine_cause (struct MHD_Connection *connection, ec = TALER_EC_PRODUCTS_PATCH_TOTAL_LOST_REDUCED; hint = "total lost cannot be lowered"; } - if (pdx.total_sold > pd->total_sold) - { - ec = TALER_EC_PRODUCTS_PATCH_TOTAL_SOLD_REDUCED; - hint = "total sold cannot be lowered"; - } - if (pdx.total_stocked > pd->total_stocked) + if (pdx.total_stock > pd->total_stock) { ec = TALER_EC_PRODUCTS_PATCH_TOTAL_STOCKED_REDUCED; hint = "total stocked cannot be lowered"; } + if (pd->total_stock - pdx.total_sold > pd->total_lost) + { + ec = TALER_EC_PRODUCTS_PATCH_TOTAL_LOST_EXCEEDS_STOCKS; + hint = "total lost cannot exceed total stock minus total sold"; + } GNUNET_free (pdx.description); json_decref (pdx.description_i18n); GNUNET_free (pdx.unit); @@ -126,7 +126,7 @@ TMH_private_patch_products_ID (const struct TMH_RequestHandler *rh, struct TMH_MerchantInstance *mi = hc->instance; const char *product_id = hc->infix; struct TALER_MERCHANTDB_ProductDetails pd; - int64_t total_stocked; + int64_t total_stock; enum GNUNET_DB_QueryStatus qs; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("description", @@ -143,8 +143,10 @@ TMH_private_patch_products_ID (const struct TMH_RequestHandler *rh, &pd.taxes), GNUNET_JSON_spec_json ("address", &pd.address), - GNUNET_JSON_spec_int64 ("total_stocked", - &total_stocked), + GNUNET_JSON_spec_int64 ("total_stock", + &total_stock), + GNUNET_JSON_spec_uint64 ("total_lost", + &pd.total_lost), GNUNET_JSON_spec_absolute_time ("next_restock", &pd.next_restock), GNUNET_JSON_spec_end () @@ -172,10 +174,10 @@ TMH_private_patch_products_ID (const struct TMH_RequestHandler *rh, TALER_EC_INTERNAL_INVARIANT_FAILURE, "Impossible to parse the product description"); } - if (-1 == total_stocked) - pd.total_stocked = UINT64_MAX; + if (-1 == total_stock) + pd.total_stock = UINT64_MAX; else - pd.total_stocked = (uint64_t) total_stocked; + pd.total_stock = (uint64_t) total_stock; if (NULL != json_object_get (hc->request_body, "next_restock")) { diff --git a/src/backend/taler-merchant-httpd_private-post-products.c b/src/backend/taler-merchant-httpd_private-post-products.c index c4402841..7fd62db9 100644 --- a/src/backend/taler-merchant-httpd_private-post-products.c +++ b/src/backend/taler-merchant-httpd_private-post-products.c @@ -56,7 +56,7 @@ products_equal (const struct TALER_MERCHANTDB_ProductDetails *p1, &p2->price)) && (1 == json_equal (p1->taxes, p2->taxes)) && - (p1->total_stocked == p2->total_stocked) && + (p1->total_stock == p2->total_stock) && (p1->total_sold == p2->total_sold) && (p1->total_lost == p2->total_lost) && (1 == json_equal (p1->image, @@ -84,7 +84,7 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh, struct TMH_MerchantInstance *mi = hc->instance; struct TALER_MERCHANTDB_ProductDetails pd; const char *product_id; - int64_t total_stocked; + int64_t total_stock; enum GNUNET_DB_QueryStatus qs; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("product_id", @@ -103,8 +103,8 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh, &pd.taxes), GNUNET_JSON_spec_json ("address", &pd.address), - GNUNET_JSON_spec_int64 ("total_stocked", - &total_stocked), + GNUNET_JSON_spec_int64 ("total_stock", + &total_stock), GNUNET_JSON_spec_absolute_time ("next_restock", &pd.next_restock), GNUNET_JSON_spec_end () @@ -131,10 +131,10 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh, "Impossible to parse the order"); } - if (-1 == total_stocked) - pd.total_stocked = UINT64_MAX; + if (-1 == total_stock) + pd.total_stock = UINT64_MAX; else - pd.total_stocked = (uint64_t) total_stocked; + pd.total_stock = (uint64_t) total_stock; if (NULL != json_object_get (hc->request_body, "next_restock")) { diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql index f49c2cc6..a4f720ee 100644 --- a/src/backenddb/merchant-0001.sql +++ b/src/backenddb/merchant-0001.sql @@ -129,8 +129,8 @@ CREATE TABLE IF NOT EXISTS merchant_inventory ,price_val INT8 NOT NULL ,price_frac INT4 NOT NULL ,total_stock BIGINT NOT NULL - ,total_sold BIGINT NOT NULL - ,total_lost BIGINT NOT NULL + ,total_sold BIGINT NOT NULL DEFAULT 0 + ,total_lost BIGINT NOT NULL DEFAULT 0 ,address BYTEA NOT NULL ,next_restock INT8 NOT NULL ,UNIQUE (merchant_serial, product_id) diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 57da9811..b5291172 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -846,7 +846,7 @@ postgres_lookup_product (void *cls, TALER_PQ_result_spec_json ("taxes", &pd->taxes), GNUNET_PQ_result_spec_uint64 ("total_stock", - &pd->total_stocked), + &pd->total_stock), GNUNET_PQ_result_spec_uint64 ("total_sold", &pd->total_sold), GNUNET_PQ_result_spec_uint64 ("total_lost", @@ -927,9 +927,7 @@ postgres_insert_product (void *cls, TALER_PQ_query_param_json (pd->image), TALER_PQ_query_param_json (pd->taxes), TALER_PQ_query_param_amount (&pd->price), - GNUNET_PQ_query_param_uint64 (&pd->total_stocked), - GNUNET_PQ_query_param_uint64 (&pd->total_sold), - GNUNET_PQ_query_param_uint64 (&pd->total_lost), + GNUNET_PQ_query_param_uint64 (&pd->total_stock), TALER_PQ_query_param_json (pd->address), GNUNET_PQ_query_param_absolute_time (&pd->next_restock), GNUNET_PQ_query_param_end @@ -969,16 +967,16 @@ postgres_update_product (void *cls, { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (instance_id), + GNUNET_PQ_query_param_string (instance_id), /* $1 */ GNUNET_PQ_query_param_string (product_id), GNUNET_PQ_query_param_string (pd->description), TALER_PQ_query_param_json (pd->description_i18n), GNUNET_PQ_query_param_string (pd->unit), - TALER_PQ_query_param_json (pd->image), + TALER_PQ_query_param_json (pd->image), /* $6 */ TALER_PQ_query_param_json (pd->taxes), TALER_PQ_query_param_amount (&pd->price), - GNUNET_PQ_query_param_uint64 (&pd->total_stocked), - GNUNET_PQ_query_param_uint64 (&pd->total_lost), + GNUNET_PQ_query_param_uint64 (&pd->total_stock), + GNUNET_PQ_query_param_uint64 (&pd->total_lost), /* $11 */ TALER_PQ_query_param_json (pd->address), GNUNET_PQ_query_param_absolute_time (&pd->next_restock), GNUNET_PQ_query_param_end @@ -4099,15 +4097,13 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) ",price_val" ",price_frac" ",total_stock" - ",total_sold" - ",total_lost" ",address" ",next_restock)" " SELECT merchant_serial," - " $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14" + " $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12" " FROM merchant_instances" " WHERE merchant_id=$1", - 14), + 12), /* for postgres_update_product() */ GNUNET_PQ_make_prepare ("update_product", "UPDATE merchant_inventory SET" @@ -4163,7 +4159,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) GNUNET_PQ_make_prepare ("delete_order", "DELETE" " FROM merchant_orders" - " WHERE merchant_inventory.merchant_serial=" + " WHERE merchant_orders.merchant_serial=" " (SELECT merchant_serial " " FROM merchant_instances" " WHERE merchant_id=$1)" diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 98acae6f..2fa62302 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -792,7 +792,7 @@ struct TALER_MERCHANT_ProductGetHandle; * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books), + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books), * does NOT indicate remaining stocks, to get remaining stocks, * subtract @a total_sold and @a total_lost. Note that this still * does not then say how many of the remaining inventory are locked. @@ -812,7 +812,7 @@ typedef void const struct TALER_Amount *price, const json_t *image, const json_t *taxes, - int64_t total_stocked, + int64_t total_stock, uint64_t total_sold, uint64_t total_lost, const json_t *location, @@ -883,7 +883,7 @@ typedef void * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books) + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books) * @param address where the product is in stock * @param next_restock when the next restocking is expected to happen, 0 for unknown, * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'. @@ -902,7 +902,7 @@ TALER_MERCHANT_products_post ( const struct TALER_Amount *price, const json_t *image, const json_t *taxes, - int64_t total_stocked, + int64_t total_stock, const json_t *address, struct GNUNET_TIME_Absolute next_restock, TALER_MERCHANT_ProductsPostCallback cb, @@ -955,10 +955,10 @@ typedef void * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books), + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books), * must be larger than previous values * @param total_lost in @a units, must be larger than previous values, and may - * not exceed total_stocked minus total_sold; if it does, the transaction + * not exceed total_stock minus total_sold; if it does, the transaction * will fail with a #MHD_HTTP_CONFLICT HTTP status code * @param address where the product is in stock * @param next_restock when the next restocking is expected to happen @@ -977,7 +977,7 @@ TALER_MERCHANT_product_patch ( const struct TALER_Amount *price, const json_t *image, const json_t *taxes, - int64_t total_stocked, + int64_t total_stock, uint64_t total_lost, const json_t *address, struct GNUNET_TIME_Absolute next_restock, diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h index bba80d3b..1da7478f 100644 --- a/src/include/taler_merchant_testing_lib.h +++ b/src/include/taler_merchant_testing_lib.h @@ -266,7 +266,7 @@ TALER_TESTING_cmd_merchant_delete_instance (const char *label, * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books) + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books) * @param address where the product is in stock * @param next_restock when the next restocking is expected to happen, 0 for unknown, * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'. @@ -284,7 +284,7 @@ TALER_TESTING_cmd_merchant_post_products2 ( const char *price, json_t *image, json_t *taxes, - int64_t total_stocked, + int64_t total_stock, json_t *address, struct GNUNET_TIME_Absolute next_restock, unsigned int http_status); @@ -327,9 +327,9 @@ TALER_TESTING_cmd_merchant_post_products (const char *label, * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books) + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books) * @param total_lost in @a units, must be larger than previous values, and may - * not exceed total_stocked minus total_sold; if it does, the transaction + * not exceed total_stock minus total_sold; if it does, the transaction * will fail with a #MHD_HTTP_CONFLICT HTTP status code * @param address where the product is in stock * @param next_restock when the next restocking is expected to happen, 0 for unknown, @@ -348,7 +348,7 @@ TALER_TESTING_cmd_merchant_patch_product ( const char *price, json_t *image, json_t *taxes, - int64_t total_stocked, + int64_t total_stock, uint64_t total_lost, json_t *address, struct GNUNET_TIME_Absolute next_restock, diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index 214baec9..df88210b 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -188,7 +188,7 @@ struct TALER_MERCHANTDB_ProductDetails * existing sales and lost product, in product-specific units. UINT64_MAX * indicates "infinite". */ - uint64_t total_stocked; + uint64_t total_stock; /** * Number of units of the product in sold, in product-specific units. diff --git a/src/lib/merchant_api_get_product.c b/src/lib/merchant_api_get_product.c index 0388c793..e9263b07 100644 --- a/src/lib/merchant_api_get_product.c +++ b/src/lib/merchant_api_get_product.c @@ -97,11 +97,12 @@ handle_get_product_finished (void *cls, struct TALER_Amount price; json_t *image; json_t *taxes; - int64_t total_stocked; + int64_t total_stock; uint64_t total_sold; uint64_t total_lost; - json_t *location; - struct GNUNET_TIME_Absolute next_restock; + json_t *address; + bool rst_ok = true; + struct GNUNET_TIME_Absolute next_restock = {0}; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("description", &description), @@ -109,29 +110,46 @@ handle_get_product_finished (void *cls, &description_i18n), GNUNET_JSON_spec_string ("unit", &unit), - TALER_JSON_spec_amount ("price_fee", + TALER_JSON_spec_amount ("price", &price), GNUNET_JSON_spec_json ("image", &image), GNUNET_JSON_spec_json ("taxes", &taxes), - GNUNET_JSON_spec_int64 ("total_stocked", - &total_stocked), + GNUNET_JSON_spec_int64 ("total_stock", + &total_stock), GNUNET_JSON_spec_uint64 ("total_sold", &total_sold), GNUNET_JSON_spec_uint64 ("total_lost", &total_lost), - GNUNET_JSON_spec_json ("location", - &location), - GNUNET_JSON_spec_absolute_time ("next_restock", - &next_restock), + GNUNET_JSON_spec_json ("address", + &address), GNUNET_JSON_spec_end () }; - if (GNUNET_OK == - GNUNET_JSON_parse (json, - spec, - NULL, NULL)) + if (NULL != + json_object_get (json, + "next_restock")) + { + struct GNUNET_JSON_Specification spect[] = { + GNUNET_JSON_spec_absolute_time ("next_restock", + &next_restock), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (json, + spect, + NULL, NULL)) + rst_ok = false; + } + + + if ( (rst_ok) && + (GNUNET_OK == + GNUNET_JSON_parse (json, + spec, + NULL, NULL)) ) { pgh->cb (pgh->cb_cls, &hr, @@ -141,10 +159,10 @@ handle_get_product_finished (void *cls, &price, image, taxes, - total_stocked, + total_stock, total_sold, total_lost, - location, + address, next_restock); GNUNET_JSON_parse_free (spec); TALER_MERCHANT_product_get_cancel (pgh); diff --git a/src/lib/merchant_api_patch_product.c b/src/lib/merchant_api_patch_product.c index 4fba0974..c97bd1a5 100644 --- a/src/lib/merchant_api_patch_product.c +++ b/src/lib/merchant_api_patch_product.c @@ -167,10 +167,10 @@ handle_patch_product_finished (void *cls, * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books), + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books), * must be larger than previous values * @param total_lost in @a units, must be larger than previous values, and may - * not exceed total_stocked minus total_sold; if it does, the transaction + * not exceed total_stock minus total_sold; if it does, the transaction * will fail with a #MHD_HTTP_CONFLICT HTTP status code * @param location where the product is in stock * @param next_restock when the next restocking is expected to happen @@ -189,7 +189,7 @@ TALER_MERCHANT_product_patch ( const struct TALER_Amount *price, const json_t *image, const json_t *taxes, - int64_t total_stocked, + int64_t total_stock, uint64_t total_lost, const json_t *address, struct GNUNET_TIME_Absolute next_restock, @@ -199,6 +199,7 @@ TALER_MERCHANT_product_patch ( struct TALER_MERCHANT_ProductPatchHandle *pph; json_t *req_obj; + (void) GNUNET_TIME_round_abs (&next_restock); req_obj = json_pack ("{s:s, s:O, s:s, s:o, s:O," " s:O, s:I: s:I, s:O, s:o}", "description", @@ -214,8 +215,8 @@ TALER_MERCHANT_product_patch ( /* End of first group of 5 */ "taxes", taxes, - "total_stocked", - (json_int_t) total_stocked, + "total_stock", + (json_int_t) total_stock, "total_lost", (json_int_t) total_lost, "address", diff --git a/src/lib/merchant_api_post_products.c b/src/lib/merchant_api_post_products.c index 7c3f57ba..af2e4ea6 100644 --- a/src/lib/merchant_api_post_products.c +++ b/src/lib/merchant_api_post_products.c @@ -167,7 +167,7 @@ handle_post_products_finished (void *cls, * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books) + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books) * @param address where the product is in stock * @param next_restock when the next restocking is expected to happen, 0 for unknown, * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'. @@ -186,7 +186,7 @@ TALER_MERCHANT_products_post ( const struct TALER_Amount *price, const json_t *image, const json_t *taxes, - int64_t total_stocked, + int64_t total_stock, const json_t *address, struct GNUNET_TIME_Absolute next_restock, TALER_MERCHANT_ProductsPostCallback cb, @@ -195,6 +195,7 @@ TALER_MERCHANT_products_post ( struct TALER_MERCHANT_ProductsPostHandle *pph; json_t *req_obj; + (void) GNUNET_TIME_round_abs (&next_restock); req_obj = json_pack ("{s:s, s:s, s:O, s:s, s:o," " s:O, s:O, s:I, s:O, s:o}", "product_id", @@ -212,8 +213,8 @@ TALER_MERCHANT_products_post ( image, "taxes", taxes, - "total_stocked", - (json_int_t) total_stocked, + "total_stock", + (json_int_t) total_stock, "address", address, "next_restock", diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 1e91d4eb..18380845 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -1034,6 +1034,10 @@ run (void *cls, TALER_TESTING_cmd_merchant_delete_product ("get-products-empty", merchant_url, "p1", + MHD_HTTP_NOT_FOUND), + TALER_TESTING_cmd_merchant_delete_product ("get-products-empty", + merchant_url, + "product-1", MHD_HTTP_NO_CONTENT), #if 0 TALER_TESTING_cmd_batch ("pay", diff --git a/src/testing/testing_api_cmd_get_product.c b/src/testing/testing_api_cmd_get_product.c index 43d39bbc..8ba63af6 100644 --- a/src/testing/testing_api_cmd_get_product.c +++ b/src/testing/testing_api_cmd_get_product.c @@ -81,7 +81,7 @@ struct GetProductState * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books), + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books), * does NOT indicate remaining stocks, to get remaining stocks, * subtract @a total_sold and @a total_lost. Note that this still * does not then say how many of the remaining inventory are locked. @@ -100,7 +100,7 @@ get_product_cb (void *cls, const struct TALER_Amount *price, const json_t *image, const json_t *taxes, - int64_t total_stocked, + int64_t total_stock, uint64_t total_sold, uint64_t total_lost, const json_t *location, diff --git a/src/testing/testing_api_cmd_patch_product.c b/src/testing/testing_api_cmd_patch_product.c index ec4bb4c4..9ddcdceb 100644 --- a/src/testing/testing_api_cmd_patch_product.c +++ b/src/testing/testing_api_cmd_patch_product.c @@ -87,7 +87,7 @@ struct PatchProductState /** * in @e units, -1 to indicate "infinite" (i.e. electronic books) */ - int64_t total_stocked; + int64_t total_stock; /** * in @e units. @@ -172,7 +172,7 @@ patch_product_run (void *cls, &pis->price, pis->image, pis->taxes, - pis->total_stocked, + pis->total_stock, pis->total_lost, pis->address, pis->next_restock, @@ -225,9 +225,9 @@ patch_product_cleanup (void *cls, * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books) + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books) * @param total_lost in @a units, must be larger than previous values, and may - * not exceed total_stocked minus total_sold; if it does, the transaction + * not exceed total_stock minus total_sold; if it does, the transaction * will fail with a #MHD_HTTP_CONFLICT HTTP status code * @param address where the product is in stock * @param next_restock when the next restocking is expected to happen, 0 for unknown, @@ -246,7 +246,7 @@ TALER_TESTING_cmd_merchant_patch_product ( const char *price, json_t *image, json_t *taxes, - int64_t total_stocked, + int64_t total_stock, uint64_t total_lost, json_t *address, struct GNUNET_TIME_Absolute next_restock, @@ -266,7 +266,7 @@ TALER_TESTING_cmd_merchant_patch_product ( &pis->price)); pis->image = image; /* ownership taken */ pis->taxes = taxes; /* ownership taken */ - pis->total_stocked = total_stocked; + pis->total_stock = total_stock; pis->total_lost = total_lost; pis->address = address; /* ownership taken */ pis->next_restock = next_restock; { diff --git a/src/testing/testing_api_cmd_post_instances.c b/src/testing/testing_api_cmd_post_instances.c index 71626008..6392420d 100644 --- a/src/testing/testing_api_cmd_post_instances.c +++ b/src/testing/testing_api_cmd_post_instances.c @@ -136,10 +136,13 @@ post_instances_cb (void *cls, } switch (hr->http_status) { - case MHD_HTTP_OK: + case MHD_HTTP_NO_CONTENT: + break; + case MHD_HTTP_CONFLICT: break; // FIXME: add other legitimate states here... default: + GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unhandled HTTP status.\n"); } diff --git a/src/testing/testing_api_cmd_post_products.c b/src/testing/testing_api_cmd_post_products.c index 8f787bc1..68f68972 100644 --- a/src/testing/testing_api_cmd_post_products.c +++ b/src/testing/testing_api_cmd_post_products.c @@ -87,7 +87,7 @@ struct PostProductsState /** * in @e units, -1 to indicate "infinite" (i.e. electronic books) */ - int64_t total_stocked; + int64_t total_stock; /** * where the product is in stock @@ -131,10 +131,13 @@ post_products_cb (void *cls, } switch (hr->http_status) { - case MHD_HTTP_OK: + case MHD_HTTP_NO_CONTENT: + break; + case MHD_HTTP_CONFLICT: break; // FIXME: add other legitimate states here... default: + GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unhandled HTTP status.\n"); } @@ -167,7 +170,7 @@ post_products_run (void *cls, &pis->price, pis->image, pis->taxes, - pis->total_stocked, + pis->total_stock, pis->address, pis->next_restock, &post_products_cb, @@ -219,7 +222,7 @@ post_products_cleanup (void *cls, * applicable taxes. * @param image base64-encoded product image * @param taxes list of taxes paid by the merchant - * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books) + * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books) * @param address where the product is in stock * @param next_restock when the next restocking is expected to happen, 0 for unknown, * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'. @@ -237,7 +240,7 @@ TALER_TESTING_cmd_merchant_post_products2 ( const char *price, json_t *image, json_t *taxes, - int64_t total_stocked, + int64_t total_stock, json_t *address, struct GNUNET_TIME_Absolute next_restock, unsigned int http_status) @@ -256,7 +259,7 @@ TALER_TESTING_cmd_merchant_post_products2 ( &pis->price)); pis->image = image; /* ownership taken */ pis->taxes = taxes; /* ownership taken */ - pis->total_stocked = total_stocked; + pis->total_stock = total_stock; pis->address = address; /* ownership taken */ pis->next_restock = next_restock; { -- cgit v1.2.3