gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: fix misc logic issues


From: gnunet
Subject: [taler-anastasis] branch master updated: fix misc logic issues
Date: Sun, 07 Mar 2021 16:43:50 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 5e16f3b  fix misc logic issues
5e16f3b is described below

commit 5e16f3b74eba6decf3863b89e5f0cb6ab735516c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Mar 7 16:43:48 2021 +0100

    fix misc logic issues
---
 ...tasis_reducer_recovery_enter_user_attributes.sh | 24 +-------
 src/lib/anastasis_recovery.c                       | 22 ++++---
 src/reducer/anastasis_api_recovery_redux.c         | 71 +++++++++++-----------
 3 files changed, 49 insertions(+), 68 deletions(-)

diff --git a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh 
b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
index dcd9098..7d4853d 100755
--- a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
@@ -406,20 +406,7 @@ anastasis-reducer -a \
   )" \
   select_challenge < $R2FILE > $R1FILE
 
-export R1FILE
-export R2FILE
-export UUID0
-export UUID1
-bash
-
-anastasis-reducer -a \
-  "$(jq -n '
-    {
-        uuid: $UUID,
-        answer: "Hans"
-    }' \
-    --arg UUID "$UUID0"
-  )" \
+anastasis-reducer -a '{"answer": "Hans"}' \
   solve_challenge < $R1FILE > $R2FILE
 
 anastasis-reducer -a \
@@ -431,14 +418,7 @@ anastasis-reducer -a \
   )" \
   select_challenge < $R2FILE > $R1FILE
 
-anastasis-reducer -a \
-  "$(jq -n '
-    {
-        uuid: $UUID,
-        answer: "123"
-    }' \
-    --arg UUID "$UUID1"
-  )" \
+anastasis-reducer -a '{"answer": "123"}' \
   solve_challenge < $R1FILE > $R2FILE
 
 echo " OK"
diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c
index 544455a..d38aac6 100644
--- a/src/lib/anastasis_recovery.c
+++ b/src/lib/anastasis_recovery.c
@@ -247,16 +247,6 @@ keyshare_lookup_cb (void *cls,
   switch (dd->status)
   {
   case ANASTASIS_KSD_SUCCESS:
-    {
-      struct ANASTASIS_ChallengeStartResponse csr = {
-        .cs = ANASTASIS_CHALLENGE_STATUS_SOLVED,
-        .challenge = c
-      };
-
-      c->ci.solved = true;
-      c->af (c->af_cls,
-             &csr);
-    }
     break;
   case ANASTASIS_KSD_PAYMENT_REQUIRED:
     {
@@ -340,6 +330,18 @@ keyshare_lookup_cb (void *cls,
                                      &c->key_share);
   c->recovery->solved_challenges[c->recovery->solved_challenge_pos++] = c;
 
+  {
+    struct ANASTASIS_ChallengeStartResponse csr = {
+      .cs = ANASTASIS_CHALLENGE_STATUS_SOLVED,
+      .challenge = c
+    };
+
+    c->ci.solved = true;
+    c->af (c->af_cls,
+           &csr);
+  }
+
+
   /* Check if there is a policy for which all challenges have
      been satisifed, if so, store it in 'rdps'. */
   rdps = NULL;
diff --git a/src/reducer/anastasis_api_recovery_redux.c 
b/src/reducer/anastasis_api_recovery_redux.c
index bc24be4..a66889e 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -1072,6 +1072,10 @@ select_challenge_cb (void *cls,
     int ret;
 
     cd = ANASTASIS_challenge_get_details (ci);
+    if (0 !=
+        GNUNET_memcmp (&sctx->uuid,
+                       &cd->uuid))
+      continue;
     if (cd->solved)
     {
       ANASTASIS_redux_fail_ (sctx->cb,
@@ -1081,44 +1085,39 @@ select_challenge_cb (void *cls,
       sctx_free (sctx);
       return;
     }
-    if (0 ==
-        GNUNET_memcmp (&sctx->uuid,
-                       &cd->uuid))
+    GNUNET_assert (
+      0 ==
+      json_object_set_new (sctx->state,
+                           "selected_challenge_uuid",
+                           GNUNET_JSON_from_data_auto (&cd->uuid)));
+    if (0 == strcmp ("question",
+                     cd->type))
     {
-      GNUNET_assert (
-        0 ==
-        json_object_set_new (sctx->state,
-                             "selected_challenge_uuid",
-                             GNUNET_JSON_from_data_auto (&cd->uuid)));
-      if (0 == strcmp ("question",
-                       cd->type))
-      {
-        /* security question, immediately request user to answer it */
-        set_state (sctx->state,
-                   ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
-        sctx->cb (sctx->cb_cls,
-                  TALER_EC_NONE,
-                  sctx->state);
-        sctx_free (sctx);
-        return;
-      }
-      /* trigger challenge */
-      ret = ANASTASIS_challenge_start (ci,
-                                       psp,
-                                       NULL, /* no answer */
-                                       &answer_feedback_cb,
-                                       sctx);
-      if (GNUNET_OK != ret)
-      {
-        ANASTASIS_redux_fail_ (sctx->cb,
-                               sctx->cb_cls,
-                               TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
-                               "Failed to begin answering challenge");
-        sctx_free (sctx);
-        return;
-      }
-      return; /* await answer feedback */
+      /* security question, immediately request user to answer it */
+      set_state (sctx->state,
+                 ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
+      sctx->cb (sctx->cb_cls,
+                TALER_EC_NONE,
+                sctx->state);
+      sctx_free (sctx);
+      return;
+    }
+    /* trigger challenge */
+    ret = ANASTASIS_challenge_start (ci,
+                                     psp,
+                                     NULL,   /* no answer */
+                                     &answer_feedback_cb,
+                                     sctx);
+    if (GNUNET_OK != ret)
+    {
+      ANASTASIS_redux_fail_ (sctx->cb,
+                             sctx->cb_cls,
+                             TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+                             "Failed to begin answering challenge");
+      sctx_free (sctx);
+      return;
     }
+    return;   /* await answer feedback */
   }
   ANASTASIS_redux_fail_ (sctx->cb,
                          sctx->cb_cls,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]