Unverified Commit ebbb354b authored by Xiliang Chen's avatar Xiliang Chen Committed by GitHub
Browse files

Fix ArtifactId::path (#3027)



* issue with ArtifactId::path

* fix artifacts path

* Wrap an overly long line

Co-authored-by: default avatarSergei Shulepov <s.pepyakin@gmail.com>
parent d8f6170c
Pipeline #138293 passed with stages
in 29 minutes and 47 seconds
...@@ -82,7 +82,7 @@ impl ArtifactId { ...@@ -82,7 +82,7 @@ impl ArtifactId {
/// Returns the expected path to this artifact given the root of the cache. /// Returns the expected path to this artifact given the root of the cache.
pub fn path(&self, cache_path: &Path) -> PathBuf { 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) cache_path.join(file_name)
} }
} }
...@@ -276,7 +276,10 @@ async fn scan_for_known_artifacts( ...@@ -276,7 +276,10 @@ async fn scan_for_known_artifacts(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use async_std::path::Path;
use super::ArtifactId; use super::ArtifactId;
use sp_core::H256;
use std::str::FromStr;
#[test] #[test]
fn ensure_wasmtime_version() { fn ensure_wasmtime_version() {
...@@ -308,4 +311,15 @@ mod tests { ...@@ -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"),
);
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment