summaryrefslogtreecommitdiff
path: root/tests/substitute.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/substitute.scm')
-rw-r--r--tests/substitute.scm20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/substitute.scm b/tests/substitute.scm
index 10b74db084e..086bd588358 100644
--- a/tests/substitute.scm
+++ b/tests/substitute.scm
@@ -39,6 +39,7 @@
39 #:use-module (rnrs io ports) 39 #:use-module (rnrs io ports)
40 #:use-module (web uri) 40 #:use-module (web uri)
41 #:use-module (ice-9 regex) 41 #:use-module (ice-9 regex)
42 #:use-module (ice-9 binary-ports)
42 #:use-module (srfi srfi-11) 43 #:use-module (srfi srfi-11)
43 #:use-module (srfi srfi-26) 44 #:use-module (srfi srfi-26)
44 #:use-module (srfi srfi-34) 45 #:use-module (srfi srfi-34)
@@ -142,6 +143,21 @@ version identifier.."
142 ;; <https://www.rfc-editor.org/rfc/rfc5737>. 143 ;; <https://www.rfc-editor.org/rfc/rfc5737>.
143 "http://203.0.113.1") 144 "http://203.0.113.1")
144 145
146(define (plain-file-nar-sha256 string)
147 (sha256 (call-with-output-bytevector
148 (lambda (port)
149 (let ((bv (string->utf8 string)))
150 (call-with-input-bytevector
151 bv
152 (lambda (contents)
153 (write-file-tree #t port
154 #:file-type+size
155 (lambda (_)
156 (values 'regular
157 (bytevector-length
158 bv)))
159 #:file-port
160 (const contents)))))))))
145 161
146(define %narinfo 162(define %narinfo
147 ;; Skeleton of the narinfo used below. 163 ;; Skeleton of the narinfo used below.
@@ -150,7 +166,7 @@ version identifier.."
150URL: example.nar 166URL: example.nar
151Compression: none 167Compression: none
152NarHash: sha256:" (bytevector->nix-base32-string 168NarHash: sha256:" (bytevector->nix-base32-string
153 (sha256 (string->utf8 "Substitutable data."))) " 169 (plain-file-nar-sha256 "Substitutable data.")) "
154NarSize: 42 170NarSize: 42
155References: bar baz 171References: bar baz
156Deriver: " (%store-prefix) "/foo.drv 172Deriver: " (%store-prefix) "/foo.drv
@@ -819,7 +835,7 @@ Compression: lzip
819URL: example.nar 835URL: example.nar
820Compression: none 836Compression: none
821NarHash: sha256:" (bytevector->nix-base32-string 837NarHash: sha256:" (bytevector->nix-base32-string
822 (sha256 (string->utf8 "Substitutable data."))) " 838 (plain-file-nar-sha256 "Substitutable data.")) "
823NarSize: 42 839NarSize: 42
824References: bar baz 840References: bar baz
825Deriver: " (%store-prefix) "/foo.drv 841Deriver: " (%store-prefix) "/foo.drv