[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] 123/277: added tests for instance creation and lookup
From: |
gnunet |
Subject: |
[taler-merchant] 123/277: added tests for instance creation and lookup |
Date: |
Sun, 05 Jul 2020 20:50:36 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
commit 601abc17e4d63fed52de91402c15bb4d9ba3e014
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Tue May 19 16:29:13 2020 -0400
added tests for instance creation and lookup
---
src/backenddb/test_merchantdb.c | 90 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index fdcf879..d159893 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -36,6 +36,24 @@ static int result;
*/
static struct TALER_MERCHANTDB_Plugin *plugin;
+/**
+ * Number of instances detected.
+ */
+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[])
+{
+ instance_count += 1;
+}
+
/**
* Main function that will be run by the scheduler.
@@ -48,11 +66,81 @@ run (void *cls)
struct GNUNET_CONFIGURATION_Handle *cfg = cls;
/* Data for 'store_payment()' */
+ /* Load the plugin */
if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
{
result = 77;
return;
}
+
+ /* Run the preflight */
+ plugin->preflight (plugin->cls);
+
+ /* Test lookup instances- is our new instance there? */
+ instance_count = 0;
+ if (0 > plugin->lookup_instances (plugin->cls, false,
+ lookup_instances_callback, cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Lookup instances failed\n");
+ result = 1;
+ return;
+ }
+ if (instance_count != 0)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Non-zero number of instances found after initialization\n");
+ result = 1;
+ return;
+ }
+
+ /* Test making an instance */
+ struct TALER_MerchantPublicKeyP merchant_pub;
+ struct TALER_MerchantPrivateKeyP merchant_priv;
+ GNUNET_CRYPTO_eddsa_key_create (&merchant_priv.eddsa_priv);
+ GNUNET_CRYPTO_eddsa_key_get_public (&merchant_priv.eddsa_priv,
+ &merchant_pub.eddsa_pub);
+ struct TALER_MERCHANTDB_InstanceSettings is;
+ is.id = "t";
+ is.name = "Test";
+ is.address = json_array ();
+ json_array_append (is.address, json_string ("123 Example St"));
+ is.jurisdiction = json_array ();
+ json_array_append (is.jurisdiction, json_string ("Ohio"));
+ TALER_string_to_amount ("USD:1200.40", &is.default_max_deposit_fee);
+ TALER_string_to_amount ("USD:1200.40", &is.default_max_wire_fee);
+ 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))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance insertion failed\n");
+ result = 1;
+ return;
+ }
+
+ /* Test lookup instances- is our new instance there? */
+ instance_count = 0;
+ if (0 > plugin->lookup_instances (plugin->cls, false,
+ lookup_instances_callback, cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Lookup instances failed\n");
+ result = 1;
+ return;
+ }
+ if (instance_count != 1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance count doesn't match number of instances inserted\n");
+ result = 1;
+ return;
+ }
+
+ /* Test dropping tables */
if (GNUNET_OK != plugin->drop_tables (plugin->cls))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -60,6 +148,8 @@ run (void *cls)
result = 77;
return;
}
+
+ /* Unload the plugin */
TALER_MERCHANTDB_plugin_unload (plugin);
if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
{
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-merchant] 99/277: more work on post /transfers and the like, (continued)
- [taler-merchant] 99/277: more work on post /transfers and the like, gnunet, 2020/07/05
- [taler-merchant] 93/277: updates, gnunet, 2020/07/05
- [taler-merchant] 100/277: more work on POST /transfer, gnunet, 2020/07/05
- [taler-merchant] 121/277: Merge branch 'master' into protocolV1, gnunet, 2020/07/05
- [taler-merchant] 126/277: more instance and product related tests, gnunet, 2020/07/05
- [taler-merchant] 124/277: expanding DB API, gnunet, 2020/07/05
- [taler-merchant] 128/277: more work on tipping implementation, gnunet, 2020/07/05
- [taler-merchant] 132/277: Merge branch 'protocolV1' of git+ssh://git.taler.net/merchant into protocolV1, gnunet, 2020/07/05
- [taler-merchant] 136/277: add GET /tips/ID handler, gnunet, 2020/07/05
- [taler-merchant] 138/277: wrote some db tests for orders, gnunet, 2020/07/05
- [taler-merchant] 123/277: added tests for instance creation and lookup,
gnunet <=
- [taler-merchant] 127/277: implement reserve deletion, gnunet, 2020/07/05
- [taler-merchant] 135/277: fix ftbfs, gnunet, 2020/07/05
- [taler-merchant] 130/277: added more instance tests and fixed mem leaks/code style in tests, gnunet, 2020/07/05
- [taler-merchant] 133/277: fix ftbfs, gnunet, 2020/07/05
- [taler-merchant] 139/277: wrote db tests for accounts, gnunet, 2020/07/05
- [taler-merchant] 140/277: DB prep work, gnunet, 2020/07/05
- [taler-merchant] 142/277: wip on DB plugin for tip pickup, gnunet, 2020/07/05
- [taler-merchant] 144/277: refactored instance test code, gnunet, 2020/07/05
- [taler-merchant] 146/277: wrote tests for deposits in the db api, gnunet, 2020/07/05
- [taler-merchant] 149/277: more db tests for transfers and tips, gnunet, 2020/07/05