PVF: Add worker check during tests and benches (#1771)

This commit is contained in:
Marcin S
2023-10-24 16:22:15 +02:00
committed by GitHub
parent 8cba5b90f2
commit e39253c022
19 changed files with 285 additions and 113 deletions
+13
View File
@@ -116,5 +116,18 @@ pub use polkadot_node_core_pvf_common::{
SecurityStatus,
};
use std::{path::Path, process::Command};
/// The log target for this crate.
pub const LOG_TARGET: &str = "parachain::pvf";
/// Utility to get the version of a worker, used for version checks.
///
/// The worker's existence at the given path must be checked separately.
pub fn get_worker_version(worker_path: &Path) -> std::io::Result<String> {
let worker_version = Command::new(worker_path).args(["--version"]).output()?.stdout;
Ok(std::str::from_utf8(&worker_version)
.expect("version is printed as a string; qed")
.trim()
.to_string())
}