1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (test-ipfs)
20 #:use-module (guix ipfs)
21 #:use-module ((guix utils) #:select (call-with-temporary-directory))
22 #:use-module (guix tests)
23 #:use-module (web uri)
24 #:use-module (srfi srfi-64))
26 ;; Test the (guix ipfs) module.
28 (define (ipfs-gateway-running?)
29 "Return true if the IPFS gateway is running at %IPFS-BASE-URL."
30 (let* ((uri (string->uri (%ipfs-base-url)))
31 (socket (socket AF_INET SOCK_STREAM 0)))
35 (format (current-error-port)
36 "probing IPFS gateway at localhost:~a...~%"
38 (connect socket AF_INET INADDR_LOOPBACK (uri-port uri))
45 (unless (ipfs-gateway-running?)
48 (test-assert "add-file-tree + restore-file-tree"
49 (call-with-temporary-directory
51 (let* ((source (dirname (search-path %load-path "guix/base32.scm")))
52 (target (string-append directory "/r"))
53 (content (pk 'content (add-file-tree source))))
54 (restore-file-tree (content-name content) target)
55 (file=? source target)))))