Skip to content

Commit

Permalink
chore(sequencer_node): replace run node shell command
Browse files Browse the repository at this point in the history
commit-id:3dd1cf11
  • Loading branch information
Itay-Tsabary-Starkware committed Nov 26, 2024
1 parent 42db010 commit 9617c00
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/starknet_integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ tracing.workspace = true

[dev-dependencies]
futures.workspace = true
infra_utils.workspace = true
pretty_assertions.workspace = true
rstest.workspace = true
starknet_sequencer_infra.workspace = true
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::env;
use std::path::PathBuf;
use std::process::Stdio;
use std::time::Duration;

use infra_utils::command::create_shell_command;
use infra_utils::path::resolve_project_relative_path;
use mempool_test_utils::starknet_api_test_utils::{AccountId, MultiAccountTransactionGenerator};
use papyrus_execution::execution_utils::get_nonce_at;
use papyrus_storage::state::StateStorageReader;
Expand All @@ -14,8 +15,9 @@ use starknet_api::state::StateNumber;
use starknet_integration_tests::integration_test_setup::IntegrationTestSetup;
use starknet_integration_tests::utils::{create_integration_test_tx_generator, send_account_txs};
use starknet_sequencer_infra::trace_util::configure_tracing;
use starknet_sequencer_node::test_utils::compilation::{compile_node_result, NODE_EXECUTABLE_PATH};
use starknet_types_core::felt::Felt;
use tokio::process::{Child, Command};
use tokio::process::Child;
use tokio::task::{self, JoinHandle};
use tokio::time::interval;
use tracing::{error, info};
Expand All @@ -27,19 +29,16 @@ fn tx_generator() -> MultiAccountTransactionGenerator {

// TODO(Tsabary): Move to a suitable util location.
async fn spawn_node_child_task(node_config_path: PathBuf) -> Child {
// Get the current working directory for the project
let project_path = env::current_dir().expect("Failed to get current directory").join("../..");

// TODO(Tsabary): Capture output to a log file, and present it in case of a failure.
// TODO(Tsabary): Change invocation from "cargo run" to separate compilation and invocation
// (build, and then invoke the binary).
Command::new("cargo")
.arg("run")
.arg("--bin")
.arg("starknet_sequencer_node")
.arg("--quiet")
.current_dir(&project_path)
.arg("--")
info!("Compiling the node.");
compile_node_result().await.expect("Failed to compile the sequencer node.");
let node_executable = resolve_project_relative_path(NODE_EXECUTABLE_PATH)
.expect("Node executable should be available")
.to_string_lossy()
.to_string();

info!("Running the node from: {}", node_executable);
create_shell_command(node_executable.as_str())
.arg("--config_file")
.arg(node_config_path.to_str().unwrap())
.stderr(Stdio::inherit())
Expand Down Expand Up @@ -133,7 +132,7 @@ async fn test_end_to_end_integration(mut tx_generator: MultiAccountTransactionGe
let node_run_handle = spawn_run_node(integration_test_setup.node_config_path).await;

// Wait for the node to start.
match integration_test_setup.is_alive_test_client.await_alive(Duration::from_secs(5), 30).await
match integration_test_setup.is_alive_test_client.await_alive(Duration::from_secs(5), 50).await
{
Ok(_) => {}
Err(_) => panic!("Node is not alive."),
Expand Down
7 changes: 6 additions & 1 deletion crates/starknet_sequencer_node/src/test_utils/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::process::{ExitStatus, Stdio};
use infra_utils::command::create_shell_command;
use tracing::info;

pub const NODE_EXECUTABLE_PATH: &str = "target/debug/starknet_sequencer_node";

#[cfg(test)]
#[path = "compilation_test.rs"]
mod compilation_test;
Expand All @@ -18,7 +20,10 @@ pub enum NodeCompilationError {

/// Compiles the node using `cargo build` for testing purposes.
async fn compile_node() -> io::Result<ExitStatus> {
info!("Compiling the starknet_sequencer_node binary");
info!(
"Compiling the starknet_sequencer_node binary, expected destination: \
{NODE_EXECUTABLE_PATH}"
);

// Run `cargo build` to compile the project
let compilation_result = create_shell_command("cargo")
Expand Down

0 comments on commit 9617c00

Please sign in to comment.