summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Devos <maximedevos@telenet.be>2021-05-08 21:48:20 +0200
committerGuix Patches Tester <>2021-05-08 22:06:27 +0100
commitc7f7405a6f67eb269673d9530439787bc40a02fd (patch)
tree0ca9e64e03b57752b2dda4813b11d90cd4e64378
parentd2a265b08e9cc85465fdd83e9f453b2bf0a40026 (diff)
downloadguix-patches-c7f7405a6f67eb269673d9530439787bc40a02fd.tar
guix-patches-c7f7405a6f67eb269673d9530439787bc40a02fd.tar.gz
tests: networking: Test whether the gateway is usable.series-7880
The IPFS daemon listens at two endpoints. One is called the gateway and the other is called the API. There are some tests for the API, but none yet for the gateway. Test whether data can be read from the gateway. * gnu/tests/networking.scm (run-ipfs-test)[test]{read-contents/gateway}: New procedure, variant of 'read-contents'. (run-ipfs-test)[test]{can upload and download a file to/from ipfs}: Rename to ... (run-ipfs-test)[test]{can upload and download a file to/from ipfs via API} This. (run-ipfs-test)[test]{can download a file from ipfs via gateway}: New test.
-rw-r--r--gnu/tests/networking.scm27
1 files changed, 23 insertions, 4 deletions
diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm
index 453e63f52d..6e759b7679 100644
--- a/gnu/tests/networking.scm
+++ b/gnu/tests/networking.scm
@@ -620,8 +620,21 @@ COMMIT
(close-port input)
all-input)
marionette))
-
- (marionette-eval '(use-modules (guix ipfs)) marionette)
+ (define (read-contents/gateway object)
+ (marionette-eval
+ `(receive (response body)
+ (http-get (string->uri
+ (string-append "http://localhost:8082/ipfs/"
+ ,object))
+ #:decode-body? #f)
+ (list (response-code response) body))
+ marionette))
+ (marionette-eval '(use-modules (guix ipfs)
+ (web client)
+ (web response)
+ (web uri)
+ (srfi srfi-8))
+ marionette)
(mkdir #$output)
(chdir #$output)
@@ -640,9 +653,15 @@ COMMIT
(wait-for-tcp-port default-port marionette)))
(define test-bv (string->utf8 "hello ipfs!"))
- (test-equal "can upload and download a file to/from ipfs"
+ (define test-object (delay (add-data test-bv)))
+
+ (test-equal "can upload and download a file to/from ipfs via API"
test-bv
- (read-contents (add-data test-bv)))
+ (read-contents (force test-object)))
+
+ (test-equal "can download a file from ipfs via gateway"
+ (list 200 test-bv)
+ (read-contents/gateway (force test-object)))
(test-end)
(exit (= (test-runner-fail-count (test-runner-current)) 0)))))