about summary refs log tree commit diff
path: root/third_party/nix/src/nix/hash.cc
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-08-09T04·27-0400
committerglittershark <grfn@gws.fyi>2020-08-09T17·26+0000
commitd1653533a6f6f70d1d95001abf3f80665ba135e7 (patch)
tree35c29ccb38f404848eec2969862c6bd0f0671b43 /third_party/nix/src/nix/hash.cc
parentdfab786653c24b11a8e9338df29c22fd7a0c4959 (diff)
test(tvix): Cover scanForReferences in a test r/1627
Aded a few test cases covering the scanForReferences function, which had
been accidentally broken in 976a36c (which is now partially-reverted).
As part of this, since the test needed to generate hashes for store
paths, the logic in MakeStorePath to compress a sha256 hash down to 20
bytes and convert it to base32 has been extracted to a member function
on the Hash class.

Fixes: #34
Change-Id: Ie2d914688a80f42d0234d351a7cc0714fd15709e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1698
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'third_party/nix/src/nix/hash.cc')
-rw-r--r--third_party/nix/src/nix/hash.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/third_party/nix/src/nix/hash.cc b/third_party/nix/src/nix/hash.cc
index 24529c67ce..08ada7ccfb 100644
--- a/third_party/nix/src/nix/hash.cc
+++ b/third_party/nix/src/nix/hash.cc
@@ -36,8 +36,8 @@ struct CmdHash final : Command {
   void run() override {
     for (const auto& path : paths) {
       Hash h = mode == mFile ? hashFile(ht, path) : hashPath(ht, path).first;
-      if (truncate && h.hashSize > 20) {
-        h = compressHash(h, 20);
+      if (truncate && h.hashSize > nix::kStorePathHashSize) {
+        h = compressHash(h, nix::kStorePathHashSize);
       }
       std::cout << format("%1%\n") % h.to_string(base, base == SRI);
     }