[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] branch master updated: dht/client: Verify that 'start-ge
From: |
gnunet |
Subject: |
[gnunet-scheme] branch master updated: dht/client: Verify that 'start-get!' can be called from callbacks. |
Date: |
Mon, 14 Feb 2022 21:10:05 +0100 |
This is an automated email from the git hooks/post-receive script.
maxime-devos pushed a commit to branch master
in repository gnunet-scheme.
The following commit(s) were added to refs/heads/master by this push:
new a5e9d35 dht/client: Verify that 'start-get!' can be called from
callbacks.
a5e9d35 is described below
commit a5e9d35f43cdfc29b2a17d512458776bf931f075
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Fri Feb 11 21:00:33 2022 +0000
dht/client: Verify that 'start-get!' can be called from callbacks.
* tests/distributed-hash-table.scm ("search callback re-entrancy"):
New test.
---
tests/distributed-hash-table.scm | 48 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/tests/distributed-hash-table.scm b/tests/distributed-hash-table.scm
index 79c7592..9e2453b 100644
--- a/tests/distributed-hash-table.scm
+++ b/tests/distributed-hash-table.scm
@@ -29,6 +29,7 @@
(gnu gnunet utils hat-let)
(gnu gnunet util struct)
(gnu gnunet netstruct syntactic)
+ (only (gnu gnunet netstruct procedural) u64/big)
(gnu gnunet hashcode struct)
(gnu gnunet block)
(gnu gnunet message protocols)
@@ -709,4 +710,51 @@ supported."
;; TODO: would be nice to test that old requests are submitted again
+;; The aim is to show that the search callback can start search requests
+;; of its own without any problems. While we're at it, the search results
+;; are verified.
+;;
+;; First 'loop' searches for key 0, then for key 1 inside the search result
+;; callback, etc.
+(test-assert "search callback re-entrancy"
+ (call-with-services/fibers
+ `(("dht" . ,(simulate-dht-service)))
+ (lambda (config spawn-fiber)
+ (define server (connect config))
+ (define ROUNDS 20)
+ (define type 0) ; arbitrary
+ (define (make-a-query round)
+ (define key (make-slice/read-write (sizeof /hashcode:512 '())))
+ (slice-u64-set! key 0 round (endianness big))
+ (make-query type key))
+ (define (value round)
+ (expt 2 round))
+ (define done (make-condition))
+ (let loop ((round 0))
+ (define found? #false)
+ (if (< round ROUNDS)
+ (start-get! server (make-a-query round)
+ (lambda (search-result)
+ (define d (search-result->datum search-result))
+ (assert (= round
+ (slice-u64-ref (datum-key d) 0
+ (endianness big))))
+ (assert (= (value round)
+ (slice-u64-ref (datum-value d) 0
+ (endianness big))))
+ (assert (not found?))
+ (set! found? #true)
+ (loop (+ round 1))))
+ (signal-condition! done)))
+ (let loop ((round 0))
+ (define key-s (make-slice/read-write (sizeof /hashcode:512 '())))
+ (define value-s (make-slice/read-write (sizeof u64/big '())))
+ (slice-u64-set! key-s 0 round (endianness big))
+ (slice-u64-set! value-s 0 (value round) (endianness big))
+ (put! server (datum->insertion (make-datum type key-s value-s)))
+ (when (< round (- ROUNDS 1))
+ (loop (+ round 1))))
+ (wait done)
+ #true)))
+
(test-end)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet-scheme] branch master updated: dht/client: Verify that 'start-get!' can be called from callbacks.,
gnunet <=