mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-25 07:05:44 +00:00
PVF: Add worker check during tests and benches (#1771)
This commit is contained in:
@@ -18,8 +18,9 @@
|
||||
use assert_matches::assert_matches;
|
||||
use parity_scale_codec::Encode as _;
|
||||
use polkadot_node_core_pvf::{
|
||||
start, Config, InvalidCandidate, Metrics, PrepareError, PrepareJobKind, PrepareStats,
|
||||
PvfPrepData, ValidationError, ValidationHost, JOB_TIMEOUT_WALL_CLOCK_FACTOR,
|
||||
start, testing::get_and_check_worker_paths, Config, InvalidCandidate, Metrics, PrepareError,
|
||||
PrepareJobKind, PrepareStats, PvfPrepData, ValidationError, ValidationHost,
|
||||
JOB_TIMEOUT_WALL_CLOCK_FACTOR,
|
||||
};
|
||||
use polkadot_parachain_primitives::primitives::{BlockData, ValidationParams, ValidationResult};
|
||||
use polkadot_primitives::ExecutorParams;
|
||||
@@ -50,13 +51,8 @@ impl TestHost {
|
||||
where
|
||||
F: FnOnce(&mut Config),
|
||||
{
|
||||
let mut workers_path = std::env::current_exe().unwrap();
|
||||
workers_path.pop();
|
||||
workers_path.pop();
|
||||
let mut prepare_worker_path = workers_path.clone();
|
||||
prepare_worker_path.push("polkadot-prepare-worker");
|
||||
let mut execute_worker_path = workers_path.clone();
|
||||
execute_worker_path.push("polkadot-execute-worker");
|
||||
let (prepare_worker_path, execute_worker_path) = get_and_check_worker_paths();
|
||||
|
||||
let cache_dir = tempfile::tempdir().unwrap();
|
||||
let mut config = Config::new(
|
||||
cache_dir.path().to_owned(),
|
||||
@@ -296,25 +292,9 @@ async fn deleting_prepared_artifact_does_not_dispute() {
|
||||
let host = TestHost::new();
|
||||
let cache_dir = host.cache_dir.path();
|
||||
|
||||
let result = host
|
||||
.validate_candidate(
|
||||
halt::wasm_binary_unwrap(),
|
||||
ValidationParams {
|
||||
block_data: BlockData(Vec::new()),
|
||||
parent_head: Default::default(),
|
||||
relay_parent_number: 1,
|
||||
relay_parent_storage_root: Default::default(),
|
||||
},
|
||||
Default::default(),
|
||||
)
|
||||
.await;
|
||||
let _stats = host.precheck_pvf(halt::wasm_binary_unwrap(), Default::default()).await.unwrap();
|
||||
|
||||
match result {
|
||||
Err(ValidationError::InvalidCandidate(InvalidCandidate::HardTimeout)) => {},
|
||||
r => panic!("{:?}", r),
|
||||
}
|
||||
|
||||
// Delete the prepared artifact.
|
||||
// Manually delete the prepared artifact from disk. The in-memory artifacts table won't change.
|
||||
{
|
||||
// Get the artifact path (asserting it exists).
|
||||
let mut cache_dir: Vec<_> = std::fs::read_dir(cache_dir).unwrap().collect();
|
||||
@@ -329,7 +309,7 @@ async fn deleting_prepared_artifact_does_not_dispute() {
|
||||
std::fs::remove_file(artifact_path.path()).unwrap();
|
||||
}
|
||||
|
||||
// Try to validate again, artifact should get recreated.
|
||||
// Try to validate, artifact should get recreated.
|
||||
let result = host
|
||||
.validate_candidate(
|
||||
halt::wasm_binary_unwrap(),
|
||||
|
||||
@@ -15,27 +15,21 @@
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use polkadot_node_core_pvf::{
|
||||
testing::{spawn_with_program_path, SpawnErr},
|
||||
testing::{get_and_check_worker_paths, spawn_with_program_path, SpawnErr},
|
||||
SecurityStatus,
|
||||
};
|
||||
use std::{env, time::Duration};
|
||||
|
||||
fn worker_path(name: &str) -> std::path::PathBuf {
|
||||
let mut worker_path = std::env::current_exe().unwrap();
|
||||
worker_path.pop();
|
||||
worker_path.pop();
|
||||
worker_path.push(name);
|
||||
worker_path
|
||||
}
|
||||
|
||||
// Test spawning a program that immediately exits with a failure code.
|
||||
#[tokio::test]
|
||||
async fn spawn_immediate_exit() {
|
||||
let (prepare_worker_path, _) = get_and_check_worker_paths();
|
||||
|
||||
// There's no explicit `exit` subcommand in the worker; it will panic on an unknown
|
||||
// subcommand anyway
|
||||
let result = spawn_with_program_path(
|
||||
"integration-test",
|
||||
worker_path("polkadot-prepare-worker"),
|
||||
prepare_worker_path,
|
||||
&env::temp_dir(),
|
||||
&["exit"],
|
||||
Duration::from_secs(2),
|
||||
@@ -47,9 +41,11 @@ async fn spawn_immediate_exit() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn spawn_timeout() {
|
||||
let (_, execute_worker_path) = get_and_check_worker_paths();
|
||||
|
||||
let result = spawn_with_program_path(
|
||||
"integration-test",
|
||||
worker_path("polkadot-execute-worker"),
|
||||
execute_worker_path,
|
||||
&env::temp_dir(),
|
||||
&["test-sleep"],
|
||||
Duration::from_secs(2),
|
||||
@@ -61,9 +57,11 @@ async fn spawn_timeout() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn should_connect() {
|
||||
let (prepare_worker_path, _) = get_and_check_worker_paths();
|
||||
|
||||
let _ = spawn_with_program_path(
|
||||
"integration-test",
|
||||
worker_path("polkadot-prepare-worker"),
|
||||
prepare_worker_path,
|
||||
&env::temp_dir(),
|
||||
&["prepare-worker"],
|
||||
Duration::from_secs(2),
|
||||
|
||||
Reference in New Issue
Block a user