Skip to content

Commit

Permalink
refactor!: re-implement iroha_test_network (early WiP)
Browse files Browse the repository at this point in the history
Signed-off-by: 0x009922 <[email protected]>
  • Loading branch information
0x009922 committed Sep 19, 2024
1 parent e680397 commit 9dfe7a7
Show file tree
Hide file tree
Showing 38 changed files with 2,310 additions and 2,567 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ result
**/test-smartcontracts/
test_docker
**/*.wasm
.test_network_ports.lock
.test_network_ports.json
47 changes: 42 additions & 5 deletions Cargo.lock

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

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ categories = ["cryptography::cryptocurrencies"]
[workspace.dependencies]
iroha_core = { version = "=2.0.0-rc.1.0 ", path = "crates/iroha_core" }

irohad = { version = "=2.0.0-rc.1.0", path = "crates/irohad" }
iroha_torii = { version = "=2.0.0-rc.1.0", path = "crates/iroha_torii" }
iroha_torii_const = { version = "=2.0.0-rc.1.0", path = "crates/iroha_torii_const" }

Expand Down Expand Up @@ -58,7 +57,7 @@ darling = "0.20.10"
drop_bomb = "0.1.5"

futures = { version = "0.3.30", default-features = false }
tokio = "1.39.2"
tokio = "1.40.0"
tokio-stream = "0.1.15"
tokio-tungstenite = "0.21.0"
tokio-util = "0.7.11"
Expand Down Expand Up @@ -128,9 +127,9 @@ mv = { version = "0.1.0" }
[workspace.lints]
rustdoc.private_doc_tests = "deny"

rust.future_incompatible = {level = "deny", priority = -1 }
rust.nonstandard_style = {level = "deny", priority = -1 }
rust.rust_2018_idioms = {level = "deny", priority = -1 }
rust.future_incompatible = { level = "deny", priority = -1 }
rust.nonstandard_style = { level = "deny", priority = -1 }
rust.rust_2018_idioms = { level = "deny", priority = -1 }
rust.unused = { level = "deny", priority = -1 }

rust.anonymous_parameters = "deny"
Expand Down
5 changes: 0 additions & 5 deletions crates/iroha/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ toml = { workspace = true }
nonzero_ext = { workspace = true }

[dev-dependencies]
# FIXME: These three activate `transparent_api` but client should never activate this feature.
# Additionally there is a dependency on iroha_core in dev-dependencies in iroha_telemetry/derive
# Hopefully, once the integration tests migration is finished these can be removed
irohad = { workspace = true }

iroha_wasm_builder = { workspace = true }
iroha_genesis = { workspace = true }
iroha_test_network = { workspace = true }
Expand Down
2 changes: 2 additions & 0 deletions crates/iroha/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use crate::{

mod user;

pub use user::Root as UserConfig;

#[allow(missing_docs)]
pub const DEFAULT_TRANSACTION_TIME_TO_LIVE: Duration = Duration::from_secs(100);
#[allow(missing_docs)]
Expand Down
46 changes: 0 additions & 46 deletions crates/iroha/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,5 @@ pub mod http;
mod http_default;
pub mod query;

pub mod samples {
//! Module containing sample configurations for tests and benchmarks.
use eyre::Result;
use iroha_telemetry::metrics::Status;
use url::Url;

use crate::{
client::{Client, StatusResponseHandler},
config::{
Config, DEFAULT_TRANSACTION_NONCE, DEFAULT_TRANSACTION_STATUS_TIMEOUT,
DEFAULT_TRANSACTION_TIME_TO_LIVE,
},
crypto::KeyPair,
data_model::ChainId,
http_default::DefaultRequestBuilder,
};

/// Get sample client configuration.
pub fn get_client_config(chain_id: ChainId, key_pair: KeyPair, torii_api_url: Url) -> Config {
let account_id = format!("{}@wonderland", key_pair.public_key())
.parse()
.expect("should be valid");
Config {
chain: chain_id,
key_pair,
torii_api_url,
account: account_id,
basic_auth: None,
transaction_ttl: DEFAULT_TRANSACTION_TIME_TO_LIVE,
transaction_status_timeout: DEFAULT_TRANSACTION_STATUS_TIMEOUT,
transaction_add_nonce: DEFAULT_TRANSACTION_NONCE,
}
}

/// Gets network status seen from the peer in json format
///
/// # Errors
/// Fails if sending request or decoding fails
pub fn get_status_json(client: &Client) -> Result<Status> {
let req = client.prepare_status_request::<DefaultRequestBuilder>();
let resp = req.build()?.send()?;
StatusResponseHandler::handle(&resp)
}
}

pub use iroha_crypto as crypto;
pub use iroha_data_model as data_model;
Loading

0 comments on commit 9dfe7a7

Please sign in to comment.