mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-13 04:41:11 +00:00
Add a lighthouse node implementation
This commit is contained in:
@@ -79,6 +79,15 @@ impl AsRef<GethConfiguration> for Context {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<LighthouseConfiguration> for Context {
|
||||
fn as_ref(&self) -> &LighthouseConfiguration {
|
||||
match self {
|
||||
Self::ExecuteTests(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<KitchensinkConfiguration> for Context {
|
||||
fn as_ref(&self) -> &KitchensinkConfiguration {
|
||||
match self {
|
||||
@@ -190,6 +199,10 @@ pub struct TestExecutionContext {
|
||||
#[clap(flatten, next_help_heading = "Geth Configuration")]
|
||||
pub geth_configuration: GethConfiguration,
|
||||
|
||||
/// Configuration parameters for the lighthouse node.
|
||||
#[clap(flatten, next_help_heading = "Lighthouse Configuration")]
|
||||
pub lighthouse_configuration: LighthouseConfiguration,
|
||||
|
||||
/// Configuration parameters for the Kitchensink.
|
||||
#[clap(flatten, next_help_heading = "Kitchensink Configuration")]
|
||||
pub kitchensink_configuration: KitchensinkConfiguration,
|
||||
@@ -253,6 +266,12 @@ impl AsRef<GethConfiguration> for TestExecutionContext {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<LighthouseConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &LighthouseConfiguration {
|
||||
&self.lighthouse_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<KitchensinkConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &KitchensinkConfiguration {
|
||||
&self.kitchensink_configuration
|
||||
@@ -335,7 +354,31 @@ pub struct GethConfiguration {
|
||||
#[clap(
|
||||
id = "geth.start-timeout-ms",
|
||||
long = "geth.start-timeout-ms",
|
||||
default_value = "5000",
|
||||
default_value = "30000",
|
||||
value_parser = parse_duration
|
||||
)]
|
||||
pub start_timeout_ms: Duration,
|
||||
}
|
||||
|
||||
/// A set of configuration parameters for lighthouse.
|
||||
#[derive(Clone, Debug, Parser, Serialize)]
|
||||
pub struct LighthouseConfiguration {
|
||||
/// Specifies the path of the lighthouse node to be used by the tool.
|
||||
///
|
||||
/// If this is not specified, then the tool assumes that it should use the lighthouse binary that's
|
||||
/// provided in the user's $PATH.
|
||||
#[clap(
|
||||
id = "lighthouse.path",
|
||||
long = "lighthouse.path",
|
||||
default_value = "lighthouse"
|
||||
)]
|
||||
pub path: PathBuf,
|
||||
|
||||
/// The amount of time to wait upon startup before considering that the node timed out.
|
||||
#[clap(
|
||||
id = "lighthouse.start-timeout-ms",
|
||||
long = "lighthouse.start-timeout-ms",
|
||||
default_value = "30000",
|
||||
value_parser = parse_duration
|
||||
)]
|
||||
pub start_timeout_ms: Duration,
|
||||
@@ -359,7 +402,7 @@ pub struct KitchensinkConfiguration {
|
||||
#[clap(
|
||||
id = "kitchensink.start-timeout-ms",
|
||||
long = "kitchensink.start-timeout-ms",
|
||||
default_value = "5000",
|
||||
default_value = "30000",
|
||||
value_parser = parse_duration
|
||||
)]
|
||||
pub start_timeout_ms: Duration,
|
||||
@@ -387,7 +430,7 @@ pub struct ReviveDevNodeConfiguration {
|
||||
#[clap(
|
||||
id = "revive-dev-node.start-timeout-ms",
|
||||
long = "revive-dev-node.start-timeout-ms",
|
||||
default_value = "5000",
|
||||
default_value = "30000",
|
||||
value_parser = parse_duration
|
||||
)]
|
||||
pub start_timeout_ms: Duration,
|
||||
@@ -407,7 +450,7 @@ pub struct EthRpcConfiguration {
|
||||
#[clap(
|
||||
id = "eth-rpc.start-timeout-ms",
|
||||
long = "eth-rpc.start-timeout-ms",
|
||||
default_value = "5000",
|
||||
default_value = "30000",
|
||||
value_parser = parse_duration
|
||||
)]
|
||||
pub start_timeout_ms: Duration,
|
||||
@@ -431,7 +474,7 @@ pub struct GenesisConfiguration {
|
||||
impl GenesisConfiguration {
|
||||
pub fn genesis(&self) -> anyhow::Result<&Genesis> {
|
||||
static DEFAULT_GENESIS: LazyLock<Genesis> = LazyLock::new(|| {
|
||||
let genesis = include_str!("../../../dev-genesis.json");
|
||||
let genesis = include_str!("../../../assets/dev-genesis.json");
|
||||
serde_json::from_str(genesis).unwrap()
|
||||
});
|
||||
|
||||
@@ -595,6 +638,7 @@ impl AsRef<Path> for WorkingDirectoryConfiguration {
|
||||
impl Default for WorkingDirectoryConfiguration {
|
||||
fn default() -> Self {
|
||||
TempDir::new()
|
||||
.map(|tempdir| dbg!(tempdir.dont_delete_on_drop()))
|
||||
.map(Arc::new)
|
||||
.map(Self::TemporaryDirectory)
|
||||
.expect("Failed to create the temporary directory")
|
||||
|
||||
@@ -6,6 +6,7 @@ use revive_dt_node_interaction::EthereumNode;
|
||||
pub mod common;
|
||||
pub mod constants;
|
||||
pub mod geth;
|
||||
pub mod lighthouse_geth;
|
||||
pub mod process;
|
||||
pub mod substrate;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -93,10 +93,22 @@ impl Process {
|
||||
let mut stdout_lines = BufReader::new(stdout_logs_file).lines();
|
||||
let mut stderr_lines = BufReader::new(stderr_logs_file).lines();
|
||||
|
||||
let mut stdout = String::new();
|
||||
let mut stderr = String::new();
|
||||
|
||||
loop {
|
||||
let stdout_line = stdout_lines.next().and_then(Result::ok);
|
||||
let stderr_line = stderr_lines.next().and_then(Result::ok);
|
||||
|
||||
if let Some(stdout_line) = stdout_line.as_ref() {
|
||||
stdout.push_str(stdout_line);
|
||||
stdout.push('\n');
|
||||
}
|
||||
if let Some(stderr_line) = stderr_line.as_ref() {
|
||||
stderr.push_str(stderr_line);
|
||||
stdout.push('\n');
|
||||
}
|
||||
|
||||
let check_result =
|
||||
check_function(stdout_line.as_deref(), stderr_line.as_deref())
|
||||
.context("Failed to wait for the process to be ready")?;
|
||||
@@ -106,7 +118,9 @@ impl Process {
|
||||
}
|
||||
|
||||
if Instant::now().duration_since(spawn_time) > max_wait_duration {
|
||||
bail!("Waited for the process to start but it failed to start in time")
|
||||
bail!(
|
||||
"Waited for the process to start but it failed to start in time. stderr {stderr} - stdout {stdout}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user