gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] branch master updated (1666596 -> 441aaec)


From: gnunet
Subject: [gnunet-scheme] branch master updated (1666596 -> 441aaec)
Date: Thu, 03 Feb 2022 13:52:30 +0100

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

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

    from 1666596  bv-slice: Let slice-u8-ref and friends raise 
&missing-capabilities.
     new 4244688  nse/client: Simplify 'connected', 'disconnected' and 
'updated'.
     new 1fa54f0  tests/distributed-hash-table: Test 'copy-insertion'.
     new 750123f  tests/distributed-hash-table: Test 'copy-query'.
     new 441aaec  tests/distributed-hash-table: Simplify nested 'let*' forms.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 gnu/gnunet/nse/client.scm        | 13 ++++-----
 tests/distributed-hash-table.scm | 60 ++++++++++++++++++++++++++++++++--------
 2 files changed, 55 insertions(+), 18 deletions(-)

diff --git a/gnu/gnunet/nse/client.scm b/gnu/gnunet/nse/client.scm
index 3bb1095..945e2bd 100644
--- a/gnu/gnunet/nse/client.scm
+++ b/gnu/gnunet/nse/client.scm
@@ -1,5 +1,5 @@
 ;; This file is part of scheme-GNUnet, a partial Scheme port of GNUnet.
-;; Copyright (C) 2021 GNUnet e.V.
+;; Copyright © 2021, 2022 GNUnet e.V.
 ;;
 ;; scheme-GNUnet is free software: you can redistribute it and/or modify it
 ;; under the terms of the GNU Affero General Public License as published
@@ -135,8 +135,7 @@ even if not connected.  This is an idempotent operation."
           (read% /:msg:nse:estimate '(std-deviation) estimate-slice)
           (read% /:msg:nse:estimate '(timestamp) estimate-slice)))
        (atomic-box-set! estimate/box estimate)
-       (when updated
-         (updated estimate)))
+       (updated estimate))
       (define handlers
        (message-handlers
         (message-handler
@@ -173,14 +172,14 @@ even if not connected.  This is an idempotent operation."
           ;; uses @var{mq}.
           (wait mq-defined)
           (send-start!)
-          (when connected (connected)))
+          (connected))
          ((input:regular-end-of-file input:premature-end-of-file)
           ;; Call 'reconnect' after 'disconnected'.  Otherwise,
           ;; it is possible that 'connected' is called twice without
           ;; a call to 'disconnected' in-between, which would presumably
           ;; be confusing.
           (signal-condition! mq-closed)
-          (when disconnected (disconnected))
+          (disconnected)
           ;; Don't reconnect after 'close-queue!'.  About races: it's not
           ;; paramount we stop reconnecting immediately, but we should stop
           ;; eventually after 'request-close?/box' is set and
@@ -211,8 +210,8 @@ even if not connected.  This is an idempotent operation."
       (signal-condition! mq-defined)
       (spawn request-close-handler))
 
-    (define* (connect config #:key updated connected disconnected
-                     (spawn spawn-fiber))
+    (define* (connect config #:key (updated values) (connected values)
+                     (disconnected values) (spawn spawn-fiber))
       "Connect to the NSE service in the background.
 
 When connected, the thunk @var{connected} is called and estimates
diff --git a/tests/distributed-hash-table.scm b/tests/distributed-hash-table.scm
index 7f3c6f2..193b295 100644
--- a/tests/distributed-hash-table.scm
+++ b/tests/distributed-hash-table.scm
@@ -227,30 +227,50 @@
   (slice-copy! s s2)
   b)
 
+(define (query->sexp z)
+  (list (query-type z) (slice->bytevector (query-key z))
+       (query-desired-replication-level z)))
+
 (define (datum->sexp z)
    (list (datum-type z)
         (slice->bytevector (datum-key z))
         (slice->bytevector (datum-value z))
         (datum-expiration z)))
 
+(define (insertion->sexp z)
+  (list (datum->sexp (insertion->datum z))
+       (insertion-desired-replication-level z)))
+
 (define (search-result->sexp z)
   (list (slice->bytevector (search-result-get-path z))
        (slice->bytevector (search-result-put-path z))
        (datum->sexp (search-result->datum z))))
 
+(define (query=? x y)
+  (equal? (query->sexp x) (query->sexp y)))
+
 (define (datum=? x y)
   (equal? (datum->sexp x) (datum->sexp y)))
 
 (define (search-result=? x y)
   (equal? (search-result->sexp x) (search-result->sexp y)))
 
+(define (insertion=? x y)
+  (equal? (insertion->sexp x) (insertion->sexp y)))
+
 (define (slice-independent? x y)
   (not (eq? (slice-bv x) (slice-bv y))))
 
+(define (query-independent? x y)
+  (slice-independent? (query-key x) (query-key y)))
+
 (define (datum-independent? x y)
   (and (slice-independent? (datum-key x) (datum-key y))
        (slice-independent? (datum-value x) (datum-value y))))
 
+(define (insertion-independent? x y)
+  (datum-independent? (insertion->datum x) (insertion->datum y)))
+
 (define (search-result-independent? x y)
   (and (datum-independent? (search-result->datum x) (search-result->datum y))
        (slice-independent? (search-result-get-path x)
@@ -258,16 +278,25 @@
        (slice-independent? (search-result-put-path x)
                           (search-result-put-path y))))
 
+(test-assert "copy-query: equal and independent"
+  (let* ((old-key (make-slice/read-write* (sizeof /hashcode:512 '())))
+        (type (random 65536))
+        (desired-replication-level (+ 1 %maximum-replication-level))
+        (old (make-query type old-key))
+        (new (copy-query old)))
+    (and (query=? old new)
+        (query-independent? old new))))
+
 (test-assert "copy-datum: equal and independent"
   ;; A least in Guile 3.0.5, all bytevectors of length 0 are eq?,
   ;; so let the value be non-empty such that datum-independent?
   ;; can return #true.
   (let* ((old-key (make-slice/read-write* (sizeof /hashcode:512 '())))
         (old-value (make-slice/read-write* 70))
-        (old (make-a-datum #:key old-key #:value old-value #:expiration 777)))
-     (let ((new (copy-datum old)))
-      (and (datum=? old new)
-          (datum-independent? old new)))))
+        (old (make-a-datum #:key old-key #:value old-value #:expiration 777))
+        (new (copy-datum old)))
+    (and (datum=? old new)
+        (datum-independent? old new))))
 
 (define (path-length->size l)
   (* l (sizeof /dht:path-element '())))
@@ -277,13 +306,22 @@
   (let* ((old-key (make-slice/read-write* (sizeof /hashcode:512 '())))
         (old-value (make-slice/read-write* 70))
         (old-get-path (make-slice/read-write* (path-length->size 5)))
-        (old-put-path (make-slice/read-write* (path-length->size 9))))
-    (let* ((old-datum (make-a-datum #:value old-value #:expiration 555))
-          (old (datum->search-result old-datum #:get-path old-get-path
-                                     #:put-path old-put-path))
-          (new (copy-search-result old)))
-      (and (search-result=? old new)
-          (search-result-independent? old new)))))
+        (old-put-path (make-slice/read-write* (path-length->size 9)))
+        (old-datum (make-a-datum #:value old-value #:expiration 555))
+        (old (datum->search-result old-datum #:get-path old-get-path
+                                   #:put-path old-put-path))
+        (new (copy-search-result old)))
+    (and (search-result=? old new)
+        (search-result-independent? old new))))
+
+(test-assert "copy-insertion: equal and independent"
+  (let* ((old-value (make-slice/read-write* 71))
+        (old-datum (make-a-datum #:value old-value))
+        (old
+         (datum->insertion old-datum #:desired-replication-level (random 8)))
+        (new (copy-insertion old)))
+    (and (insertion=? old new)
+        (insertion-independent? old new))))
 
 (define-syntax-rule (search-result-get-path-slice-test test-case k)
   (slice-property-test test-case (lambda () k) search-result?

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