From 9450aecd0df004f49d234b13269ccba22d64a334 Mon Sep 17 00:00:00 2001 From: 0x009922 <43530070+0x009922@users.noreply.github.com> Date: Thu, 3 Oct 2024 08:24:20 +0900 Subject: [PATCH] fix: lints, correct upload of `executor.wasm` Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com> --- .github/workflows/iroha2-dev-pr.yml | 2 +- crates/iroha_test_network/src/fslock_ports.rs | 3 +- crates/iroha_test_network/src/lib.rs | 31 +++++++++---------- crates/iroha_torii/src/lib.rs | 9 ++---- crates/iroha_torii/src/utils.rs | 1 + 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.github/workflows/iroha2-dev-pr.yml b/.github/workflows/iroha2-dev-pr.yml index e5e49737625..13f7d14ecdc 100644 --- a/.github/workflows/iroha2-dev-pr.yml +++ b/.github/workflows/iroha2-dev-pr.yml @@ -80,7 +80,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: executor.wasm - path: ${{ env.DOCKER_COMPOSE_PATH }}/executor.wasm + path: ${{ env.WASM_SAMPLES_TARGET_DIR }}/default_executor.wasm retention-days: 1 unit_tests_with_coverage: diff --git a/crates/iroha_test_network/src/fslock_ports.rs b/crates/iroha_test_network/src/fslock_ports.rs index f0023f53680..2e861769dfd 100644 --- a/crates/iroha_test_network/src/fslock_ports.rs +++ b/crates/iroha_test_network/src/fslock_ports.rs @@ -60,6 +60,7 @@ impl LockContent { }; let mut file = OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(DATA_FILE)?; file.write_all(serde_json::to_string(&self).unwrap().as_bytes())?; @@ -84,7 +85,7 @@ impl AllocatedPort { if !value.ports_in_use.contains(&port) { break port; } - i = i + 1; + i += 1; if i == 1000 { panic!("cannot find a free port") } diff --git a/crates/iroha_test_network/src/lib.rs b/crates/iroha_test_network/src/lib.rs index 6e4725759ef..580606a2a9a 100644 --- a/crates/iroha_test_network/src/lib.rs +++ b/crates/iroha_test_network/src/lib.rs @@ -72,13 +72,13 @@ fn iroha_bin() -> impl AsRef { }) } -const TEMPDIR_PREFIX: &'static str = "irohad_test_network_"; +const TEMPDIR_PREFIX: &str = "irohad_test_network_"; const TEMPDIR_IN_ENV: &str = "TEST_NETWORK_TMP_DIR"; fn tempdir_in() -> Option> { static ENV: OnceLock> = OnceLock::new(); - ENV.get_or_init(|| std::env::var(TEMPDIR_IN_ENV).map(|s| PathBuf::from(s)).ok()) + ENV.get_or_init(|| std::env::var(TEMPDIR_IN_ENV).map(PathBuf::from).ok()) .as_ref() } @@ -236,6 +236,12 @@ pub struct NetworkBuilder { extra_isi: Vec, } +impl Default for NetworkBuilder { + fn default() -> Self { + Self::new() + } +} + /// Test network builder impl NetworkBuilder { /// Constructor @@ -252,7 +258,6 @@ impl NetworkBuilder { /// /// One by default. pub fn with_peers(mut self, n_peers: usize) -> Self { - let n_peers = n_peers.into(); assert_ne!(n_peers, 0); self.n_peers = n_peers; self @@ -665,20 +670,14 @@ impl NetworkPeer { }); while let Some(Ok(event)) = events.next().await { - match event { - EventBox::Pipeline(PipelineEventBox::Block(block)) => { - // FIXME: should we wait for `Applied` event instead? - if *block.status() == BlockStatus::Applied { - let height = block.header().height().get(); - eprintln!("{log_prefix} BlockStatus::Applied height={height}",); - let _ = events_tx.send(PeerLifecycleEvent::BlockApplied { height }); - block_height_tx.send_modify(|x| *x = Some(height)); - } + if let EventBox::Pipeline(PipelineEventBox::Block(block)) = event { + // FIXME: should we wait for `Applied` event instead? + if *block.status() == BlockStatus::Applied { + let height = block.header().height().get(); + eprintln!("{log_prefix} BlockStatus::Applied height={height}",); + let _ = events_tx.send(PeerLifecycleEvent::BlockApplied { height }); + block_height_tx.send_modify(|x| *x = Some(height)); } - // EventBox::Pipeline(PipelineEventBox::Transaction(event)) => { - // eprintln!("{log_prefix} transaction event {:?}", event) - // } - _ => {} } } eprintln!("{log_prefix} events stream is closed"); diff --git a/crates/iroha_torii/src/lib.rs b/crates/iroha_torii/src/lib.rs index 136fedeeecb..f63da3ff4df 100644 --- a/crates/iroha_torii/src/lib.rs +++ b/crates/iroha_torii/src/lib.rs @@ -39,10 +39,7 @@ use tower_http::{ timeout::TimeoutLayer, trace::{DefaultMakeSpan, TraceLayer}, }; -use utils::{ - extractors::{ExtractAccept, ScaleVersioned}, - Scale, -}; +use utils::{extractors::ScaleVersioned, Scale}; #[macro_use] pub(crate) mod utils; @@ -115,7 +112,7 @@ impl Torii { &format!("{}/*tail", uri::STATUS), get({ let metrics_reporter = self.metrics_reporter.clone(); - move |accept: Option, axum::extract::Path(tail): axum::extract::Path| { + move |accept: Option, axum::extract::Path(tail): axum::extract::Path| { core::future::ready(routing::handle_status( &metrics_reporter, accept.map(|extract| extract.0), @@ -128,7 +125,7 @@ impl Torii { uri::STATUS, get({ let metrics_reporter = self.metrics_reporter.clone(); - move |accept: Option| { + move |accept: Option| { core::future::ready(routing::handle_status(&metrics_reporter, accept.map(|extract| extract.0), None)) } }), diff --git a/crates/iroha_torii/src/utils.rs b/crates/iroha_torii/src/utils.rs index f5afe132bbc..bf861b8ec58 100644 --- a/crates/iroha_torii/src/utils.rs +++ b/crates/iroha_torii/src/utils.rs @@ -64,6 +64,7 @@ pub mod extractors { } /// Extractor of Accept header + #[allow(unused)] // unused without `telemetry` feature pub struct ExtractAccept(pub HeaderValue); #[async_trait]