about summary refs log tree commit diff
path: root/tvix/store
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2022-12-27T16·41+0100
committerflokli <flokli@flokli.de>2022-12-27T21·31+0000
commit35b18b2fdb986aabc1ca22a48c203e2358b1b23e (patch)
tree5bb28940b4900254611c87db6922bb51ff203e0a /tvix/store
parentdfd9286f680ef69ff89ab9a9081b2beaabda92be (diff)
chore(tvix/store): use lazy_static and dummy digests r/5510
While there's currently nothing in here checking the size of the digest,
we should use something that passes the to-be-introduced validate()
function.

Change-Id: I0c515d9e3afc79292dedebce659a32485aa3d936
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7649
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store')
-rw-r--r--tvix/store/Cargo.toml1
-rw-r--r--tvix/store/src/proto.rs12
2 files changed, 11 insertions, 2 deletions
diff --git a/tvix/store/Cargo.toml b/tvix/store/Cargo.toml
index 2e03788067cb..66eac5206363 100644
--- a/tvix/store/Cargo.toml
+++ b/tvix/store/Cargo.toml
@@ -5,6 +5,7 @@ edition = "2021"
 
 [dependencies]
 blake3 = { version = "1.3.1", features = ["rayon", "std"] }
+lazy_static = "1.4.0"
 prost = "0.11.2"
 tonic = "0.8.2"
 
diff --git a/tvix/store/src/proto.rs b/tvix/store/src/proto.rs
index de8095495e58..cee8aeec5472 100644
--- a/tvix/store/src/proto.rs
+++ b/tvix/store/src/proto.rs
@@ -24,7 +24,15 @@ impl Directory {
 #[cfg(test)]
 mod tests {
     use super::{Directory, DirectoryNode, FileNode, SymlinkNode};
+    use lazy_static::lazy_static;
 
+    lazy_static! {
+        static ref DUMMY_DIGEST: Vec<u8> = vec![
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+            0x00, 0x00, 0x00, 0x00,
+        ];
+    }
     #[test]
     fn test_directory_size() {
         {
@@ -51,7 +59,7 @@ mod tests {
             let d = Directory {
                 directories: vec![DirectoryNode {
                     name: String::from("foo"),
-                    digest: vec![],
+                    digest: DUMMY_DIGEST.to_vec(),
                     size: 4,
                 }],
                 files: vec![],
@@ -64,7 +72,7 @@ mod tests {
                 directories: vec![],
                 files: vec![FileNode {
                     name: String::from("foo"),
-                    digest: vec![],
+                    digest: DUMMY_DIGEST.to_vec(),
                     size: 42,
                     executable: false,
                 }],