[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 02/04: tests/distributed-hash-table: Test 'copy-insertio
From: |
gnunet |
Subject: |
[gnunet-scheme] 02/04: tests/distributed-hash-table: Test 'copy-insertion'. |
Date: |
Thu, 03 Feb 2022 13:52:32 +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.
commit 1fa54f05d44d3083cd7c0d28443d6ff3e801e047
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Thu Feb 3 11:58:13 2022 +0000
tests/distributed-hash-table: Test 'copy-insertion'.
* tests/distributed-hash-table.scm
(insertion->sexp,insertion=?,insertion-independent?): New procedures.
("copy-insertion: equal and independent"): New test.
---
tests/distributed-hash-table.scm | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tests/distributed-hash-table.scm b/tests/distributed-hash-table.scm
index 7f3c6f2..9f84a29 100644
--- a/tests/distributed-hash-table.scm
+++ b/tests/distributed-hash-table.scm
@@ -233,6 +233,10 @@
(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))
@@ -244,6 +248,9 @@
(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))))
@@ -251,6 +258,9 @@
(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)
@@ -285,6 +295,15 @@
(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?
(lambda (s) (datum->search-result (make-a-datum)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.