[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: fixed db test
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: fixed db test |
Date: |
Tue, 15 Sep 2020 16:37:28 +0200 |
This is an automated email from the git hooks/post-receive script.
ds-meister pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new aa001ce fixed db test
aa001ce is described below
commit aa001cea2a37a56038ebc4e2217ea1761f5a85c5
Author: Dominik Meister <dominik.meister@hotmail.ch>
AuthorDate: Tue Sep 15 16:37:18 2020 +0200
fixed db test
---
src/stasis/plugin_anastasis_postgres.c | 25 ++++++++++++++++++------
src/stasis/test_anastasis_db.c | 35 ++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/src/stasis/plugin_anastasis_postgres.c
b/src/stasis/plugin_anastasis_postgres.c
index b67a144..6eb054f 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -1435,12 +1435,22 @@ postgres_verify_challenge_code (void *cls,
{
struct PostgresClosure *pg = cls;
enum ANASTASIS_DB_QueryStatus qs;
- uint64_t server_code;
+ struct GNUNET_TIME_Absolute time_now = GNUNET_TIME_absolute_get ();
+ GNUNET_TIME_round_abs (&time_now);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d Public key used to query db is: %s\n",
+ __FILE__,
+ __LINE__,
+ TALER_B2S (truth_pub));
+
{
+ uint64_t server_code;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_pub),
+ TALER_PQ_query_param_absolute_time (&time_now),
GNUNET_PQ_query_param_end
};
+
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("code",
&server_code),
@@ -1448,10 +1458,12 @@ postgres_verify_challenge_code (void *cls,
};
check_connection (pg);
+
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"challengecode_select",
params,
rs);
+
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
@@ -1462,6 +1474,7 @@ postgres_verify_challenge_code (void *cls,
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
return ANASTASIS_DB_STATUS_NO_RESULTS;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+
if (server_code == code)
{
return ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT;
@@ -1914,17 +1927,17 @@ libanastasis_plugin_db_postgres_init (void *cls)
"code "
"FROM "
"anastasis_challengecode "
- "WHERE (truth_public_key =$1) "
- "AND (expiration_date > $2) "
- "AND (retry_counter > 0);",
+ "WHERE truth_public_key =$1 "
+ "AND expiration_date > $2 "
+ "AND retry_counter > 0;",
2),
GNUNET_PQ_make_prepare ("challengecode_update_retry",
"UPDATE anastasis_challengecode "
"SET "
"retry_counter = retry_counter -1 "
- "WHERE (truth_public_key =$1) "
- "AND (retry_counter > 0);",
+ "WHERE truth_public_key =$1 "
+ "AND retry_counter > 0;",
1),
GNUNET_PQ_make_prepare ("gc_challengecodes",
"DELETE FROM anastasis_challengecode "
diff --git a/src/stasis/test_anastasis_db.c b/src/stasis/test_anastasis_db.c
index e158607..7e20a82 100644
--- a/src/stasis/test_anastasis_db.c
+++ b/src/stasis/test_anastasis_db.c
@@ -175,6 +175,10 @@ run (void *cls)
.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST),
.purpose.size = htonl (sizeof (usp))
};
+ uint64_t challenge_code = 1234;
+
+ struct GNUNET_TIME_Relative challenge_expiration;
+ challenge_expiration = GNUNET_TIME_UNIT_HOURS;
GNUNET_CRYPTO_eddsa_private_key_from_string (str,
sizeof (str),
@@ -245,6 +249,7 @@ run (void *cls)
&paymentSecretP,
&amount));
+
FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->increment_lifetime (plugin->cls,
&accountPubP,
@@ -305,6 +310,36 @@ run (void *cls)
&recoverydatasize,
&res_recovery_data,
&res_version));
+
+
+ FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->store_challenge_code (plugin->cls,
+ &truth_public_key,
+ challenge_code,
+ challenge_expiration,
+ 3));
+
+
+ FAILIF (ANASTASIS_DB_STATUS_VALID_CODE_STORED !=
+ plugin->store_challenge_code (plugin->cls,
+ &truth_public_key,
+ challenge_code,
+ challenge_expiration,
+ 3));
+
+ FAILIF (ANASTASIS_DB_STATUS_CHALLENGE_CODE_MISSMATCH !=
+ plugin->verify_challenge_code (plugin->cls,
+ &truth_public_key,
+ 123));
+
+
+
+ FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->verify_challenge_code (plugin->cls,
+ &truth_public_key,
+ challenge_code));
+
+
if (-1 == result)
result = 0;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: fixed db test,
gnunet <=