Scaffold shared node modules and deduplicate binary resolution

This commit is contained in:
andrussal 2025-12-10 13:13:19 +01:00
parent a5e6ebf5e6
commit b1ee4b5898
16 changed files with 108 additions and 48 deletions

View File

@ -0,0 +1,4 @@
#![allow(dead_code)]
/// Shared API client wrappers (placeholder).
pub struct SharedApiClient;

View File

@ -0,0 +1,2 @@
pub mod client;
pub mod proxy;

View File

@ -0,0 +1,4 @@
#![allow(dead_code)]
/// Shared API proxy helpers (placeholder).
pub struct ApiProxy;

View 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())
}
}

View File

@ -0,0 +1,4 @@
#![allow(dead_code)]
/// Shared cryptarchia/IBD config injection utilities (placeholder).
pub struct CryptarchiaConfigInjector;

View File

@ -0,0 +1,3 @@
pub mod injection;
pub mod paths;
pub mod validation;

View File

@ -0,0 +1,4 @@
#![allow(dead_code)]
/// Shared config path helpers (placeholder).
pub struct RecoveryPathsSetup;

View File

@ -0,0 +1,4 @@
#![allow(dead_code)]
/// Shared config validation helpers (placeholder).
pub struct ConfigValidator;

View File

@ -0,0 +1,4 @@
#![allow(dead_code)]
/// Shared cleanup helpers (placeholder).
pub struct CleanupManager;

View File

@ -0,0 +1,3 @@
pub mod cleanup;
pub mod monitor;
pub mod spawn;

View File

@ -0,0 +1,4 @@
#![allow(dead_code)]
/// Shared monitoring helpers (placeholder).
pub struct Monitor;

View File

@ -0,0 +1,4 @@
#![allow(dead_code)]
/// Shared spawn helpers (placeholder).
pub struct SpawnManager;

View File

@ -0,0 +1,4 @@
pub mod api;
pub mod binary;
pub mod config;
pub mod lifecycle;

View File

@ -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 {

View File

@ -1,4 +1,5 @@
mod api_client;
pub mod common;
pub mod executor;
pub mod validator;

View File

@ -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 {