[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] 164/277: fixed db test building and added test for wire
From: |
gnunet |
Subject: |
[taler-merchant] 164/277: fixed db test building and added test for wire fee storage |
Date: |
Sun, 05 Jul 2020 20:51:17 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
commit cd3a94a3c143455350be8e8c0cddbb8dc691da33
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Mon Jun 1 01:32:26 2020 -0400
fixed db test building and added test for wire fee storage
---
src/backenddb/plugin_merchantdb_postgres.c | 6 +-
src/backenddb/test_merchantdb.c | 126 +++++++++++++++++++++++++++--
2 files changed, 122 insertions(+), 10 deletions(-)
diff --git a/src/backenddb/plugin_merchantdb_postgres.c
b/src/backenddb/plugin_merchantdb_postgres.c
index eba525b..5981004 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -7078,7 +7078,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
",picked_up_frac"
",justification"
",merchant_tips.expiration"
- ",exchange_url"
+ // ",exchange_url"
",reserve_pub"
" FROM merchant_tips"
" JOIN merchant_tip_reserves USING
(reserve_serial)"
@@ -7094,8 +7094,8 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
" pickup_id"
",amount_val"
",amount_frac"
- ",num_planchets"
- ",COUNT(blind_sig)"
+ // ",num_planchets"
+ // ",COUNT(blind_sig)"
" FROM merchant_tip_pickups"
" JOIN merchant_tip_pickup_signatures USING
(pickup_serial)"
" WHERE tip_serial = $1",
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index a834eff..49b086b 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -200,6 +200,25 @@ test_insert_instance (const struct
TALER_MerchantPublicKeyP *merchant_pub,
}
+static int
+test_insert_instance_fails (const struct TALER_MerchantPublicKeyP
*merchant_pub,
+ const struct
+ TALER_MerchantPrivateKeyP *merchant_priv,
+ const struct TALER_MERCHANTDB_InstanceSettings *is)
+{
+ if (0 != plugin->insert_instance (plugin->cls,
+ merchant_pub,
+ merchant_priv,
+ is))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance insertion succeeded when expected to fail\n");
+ return 1;
+ }
+ return 0;
+}
+
+
static int
test_lookup_instances (bool active_only,
unsigned int instances_length,
@@ -257,6 +276,23 @@ test_insert_account (const char *instance_id,
}
+static int
+test_insert_account_fails (const char *instance_id,
+ const struct
+ TALER_MERCHANTDB_AccountDetails *account)
+{
+ if (0 != plugin->insert_account (plugin->cls,
+ instance_id,
+ account))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Insert account failed\n");
+ return 1;
+ }
+ return 0;
+}
+
+
/**
* Closure for instance tests
*/
@@ -290,6 +326,7 @@ struct TestInstances_Closure
static void
pre_test_instances (struct TestInstances_Closure *cls)
{
+ /* Instance */
GNUNET_CRYPTO_eddsa_key_create (&cls->merchant_priv.eddsa_priv);
GNUNET_CRYPTO_eddsa_key_get_public (&cls->merchant_priv.eddsa_priv,
&cls->merchant_pub.eddsa_pub);
@@ -313,6 +350,7 @@ pre_test_instances (struct TestInstances_Closure *cls)
cls->is.default_wire_transfer_delay = GNUNET_TIME_relative_get_minute_ ();
cls->is.default_pay_delay = GNUNET_TIME_relative_get_second_ ();
+ /* Accounts */
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG,
&cls->accounts[0].h_wire);
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG,
@@ -362,6 +400,11 @@ run_test_instances (struct TestInstances_Closure *cls)
&cls->merchant_priv,
&cls->is));
+ /* Test double insertion fails */
+ TEST_RET_ON_FAIL (test_insert_instance_fails (&cls->merchant_pub,
+ &cls->merchant_priv,
+ &cls->is));
+
/* Test lookup instances- is our new instance there? */
TEST_RET_ON_FAIL (test_lookup_instances (false,
1,
@@ -384,6 +427,10 @@ run_test_instances (struct TestInstances_Closure *cls)
TEST_RET_ON_FAIL (test_insert_account (cls->is.id,
&cls->accounts[0]));
+ /* Test double account insertion fails */
+ TEST_RET_ON_FAIL (test_insert_account_fails (cls->is.id,
+ &cls->accounts[0]));
+
/* Test accounts from instance lookup */
instances[0].accounts_length = 1;
instances[0].accounts = cls->accounts;
@@ -2434,6 +2481,17 @@ struct TestTransfers_Closure
* The deposit data
*/
struct DepositData deposit;
+
+ /**
+ * Wire fee data
+ */
+ const char *exch_wire_method;
+ struct GNUNET_HashCode exch_h_wire_method;
+ struct TALER_Amount exch_wire_fee;
+ struct TALER_Amount exch_closing_fee;
+ struct GNUNET_TIME_Absolute exch_wire_fee_start;
+ struct GNUNET_TIME_Absolute exch_wire_fee_end;
+ struct TALER_MasterSignatureP exch_fee_sig;
};
@@ -2458,6 +2516,14 @@ pre_test_transfers (struct TestTransfers_Closure *cls)
}
+ };
+ struct TALER_MasterWireFeePS fee_sign = {
+ .purpose = {
+ .size = htonl (sizeof (struct TALER_MasterWireFeePS)),
+ .purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES)
+ }
+
+
};
/* Instance */
@@ -2563,6 +2629,31 @@ pre_test_transfers (struct TestTransfers_Closure *cls)
cls->signkey_start = GNUNET_TIME_absolute_get ();
cls->signkey_expire = GNUNET_TIME_absolute_get ();
cls->signkey_end = GNUNET_TIME_absolute_get ();
+
+ /* Wire fee */
+ cls->exch_wire_method = "wire-method";
+ GNUNET_CRYPTO_hash (cls->exch_wire_method,
+ strlen (cls->exch_wire_method) + 1,
+ &cls->exch_h_wire_method);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount ("EUR:0.49",
+ &cls->exch_wire_fee));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount ("EUR:0.49",
+ &cls->exch_closing_fee));
+ cls->exch_wire_fee_start = GNUNET_TIME_absolute_get ();
+ cls->exch_wire_fee_end = GNUNET_TIME_absolute_add (cls->exch_wire_fee_start,
+ GNUNET_TIME_UNIT_MONTHS);
+ fee_sign.h_wire_method = cls->exch_h_wire_method;
+ TALER_amount_hton (&fee_sign.wire_fee,
+ &cls->exch_wire_fee);
+ TALER_amount_hton (&fee_sign.closing_fee,
+ &cls->exch_closing_fee);
+ fee_sign.start_date = GNUNET_TIME_absolute_hton (cls->exch_wire_fee_start);
+ fee_sign.end_date = GNUNET_TIME_absolute_hton (cls->exch_wire_fee_end);
+ GNUNET_CRYPTO_eddsa_sign (&cls->master_priv.eddsa_priv,
+ &fee_sign,
+ &cls->exch_fee_sig.eddsa_signature);
}
@@ -2599,6 +2690,33 @@ run_test_transfers (struct TestTransfers_Closure *cls)
.wtid = wtid
};
+ /* Test store wire fee by exchange */
+ if (1 != plugin->store_wire_fee_by_exchange (plugin->cls,
+ &cls->master_pub,
+ &cls->exch_h_wire_method,
+ &cls->exch_wire_fee,
+ &cls->exch_closing_fee,
+ cls->exch_wire_fee_start,
+ cls->exch_wire_fee_end,
+ &cls->exch_fee_sig))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error storing wire fee for exchange\n");
+ return 1;
+ }
+
+ /* Test lookup wire fee by exchange */
+ TEST_RET_ON_FAIL (test_lookup_wire_fee (&cls->master_pub,
+ cls->exch_wire_method,
+ GNUNET_TIME_absolute_add (
+ cls->exch_wire_fee_start,
+ GNUNET_TIME_UNIT_DAYS),
+ &cls->exch_wire_fee,
+ &cls->exch_closing_fee,
+ &cls->exch_wire_fee_start,
+ &cls->exch_wire_fee_end,
+ &cls->exch_fee_sig));
+
/* Insert the instance */
TEST_RET_ON_FAIL (test_insert_instance (&cls->merchant_pub,
&cls->merchant_priv,
@@ -3034,7 +3152,7 @@ test_lookup_tip_details (const char *instance_id,
unsigned int results_matching[expected_pickups_length];
if (TALER_EC_NONE != plugin->lookup_tip_details (plugin->cls,
instance_id,
- tip_id,
+ &tip_id,
true,
&total_authorized,
&total_picked_up,
@@ -3089,12 +3207,6 @@ test_lookup_tip_details (const char *instance_id,
&&
(0 == TALER_amount_cmp (&expected_pickups[i].requested_amount,
&pickups[j].requested_amount)) &&
- (GNUNET_OK == TALER_amount_cmp_currency (
- &expected_pickups[i].exchange_amount,
- &pickups[j].requested_amount))
- &&
- (0 == TALER_amount_cmp (&expected_pickups[i].exchange_amount,
- &pickups[j].exchange_amount)) &&
(expected_pickups[i].num_planchets == pickups[j].num_planchets))
{
results_matching[i] += 1;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-merchant] 134/277: finished writing db tests for products, (continued)
- [taler-merchant] 134/277: finished writing db tests for products, gnunet, 2020/07/05
- [taler-merchant] 137/277: implement POST /tips/ID/pickup, gnunet, 2020/07/05
- [taler-merchant] 141/277: Merge branch 'protocolV1' of git+ssh://git.taler.net/merchant into protocolV1, gnunet, 2020/07/05
- [taler-merchant] 143/277: more SQL for tips, gnunet, 2020/07/05
- [taler-merchant] 148/277: fixed inventory locking, test code for transfer lookups, gnunet, 2020/07/05
- [taler-merchant] 155/277: fix ftbfs, gnunet, 2020/07/05
- [taler-merchant] 154/277: return creation_time instead of leaving it uninitizlied, mark problematic missing lines, gnunet, 2020/07/05
- [taler-merchant] 158/277: work on tip APIs, gnunet, 2020/07/05
- [taler-merchant] 156/277: implement lookup tip details, gnunet, 2020/07/05
- [taler-merchant] 159/277: add POST /tips logic, gnunet, 2020/07/05
- [taler-merchant] 164/277: fixed db test building and added test for wire fee storage,
gnunet <=
- [taler-merchant] 163/277: implement filter, gnunet, 2020/07/05
- [taler-merchant] 165/277: add logic for activation of reserves to merchant backend DB, gnunet, 2020/07/05
- [taler-merchant] 147/277: added more tests for contract terms, deposits, and transfers, gnunet, 2020/07/05
- [taler-merchant] 160/277: address DB fixes for missing EC values, gnunet, 2020/07/05
- [taler-merchant] 157/277: fix DB use, gnunet, 2020/07/05
- [taler-merchant] 166/277: SQL fixing, gnunet, 2020/07/05
- [taler-merchant] 152/277: wrote db tests for tips/lookups, gnunet, 2020/07/05
- [taler-merchant] 145/277: refactored the existing product and order tests, gnunet, 2020/07/05
- [taler-merchant] 171/277: tests/fixes for tips and pickups in backenddb, gnunet, 2020/07/05
- [taler-merchant] 169/277: implement POST /private/reserves, gnunet, 2020/07/05