[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 225/324: mq: Inject errors when message verification has
From: |
gnunet |
Subject: |
[gnunet-scheme] 225/324: mq: Inject errors when message verification has negative result. |
Date: |
Tue, 21 Sep 2021 13:24:25 +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 289c4adba9ab875223a269aaee1b9b28b3981537
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Thu Sep 2 18:55:54 2021 +0200
mq: Inject errors when message verification has negative result.
* README.org (List of errors): Document logic:ill-formed.
* doc/scheme-gnunet.tm (logic:ill-formed): New explanation.
* gnu/gnunet/mq.scm (inject-message!): Document logic:ill-formed
error. Inject that error when the verificator returns falsehood.
* tests/mq.scm ("ill-formed message error"): New test.
---
README.org | 4 +++-
doc/scheme-gnunet.tm | 12 ++++++++++--
gnu/gnunet/mq.scm | 7 +++----
tests/mq.scm | 26 +++++++++++++++++++++++++-
4 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/README.org b/README.org
index d1a9710..13e68a1 100644
--- a/README.org
+++ b/README.org
@@ -132,7 +132,9 @@
Input errors (decoding)
+ logic:no-handler type . rest
No handler for received message type (rest is currently unspecified)
- + TODO verification failed, unknown message type
+ + logic:ill-formed type . rest
+ Message is invalid according to message handler (rest is currently
+ unspecified)
** Configuration :test:good:
+ gnu/gnunet/config/parser.scm: Parse configuration files.
+ gnu/gnunet/config/expand.scm: Perform variable expansion.
diff --git a/doc/scheme-gnunet.tm b/doc/scheme-gnunet.tm
index 3005ed9..51f65c7 100644
--- a/doc/scheme-gnunet.tm
+++ b/doc/scheme-gnunet.tm
@@ -424,8 +424,16 @@
<\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
+ <|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.
+ </explain>
+
+ <\explain>
+ <scm|logic:ill-formed> <var|type> . <var|rest>
+ </explain|The received message of type (as an integer) is ill-formed
+ according to the message handler.<space|1em><var|rest> is currently
unspecified.>
<todo|errors for no message handler and malformed messages>
diff --git a/gnu/gnunet/mq.scm b/gnu/gnunet/mq.scm
index 540e463..24546ca 100644
--- a/gnu/gnunet/mq.scm
+++ b/gnu/gnunet/mq.scm
@@ -184,8 +184,8 @@ messages must be sent in-order (TODO really received
in-order?)."
"Call the message handler that was registered
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,
+(according to the message handler), inject a @code{logic:ill-formed}
+error instead. 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
@@ -220,8 +220,7 @@ of message queues."
(? (not handler)
(inject-error! mq 'logic:no-handler type))
(? (not (verify-message? handler message))
- ;; TODO: error handling
- (inject-error! handler ???))) ; malformed message
+ (inject-error! mq 'logic:ill-formed type)))
;; TODO: maybe a good place to catch out-of-memory
;; and stack overflow errors ...
(handle-message! handler message)))
diff --git a/tests/mq.scm b/tests/mq.scm
index 3485022..c4763c9 100644
--- a/tests/mq.scm
+++ b/tests/mq.scm
@@ -631,7 +631,31 @@ with @code{x}."
(! mq (make-message-queue no-handlers error-handler #f)))
(inject-message! mq slice)
errored?))
-;; TODO: what if the message is (otherwise) malformed?
+
+(test-assert "ill-formed message error"
+ (let^ ((! errored? #f)
+ (! slice (bv-slice/read-write #vu8(0 4 0 0)))
+ (! handlers
+ (message-handlers
+ (message-handler
+ (type 0)
+ ((interpose code) code)
+ ((well-formed? s)
+ (assert (eq? s slice))
+ #f)
+ ((handle! slice)
+ (error "unreachable")))))
+ (! (error-handler . e)
+ (match e
+ ;; Note: it theoretically may have some unspecified rest
+ ;; rest arguments. In ‘real code’, use
+ ;; (logic:ill-formed 0 . rest) instead.
+ ('(logic:ill-formed 0)
+ (assert (not errored?))
+ (set! errored? #t))))
+ (! mq (make-message-queue handlers error-handler #f)))
+ (inject-message! mq slice)
+ errored?))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 210/324: mq-stream: Reuse 'type' variable instead of reading the type again., (continued)
- [gnunet-scheme] 210/324: mq-stream: Reuse 'type' variable instead of reading the type again., gnunet, 2021/09/21
- [gnunet-scheme] 219/324: mq-impl/stream: Create the message queue as late as possible., gnunet, 2021/09/21
- [gnunet-scheme] 230/324: doc: Correct errors in ‘network structure’ section., gnunet, 2021/09/21
- [gnunet-scheme] 235/324: doc: Document how errors and received/sent messages are ordered., gnunet, 2021/09/21
- [gnunet-scheme] 199/324: guix: Use patched version of guile-fibers., gnunet, 2021/09/21
- [gnunet-scheme] 209/324: doc: Resolve the TODO about broken pipes., gnunet, 2021/09/21
- [gnunet-scheme] 213/324: nse/client: Use 'message-handler' macro., gnunet, 2021/09/21
- [gnunet-scheme] 222/324: mq-impl/stream: Handle closed ports more gracefully., gnunet, 2021/09/21
- [gnunet-scheme] 223/324: mq,doc: Update TODOs about message queues., gnunet, 2021/09/21
- [gnunet-scheme] 224/324: doc: Don't forget the message verifier., gnunet, 2021/09/21
- [gnunet-scheme] 225/324: mq: Inject errors when message verification has negative result.,
gnunet <=
- [gnunet-scheme] 234/324: doc: Remove resolved TODO., gnunet, 2021/09/21
- [gnunet-scheme] 240/324: mq-impl/stream: Handle ECONNRESET gracefully., gnunet, 2021/09/21
- [gnunet-scheme] 238/324: mq-impl/stream: Allow closing queues made with connect-fibers., gnunet, 2021/09/21
- [gnunet-scheme] 244/324: doc: Document the 'disconnected' callback., gnunet, 2021/09/21
- [gnunet-scheme] 246/324: mq,mq-impl: Remove TODOs about allocating memory., gnunet, 2021/09/21
- [gnunet-scheme] 245/324: mq-impl/stream: Eliminate 'return' argument of 'handle-input!'., gnunet, 2021/09/21
- [gnunet-scheme] 251/324: tests/utils: Move call-with-spawner from tests/mq-stream.scm., gnunet, 2021/09/21
- [gnunet-scheme] 221/324: mq-impl/stream: Delay knowing the port., gnunet, 2021/09/21
- [gnunet-scheme] 228/324: doc/fdl: Correct ‘quote’ typography., gnunet, 2021/09/21
- [gnunet-scheme] 231/324: doc: Document message verifiers., gnunet, 2021/09/21