Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix ArtifactId::path #3027

Merged
merged 3 commits into from
May 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion node/core/pvf/src/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl ArtifactId {

/// Returns the expected path to this artifact given the root of the cache.
pub fn path(&self, cache_path: &Path) -> PathBuf {
let file_name = format!("{}{}", Self::PREFIX, self.code_hash.to_string());
let file_name = format!("{}{:#x}", Self::PREFIX, self.code_hash);
cache_path.join(file_name)
}
}
Expand Down Expand Up @@ -276,7 +276,10 @@ async fn scan_for_known_artifacts(

#[cfg(test)]
mod tests {
use async_std::path::Path;
use super::ArtifactId;
use sp_core::H256;
use std::str::FromStr;

#[test]
fn ensure_wasmtime_version() {
Expand Down Expand Up @@ -308,4 +311,15 @@ mod tests {
)),
);
}

#[test]
fn path() {
let path = Path::new("/test");
let hash = H256::from_str("1234567890123456789012345678901234567890123456789012345678901234").unwrap();

assert_eq!(
ArtifactId::new(hash).path(path).to_str(),
Some("/test/wasmtime_1_0x1234567890123456789012345678901234567890123456789012345678901234"),
);
}
}