merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 90eec618406ba4e664b228d4f6e03c5e2803c106
parent 08d795551739e047805fd2f89d6c16ca743289d1
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 17 Apr 2021 21:52:21 +0200

fix backend-db test

Diffstat:
Msrc/backenddb/test_merchantdb.c | 39+++++++++------------------------------
Msrc/include/taler_merchantdb_lib.h | 5+++--
2 files changed, 12 insertions(+), 32 deletions(-)

diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c @@ -702,25 +702,6 @@ test_instances (void) /** - * Frees memory associated with a product. - * - * @param pd the product containing the memory to free. - */ -static void -free_product (struct TALER_MERCHANTDB_ProductDetails *pd) -{ - GNUNET_free (pd->description); - if (NULL != pd->description_i18n) - json_decref (pd->description_i18n); - GNUNET_free (pd->unit); - if (NULL != pd->image) - json_decref (pd->image); - if (NULL != pd->address) - json_decref (pd->address); -} - - -/** * A container for data relevant to a product. */ struct ProductData @@ -760,7 +741,7 @@ make_product (const char *id, product->product.total_stock = 55; product->product.total_sold = 0; product->product.total_lost = 0; - product->product.image = json_array (); + product->product.image = GNUNET_strdup (""); GNUNET_assert (NULL != product->product.image); product->product.address = json_array (); GNUNET_assert (NULL != product->product.address); @@ -778,7 +759,7 @@ free_product_data (struct ProductData *product) { json_decref (product->product.description_i18n); json_decref (product->product.taxes); - json_decref (product->product.image); + GNUNET_free (product->product.image); json_decref (product->product.address); } @@ -809,8 +790,8 @@ check_products_equal (const struct TALER_MERCHANTDB_ProductDetails *a, (a->total_stock != b->total_stock) || (a->total_sold != b->total_sold) || (a->total_lost != b->total_lost) || - (1 != json_equal (a->image, - b->image)) || + (0 != strcmp (a->image, + b->image)) || (1 != json_equal (a->address, b->address)) || (a->next_restock.abs_value_us != b->next_restock.abs_value_us)) @@ -884,7 +865,7 @@ test_lookup_product (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup product failed\n"); - free_product (&lookup_result); + TALER_MERCHANTDB_product_details_free (&lookup_result); return 1; } const struct TALER_MERCHANTDB_ProductDetails *to_cmp = &product->product; @@ -893,10 +874,10 @@ test_lookup_product (const struct InstanceData *instance, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup product failed: incorrect product returned\n"); - free_product (&lookup_result); + TALER_MERCHANTDB_product_details_free (&lookup_result); return 1; } - free_product (&lookup_result); + TALER_MERCHANTDB_product_details_free (&lookup_result); return 0; } @@ -1141,10 +1122,8 @@ run_test_products (struct TestProducts_Closure *cls) cls->products[0].product.total_stock = 100; cls->products[0].product.total_sold = 10; cls->products[0].product.total_lost = 7; - GNUNET_assert (0 == - json_array_append_new (cls->products[0].product.image, - json_string ( - "http://some-website.com/image.png"))); + GNUNET_free (cls->products[0].product.image); + cls->products[0].product.image = GNUNET_strdup ("image"); GNUNET_assert (0 == json_array_append_new (cls->products[0].product.address, json_string ("444 Some Street"))); diff --git a/src/include/taler_merchantdb_lib.h b/src/include/taler_merchantdb_lib.h @@ -55,8 +55,9 @@ TALER_MERCHANTDB_plugin_unload (struct TALER_MERCHANTDB_Plugin *dbh); * @param[in] pd product details to clean up */ void -TALER_MERCHANTDB_product_details_free (struct - TALER_MERCHANTDB_ProductDetails *pd); +TALER_MERCHANTDB_product_details_free ( + struct + TALER_MERCHANTDB_ProductDetails *pd); #endif /* MERCHANT_DB_H */