Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
commit-id:4d9607d8
  • Loading branch information
Itay-Tsabary-Starkware committed Nov 24, 2024
1 parent 6252b51 commit 5b402c9
Show file tree
Hide file tree
Showing 4 changed files with 51 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
Expand Up @@ -3,6 +3,7 @@ use std::path::PathBuf;
use std::process::Stdio;
use std::time::Duration;

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,6 +15,7 @@ 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;
use starknet_types_core::felt::Felt;
use tokio::process::{Child, Command};
use tokio::task::{self, JoinHandle};
Expand All @@ -28,25 +30,53 @@ 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")
// let project_path = env::current_dir().expect("Failed to get current
// directory").join("../..");

let compile_result = compile_node_result();
info!("Compilation result {:?}.", compile_result);

assert!(compile_result.is_ok(), "Compilation failed.");
// let compilation_result = Command::new("cargo")
// .arg("build")
// .arg("--bin")
// .arg("starknet_sequencer_node")
// .arg("--quiet")
// .current_dir(&project_path)
// .status().await;

info!("Compiling the starknet_sequencer_node binary");
let project_path = resolve_project_relative_path(".").expect("Failed to resolve project path");
info!("project_path {:?}", project_path);

// Run `cargo build` to compile the project
Command::new("target/debug/starknet_sequencer_node")
.current_dir(&project_path)
.arg("--")
.arg("--config_file")
.arg(node_config_path.to_str().unwrap())
.stderr(Stdio::inherit())
.stdout(Stdio::null())
.kill_on_drop(true) // Required for stopping the node when the handle is dropped.
.spawn()
.expect("Failed to spawn the sequencer node.")

// // 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("--")
// .arg("--config_file")
// .arg(node_config_path.to_str().unwrap())
// .stderr(Stdio::inherit())
// .stdout(Stdio::null())
// .kill_on_drop(true) // Required for stopping the node when the handle is dropped.
// .spawn()
// .expect("Failed to spawn the sequencer node.")
}

async fn spawn_run_node(node_config_path: PathBuf) -> JoinHandle<()> {
Expand Down
13 changes: 8 additions & 5 deletions crates/starknet_sequencer_node/src/test_utils/compilation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::io;
use std::process::{Command, ExitStatus, Stdio};
use std::{env, io};

use infra_utils::path::resolve_project_relative_path;
use tracing::info;

#[cfg(test)]
Expand All @@ -17,15 +18,17 @@ pub enum NodeCompilationError {

/// Compiles the node using `cargo build` for testing purposes.
fn compile_node() -> io::Result<ExitStatus> {
info!("Compiling the project");
// Get the current working directory for the project
let project_path = env::current_dir().expect("Failed to get current directory");
info!("Compiling the starknet_sequencer_node binary");
let project_path = resolve_project_relative_path(".").expect("Failed to resolve project path");
info!("project_path {:?}", project_path);

// Run `cargo build` to compile the project
let compilation_result = Command::new("cargo")
.arg("build")
.arg("--bin")
.arg("starknet_sequencer_node")
.current_dir(&project_path)
.arg("--quiet")
// .arg("--quiet")
.stderr(Stdio::inherit())
.stdout(Stdio::inherit())
.status();
Expand Down

0 comments on commit 5b402c9

Please sign in to comment.