From d1653533a6f6f70d1d95001abf3f80665ba135e7 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 9 Aug 2020 00:27:55 -0400 Subject: test(tvix): Cover scanForReferences in a test 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 --- third_party/nix/src/libutil/hash.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'third_party/nix/src/libutil/hash.cc') diff --git a/third_party/nix/src/libutil/hash.cc b/third_party/nix/src/libutil/hash.cc index 426096e73af8..9d14ad9dfe14 100644 --- a/third_party/nix/src/libutil/hash.cc +++ b/third_party/nix/src/libutil/hash.cc @@ -158,6 +158,10 @@ bool Hash::IsValidBase32(absl::string_view s) { return true; } +std::string Hash::ToStorePathHash() const { + return compressHash(*this, kStorePathHashSize).to_string(Base32, false); +} + static std::string printHash32(const Hash& hash) { assert(hash.hashSize); size_t len = hash.base32Len(); -- cgit 1.4.1