gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 216/324: mq: Inject errors if no appropriate message han


From: gnunet
Subject: [gnunet-scheme] 216/324: mq: Inject errors if no appropriate message handler exists.
Date: Tue, 21 Sep 2021 13:24:16 +0200

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

maxime-devos pushed a commit to branch master
in repository gnunet-scheme.

commit deee34490d251cbfb19d6a9c6c4b9d81131250ac
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Tue Aug 31 19:15:19 2021 +0200

    mq: Inject errors if no appropriate message handler exists.
    
    * gnu/gnunet/mq.scm (inject-message!): Inject logic:no-handler error
      when the handler does not exist.
    * tests/mq.scm ("no applicable message handler error"): New test.
    * README.org (List of errors): Document it.
    * doc/scheme-gnunet.tm (logic:no-handler): Likewise.
---
 README.org           |  2 ++
 doc/scheme-gnunet.tm |  6 ++++++
 gnu/gnunet/mq.scm    |  9 +++------
 tests/mq.scm         | 14 ++++++++++++++
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/README.org b/README.org
index a5b4c98..790c7be 100644
--- a/README.org
+++ b/README.org
@@ -133,6 +133,8 @@
      Injected by (gnu gnunet mq-impl stream).
 
    Input errors (decoding)
+   + logic:no-handler type . rest
+     No handler for received message type (rest is currently unspecified)
    + TODO verification failed, unknown message type
 ** Configuration                                                  :test:good:
    + gnu/gnunet/config/parser.scm: Parse configuration files.
diff --git a/doc/scheme-gnunet.tm b/doc/scheme-gnunet.tm
index 2869c26..ec47153 100644
--- a/doc/scheme-gnunet.tm
+++ b/doc/scheme-gnunet.tm
@@ -421,6 +421,12 @@
   are <scm|#false> instead.<space|1em>This can only happen if the server or
   connection to the server is buggy.>
 
+  <\explain>
+    <scm|logic:no-handler> <var|type> . <var|rest>
+  </explain|The received message of type <var|type> (as an integer) does not
+  have a corresponding message handler.<space|1em><var|rest> is currently
+  unspecified.>
+
   <todo|errors for no message handler and malformed messages>
 
   Consider automatically reconnecting after
diff --git a/gnu/gnunet/mq.scm b/gnu/gnunet/mq.scm
index e53fdee..deaca3f 100644
--- a/gnu/gnunet/mq.scm
+++ b/gnu/gnunet/mq.scm
@@ -187,10 +187,8 @@ messages must be sent in-order (TODO really received 
in-order?)."
 for the type of the message @var{mq} in the message queue var{mq}
 with the message @var{message}. In case the message is malformed
 (according to the message handler), inject a @code{&malformed-message}
-error instead.
-
-(TODO). In case no appropriate message handler exists,
-inject a ??? instead.
+error instead (TODO).  In case no appropriate message handler exists,
+inject a @code{logic:no-handler} error instead.
 
 It is an error for @var{message} to be so small it doesn't have
 a @code{/:message-header}. Likewise, it is also an error for the
@@ -222,8 +220,7 @@ of message queues."
                         (message-queue-handlers mq)
                         type))
             (? (not handler)
-               ;; TODO: error handling
-               (inject-error! handler ???))
+               (inject-error! mq 'logic:no-handler type))
             (? (not (verify-message? handler message))
                ;; TODO: error handling
                (inject-error! handler ???))) ; malformed message
diff --git a/tests/mq.scm b/tests/mq.scm
index 987dfa8..82f2f82 100644
--- a/tests/mq.scm
+++ b/tests/mq.scm
@@ -33,6 +33,7 @@
             (srfi srfi-43)
             (srfi srfi-64)
             (srfi srfi-111)
+            (ice-9 match)
             ((rnrs base) #:select (assert mod))
             ((rnrs exceptions) #:select (guard))
             ((rnrs conditions) #:select (condition-who))
@@ -45,6 +46,7 @@
             (gnu gnunet mq prio-prefs2)
             (gnu gnunet util struct)
             (gnu gnunet utils bv-slice)
+            (gnu gnunet utils hat-let)
             ((gnu extractor enum)
              #:select (symbol-value value->index))
             (gnu gnunet message protocols)
@@ -617,6 +619,18 @@ with @code{x}."
         (inject-message! mq s)
         #f)))))
 
+(test-assert "no applicable message handler error"
+  (let^ ((! errored? #f)
+        (! slice (bv-slice/read-write #vu8(0 4 0 0)))
+        (! (error-handler . e)
+           (match e
+             ('(logic:no-handler 0)
+              (assert (not errored?))
+              (set! errored? #t)
+              (values))))
+        (! mq (make-message-queue no-handlers error-handler #f)))
+       (inject-message! mq slice)
+       errored?))
 ;; TODO: what if the message is (otherwise) malformed?
 
 

-- 
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]