mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 13:23:13 +00:00
Scaffold shared node modules and deduplicate binary resolution
This commit is contained in:
parent
a5e6ebf5e6
commit
b1ee4b5898
4
testing-framework/core/src/nodes/common/api/client.rs
Normal file
4
testing-framework/core/src/nodes/common/api/client.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Shared API client wrappers (placeholder).
|
||||
pub struct SharedApiClient;
|
||||
2
testing-framework/core/src/nodes/common/api/mod.rs
Normal file
2
testing-framework/core/src/nodes/common/api/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod client;
|
||||
pub mod proxy;
|
||||
4
testing-framework/core/src/nodes/common/api/proxy.rs
Normal file
4
testing-framework/core/src/nodes/common/api/proxy.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Shared API proxy helpers (placeholder).
|
||||
pub struct ApiProxy;
|
||||
35
testing-framework/core/src/nodes/common/binary.rs
Normal file
35
testing-framework/core/src/nodes/common/binary.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
pub struct BinaryConfig {
|
||||
pub env_var: &'static str,
|
||||
pub binary_name: &'static str,
|
||||
pub fallback_path: &'static str,
|
||||
pub shared_bin_subpath: &'static str,
|
||||
}
|
||||
|
||||
pub struct BinaryResolver;
|
||||
|
||||
impl BinaryResolver {
|
||||
pub fn resolve_path(config: &BinaryConfig) -> PathBuf {
|
||||
if let Some(path) = env::var_os(config.env_var) {
|
||||
return PathBuf::from(path);
|
||||
}
|
||||
if let Some(path) = Self::which_on_path(config.binary_name) {
|
||||
return path;
|
||||
}
|
||||
let shared_bin = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(config.shared_bin_subpath);
|
||||
if shared_bin.exists() {
|
||||
return shared_bin;
|
||||
}
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../")
|
||||
.join(config.fallback_path)
|
||||
}
|
||||
|
||||
fn which_on_path(bin: &str) -> Option<PathBuf> {
|
||||
let path_env = env::var_os("PATH")?;
|
||||
env::split_paths(&path_env)
|
||||
.map(|p| p.join(bin))
|
||||
.find(|candidate| candidate.is_file())
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Shared cryptarchia/IBD config injection utilities (placeholder).
|
||||
pub struct CryptarchiaConfigInjector;
|
||||
3
testing-framework/core/src/nodes/common/config/mod.rs
Normal file
3
testing-framework/core/src/nodes/common/config/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub mod injection;
|
||||
pub mod paths;
|
||||
pub mod validation;
|
||||
4
testing-framework/core/src/nodes/common/config/paths.rs
Normal file
4
testing-framework/core/src/nodes/common/config/paths.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Shared config path helpers (placeholder).
|
||||
pub struct RecoveryPathsSetup;
|
||||
@ -0,0 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Shared config validation helpers (placeholder).
|
||||
pub struct ConfigValidator;
|
||||
@ -0,0 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Shared cleanup helpers (placeholder).
|
||||
pub struct CleanupManager;
|
||||
3
testing-framework/core/src/nodes/common/lifecycle/mod.rs
Normal file
3
testing-framework/core/src/nodes/common/lifecycle/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub mod cleanup;
|
||||
pub mod monitor;
|
||||
pub mod spawn;
|
||||
@ -0,0 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Shared monitoring helpers (placeholder).
|
||||
pub struct Monitor;
|
||||
@ -0,0 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
/// Shared spawn helpers (placeholder).
|
||||
pub struct SpawnManager;
|
||||
4
testing-framework/core/src/nodes/common/mod.rs
Normal file
4
testing-framework/core/src/nodes/common/mod.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub mod api;
|
||||
pub mod binary;
|
||||
pub mod config;
|
||||
pub mod lifecycle;
|
||||
@ -1,6 +1,5 @@
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
env,
|
||||
path::PathBuf,
|
||||
process::{Child, Command, Stdio},
|
||||
time::Duration,
|
||||
@ -26,33 +25,24 @@ use serde_yaml::{Mapping, Number as YamlNumber, Value};
|
||||
pub use testing_framework_config::nodes::executor::create_executor_config;
|
||||
|
||||
use super::{ApiClient, create_tempdir, persist_tempdir, should_persist_tempdir};
|
||||
use crate::{IS_DEBUG_TRACING, adjust_timeout, nodes::LOGS_PREFIX};
|
||||
use crate::{
|
||||
IS_DEBUG_TRACING, adjust_timeout,
|
||||
nodes::{
|
||||
LOGS_PREFIX,
|
||||
common::binary::{BinaryConfig, BinaryResolver},
|
||||
},
|
||||
};
|
||||
|
||||
const BIN_PATH: &str = "target/debug/nomos-executor";
|
||||
|
||||
fn binary_path() -> PathBuf {
|
||||
if let Some(path) = env::var_os("NOMOS_EXECUTOR_BIN") {
|
||||
return PathBuf::from(path);
|
||||
}
|
||||
if let Some(path) = which_on_path("nomos-executor") {
|
||||
return path;
|
||||
}
|
||||
// Default to the shared bin staging area; fall back to workspace target.
|
||||
let shared_bin = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../testing-framework/assets/stack/bin/nomos-executor");
|
||||
if shared_bin.exists() {
|
||||
return shared_bin;
|
||||
}
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../")
|
||||
.join(BIN_PATH)
|
||||
}
|
||||
|
||||
fn which_on_path(bin: &str) -> Option<PathBuf> {
|
||||
let path_env = env::var_os("PATH")?;
|
||||
env::split_paths(&path_env)
|
||||
.map(|p| p.join(bin))
|
||||
.find(|candidate| candidate.is_file())
|
||||
let cfg = BinaryConfig {
|
||||
env_var: "NOMOS_EXECUTOR_BIN",
|
||||
binary_name: "nomos-executor",
|
||||
fallback_path: BIN_PATH,
|
||||
shared_bin_subpath: "testing-framework/assets/stack/bin/nomos-executor",
|
||||
};
|
||||
BinaryResolver::resolve_path(&cfg)
|
||||
}
|
||||
|
||||
pub struct Executor {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
mod api_client;
|
||||
pub mod common;
|
||||
pub mod executor;
|
||||
pub mod validator;
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
env,
|
||||
path::PathBuf,
|
||||
process::{Child, Command, Stdio},
|
||||
time::Duration,
|
||||
@ -25,33 +24,24 @@ use tokio::time::error::Elapsed;
|
||||
use tx_service::MempoolMetrics;
|
||||
|
||||
use super::{ApiClient, create_tempdir, persist_tempdir, should_persist_tempdir};
|
||||
use crate::{IS_DEBUG_TRACING, adjust_timeout, nodes::LOGS_PREFIX};
|
||||
use crate::{
|
||||
IS_DEBUG_TRACING, adjust_timeout,
|
||||
nodes::{
|
||||
LOGS_PREFIX,
|
||||
common::binary::{BinaryConfig, BinaryResolver},
|
||||
},
|
||||
};
|
||||
|
||||
const BIN_PATH: &str = "target/debug/nomos-node";
|
||||
|
||||
fn binary_path() -> PathBuf {
|
||||
if let Some(path) = env::var_os("NOMOS_NODE_BIN") {
|
||||
return PathBuf::from(path);
|
||||
}
|
||||
if let Some(path) = which_on_path("nomos-node") {
|
||||
return path;
|
||||
}
|
||||
// Default to the shared bin staging area; fall back to workspace target.
|
||||
let shared_bin = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../testing-framework/assets/stack/bin/nomos-node");
|
||||
if shared_bin.exists() {
|
||||
return shared_bin;
|
||||
}
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../")
|
||||
.join(BIN_PATH)
|
||||
}
|
||||
|
||||
fn which_on_path(bin: &str) -> Option<PathBuf> {
|
||||
let path_env = env::var_os("PATH")?;
|
||||
env::split_paths(&path_env)
|
||||
.map(|p| p.join(bin))
|
||||
.find(|candidate| candidate.is_file())
|
||||
let cfg = BinaryConfig {
|
||||
env_var: "NOMOS_NODE_BIN",
|
||||
binary_name: "nomos-node",
|
||||
fallback_path: BIN_PATH,
|
||||
shared_bin_subpath: "testing-framework/assets/stack/bin/nomos-node",
|
||||
};
|
||||
BinaryResolver::resolve_path(&cfg)
|
||||
}
|
||||
|
||||
pub enum Pool {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user