about summary refs log tree commit diff
path: root/tvix/castore
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/castore')
-rw-r--r--tvix/castore/Cargo.toml1
-rw-r--r--tvix/castore/src/fixtures.rs17
-rw-r--r--tvix/castore/src/proto/tests/directory.rs22
3 files changed, 13 insertions, 27 deletions
diff --git a/tvix/castore/Cargo.toml b/tvix/castore/Cargo.toml
index 69da905a8777..573c7daa084f 100644
--- a/tvix/castore/Cargo.toml
+++ b/tvix/castore/Cargo.toml
@@ -36,6 +36,7 @@ tonic-build = "0.10.2"
 test-case = "2.2.2"
 tempfile = "3.3.0"
 tokio-retry = "0.3.0"
+hex-literal = "0.4.1"
 
 [features]
 default = []
diff --git a/tvix/castore/src/fixtures.rs b/tvix/castore/src/fixtures.rs
index ed3d1ca6e855..a206d9b7ddc6 100644
--- a/tvix/castore/src/fixtures.rs
+++ b/tvix/castore/src/fixtures.rs
@@ -9,20 +9,13 @@ pub const EMPTY_BLOB_CONTENTS: &[u8] = b"";
 
 lazy_static! {
     pub static ref DUMMY_DIGEST: B3Digest = {
-        let u: &[u8; 32] = &[
-            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,
-        ];
-        u.into()
+        let u = [0u8; 32];
+        (&u).into()
     };
     pub static ref DUMMY_DIGEST_2: B3Digest = {
-        let u: &[u8; 32] = &[
-            0x10, 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,
-        ];
-        u.into()
+        let mut u = [0u8; 32];
+        u[0] = 0x10;
+        (&u).into()
     };
     pub static ref DUMMY_DATA_1: bytes::Bytes = vec![0x01, 0x02, 0x03].into();
     pub static ref DUMMY_DATA_2: bytes::Bytes = vec![0x04, 0x05].into();
diff --git a/tvix/castore/src/proto/tests/directory.rs b/tvix/castore/src/proto/tests/directory.rs
index 69d9b5b4efe6..d4de19b77114 100644
--- a/tvix/castore/src/proto/tests/directory.rs
+++ b/tvix/castore/src/proto/tests/directory.rs
@@ -1,15 +1,11 @@
 use crate::proto::{
     Directory, DirectoryNode, FileNode, SymlinkNode, ValidateDirectoryError, ValidateNodeError,
 };
-use lazy_static::lazy_static;
 
-lazy_static! {
-    static ref DUMMY_DIGEST: [u8; 32] = [
-        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,
-    ];
-}
+use hex_literal::hex;
+
+const DUMMY_DIGEST: [u8; 32] = [0; 32];
+
 #[test]
 fn size() {
     {
@@ -145,13 +141,9 @@ fn digest() {
 
     assert_eq!(
         d.digest(),
-        vec![
-            0xaf, 0x13, 0x49, 0xb9, 0xf5, 0xf9, 0xa1, 0xa6, 0xa0, 0x40, 0x4d, 0xea, 0x36, 0xdc,
-            0xc9, 0x49, 0x9b, 0xcb, 0x25, 0xc9, 0xad, 0xc1, 0x12, 0xb7, 0xcc, 0x9a, 0x93, 0xca,
-            0xe4, 0x1f, 0x32, 0x62
-        ]
-        .try_into()
-        .unwrap()
+        (&hex!("af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262"))
+            .try_into()
+            .unwrap()
     )
 }