From c89af03a030b8447954d17972ce6f64fb6d42f57 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 6 Jan 2023 16:27:27 +0100 Subject: refactor(tvix/store): rename NixPath to StorePath As discussed in #tvl, this is a more common term for it. Change-Id: I9b904222b8c076f82192c9b7f0b42be171614ab7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7776 Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/derivation/src/derivation.rs | 14 +-- tvix/derivation/src/output.rs | 4 +- tvix/derivation/src/tests/mod.rs | 6 +- tvix/derivation/src/validate.rs | 6 +- tvix/store/src/lib.rs | 2 +- tvix/store/src/nixbase32.rs | 4 +- tvix/store/src/nixpath.rs | 193 -------------------------------------- tvix/store/src/proto.rs | 18 ++-- tvix/store/src/store_path.rs | 193 ++++++++++++++++++++++++++++++++++++++ tvix/store/src/tests/pathinfo.rs | 25 ++--- 10 files changed, 234 insertions(+), 231 deletions(-) delete mode 100644 tvix/store/src/nixpath.rs create mode 100644 tvix/store/src/store_path.rs diff --git a/tvix/derivation/src/derivation.rs b/tvix/derivation/src/derivation.rs index 2afe672e2e9b..bf26e1baac69 100644 --- a/tvix/derivation/src/derivation.rs +++ b/tvix/derivation/src/derivation.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use std::{collections::BTreeMap, fmt, fmt::Write}; use tvix_store::nixbase32::NIXBASE32; -use tvix_store::nixpath::{NixPath, ParseNixPathError, STORE_DIR}; +use tvix_store::nixpath::{ParseStorePathError, StorePath, STORE_DIR}; #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub struct Derivation { @@ -34,10 +34,10 @@ fn build_store_path( is_derivation: bool, path_hash: &[u8], name: &str, -) -> Result { +) -> Result { let compressed = nix_hash::compress_hash(path_hash, 20); if is_derivation { - NixPath::from_string( + StorePath::from_string( format!( "{}-{}{}", NIXBASE32.encode(&compressed), @@ -47,7 +47,7 @@ fn build_store_path( .as_str(), ) } else { - NixPath::from_string(format!("{}-{}", NIXBASE32.encode(&compressed), name,).as_str()) + StorePath::from_string(format!("{}-{}", NIXBASE32.encode(&compressed), name,).as_str()) } } @@ -105,8 +105,8 @@ impl Derivation { /// - Write the .drv A-Term contents to a hash function /// - Take the digest, run hash.CompressHash(digest, 20) on it. /// - Encode it with nixbase32 - /// - Use it (and the name) to construct a NixPath. - pub fn calculate_derivation_path(&self, name: &str) -> Result { + /// - Use it (and the name) to construct a [StorePath]. + pub fn calculate_derivation_path(&self, name: &str) -> Result { let mut hasher = Sha256::new(); // collect the list of paths from input_sources and input_derivations @@ -223,7 +223,7 @@ impl Derivation { &mut self, name: &str, drv_replacement_str: &str, - ) -> Result<(), ParseNixPathError> { + ) -> Result<(), ParseStorePathError> { let mut hasher = Sha256::new(); // Check if the Derivation is fixed output, because they cause diff --git a/tvix/derivation/src/output.rs b/tvix/derivation/src/output.rs index b038f6b5fc6d..02ba7e42e885 100644 --- a/tvix/derivation/src/output.rs +++ b/tvix/derivation/src/output.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use tvix_store::nixpath::NixPath; +use tvix_store::nixpath::StorePath; #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub struct Output { @@ -23,7 +23,7 @@ impl Output { } pub fn validate(&self) -> anyhow::Result<()> { - NixPath::from_absolute_path(&self.path)?; + StorePath::from_absolute_path(&self.path)?; Ok(()) } } diff --git a/tvix/derivation/src/tests/mod.rs b/tvix/derivation/src/tests/mod.rs index 700a25860571..8d1771f711f6 100644 --- a/tvix/derivation/src/tests/mod.rs +++ b/tvix/derivation/src/tests/mod.rs @@ -6,7 +6,7 @@ use std::io::Read; use std::path::Path; use test_case::test_case; use test_generator::test_resources; -use tvix_store::nixpath::NixPath; +use tvix_store::nixpath::StorePath; const RESOURCES_PATHS: &str = "src/tests/derivation_tests"; @@ -66,7 +66,7 @@ fn derivation_path(name: &str, expected_path: &str) { assert_eq!( derivation.calculate_derivation_path(name).unwrap(), - NixPath::from_string(expected_path).unwrap() + StorePath::from_string(expected_path).unwrap() ); } @@ -309,7 +309,7 @@ fn output_path_construction() { assert_eq!(foo_drv_expected, foo_drv); assert_eq!( - NixPath::from_string("4wvvbi4jwn0prsdxb7vs673qa5h9gr7x-foo.drv").expect("must succeed"), + StorePath::from_string("4wvvbi4jwn0prsdxb7vs673qa5h9gr7x-foo.drv").expect("must succeed"), foo_drv .calculate_derivation_path("foo") .expect("must succeed") diff --git a/tvix/derivation/src/validate.rs b/tvix/derivation/src/validate.rs index e0f62a323fcf..4e0503833913 100644 --- a/tvix/derivation/src/validate.rs +++ b/tvix/derivation/src/validate.rs @@ -1,6 +1,6 @@ use crate::{derivation::Derivation, write::DOT_FILE_EXT}; use anyhow::bail; -use tvix_store::nixpath::NixPath; +use tvix_store::nixpath::StorePath; impl Derivation { /// validate ensures a Derivation struct is properly populated, @@ -35,7 +35,7 @@ impl Derivation { // Validate all input_derivations for (input_derivation_path, output_names) in &self.input_derivations { // Validate input_derivation_path - NixPath::from_absolute_path(input_derivation_path)?; + StorePath::from_absolute_path(input_derivation_path)?; if !input_derivation_path.ends_with(DOT_FILE_EXT) { bail!( "derivation {} does not end with .drv", @@ -70,7 +70,7 @@ impl Derivation { // Validate all input_sources for (i, input_source) in self.input_sources.iter().enumerate() { - NixPath::from_absolute_path(input_source)?; + StorePath::from_absolute_path(input_source)?; if i > 0 && self.input_sources[i - 1] >= *input_source { bail!( diff --git a/tvix/store/src/lib.rs b/tvix/store/src/lib.rs index de1cd6557331..642d285990dd 100644 --- a/tvix/store/src/lib.rs +++ b/tvix/store/src/lib.rs @@ -1,6 +1,6 @@ pub mod nixbase32; -pub mod nixpath; pub mod proto; +pub mod store_path; pub mod dummy_blob_service; pub mod dummy_directory_service; diff --git a/tvix/store/src/nixbase32.rs b/tvix/store/src/nixbase32.rs index 78a90f605507..913e60714b47 100644 --- a/tvix/store/src/nixbase32.rs +++ b/tvix/store/src/nixbase32.rs @@ -72,7 +72,7 @@ mod tests { // #[test_case("0z", vec![0x1f]; "one byte")] #[test_case("00bgd045z0d4icpbc2yyz4gx48ak44la", vec![ 0x8a, 0x12, 0x32, 0x15, 0x22, 0xfd, 0x91, 0xef, 0xbd, 0x60, 0xeb, 0xb2, 0x48, 0x1a, - 0xf8, 0x85, 0x80, 0xf6, 0x16, 0x00]; "nixpath")] + 0xf8, 0x85, 0x80, 0xf6, 0x16, 0x00]; "store path")] fn encode(enc: &str, dec: Vec) { assert_eq!(enc, NIXBASE32.encode(&dec)); } @@ -83,7 +83,7 @@ mod tests { // #[test_case("0z", Some(vec![0x1f]); "one byte")] #[test_case("00bgd045z0d4icpbc2yyz4gx48ak44la", Some(vec![ 0x8a, 0x12, 0x32, 0x15, 0x22, 0xfd, 0x91, 0xef, 0xbd, 0x60, 0xeb, 0xb2, 0x48, 0x1a, - 0xf8, 0x85, 0x80, 0xf6, 0x16, 0x00]); "nixpath")] + 0xf8, 0x85, 0x80, 0xf6, 0x16, 0x00]); "store path")] // this is invalid encoding, because it encodes 10 1-bytes, so the carry // would be 2 1-bytes #[test_case("zz", None; "invalid encoding-1")] diff --git a/tvix/store/src/nixpath.rs b/tvix/store/src/nixpath.rs deleted file mode 100644 index 54b964e83f04..000000000000 --- a/tvix/store/src/nixpath.rs +++ /dev/null @@ -1,193 +0,0 @@ -use crate::nixbase32::NIXBASE32; -use data_encoding::DecodeError; -use std::fmt; -use thiserror::Error; - -pub const DIGEST_SIZE: usize = 20; -// lazy_static doesn't allow us to call NIXBASE32.encode_len(), so we ran it -// manually and have an assert in the tests. -pub const ENCODED_DIGEST_SIZE: usize = 32; - -// The store dir prefix, without trailing slash. -// That's usually where the Nix store is mounted at. -pub const STORE_DIR: &str = "/nix/store"; -pub const STORE_DIR_WITH_SLASH: &str = "/nix/store/"; - -/// Errors that can occur during the validation of name characters. -#[derive(Debug, PartialEq, Eq, Error)] -pub enum ParseNixPathError { - #[error("Dash is missing")] - MissingDash(), - #[error("Hash encoding is invalid {0}")] - InvalidHashEncoding(DecodeError), - #[error("Invalid name {0}")] - InvalidName(String), - #[error("Tried to parse an absolute path which was missing the store dir prefix.")] - MissingStoreDir(), -} - -#[derive(Debug, PartialEq, Eq)] -pub struct NixPath { - pub digest: [u8; DIGEST_SIZE], - pub name: String, -} - -impl NixPath { - pub fn from_string(s: &str) -> Result { - // the whole string needs to be at least: - // - // - 32 characters (encoded hash) - // - 1 dash - // - 1 character for the name - if s.len() < ENCODED_DIGEST_SIZE + 2 { - return Err(ParseNixPathError::InvalidName("".to_string())); - } - - let digest = match NIXBASE32.decode(s[..ENCODED_DIGEST_SIZE].as_bytes()) { - Ok(decoded) => decoded, - Err(decoder_error) => { - return Err(ParseNixPathError::InvalidHashEncoding(decoder_error)) - } - }; - - if s.as_bytes()[ENCODED_DIGEST_SIZE] != b'-' { - return Err(ParseNixPathError::MissingDash()); - } - - NixPath::validate_characters(&s[ENCODED_DIGEST_SIZE + 2..])?; - - Ok(NixPath { - name: s[ENCODED_DIGEST_SIZE + 1..].to_string(), - digest: digest.try_into().expect("size is known"), - }) - } - - /// Construct a NixPath from an absolute store path string. - /// That is a string starting with the store prefix (/nix/store) - pub fn from_absolute_path(s: &str) -> Result { - match s.strip_prefix(STORE_DIR_WITH_SLASH) { - Some(s_stripped) => Self::from_string(s_stripped), - None => Err(ParseNixPathError::MissingStoreDir()), - } - } - - // Converts the NixPath to an absolute store path string. - /// That is a string starting with the store prefix (/nix/store) - pub fn to_absolute_path(&self) -> String { - format!("{}/{}", STORE_DIR, self) - } - - fn validate_characters(s: &str) -> Result<(), ParseNixPathError> { - for c in s.chars() { - if c.is_ascii_alphanumeric() - || c == '-' - || c == '_' - || c == '.' - || c == '+' - || c == '?' - || c == '=' - { - continue; - } - - return Err(ParseNixPathError::InvalidName(s.to_string())); - } - - Ok(()) - } -} - -impl fmt::Display for NixPath { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "{}-{}", - crate::nixbase32::NIXBASE32.encode(&self.digest), - self.name - ) - } -} - -#[cfg(test)] -mod tests { - use crate::nixbase32::NIXBASE32; - use crate::nixpath::{DIGEST_SIZE, ENCODED_DIGEST_SIZE}; - - use super::{NixPath, ParseNixPathError}; - - #[test] - fn encoded_digest_size() { - assert_eq!(ENCODED_DIGEST_SIZE, NIXBASE32.encode_len(DIGEST_SIZE)); - } - - #[test] - fn happy_path() { - let example_nix_path_str = - "00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432"; - let nixpath = - NixPath::from_string(&example_nix_path_str).expect("Error parsing example string"); - - let expected_digest: [u8; DIGEST_SIZE] = [ - 0x8a, 0x12, 0x32, 0x15, 0x22, 0xfd, 0x91, 0xef, 0xbd, 0x60, 0xeb, 0xb2, 0x48, 0x1a, - 0xf8, 0x85, 0x80, 0xf6, 0x16, 0x00, - ]; - - assert_eq!("net-tools-1.60_p20170221182432", nixpath.name); - assert_eq!(nixpath.digest, expected_digest); - - assert_eq!(example_nix_path_str, nixpath.to_string()) - } - - #[test] - fn invalid_hash_length() { - NixPath::from_string("00bgd045z0d4icpbc2yy-net-tools-1.60_p20170221182432") - .expect_err("No error raised."); - } - - #[test] - fn invalid_encoding_hash() { - NixPath::from_string("00bgd045z0d4icpbc2yyz4gx48aku4la-net-tools-1.60_p20170221182432") - .expect_err("No error raised."); - } - - #[test] - fn more_than_just_the_bare_nix_store_path() { - NixPath::from_string( - "00bgd045z0d4icpbc2yyz4gx48aku4la-net-tools-1.60_p20170221182432/bin/arp", - ) - .expect_err("No error raised."); - } - - #[test] - fn no_dash_between_hash_and_name() { - NixPath::from_string("00bgd045z0d4icpbc2yyz4gx48ak44lanet-tools-1.60_p20170221182432") - .expect_err("No error raised."); - } - - #[test] - fn absolute_path() { - let example_nix_path_str = - "00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432"; - let nixpath_expected = NixPath::from_string(&example_nix_path_str).expect("must parse"); - - let nixpath_actual = NixPath::from_absolute_path( - "/nix/store/00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432", - ) - .expect("must parse"); - - assert_eq!(nixpath_expected, nixpath_actual); - - assert_eq!( - "/nix/store/00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432", - nixpath_actual.to_absolute_path(), - ); - } - - #[test] - fn absolute_path_missing_prefix() { - assert_eq!( - ParseNixPathError::MissingStoreDir(), - NixPath::from_absolute_path("foobar-123").expect_err("must fail") - ); - } -} diff --git a/tvix/store/src/proto.rs b/tvix/store/src/proto.rs index f2af69ab0dbb..f2dfe1a86d1c 100644 --- a/tvix/store/src/proto.rs +++ b/tvix/store/src/proto.rs @@ -5,7 +5,7 @@ use thiserror::Error; use prost::Message; -use crate::nixpath::{NixPath, ParseNixPathError}; +use crate::store_path::{ParseStorePathError, StorePath}; tonic::include_proto!("tvix.store.v1"); @@ -41,7 +41,7 @@ pub enum ValidatePathInfoError { /// Invalid node name encountered. #[error("{0} is an invalid node name: {1}")] - InvalidNodeName(String, ParseNixPathError), + InvalidNodeName(String, ParseStorePathError), /// The digest the (root) node refers to has invalid length. #[error("Invalid Digest length: {0}")] @@ -76,13 +76,13 @@ fn validate_digest(digest: &Vec, err: fn(usize) -> E) -> Result<(), E> { /// Parses a root node name. /// -/// On success, this returns the parsed [NixPath]. +/// On success, this returns the parsed [StorePath]. /// On error, it returns an error generated from the supplied constructor. fn parse_node_name_root( name: &str, - err: fn(String, ParseNixPathError) -> E, -) -> Result { - match NixPath::from_string(name) { + err: fn(String, ParseStorePathError) -> E, +) -> Result { + match StorePath::from_string(name) { Ok(np) => Ok(np), Err(e) => Err(err(name.to_string(), e)), } @@ -90,9 +90,9 @@ fn parse_node_name_root( impl PathInfo { /// validate performs some checks on the PathInfo struct, - /// Returning either a [NixPath] of the root node, or a + /// Returning either a [StorePath] of the root node, or a /// [ValidatePathInfoError]. - pub fn validate(&self) -> Result { + pub fn validate(&self) -> Result { // If there is a narinfo field populated, ensure the number of references there // matches PathInfo.references count. if let Some(narinfo) = &self.narinfo { @@ -106,7 +106,7 @@ impl PathInfo { // FUTUREWORK: parse references in reference_names. ensure they start // with storeDir, and use the same digest as in self.references. - // Ensure there is a (root) node present, and it properly parses to a NixPath. + // Ensure there is a (root) node present, and it properly parses to a [StorePath]. let root_nix_path = match &self.node { None => { return Err(ValidatePathInfoError::NoNodePresent()); diff --git a/tvix/store/src/store_path.rs b/tvix/store/src/store_path.rs new file mode 100644 index 000000000000..1d767e3519ac --- /dev/null +++ b/tvix/store/src/store_path.rs @@ -0,0 +1,193 @@ +use crate::nixbase32::NIXBASE32; +use data_encoding::DecodeError; +use std::fmt; +use thiserror::Error; + +pub const DIGEST_SIZE: usize = 20; +// lazy_static doesn't allow us to call NIXBASE32.encode_len(), so we ran it +// manually and have an assert in the tests. +pub const ENCODED_DIGEST_SIZE: usize = 32; + +// The store dir prefix, without trailing slash. +// That's usually where the Nix store is mounted at. +pub const STORE_DIR: &str = "/nix/store"; +pub const STORE_DIR_WITH_SLASH: &str = "/nix/store/"; + +/// Errors that can occur during the validation of name characters. +#[derive(Debug, PartialEq, Eq, Error)] +pub enum ParseStorePathError { + #[error("Dash is missing")] + MissingDash(), + #[error("Hash encoding is invalid {0}")] + InvalidHashEncoding(DecodeError), + #[error("Invalid name {0}")] + InvalidName(String), + #[error("Tried to parse an absolute path which was missing the store dir prefix.")] + MissingStoreDir(), +} + +#[derive(Debug, PartialEq, Eq)] +pub struct StorePath { + pub digest: [u8; DIGEST_SIZE], + pub name: String, +} + +impl StorePath { + pub fn from_string(s: &str) -> Result { + // the whole string needs to be at least: + // + // - 32 characters (encoded hash) + // - 1 dash + // - 1 character for the name + if s.len() < ENCODED_DIGEST_SIZE + 2 { + return Err(ParseStorePathError::InvalidName("".to_string())); + } + + let digest = match NIXBASE32.decode(s[..ENCODED_DIGEST_SIZE].as_bytes()) { + Ok(decoded) => decoded, + Err(decoder_error) => { + return Err(ParseStorePathError::InvalidHashEncoding(decoder_error)) + } + }; + + if s.as_bytes()[ENCODED_DIGEST_SIZE] != b'-' { + return Err(ParseStorePathError::MissingDash()); + } + + StorePath::validate_characters(&s[ENCODED_DIGEST_SIZE + 2..])?; + + Ok(StorePath { + name: s[ENCODED_DIGEST_SIZE + 1..].to_string(), + digest: digest.try_into().expect("size is known"), + }) + } + + /// Construct a [StorePath] from an absolute store path string. + /// That is a string starting with the store prefix (/nix/store) + pub fn from_absolute_path(s: &str) -> Result { + match s.strip_prefix(STORE_DIR_WITH_SLASH) { + Some(s_stripped) => Self::from_string(s_stripped), + None => Err(ParseStorePathError::MissingStoreDir()), + } + } + + // Converts the [StorePath] to an absolute store path string. + /// That is a string starting with the store prefix (/nix/store) + pub fn to_absolute_path(&self) -> String { + format!("{}/{}", STORE_DIR, self) + } + + fn validate_characters(s: &str) -> Result<(), ParseStorePathError> { + for c in s.chars() { + if c.is_ascii_alphanumeric() + || c == '-' + || c == '_' + || c == '.' + || c == '+' + || c == '?' + || c == '=' + { + continue; + } + + return Err(ParseStorePathError::InvalidName(s.to_string())); + } + + Ok(()) + } +} + +impl fmt::Display for StorePath { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "{}-{}", + crate::nixbase32::NIXBASE32.encode(&self.digest), + self.name + ) + } +} + +#[cfg(test)] +mod tests { + use crate::nixbase32::NIXBASE32; + use crate::store_path::{DIGEST_SIZE, ENCODED_DIGEST_SIZE}; + + use super::{ParseStorePathError, StorePath}; + + #[test] + fn encoded_digest_size() { + assert_eq!(ENCODED_DIGEST_SIZE, NIXBASE32.encode_len(DIGEST_SIZE)); + } + + #[test] + fn happy_path() { + let example_nix_path_str = + "00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432"; + let nixpath = + StorePath::from_string(&example_nix_path_str).expect("Error parsing example string"); + + let expected_digest: [u8; DIGEST_SIZE] = [ + 0x8a, 0x12, 0x32, 0x15, 0x22, 0xfd, 0x91, 0xef, 0xbd, 0x60, 0xeb, 0xb2, 0x48, 0x1a, + 0xf8, 0x85, 0x80, 0xf6, 0x16, 0x00, + ]; + + assert_eq!("net-tools-1.60_p20170221182432", nixpath.name); + assert_eq!(nixpath.digest, expected_digest); + + assert_eq!(example_nix_path_str, nixpath.to_string()) + } + + #[test] + fn invalid_hash_length() { + StorePath::from_string("00bgd045z0d4icpbc2yy-net-tools-1.60_p20170221182432") + .expect_err("No error raised."); + } + + #[test] + fn invalid_encoding_hash() { + StorePath::from_string("00bgd045z0d4icpbc2yyz4gx48aku4la-net-tools-1.60_p20170221182432") + .expect_err("No error raised."); + } + + #[test] + fn more_than_just_the_bare_nix_store_path() { + StorePath::from_string( + "00bgd045z0d4icpbc2yyz4gx48aku4la-net-tools-1.60_p20170221182432/bin/arp", + ) + .expect_err("No error raised."); + } + + #[test] + fn no_dash_between_hash_and_name() { + StorePath::from_string("00bgd045z0d4icpbc2yyz4gx48ak44lanet-tools-1.60_p20170221182432") + .expect_err("No error raised."); + } + + #[test] + fn absolute_path() { + let example_nix_path_str = + "00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432"; + let nixpath_expected = StorePath::from_string(&example_nix_path_str).expect("must parse"); + + let nixpath_actual = StorePath::from_absolute_path( + "/nix/store/00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432", + ) + .expect("must parse"); + + assert_eq!(nixpath_expected, nixpath_actual); + + assert_eq!( + "/nix/store/00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432", + nixpath_actual.to_absolute_path(), + ); + } + + #[test] + fn absolute_path_missing_prefix() { + assert_eq!( + ParseStorePathError::MissingStoreDir(), + StorePath::from_absolute_path("foobar-123").expect_err("must fail") + ); + } +} diff --git a/tvix/store/src/tests/pathinfo.rs b/tvix/store/src/tests/pathinfo.rs index 8f4e9d399084..a278cf5e8eb0 100644 --- a/tvix/store/src/tests/pathinfo.rs +++ b/tvix/store/src/tests/pathinfo.rs @@ -1,6 +1,6 @@ use crate::{ - nixpath::{NixPath, ParseNixPathError}, proto::{self, Node, PathInfo, ValidatePathInfoError}, + store_path::{ParseStorePathError, StorePath}, }; use lazy_static::lazy_static; use test_case::test_case; @@ -30,7 +30,10 @@ const DUMMY_NAME: &str = "00000000000000000000000000000000-dummy"; Err(ValidatePathInfoError::NoNodePresent()); "No node 2" )] -fn validate_no_node(t_node: Option, t_result: Result) { +fn validate_no_node( + t_node: Option, + t_result: Result, +) { // construct the PathInfo object let p = PathInfo { node: t_node, @@ -45,7 +48,7 @@ fn validate_no_node(t_node: Option, t_result: Result, t_result: Result, + t_result: Result, ) { // construct the PathInfo object let p = PathInfo { @@ -90,7 +93,7 @@ fn validate_directory( size: 0, executable: false, }, - Ok(NixPath::from_string(DUMMY_NAME).expect("must succeed")); + Ok(StorePath::from_string(DUMMY_NAME).expect("must succeed")); "ok" )] #[test_case( @@ -110,11 +113,11 @@ fn validate_directory( }, Err(ValidatePathInfoError::InvalidNodeName( "invalid".to_string(), - ParseNixPathError::InvalidName("".to_string()) + ParseStorePathError::InvalidName("".to_string()) )); "invalid node name" )] -fn validate_file(t_file_node: proto::FileNode, t_result: Result) { +fn validate_file(t_file_node: proto::FileNode, t_result: Result) { // construct the PathInfo object let p = PathInfo { node: Some(Node { @@ -130,7 +133,7 @@ fn validate_file(t_file_node: proto::FileNode, t_result: Result, + t_result: Result, ) { // construct the PathInfo object let p = PathInfo { -- cgit 1.4.1