Skip to content

Commit

Permalink
fix: lints, correct upload of executor.wasm
Browse files Browse the repository at this point in the history
Signed-off-by: 0x009922 <[email protected]>
  • Loading branch information
0x009922 committed Oct 2, 2024
1 parent c304e9e commit 9450aec
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/iroha2-dev-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion crates/iroha_test_network/src/fslock_ports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())?;
Expand All @@ -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")
}
Expand Down
31 changes: 15 additions & 16 deletions crates/iroha_test_network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ fn iroha_bin() -> impl AsRef<Path> {
})
}

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<impl AsRef<Path>> {
static ENV: OnceLock<Option<PathBuf>> = 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()
}

Expand Down Expand Up @@ -236,6 +236,12 @@ pub struct NetworkBuilder {
extra_isi: Vec<InstructionBox>,
}

impl Default for NetworkBuilder {
fn default() -> Self {
Self::new()
}
}

/// Test network builder
impl NetworkBuilder {
/// Constructor
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand Down
9 changes: 3 additions & 6 deletions crates/iroha_torii/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -115,7 +112,7 @@ impl Torii {
&format!("{}/*tail", uri::STATUS),
get({
let metrics_reporter = self.metrics_reporter.clone();
move |accept: Option<ExtractAccept>, axum::extract::Path(tail): axum::extract::Path<String>| {
move |accept: Option<utils::extractors::ExtractAccept>, axum::extract::Path(tail): axum::extract::Path<String>| {
core::future::ready(routing::handle_status(
&metrics_reporter,
accept.map(|extract| extract.0),
Expand All @@ -128,7 +125,7 @@ impl Torii {
uri::STATUS,
get({
let metrics_reporter = self.metrics_reporter.clone();
move |accept: Option<ExtractAccept>| {
move |accept: Option<utils::extractors::ExtractAccept>| {
core::future::ready(routing::handle_status(&metrics_reporter, accept.map(|extract| extract.0), None))
}
}),
Expand Down
1 change: 1 addition & 0 deletions crates/iroha_torii/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub mod extractors {
}

/// Extractor of Accept header
#[allow(unused)] // unused without `telemetry` feature
pub struct ExtractAccept(pub HeaderValue);

#[async_trait]
Expand Down

0 comments on commit 9450aec

Please sign in to comment.