[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 01/09: fs/client: New client code.
From: |
gnunet |
Subject: |
[gnunet-scheme] 01/09: fs/client: New client code. |
Date: |
Wed, 21 Sep 2022 16:57:15 +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 204f416d4f89784142654a66a86a5b8ca75509f3
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat Sep 10 21:05:02 2022 +0200
fs/client: New client code.
Doesn't support any operations yet ...
* gnu/gnunet/fs/client.scm: New module.
* tests/file-sharing.scm: New tests.
* Makefile (modules,SCM_TESTS): Register new files.
---
Makefile.am | 3 +++
gnu/gnunet/fs/client.scm | 68 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/file-sharing.scm | 34 ++++++++++++++++++++++++
3 files changed, 105 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index f2a6bb1..19d547c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -86,6 +86,8 @@ modules = \
gnu/gnunet/dht/network.scm \
gnu/gnunet/dht/struct.scm \
\
+ gnu/gnunet/fs/client.scm \
+ \
gnu/gnunet/util/cmsg.scm \
gnu/gnunet/util/time.scm \
gnu/gnunet/icmp/struct.scm \
@@ -206,6 +208,7 @@ SCM_TESTS = \
tests/cadet.scm \
tests/crypto.scm \
tests/distributed-hash-table.scm \
+ tests/file-sharing.scm \
tests/form.scm \
tests/lost-and-found.scm \
tests/netstruct.scm \
diff --git a/gnu/gnunet/fs/client.scm b/gnu/gnunet/fs/client.scm
new file mode 100644
index 0000000..33f6aea
--- /dev/null
+++ b/gnu/gnunet/fs/client.scm
@@ -0,0 +1,68 @@
+;#!r6rs
+;; This file is part of Scheme-GNUnet
+;; Copyright © 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
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+;;
+;; Scheme-GNUnet is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; Affero General Public License for more details.
+;;
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;
+;; SPDX-License-Identifier: AGPL-3.0-or-later
+
+;; Author: Maxime Devos
+
+;; TODO: maybe rename to (gnu gnunet file-sharing client),
+;; and likewise for the other services?
+(define-library (gnu gnunet fs client)
+ (export (rename (server:fs? server?))
+ connect disconnect!)
+ (import (only (rnrs base) begin lambda define apply quote)
+ (only (rnrs records syntactic) define-record-type)
+ (only (guile) define*)
+ (only (ice-9 match) match)
+ (only (gnu gnunet mq handler) message-handlers)
+ (only (gnu gnunet server) <server> make-disconnect!
+ spawn-server-loop run-loop loop:terminal-condition
+ handle-control-message!)
+ (only (srfi srfi-26) cut))
+ (begin
+ (define-record-type (<server:fs> make-server:fs server:fs?)
+ (parent <server>)
+ (protocol (lambda (%make) (lambda () ((%make))))))
+
+ (define (make-message-handlers . _)
+ (message-handlers)) ; TODO
+
+ (define (control-message-handler message continue continue* message-queue
+ loop)
+ (define (k/reconnect!)
+ (run-loop loop))
+ (match message
+ (('resend-old-operations!) ; TODO no operations implemented yet
+ (continue loop))
+ (('lost . _)
+ ;; Server became unreachable, disconnect. Tested by the
+ ;; "garbage collectable" test.
+ (continue* '(disconnect!) loop))
+ (rest (handle-control-message! message message-queue
+ (loop:terminal-condition loop)
+ (cut run-loop loop)))))
+
+ (define* (connect config #:key connected disconnected spawn #:rest r)
+ "Connect to the file-sharing service in the background. This is an
+instance of the @code{connect} procedure of the @emph{server object} pattern."
+ (apply spawn-server-loop (make-server:fs)
+ #:make-message-handlers make-message-handlers
+ #:control-message-handler control-message-handler
+ #:configuration config
+ #:service-name "fs" r))
+
+ (define disconnect! (make-disconnect! 'fs server:fs?))))
diff --git a/tests/file-sharing.scm b/tests/file-sharing.scm
new file mode 100644
index 0000000..986db6c
--- /dev/null
+++ b/tests/file-sharing.scm
@@ -0,0 +1,34 @@
+;; This file is part of scheme-GNUnet, a partial Scheme port of GNUnet.
+;; Copyright © 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
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+;;
+;; scheme-GNUnet is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; Affero General Public License for more details.
+;;
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;
+;; SPDX-License-Identifier: AGPL-3.0-or-later
+(define-module (test-file-sharing))
+(import (gnu gnunet fs client)
+ (srfi srfi-64)
+ (tests utils))
+
+(test-begin "file-sharing")
+
+;; Standard tests
+(test-assert "close, not connected --> all fibers stop, no callbacks called"
+ (close-not-connected-no-callbacks "fs" (pk connect) disconnect!))
+(test-assert "garbage collectable"
+ (garbage-collectable "fs" connect))
+(test-assert "notify disconnected after end-of-file, after 'connected'"
+ (disconnect-after-eof-after-connected "fs" connect))
+(test-assert "reconnects"
+ (reconnects "fs" connect))
+(test-end "file-sharing")
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] branch master updated (c0c1dff -> 446af15), gnunet, 2022/09/21
- [gnunet-scheme] 02/09: Move file-sharing modules into gnu/gnunet/fs., gnunet, 2022/09/21
- [gnunet-scheme] 05/09: examples/web: Remove unused procedure 'slice-copy'., gnunet, 2022/09/21
- [gnunet-scheme] 03/09: Makefile.am: Compile and install (gnu gnunet fs uri)., gnunet, 2022/09/21
- [gnunet-scheme] 04/09: bv-slice: Implement slice-copy/bytevector., gnunet, 2022/09/21
- [gnunet-scheme] 08/09: fs/struct: New module., gnunet, 2022/09/21
- [gnunet-scheme] 09/09: fs: Clarify the requesting / responding of a LOC signature., gnunet, 2022/09/21
- [gnunet-scheme] 06/09: hashcode: Drop exception., gnunet, 2022/09/21
- [gnunet-scheme] 01/09: fs/client: New client code.,
gnunet <=
- [gnunet-scheme] 07/09: Merge branches 'fs' (early part) and 'bytevector-slices', gnunet, 2022/09/21