summaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-05-20 15:43:39 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-05-20 15:43:39 -0400
commitd46bd871bcd34b9e0d633ab15fd9a4747861616c (patch)
tree5d94f8bf094936d0b6da80d6a999bd231b3203b5 /src/backenddb
parente6cd3507114e625f89d8d2383fd7a88b21d22b97 (diff)
downloadmerchant-d46bd871bcd34b9e0d633ab15fd9a4747861616c.tar.gz
merchant-d46bd871bcd34b9e0d633ab15fd9a4747861616c.tar.bz2
merchant-d46bd871bcd34b9e0d633ab15fd9a4747861616c.zip
fixed coding style in db tests and double callbacks in lookup_instances
Diffstat (limited to 'src/backenddb')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c4
-rw-r--r--src/backenddb/test_merchantdb.c64
2 files changed, 26 insertions, 42 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 670f1d00..874d33c9 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -472,9 +472,9 @@ lookup_instances_cb (void *cls,
params,
&lookup_accounts_cb,
lic);
- if (0 == lic->qs)
+ if (0 > lic->qs)
{
- /* find_accounts_cb() did not run, still notify about the
+ /* lookup_accounts_cb() did not run, still notify about the
account-less instance! */
call_with_accounts (lic,
0,
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index a3f23d48..30a0d883 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -42,46 +42,33 @@ static struct TALER_MERCHANTDB_Plugin *plugin;
static int instance_count;
void
-lookup_instances_callback (void *cls, const struct
- TALER_MerchantPublicKeyP *merchant_pub,
- const struct
- TALER_MerchantPrivateKeyP *merchant_priv, const
- struct
- TALER_MERCHANTDB_InstanceSettings *is,
- unsigned int accounts_length, const struct
- TALER_MERCHANTDB_AccountDetails accounts[])
+lookup_instances_cb (void *cls,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantPrivateKeyP *merchant_priv,
+ const struct TALER_MERCHANTDB_InstanceSettings *is,
+ unsigned int accounts_length,
+ const struct TALER_MERCHANTDB_AccountDetails accounts[])
{
instance_count += 1;
}
int
-check_products_equal (struct TALER_MERCHANTDB_ProductDetails *a, struct
- TALER_MERCHANTDB_ProductDetails *b)
+check_products_equal (struct TALER_MERCHANTDB_ProductDetails *a,
+ struct TALER_MERCHANTDB_ProductDetails *b)
{
- if (strcmp (a->description, b->description) != 0)
- return 1;
- if (json_equal (a->description_i18n, b->description_i18n) != 1)
- return 1;
- if (strcmp (a->unit, b->unit) != 0)
- return 1;
- if (TALER_amount_cmp_currency (&a->price, &b->price) != 0)
- return 1;
- if (TALER_amount_cmp (&a->price, &b->price) != 0)
- return 1;
- if (json_equal (a->taxes, b->taxes) != 1)
- return 1;
- if (a->total_stock != b->total_stock)
- return 1;
- if (a->total_sold != b->total_sold)
- return 1;
- if (a->total_lost != b->total_lost)
- return 1;
- if (json_equal (a->image, b->image) != 1)
- return 1;
- if (json_equal (a->address, b->address) != 1)
- return 1;
- if (a->next_restock.abs_value_us != b->next_restock.abs_value_us)
+ if ((0 != strcmp (a->description, b->description)) ||
+ (1 != json_equal (a->description_i18n, b->description_i18n)) ||
+ (0 != strcmp (a->unit, b->unit)) ||
+ (0 != TALER_amount_cmp_currency (&a->price, &b->price)) ||
+ (0 != TALER_amount_cmp (&a->price, &b->price)) ||
+ (1 != json_equal (a->taxes, b->taxes)) ||
+ (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)) ||
+ (1 != json_equal (a->address, b->address)) ||
+ (a->next_restock.abs_value_us != b->next_restock.abs_value_us))
return 1;
return 0;
}
@@ -111,7 +98,7 @@ run (void *cls)
/* Test lookup instances- there should be nothing here */
instance_count = 0;
if (0 > plugin->lookup_instances (plugin->cls, false,
- lookup_instances_callback, cls))
+ lookup_instances_cb, cls))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Lookup instances failed\n");
@@ -146,7 +133,6 @@ run (void *cls)
is.default_wire_fee_amortization = 1;
is.default_wire_transfer_delay = GNUNET_TIME_relative_get_minute_ ();
is.default_pay_delay = GNUNET_TIME_relative_get_second_ ();
-
if (0 > plugin->insert_instance (plugin->cls, &merchant_pub, &merchant_priv,
&is))
{
@@ -160,7 +146,7 @@ run (void *cls)
/* Test lookup instances- is our new instance there? */
instance_count = 0;
if (0 > plugin->lookup_instances (plugin->cls, false,
- lookup_instances_callback, cls))
+ lookup_instances_cb, cls))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Lookup instances failed\n");
@@ -168,14 +154,13 @@ run (void *cls)
plugin->drop_tables (plugin->cls);
return;
}
- /* This test currently FAILS */
- /*if (instance_count != 1)
+ if (instance_count != 1)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Instance count doesn't match number of instances inserted\n");
result = 1;
return;
- }*/
+ }
/* Test update instance */
is.name = "Test - updated";
@@ -281,7 +266,6 @@ run (void *cls)
}
result = 0;
-
GNUNET_break (GNUNET_OK ==
plugin->drop_tables (plugin->cls));
TALER_MERCHANTDB_plugin_unload (plugin);