diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index beeca40fe7a..22024e8e2f0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -199,7 +199,7 @@ Follow these commit guidelines: - To run the source-code based tests, execute [`cargo test`](https://doc.rust-lang.org/cargo/commands/cargo-test.html) in the Iroha root. Note that this is a long process. - To run benchmarks, execute [`cargo bench`](https://doc.rust-lang.org/cargo/commands/cargo-bench.html) from the Iroha root. To help debug benchmark outputs, set the `debug_assertions` environment variable like so: `RUSTFLAGS="--cfg debug_assertions" cargo bench`. - If you are working on a particular component, be mindful that when you run `cargo test` in a [workspace](https://doc.rust-lang.org/cargo/reference/workspaces.html), it will only run the tests for that workspace, which usually doesn't include any [integration tests](https://www.testingxperts.com/blog/what-is-integration-testing). -- If you want to test your changes on a minimal network, the provided [`docker-compose.yml`](configs/swarm/docker-compose.yml) creates a network of 4 Iroha peers in docker containers that can be used to test consensus and asset propagation-related logic. We recommend interacting with that network using either [`iroha-python`](https://github.com/hyperledger/iroha-python), or the included `iroha_client_cli`. +- If you want to test your changes on a minimal network, the provided [`docker-compose.yml`](configs/swarm/docker-compose.yml) creates a network of 4 Iroha peers in docker containers that can be used to test consensus and asset propagation-related logic. We recommend interacting with that network using either [`iroha-python`](https://github.com/hyperledger/iroha-python), or the included Iroha client CLI. - Do not remove failing tests. Even tests that are ignored will be run in our pipeline eventually. - If possible, please benchmark your code both before and after making your changes, as a significant performance regression can break existing users' installations. diff --git a/Cargo.lock b/Cargo.lock index 3e3179fc3ef..d51bc57ea19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2764,7 +2764,7 @@ dependencies = [ ] [[package]] -name = "iroha_client" +name = "iroha" version = "2.0.0-pre-rc.21" dependencies = [ "attohttpc", @@ -2820,7 +2820,7 @@ dependencies = [ "erased-serde", "error-stack", "eyre", - "iroha_client", + "iroha", "iroha_config_base", "iroha_primitives", "json5", @@ -5631,7 +5631,7 @@ version = "2.0.0-pre-rc.21" dependencies = [ "eyre", "futures", - "iroha_client", + "iroha", "iroha_config", "iroha_core", "iroha_crypto", diff --git a/Cargo.toml b/Cargo.toml index dd1a096b653..7b416cec711 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ iroha_torii = { version = "=2.0.0-pre-rc.21", path = "torii" } iroha_torii_derive = { version = "=2.0.0-pre-rc.21", path = "torii/derive" } iroha_torii_const = { version = "=2.0.0-pre-rc.21", path = "torii/const" } -iroha_client = { version = "=2.0.0-pre-rc.21", path = "client" } +iroha = { version = "=2.0.0-pre-rc.21", path = "client" } iroha_macro_utils = { version = "=2.0.0-pre-rc.21", path = "macro/utils" } iroha_telemetry = { version = "=2.0.0-pre-rc.21", path = "telemetry" } diff --git a/Dockerfile b/Dockerfile index e9d570f8179..2497b6e7615 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=/x86_64-linux-musl-native/bin/ # builder stage WORKDIR /iroha COPY . . -# FIXME: consider building only `irohad`, `iroha_client_cli`, and `kagami`? +# FIXME: consider building only `irohad`, `iroha`, and `kagami`? RUN cargo build --target x86_64-unknown-linux-musl --profile deploy @@ -67,7 +67,7 @@ RUN set -ex && \ chown $USER:$USER $WASM_DIRECTORY COPY --from=builder $TARGET_DIR/irohad $BIN_PATH -COPY --from=builder $TARGET_DIR/iroha_client_cli $BIN_PATH +COPY --from=builder $TARGET_DIR/iroha $BIN_PATH COPY --from=builder $TARGET_DIR/kagami $BIN_PATH USER $USER CMD ["irohad"] diff --git a/Dockerfile.glibc b/Dockerfile.glibc index 394280db5ee..0aacc8d256e 100644 --- a/Dockerfile.glibc +++ b/Dockerfile.glibc @@ -56,7 +56,7 @@ RUN set -ex && \ chown $USER:$USER $WASM_DIRECTORY COPY --from=builder $TARGET_DIR/irohad $BIN_PATH -COPY --from=builder $TARGET_DIR/iroha_client_cli $BIN_PATH +COPY --from=builder $TARGET_DIR/iroha $BIN_PATH COPY --from=builder $TARGET_DIR/kagami $BIN_PATH USER $USER CMD ["irohad"] diff --git a/README.md b/README.md index 5f23254cbf1..11d8cfb1c72 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Run API functional tests: ```bash cargo build chmod +x target/debug/irohad -chmod +x target/debug/iroha_client_cli +chmod +x target/debug/iroha bash ./scripts/test_env.sh setup bash ./scripts/tests/register_mint_quantity.sh @@ -124,19 +124,18 @@ docker compose up With the `docker-compose` instance running, use [Iroha Client CLI](./client_cli/README.md): ```bash -cargo run --bin iroha_client_cli -- --config ./configs/swarm/client.toml +cargo run --bin iroha -- --config ./configs/swarm/client.toml ``` ## Integration Iroha project mainly consists of the following crates: -* [`iroha`](cli) is the command-line application for deploying an Iroha peer. Contains the routing table and definitions of API endpoints. -* [`iroha_actor`](actor) provides a message passing model for Iroha components. -* [`iroha_client`](client) provides a library for building clients that communicate with peers. -* [`iroha_client_cli`](client_cli) is the reference implementation of a client. -* [`iroha_config`](config) handles configuration and documentation generation for options and run-time changes. +* [`iroha`](client) provides a library for building clients that communicate with peers. +* [`irohad`](server cli) is the command-line application for deploying an Iroha peer. Contains the routing table and definitions of API endpoints. +* [`iroha_client_cli`](client cli) is the reference implementation of a client. * [`iroha_core`](core) is the primary library used by all other crates, including the peer endpoint management. +* [`iroha_config`](config) handles configuration and documentation generation for options and run-time changes. * [`iroha_crypto`](crypto) defines cryptographic aspects of Iroha. * [`kagami`](tools/kagami) is used to generate cryptographic keys, default genesis, configuration reference, and schema. * [`iroha_data_model`](data_model) defines common data models in Iroha. diff --git a/client/Cargo.toml b/client/Cargo.toml index 13e823959b3..c3a99eba1ae 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iroha_client" +name = "iroha" edition.workspace = true version.workspace = true diff --git a/client/README.md b/client/README.md index 791dbe2a8f0..9faa164a258 100644 --- a/client/README.md +++ b/client/README.md @@ -16,9 +16,9 @@ Follow the [Iroha 2 tutorial](https://hyperledger.github.io/iroha-2-docs/guide/r Add the following to the manifest file of your Rust project: ```toml -iroha_client = { git = "https://github.com/hyperledger/iroha", branch = "main" } +iroha = { git = "https://github.com/hyperledger/iroha", branch = "main" } ``` ## Examples -We highly recommend looking at the sample [`iroha_client_cli`](../client_cli) implementation binary as well as our [tutorial](https://hyperledger.github.io/iroha-2-docs/guide/rust.html) for more examples and explanations. +We highly recommend looking at the sample [`iroha`](../client_cli) implementation binary as well as our [tutorial](https://hyperledger.github.io/iroha-2-docs/guide/rust.html) for more examples and explanations. diff --git a/client/benches/torii.rs b/client/benches/torii.rs index ca8df450b81..3619df46cae 100644 --- a/client/benches/torii.rs +++ b/client/benches/torii.rs @@ -3,14 +3,14 @@ use std::thread; use criterion::{criterion_group, criterion_main, Criterion, Throughput}; -use irohad::samples::{construct_executor, get_config}; -use iroha_client::{ +use iroha::{ client::{asset, Client}, data_model::prelude::*, }; use iroha_genesis::{GenesisNetwork, RawGenesisBlockBuilder}; use iroha_primitives::unique_vec; use iroha_version::Encode; +use irohad::samples::{construct_executor, get_config}; use test_network::{get_chain_id, get_key_pair, Peer as TestPeer, PeerBuilder, TestRuntime}; use test_samples::gen_account_in; use tokio::runtime::Runtime; @@ -52,7 +52,7 @@ fn query_requests(criterion: &mut Criterion) { rt.block_on(builder.start_with_peer(&mut peer)); rt.block_on(async { iroha_logger::test_logger() - .reload_level(iroha_client::data_model::Level::ERROR) + .reload_level(iroha::data_model::Level::ERROR) .await .unwrap() }); @@ -68,13 +68,13 @@ fn query_requests(criterion: &mut Criterion) { 200u32, AssetId::new(asset_definition_id, account_id.clone()), ); - let client_config = iroha_client::samples::get_client_config( + let client_config = iroha::samples::get_client_config( get_chain_id(), get_key_pair(test_network::Signatory::Alice), format!("http://{}", peer.api_address).parse().unwrap(), ); - let iroha_client = Client::new(client_config); + let iroha = Client::new(client_config); thread::sleep(std::time::Duration::from_millis(5000)); let instructions: [InstructionBox; 4] = [ @@ -83,7 +83,7 @@ fn query_requests(criterion: &mut Criterion) { create_asset.into(), mint_asset.into(), ]; - let _ = iroha_client + let _ = iroha .submit_all(instructions) .expect("Failed to prepare state"); @@ -94,9 +94,8 @@ fn query_requests(criterion: &mut Criterion) { let _dropable = group.throughput(Throughput::Bytes(request.encode().len() as u64)); let _dropable2 = group.bench_function("query", |b| { b.iter(|| { - let iter: Result, _> = iroha_client - .request(request.clone()) - .and_then(Iterator::collect); + let iter: Result, _> = + iroha.request(request.clone()).and_then(Iterator::collect); match iter { Ok(assets) => { @@ -157,14 +156,14 @@ fn instruction_submits(criterion: &mut Criterion) { let (account_id, _account_keypair) = gen_account_in("domain"); let create_account = Register::account(Account::new(account_id.clone())).into(); let asset_definition_id: AssetDefinitionId = "xor#domain".parse().expect("Valid"); - let client_config = iroha_client::samples::get_client_config( + let client_config = iroha::samples::get_client_config( get_chain_id(), get_key_pair(test_network::Signatory::Alice), format!("http://{}", peer.api_address).parse().unwrap(), ); - let iroha_client = Client::new(client_config); + let iroha = Client::new(client_config); thread::sleep(std::time::Duration::from_millis(5000)); - let _ = iroha_client + let _ = iroha .submit_all([create_domain, create_account]) .expect("Failed to create role."); thread::sleep(std::time::Duration::from_millis(500)); @@ -176,7 +175,7 @@ fn instruction_submits(criterion: &mut Criterion) { 200u32, AssetId::new(asset_definition_id.clone(), account_id.clone()), ); - match iroha_client.submit(mint_asset) { + match iroha.submit(mint_asset) { Ok(_) => success_count += 1, Err(e) => { eprintln!("Failed to execute instruction: {e}"); diff --git a/client/benches/tps/utils.rs b/client/benches/tps/utils.rs index a7f0fd662c6..07f6a350fa3 100644 --- a/client/benches/tps/utils.rs +++ b/client/benches/tps/utils.rs @@ -1,7 +1,7 @@ use std::{fmt, fs::File, io::BufReader, path::Path, sync::mpsc, thread, time}; use eyre::{Result, WrapErr}; -use iroha_client::{ +use iroha::{ client::Client, crypto::KeyPair, data_model::{ diff --git a/client/examples/million_accounts_genesis.rs b/client/examples/million_accounts_genesis.rs index d30cb6a6e15..9a802816672 100644 --- a/client/examples/million_accounts_genesis.rs +++ b/client/examples/million_accounts_genesis.rs @@ -1,11 +1,11 @@ //! This file contains examples from the Rust tutorial. use std::{thread, time::Duration}; -use irohad::samples::{construct_executor, get_config}; -use iroha_client::{crypto::KeyPair, data_model::prelude::*}; +use iroha::{crypto::KeyPair, data_model::prelude::*}; use iroha_data_model::isi::InstructionBox; use iroha_genesis::{GenesisNetwork, RawGenesisBlock, RawGenesisBlockBuilder}; use iroha_primitives::unique_vec; +use irohad::samples::{construct_executor, get_config}; use test_network::{ get_chain_id, get_key_pair, wait_for_genesis_committed, Peer as TestPeer, PeerBuilder, TestRuntime, diff --git a/client/examples/register_1000_triggers.rs b/client/examples/register_1000_triggers.rs index fff4a33159c..b4461fa2001 100644 --- a/client/examples/register_1000_triggers.rs +++ b/client/examples/register_1000_triggers.rs @@ -2,11 +2,11 @@ //! Used to show Iroha's trigger deduplication capabilities use std::str::FromStr; -use irohad::samples::{construct_executor, get_config}; -use iroha_client::{client::Client, data_model::prelude::*}; +use iroha::{client::Client, data_model::prelude::*}; use iroha_data_model::trigger::TriggerId; use iroha_genesis::{GenesisNetwork, RawGenesisBlock, RawGenesisBlockBuilder}; use iroha_primitives::unique_vec; +use irohad::samples::{construct_executor, get_config}; use test_network::{ get_chain_id, get_key_pair, wait_for_genesis_committed_with_max_retries, Peer as TestPeer, PeerBuilder, TestClient, TestRuntime, diff --git a/client/examples/tutorial.rs b/client/examples/tutorial.rs index a5194db6f3d..1589b8d78ad 100644 --- a/client/examples/tutorial.rs +++ b/client/examples/tutorial.rs @@ -2,7 +2,7 @@ //! use eyre::{Error, WrapErr}; -use iroha_client::config::Config; +use iroha::config::Config; use iroha_primitives::numeric::Numeric; // #region rust_config_crates // #endregion rust_config_crates @@ -31,7 +31,7 @@ fn main() { fn domain_registration_test(config: Config) -> Result<(), Error> { // #region domain_register_example_crates - use iroha_client::{ + use iroha::{ client::Client, data_model::{ metadata::UnlimitedMetadata, @@ -52,19 +52,19 @@ fn domain_registration_test(config: Config) -> Result<(), Error> { // #region rust_client_create // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // #endregion rust_client_create // #region domain_register_example_prepare_tx // Prepare a transaction let metadata = UnlimitedMetadata::default(); let instructions: Vec = vec![create_looking_glass.into()]; - let tx = iroha_client.build_transaction(instructions, metadata); + let tx = iroha.build_transaction(instructions, metadata); // #endregion domain_register_example_prepare_tx // #region domain_register_example_submit_tx // Submit a prepared domain registration transaction - iroha_client + iroha .submit_transaction(&tx) .wrap_err("Failed to submit transaction")?; // #endregion domain_register_example_submit_tx @@ -75,7 +75,7 @@ fn domain_registration_test(config: Config) -> Result<(), Error> { fn account_definition_test() -> Result<(), Error> { // #region account_definition_comparison - use iroha_client::{crypto::KeyPair, data_model::prelude::AccountId}; + use iroha::{crypto::KeyPair, data_model::prelude::AccountId}; // Generate a new public key for a new account let (public_key, _) = KeyPair::random().into_parts(); @@ -97,7 +97,7 @@ fn account_definition_test() -> Result<(), Error> { fn account_registration_test(config: Config) -> Result<(), Error> { // #region register_account_crates - use iroha_client::{ + use iroha::{ client::Client, crypto::KeyPair, data_model::{ @@ -108,7 +108,7 @@ fn account_registration_test(config: Config) -> Result<(), Error> { // #endregion register_account_crates // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // #region register_account_create // Generate a new public key for a new account @@ -129,12 +129,12 @@ fn account_registration_test(config: Config) -> Result<(), Error> { // Account's RegisterBox let metadata = UnlimitedMetadata::new(); let instructions: Vec = vec![create_account.into()]; - let tx = iroha_client.build_transaction(instructions, metadata); + let tx = iroha.build_transaction(instructions, metadata); // #endregion register_account_prepare_tx // #region register_account_submit_tx // Submit a prepared account registration transaction - iroha_client.submit_transaction(&tx)?; + iroha.submit_transaction(&tx)?; // #endregion register_account_submit_tx // Finish the test successfully @@ -145,7 +145,7 @@ fn asset_registration_test(config: Config) -> Result<(), Error> { // #region register_asset_crates use std::str::FromStr as _; - use iroha_client::{ + use iroha::{ client::Client, crypto::KeyPair, data_model::prelude::{ @@ -155,7 +155,7 @@ fn asset_registration_test(config: Config) -> Result<(), Error> { // #endregion register_asset_crates // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // #region register_asset_create_asset // Create an asset @@ -169,7 +169,7 @@ fn asset_registration_test(config: Config) -> Result<(), Error> { Register::asset_definition(AssetDefinition::numeric(asset_def_id.clone()).mintable_once()); // Submit a registration time - iroha_client.submit(register_time)?; + iroha.submit(register_time)?; // #endregion register_asset_init_submit // Generate a new public key for a new account @@ -184,7 +184,7 @@ fn asset_registration_test(config: Config) -> Result<(), Error> { let mint = Mint::asset_numeric(numeric!(12.34), AssetId::new(asset_def_id, account_id)); // Submit a minting transaction - iroha_client.submit_all([mint])?; + iroha.submit_all([mint])?; // #endregion register_asset_mint_submit // Finish the test successfully @@ -195,14 +195,14 @@ fn asset_minting_test(config: Config) -> Result<(), Error> { // #region mint_asset_crates use std::str::FromStr; - use iroha_client::{ + use iroha::{ client::Client, data_model::prelude::{AccountId, AssetDefinitionId, AssetId, Mint}, }; // #endregion mint_asset_crates // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // Define the instances of an Asset and Account // #region mint_asset_define_asset_account @@ -218,7 +218,7 @@ fn asset_minting_test(config: Config) -> Result<(), Error> { // #endregion mint_asset_mint // #region mint_asset_submit_tx - iroha_client + iroha .submit(mint_roses) .wrap_err("Failed to submit transaction")?; // #endregion mint_asset_submit_tx @@ -236,7 +236,7 @@ fn asset_minting_test(config: Config) -> Result<(), Error> { // #endregion mint_asset_mint_alt // #region mint_asset_submit_tx_alt - iroha_client + iroha .submit(mint_roses_alt) .wrap_err("Failed to submit transaction")?; // #endregion mint_asset_submit_tx_alt @@ -249,14 +249,14 @@ fn asset_burning_test(config: Config) -> Result<(), Error> { // #region burn_asset_crates use std::str::FromStr; - use iroha_client::{ + use iroha::{ client::Client, data_model::prelude::{AccountId, AssetDefinitionId, AssetId, Burn}, }; // #endregion burn_asset_crates // Create an Iroha client - let iroha_client = Client::new(config); + let iroha = Client::new(config); // #region burn_asset_define_asset_account // Define the instances of an Asset and Account @@ -272,7 +272,7 @@ fn asset_burning_test(config: Config) -> Result<(), Error> { // #endregion burn_asset_burn // #region burn_asset_submit_tx - iroha_client + iroha .submit(burn_roses) .wrap_err("Failed to submit transaction")?; // #endregion burn_asset_submit_tx @@ -290,7 +290,7 @@ fn asset_burning_test(config: Config) -> Result<(), Error> { // #endregion burn_asset_burn_alt // #region burn_asset_submit_tx_alt - iroha_client + iroha .submit(burn_roses_alt) .wrap_err("Failed to submit transaction")?; // #endregion burn_asset_submit_tx_alt diff --git a/client/src/http.rs b/client/src/http.rs index 25a147fbed5..253b3fd808a 100644 --- a/client/src/http.rs +++ b/client/src/http.rs @@ -96,7 +96,7 @@ pub mod ws { /// /// ```rust /// use eyre::{eyre, Result}; - /// use iroha_client::http::{ + /// use iroha::http::{ /// ws::conn_flow::{Events as FlowEvents, Init as FlowInit, InitData}, /// Method, RequestBuilder, /// }; @@ -143,7 +143,7 @@ pub mod ws { /// /// ```rust /// use eyre::Result; - /// use iroha_client::{ + /// use iroha::{ /// client::events_api::flow as events_api_flow, /// data_model::prelude::EventBox, /// http::{ diff --git a/client/tests/integration/add_domain.rs b/client/tests/integration/add_domain.rs index 443978885d8..514e18b85d6 100644 --- a/client/tests/integration/add_domain.rs +++ b/client/tests/integration/add_domain.rs @@ -1,12 +1,12 @@ use std::thread; use eyre::Result; -use iroha_client::{client, data_model::prelude::*}; +use iroha::{client, data_model::prelude::*}; use iroha_config::parameters::actual::Root as Config; use test_network::*; #[test] -// This test suite is also covered at the UI level in the iroha_client_cli tests +// This test suite is also covered at the UI level in the iroha_cli tests // in test_register_domains.py fn client_add_domain_with_name_length_more_than_limit_should_not_commit_transaction() -> Result<()> { diff --git a/client/tests/integration/asset.rs b/client/tests/integration/asset.rs index b5912ddf528..2091fba9184 100644 --- a/client/tests/integration/asset.rs +++ b/client/tests/integration/asset.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, thread}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, crypto::KeyPair, data_model::prelude::*, @@ -17,7 +17,7 @@ use test_network::*; use test_samples::{gen_account_in, ALICE_ID, BOB_ID}; #[test] -// This test is also covered at the UI level in the iroha_client_cli tests +// This test is also covered at the UI level in the iroha_cli tests // in test_register_asset_definitions.py fn client_register_asset_should_add_asset_once_but_not_twice() -> Result<()> { let (_rt, _peer, test_client) = ::new().with_port(10_620).start_with_runtime(); @@ -95,7 +95,7 @@ fn unregister_asset_should_remove_asset_from_account() -> Result<()> { } #[test] -// This test is also covered at the UI level in the iroha_client_cli tests +// This test is also covered at the UI level in the iroha_cli tests // in test_mint_assets.py fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount() -> Result<()> { let (_rt, _peer, test_client) = ::new().with_port(10_000).start_with_runtime(); @@ -106,7 +106,7 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount() -> let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid"); let create_asset = Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); - let metadata = iroha_client::data_model::metadata::UnlimitedMetadata::default(); + let metadata = iroha::data_model::metadata::UnlimitedMetadata::default(); //When let quantity = numeric!(200); let mint = Mint::asset_numeric( @@ -137,7 +137,7 @@ fn client_add_big_asset_quantity_to_existing_asset_should_increase_asset_amount( let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid"); let create_asset = Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); - let metadata = iroha_client::data_model::metadata::UnlimitedMetadata::default(); + let metadata = iroha::data_model::metadata::UnlimitedMetadata::default(); //When let quantity = Numeric::new(2_u128.pow(65), 0); let mint = Mint::asset_numeric( @@ -168,7 +168,7 @@ fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> { let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid"); let asset_definition = AssetDefinition::numeric(asset_definition_id.clone()); let create_asset = Register::asset_definition(asset_definition); - let metadata = iroha_client::data_model::metadata::UnlimitedMetadata::default(); + let metadata = iroha::data_model::metadata::UnlimitedMetadata::default(); //When let quantity = numeric!(123.456); @@ -210,7 +210,7 @@ fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> { } #[test] -// This test is also covered at the UI level in the iroha_client_cli tests +// This test is also covered at the UI level in the iroha_cli tests // in test_register_asset_definitions.py fn client_add_asset_with_name_length_more_than_limit_should_not_commit_transaction() -> Result<()> { let (_rt, _peer, test_client) = ::new().with_port(10_520).start_with_runtime(); diff --git a/client/tests/integration/asset_propagation.rs b/client/tests/integration/asset_propagation.rs index 84396976c85..1e8326dd237 100644 --- a/client/tests/integration/asset_propagation.rs +++ b/client/tests/integration/asset_propagation.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, thread}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{ parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, @@ -13,7 +13,7 @@ use test_network::*; use test_samples::gen_account_in; #[test] -// This test is also covered at the UI level in the iroha_client_cli tests +// This test is also covered at the UI level in the iroha_cli tests // in test_mint_asset.py fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount_on_another_peer( ) -> Result<()> { diff --git a/client/tests/integration/domain_owner_permissions.rs b/client/tests/integration/domain_owner_permissions.rs index c5dd5d38a52..7e71973db1c 100644 --- a/client/tests/integration/domain_owner_permissions.rs +++ b/client/tests/integration/domain_owner_permissions.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::data_model::prelude::*; +use iroha::data_model::prelude::*; use iroha_data_model::transaction::error::TransactionRejectionReason; use serde_json::json; use test_network::*; diff --git a/client/tests/integration/events/data.rs b/client/tests/integration/events/data.rs index 9d29901409f..2dff130ee4d 100644 --- a/client/tests/integration/events/data.rs +++ b/client/tests/integration/events/data.rs @@ -1,7 +1,7 @@ use std::{fmt::Write as _, str::FromStr, sync::mpsc, thread}; use eyre::Result; -use iroha_client::data_model::{prelude::*, transaction::WasmSmartContract}; +use iroha::data_model::{prelude::*, transaction::WasmSmartContract}; use parity_scale_codec::Encode as _; use serde_json::json; use test_network::*; @@ -207,7 +207,7 @@ fn produce_multiple_events() -> Result<()> { "CanSetKeyValueInAccount".parse()?, &json!({ "account_id": alice_id }), ); - let role = iroha_client::data_model::role::Role::new(role_id.clone()) + let role = iroha::data_model::role::Role::new(role_id.clone()) .add_permission(token_1.clone()) .add_permission(token_2.clone()); let instructions = [Register::role(role.clone())]; diff --git a/client/tests/integration/events/notification.rs b/client/tests/integration/events/notification.rs index 093fd213bc3..8c36edc64c3 100644 --- a/client/tests/integration/events/notification.rs +++ b/client/tests/integration/events/notification.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, sync::mpsc, thread, time::Duration}; use eyre::{eyre, Result, WrapErr}; -use iroha_client::data_model::prelude::*; +use iroha::data_model::prelude::*; use test_network::*; use test_samples::ALICE_ID; diff --git a/client/tests/integration/events/pipeline.rs b/client/tests/integration/events/pipeline.rs index 90b19fde177..28afa87ac40 100644 --- a/client/tests/integration/events/pipeline.rs +++ b/client/tests/integration/events/pipeline.rs @@ -1,7 +1,7 @@ use std::thread::{self, JoinHandle}; use eyre::Result; -use iroha_client::{ +use iroha::{ crypto::HashOf, data_model::{ parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, @@ -85,7 +85,7 @@ fn test_with_instruction_and_status_and_port( #[derive(Clone)] struct Checker { - listener: iroha_client::client::Client, + listener: iroha::client::Client, hash: HashOf, } diff --git a/client/tests/integration/extra_functional/connected_peers.rs b/client/tests/integration/extra_functional/connected_peers.rs index 000a352ce3d..fb98d69e141 100644 --- a/client/tests/integration/extra_functional/connected_peers.rs +++ b/client/tests/integration/extra_functional/connected_peers.rs @@ -1,7 +1,7 @@ use std::thread; use eyre::{Context, Result}; -use iroha_client::{ +use iroha::{ client::Client, data_model::{ isi::{Register, Unregister}, diff --git a/client/tests/integration/extra_functional/multiple_blocks_created.rs b/client/tests/integration/extra_functional/multiple_blocks_created.rs index 0c96b849824..afa8737c974 100644 --- a/client/tests/integration/extra_functional/multiple_blocks_created.rs +++ b/client/tests/integration/extra_functional/multiple_blocks_created.rs @@ -1,7 +1,7 @@ use std::thread; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, data_model::{ parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, diff --git a/client/tests/integration/extra_functional/offline_peers.rs b/client/tests/integration/extra_functional/offline_peers.rs index b6455eed100..f0d847ee048 100644 --- a/client/tests/integration/extra_functional/offline_peers.rs +++ b/client/tests/integration/extra_functional/offline_peers.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, crypto::KeyPair, data_model::{ diff --git a/client/tests/integration/extra_functional/restart_peer.rs b/client/tests/integration/extra_functional/restart_peer.rs index 5b1995ad2d2..2b919073c68 100644 --- a/client/tests/integration/extra_functional/restart_peer.rs +++ b/client/tests/integration/extra_functional/restart_peer.rs @@ -1,7 +1,7 @@ use std::{str::FromStr, thread}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/extra_functional/unregister_peer.rs b/client/tests/integration/extra_functional/unregister_peer.rs index 5742025cc01..3ea3a3292f8 100644 --- a/client/tests/integration/extra_functional/unregister_peer.rs +++ b/client/tests/integration/extra_functional/unregister_peer.rs @@ -1,7 +1,7 @@ use std::thread; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{ parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, @@ -67,12 +67,12 @@ fn unstable_network_stable_after_add_and_after_remove_peer() -> Result<()> { } fn check_assets( - iroha_client: &client::Client, + iroha: &client::Client, account_id: &AccountId, asset_definition_id: &AssetDefinitionId, quantity: Numeric, ) { - iroha_client + iroha .poll_request_with_period( client::asset::by_account_id(account_id.clone()), Config::block_sync_gossip_time(), @@ -109,7 +109,7 @@ fn mint( fn init() -> Result<( tokio::runtime::Runtime, test_network::Network, - iroha_client::client::Client, + iroha::client::Client, std::time::Duration, AccountId, AssetDefinitionId, diff --git a/client/tests/integration/extra_functional/unstable_network.rs b/client/tests/integration/extra_functional/unstable_network.rs index 52b2b9ad851..e96bfb428fc 100644 --- a/client/tests/integration/extra_functional/unstable_network.rs +++ b/client/tests/integration/extra_functional/unstable_network.rs @@ -1,7 +1,7 @@ use core::sync::atomic::Ordering; use std::thread; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, data_model::{prelude::*, Level}, }; @@ -52,7 +52,7 @@ fn unstable_network( } let rt = Runtime::test(); // Given - let (network, iroha_client) = rt.block_on(async { + let (network, iroha) = rt.block_on(async { let mut configuration = Config::test(); configuration.chain_wide.max_transactions_in_block = MAX_TRANSACTIONS_IN_BLOCK.try_into().unwrap(); @@ -80,7 +80,7 @@ fn unstable_network( let asset_definition_id: AssetDefinitionId = "camomile#wonderland".parse().expect("Valid"); let register_asset = Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); - iroha_client + iroha .submit_blocking(register_asset) .expect("Failed to register asset"); // Initially there are 0 camomile @@ -105,13 +105,11 @@ fn unstable_network( quantity, AssetId::new(asset_definition_id.clone(), account_id.clone()), ); - iroha_client - .submit(mint_asset) - .expect("Failed to create asset."); + iroha.submit(mint_asset).expect("Failed to create asset."); account_has_quantity = account_has_quantity.checked_add(quantity).unwrap(); thread::sleep(pipeline_time); - iroha_client + iroha .poll_request_with_period( client::asset::by_account_id(account_id.clone()), Config::pipeline_time(), diff --git a/client/tests/integration/non_mintable.rs b/client/tests/integration/non_mintable.rs index 301ecb93b81..b6561028e41 100644 --- a/client/tests/integration/non_mintable.rs +++ b/client/tests/integration/non_mintable.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{metadata::UnlimitedMetadata, prelude::*}, }; diff --git a/client/tests/integration/pagination.rs b/client/tests/integration/pagination.rs index 176e3726e2e..5b508734523 100644 --- a/client/tests/integration/pagination.rs +++ b/client/tests/integration/pagination.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{ +use iroha::{ client::{asset, Client, QueryResult}, data_model::{asset::AssetDefinition, prelude::*, query::Pagination}, }; diff --git a/client/tests/integration/permissions.rs b/client/tests/integration/permissions.rs index 678d7b71b1a..d18b9ec03c3 100644 --- a/client/tests/integration/permissions.rs +++ b/client/tests/integration/permissions.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, thread, time::Duration}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, crypto::KeyPair, data_model::prelude::*, @@ -55,8 +55,8 @@ fn genesis_transactions_are_validated() { } } -fn get_assets(iroha_client: &Client, id: &AccountId) -> Vec { - iroha_client +fn get_assets(iroha: &Client, id: &AccountId) -> Vec { + iroha .request(client::asset::by_account_id(id.clone())) .expect("Failed to execute request.") .collect::>>() @@ -68,8 +68,8 @@ fn get_assets(iroha_client: &Client, id: &AccountId) -> Vec { fn permissions_disallow_asset_transfer() { let chain_id = ChainId::from("0"); - let (_rt, _peer, iroha_client) = ::new().with_port(10_730).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(10_730).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); // Given let alice_id = ALICE_ID.clone(); @@ -80,8 +80,8 @@ fn permissions_disallow_asset_transfer() { Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); let mouse_keypair = KeyPair::random(); - let alice_start_assets = get_assets(&iroha_client, &alice_id); - iroha_client + let alice_start_assets = get_assets(&iroha, &alice_id); + iroha .submit_blocking(create_asset) .expect("Failed to prepare state."); @@ -90,7 +90,7 @@ fn permissions_disallow_asset_transfer() { quantity, AssetId::new(asset_definition_id.clone(), bob_id.clone()), ); - iroha_client + iroha .submit_blocking(mint_asset) .expect("Failed to create asset."); @@ -103,7 +103,7 @@ fn permissions_disallow_asset_transfer() { let transfer_tx = TransactionBuilder::new(chain_id, mouse_id) .with_instructions([transfer_asset]) .sign(&mouse_keypair); - let err = iroha_client + let err = iroha .submit_transaction_blocking(&transfer_tx) .expect_err("Transaction was not rejected."); let rejection_reason = err @@ -114,7 +114,7 @@ fn permissions_disallow_asset_transfer() { rejection_reason, &TransactionRejectionReason::Validation(ValidationFail::NotPermitted(_)) )); - let alice_assets = get_assets(&iroha_client, &alice_id); + let alice_assets = get_assets(&iroha, &alice_id); assert_eq!(alice_assets, alice_start_assets); } @@ -123,7 +123,7 @@ fn permissions_disallow_asset_transfer() { fn permissions_disallow_asset_burn() { let chain_id = ChainId::from("0"); - let (_rt, _peer, iroha_client) = ::new().with_port(10_735).start_with_runtime(); + let (_rt, _peer, iroha) = ::new().with_port(10_735).start_with_runtime(); let alice_id = ALICE_ID.clone(); let bob_id = BOB_ID.clone(); @@ -133,16 +133,16 @@ fn permissions_disallow_asset_burn() { Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); let mouse_keypair = KeyPair::random(); - let alice_start_assets = get_assets(&iroha_client, &alice_id); + let alice_start_assets = get_assets(&iroha, &alice_id); - iroha_client + iroha .submit_blocking(create_asset) .expect("Failed to prepare state."); let quantity = numeric!(200); let mint_asset = Mint::asset_numeric(quantity, AssetId::new(asset_definition_id.clone(), bob_id)); - iroha_client + iroha .submit_blocking(mint_asset) .expect("Failed to create asset."); let burn_asset = Burn::asset_numeric( @@ -153,7 +153,7 @@ fn permissions_disallow_asset_burn() { .with_instructions([burn_asset]) .sign(&mouse_keypair); - let err = iroha_client + let err = iroha .submit_transaction_blocking(&burn_tx) .expect_err("Transaction was not rejected."); let rejection_reason = err @@ -165,7 +165,7 @@ fn permissions_disallow_asset_burn() { &TransactionRejectionReason::Validation(ValidationFail::NotPermitted(_)) )); - let alice_assets = get_assets(&iroha_client, &alice_id); + let alice_assets = get_assets(&iroha, &alice_id); assert_eq!(alice_assets, alice_start_assets); } @@ -292,8 +292,8 @@ fn permissions_differ_not_only_by_names() { fn stored_vs_granted_token_payload() -> Result<()> { let chain_id = ChainId::from("0"); - let (_rt, _peer, iroha_client) = ::new().with_port(10_730).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(10_730).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); // Given let alice_id = ALICE_ID.clone(); @@ -308,7 +308,7 @@ fn stored_vs_granted_token_payload() -> Result<()> { Register::account(new_mouse_account).into(), create_asset.into(), ]; - iroha_client + iroha .submit_all_blocking(instructions) .expect("Failed to register mouse"); @@ -326,13 +326,13 @@ fn stored_vs_granted_token_payload() -> Result<()> { let transaction = TransactionBuilder::new(chain_id, mouse_id) .with_instructions([allow_alice_to_set_key_value_in_mouse_asset]) .sign(&mouse_keypair); - iroha_client + iroha .submit_transaction_blocking(&transaction) .expect("Failed to grant permission to alice."); // Check that alice can indeed mint mouse asset let set_key_value = SetKeyValue::asset(mouse_asset, Name::from_str("color")?, "red".to_owned()); - iroha_client + iroha .submit_blocking(set_key_value) .expect("Failed to mint asset for mouse."); @@ -342,8 +342,8 @@ fn stored_vs_granted_token_payload() -> Result<()> { #[test] #[allow(deprecated)] fn permissions_are_unified() { - let (_rt, _peer, iroha_client) = ::new().with_port(11_230).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(11_230).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); // Given let alice_id = ALICE_ID.clone(); @@ -366,19 +366,19 @@ fn permissions_are_unified() { alice_id, ); - iroha_client + iroha .submit_blocking(allow_alice_to_transfer_rose_1) .expect("failed to grant permission token"); - let _ = iroha_client + let _ = iroha .submit_blocking(allow_alice_to_transfer_rose_2) .expect_err("permission tokens are not unified"); } #[test] fn associated_permissions_removed_on_unregister() { - let (_rt, _peer, iroha_client) = ::new().with_port(11_240).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(11_240).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); let bob_id = BOB_ID.clone(); let kingdom_id: DomainId = "kingdom".parse().expect("Valid"); @@ -393,7 +393,7 @@ fn associated_permissions_removed_on_unregister() { let allow_bob_to_set_kv_in_domain = Grant::permission(bob_to_set_kv_in_domain_token.clone(), bob_id.clone()); - iroha_client + iroha .submit_all_blocking([ InstructionBox::from(register_domain), allow_bob_to_set_kv_in_domain.into(), @@ -401,7 +401,7 @@ fn associated_permissions_removed_on_unregister() { .expect("failed to register domain and grant permission"); // check that bob indeed have granted permission - assert!(iroha_client + assert!(iroha .request(client::permission::by_account_id(bob_id.clone())) .and_then(std::iter::Iterator::collect::>>) .expect("failed to get permissions for bob") @@ -409,12 +409,12 @@ fn associated_permissions_removed_on_unregister() { .any(|token| { token == bob_to_set_kv_in_domain_token })); // unregister kingdom - iroha_client + iroha .submit_blocking(Unregister::domain(kingdom_id)) .expect("failed to unregister domain"); // check that permission is removed from bob - assert!(iroha_client + assert!(iroha .request(client::permission::by_account_id(bob_id)) .and_then(std::iter::Iterator::collect::>>) .expect("failed to get permissions for bob") @@ -424,8 +424,8 @@ fn associated_permissions_removed_on_unregister() { #[test] fn associated_permissions_removed_from_role_on_unregister() { - let (_rt, _peer, iroha_client) = ::new().with_port(11_255).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(11_255).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); let role_id: RoleId = "role".parse().expect("Valid"); let kingdom_id: DomainId = "kingdom".parse().expect("Valid"); @@ -440,12 +440,12 @@ fn associated_permissions_removed_from_role_on_unregister() { let role = Role::new(role_id.clone()).add_permission(set_kv_in_domain_token.clone()); let register_role = Register::role(role); - iroha_client + iroha .submit_all_blocking([InstructionBox::from(register_domain), register_role.into()]) .expect("failed to register domain and grant permission"); // check that role indeed have permission - assert!(iroha_client + assert!(iroha .request(client::role::by_id(role_id.clone())) .map(|role| role.permissions().cloned().collect::>()) .expect("failed to get permissions for role") @@ -453,12 +453,12 @@ fn associated_permissions_removed_from_role_on_unregister() { .any(|token| { token == set_kv_in_domain_token })); // unregister kingdom - iroha_client + iroha .submit_blocking(Unregister::domain(kingdom_id)) .expect("failed to unregister domain"); // check that permission is removed from role - assert!(iroha_client + assert!(iroha .request(client::role::by_id(role_id.clone())) .map(|role| role.permissions().cloned().collect::>()) .expect("failed to get permissions for role") diff --git a/client/tests/integration/queries/account.rs b/client/tests/integration/queries/account.rs index eb047c732cc..d89d74b8ac0 100644 --- a/client/tests/integration/queries/account.rs +++ b/client/tests/integration/queries/account.rs @@ -1,7 +1,7 @@ use std::{collections::HashSet, str::FromStr as _}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/queries/asset.rs b/client/tests/integration/queries/asset.rs index 68ce747732f..d306f5b9540 100644 --- a/client/tests/integration/queries/asset.rs +++ b/client/tests/integration/queries/asset.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{ +use iroha::{ client::{Client, ClientQueryError}, data_model::{ asset::AssetValue, diff --git a/client/tests/integration/queries/mod.rs b/client/tests/integration/queries/mod.rs index d53bb97853e..f9d15a11e62 100644 --- a/client/tests/integration/queries/mod.rs +++ b/client/tests/integration/queries/mod.rs @@ -1,4 +1,4 @@ -use iroha_client::{ +use iroha::{ client::{self, ClientQueryError}, data_model::{ prelude::*, diff --git a/client/tests/integration/queries/query_errors.rs b/client/tests/integration/queries/query_errors.rs index 5d8194fc043..e3a756f1522 100644 --- a/client/tests/integration/queries/query_errors.rs +++ b/client/tests/integration/queries/query_errors.rs @@ -1,4 +1,4 @@ -use iroha_client::{ +use iroha::{ client::{self, ClientQueryError}, data_model::{ prelude::*, diff --git a/client/tests/integration/queries/role.rs b/client/tests/integration/queries/role.rs index 80391bbf673..3cc53c8858f 100644 --- a/client/tests/integration/queries/role.rs +++ b/client/tests/integration/queries/role.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{prelude::*, query::error::QueryExecutionFail}, }; diff --git a/client/tests/integration/queries/smart_contract.rs b/client/tests/integration/queries/smart_contract.rs index 1e5cb8a3b56..33858c64c07 100644 --- a/client/tests/integration/queries/smart_contract.rs +++ b/client/tests/integration/queries/smart_contract.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::ClientQueryError, data_model::{ prelude::*, diff --git a/client/tests/integration/roles.rs b/client/tests/integration/roles.rs index 6efab725cd5..ec1ffd61450 100644 --- a/client/tests/integration/roles.rs +++ b/client/tests/integration/roles.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/set_parameter.rs b/client/tests/integration/set_parameter.rs index e35209b0101..cf2fa11accb 100644 --- a/client/tests/integration/set_parameter.rs +++ b/client/tests/integration/set_parameter.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/sorting.rs b/client/tests/integration/sorting.rs index 5e8fa205021..dd95bba5579 100644 --- a/client/tests/integration/sorting.rs +++ b/client/tests/integration/sorting.rs @@ -1,7 +1,7 @@ use std::{collections::HashSet, str::FromStr as _}; use eyre::{Result, WrapErr as _}; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, crypto::KeyPair, data_model::{ diff --git a/client/tests/integration/status_response.rs b/client/tests/integration/status_response.rs index 8209d46b5dd..1eb863d1f0e 100644 --- a/client/tests/integration/status_response.rs +++ b/client/tests/integration/status_response.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{data_model::prelude::*, samples::get_status_json}; +use iroha::{data_model::prelude::*, samples::get_status_json}; use iroha_telemetry::metrics::Status; use test_network::*; use test_samples::gen_account_in; diff --git a/client/tests/integration/transfer_asset.rs b/client/tests/integration/transfer_asset.rs index f58d479e49c..e974e9f8e2b 100644 --- a/client/tests/integration/transfer_asset.rs +++ b/client/tests/integration/transfer_asset.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::{isi::Instruction, prelude::*, Registered}, }; @@ -14,7 +14,7 @@ use test_network::*; use test_samples::{gen_account_in, ALICE_ID}; #[test] -// This test suite is also covered at the UI level in the iroha_client_cli tests +// This test suite is also covered at the UI level in the iroha_cli tests // in test_tranfer_assets.py fn simulate_transfer_numeric() { simulate_transfer( @@ -29,8 +29,8 @@ fn simulate_transfer_numeric() { #[test] fn simulate_transfer_store_asset() { - let (_rt, _peer, iroha_client) = ::new().with_port(11_145).start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + let (_rt, _peer, iroha) = ::new().with_port(11_145).start_with_runtime(); + wait_for_genesis_committed(&[iroha.clone()], 0); let (alice_id, mouse_id) = generate_two_ids(); let create_mouse = create_mouse(mouse_id.clone()); let asset_definition_id: AssetDefinitionId = "camomile#wonderland".parse().unwrap(); @@ -49,7 +49,7 @@ fn simulate_transfer_store_asset() { set_key_value.into(), ]; - iroha_client + iroha .submit_all_blocking(instructions) .expect("Failed to prepare state."); @@ -59,7 +59,7 @@ fn simulate_transfer_store_asset() { ); let transfer_box: InstructionBox = transfer_asset.into(); - iroha_client + iroha .submit_till( transfer_box, client::asset::by_account_id(mouse_id.clone()), @@ -86,10 +86,10 @@ fn simulate_transfer( Mint: Instruction, Transfer: Instruction, { - let (_rt, _peer, iroha_client) = ::new() + let (_rt, _peer, iroha) = ::new() .with_port(port_number) .start_with_runtime(); - wait_for_genesis_committed(&[iroha_client.clone()], 0); + wait_for_genesis_committed(&[iroha.clone()], 0); let (alice_id, mouse_id) = generate_two_ids(); let create_mouse = create_mouse(mouse_id.clone()); @@ -107,7 +107,7 @@ fn simulate_transfer( create_asset.into(), mint_asset.into(), ]; - iroha_client + iroha .submit_all_blocking(instructions) .expect("Failed to prepare state."); @@ -117,7 +117,7 @@ fn simulate_transfer( amount_to_transfer.clone(), mouse_id.clone(), ); - iroha_client + iroha .submit_till( transfer_asset, client::asset::by_account_id(mouse_id.clone()), diff --git a/client/tests/integration/triggers/by_call_trigger.rs b/client/tests/integration/triggers/by_call_trigger.rs index 3e8f7496336..d71d1853f0e 100644 --- a/client/tests/integration/triggers/by_call_trigger.rs +++ b/client/tests/integration/triggers/by_call_trigger.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, sync::mpsc, thread, time::Duration}; use eyre::{eyre, Result, WrapErr}; -use iroha_client::{ +use iroha::{ client::{self, Client}, data_model::{ prelude::*, diff --git a/client/tests/integration/triggers/data_trigger.rs b/client/tests/integration/triggers/data_trigger.rs index 3f070c2e4a2..b4c9789ea63 100644 --- a/client/tests/integration/triggers/data_trigger.rs +++ b/client/tests/integration/triggers/data_trigger.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{client, data_model::prelude::*}; +use iroha::{client, data_model::prelude::*}; use iroha_data_model::asset::AssetValue; use test_network::*; use test_samples::{gen_account_in, ALICE_ID}; diff --git a/client/tests/integration/triggers/event_trigger.rs b/client/tests/integration/triggers/event_trigger.rs index 756a2ee6ac3..0221d770139 100644 --- a/client/tests/integration/triggers/event_trigger.rs +++ b/client/tests/integration/triggers/event_trigger.rs @@ -1,5 +1,5 @@ use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client}, data_model::prelude::*, }; diff --git a/client/tests/integration/triggers/time_trigger.rs b/client/tests/integration/triggers/time_trigger.rs index 37f9f002407..7dde83840bc 100644 --- a/client/tests/integration/triggers/time_trigger.rs +++ b/client/tests/integration/triggers/time_trigger.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, time::Duration}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, data_model::{ asset::AssetId, diff --git a/client/tests/integration/triggers/trigger_rollback.rs b/client/tests/integration/triggers/trigger_rollback.rs index 1eb6188d916..36c9d40cd70 100644 --- a/client/tests/integration/triggers/trigger_rollback.rs +++ b/client/tests/integration/triggers/trigger_rollback.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::QueryResult, data_model::{prelude::*, query::asset::FindAllAssetsDefinitions, trigger::TriggerId}, }; diff --git a/client/tests/integration/tx_history.rs b/client/tests/integration/tx_history.rs index 19a57bd638e..77ee2fcfa2e 100644 --- a/client/tests/integration/tx_history.rs +++ b/client/tests/integration/tx_history.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, thread}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{transaction, QueryResult}, data_model::{prelude::*, query::Pagination}, }; diff --git a/client/tests/integration/tx_rollback.rs b/client/tests/integration/tx_rollback.rs index a5cc76ad759..c9a713d79c0 100644 --- a/client/tests/integration/tx_rollback.rs +++ b/client/tests/integration/tx_rollback.rs @@ -1,7 +1,7 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, QueryResult}, data_model::prelude::*, }; diff --git a/client/tests/integration/upgrade.rs b/client/tests/integration/upgrade.rs index 8910e7f4abe..e023236197c 100644 --- a/client/tests/integration/upgrade.rs +++ b/client/tests/integration/upgrade.rs @@ -1,7 +1,7 @@ use std::{path::Path, str::FromStr as _}; use eyre::Result; -use iroha_client::{ +use iroha::{ client::{self, Client, QueryResult}, crypto::KeyPair, data_model::prelude::*, diff --git a/client/tests/ui_fail/cant_filter_singular_query.rs b/client/tests/ui_fail/cant_filter_singular_query.rs index f900887c656..ae0a86d75ef 100644 --- a/client/tests/ui_fail/cant_filter_singular_query.rs +++ b/client/tests/ui_fail/cant_filter_singular_query.rs @@ -1,4 +1,4 @@ -use iroha_client::{ +use iroha::{ client::{self, Client}, config::Config, data_model::query::predicate::{string, value, PredicateBox}, diff --git a/client/tests/ui_fail/cant_filter_singular_query.stderr b/client/tests/ui_fail/cant_filter_singular_query.stderr index 6533d07befc..1b3bc64063d 100644 --- a/client/tests/ui_fail/cant_filter_singular_query.stderr +++ b/client/tests/ui_fail/cant_filter_singular_query.stderr @@ -21,4 +21,4 @@ error[E0599]: the method `with_filter` exists for struct `QueryRequestBuilder<'_ | |_____- doesn't satisfy `_: IterableQuery` | = note: the following trait bounds were not satisfied: - `iroha_client::iroha_data_model::prelude::FindPermissionSchema: IterableQuery` + `iroha::iroha_data_model::prelude::FindPermissionSchema: IterableQuery` diff --git a/client_cli/Cargo.toml b/client_cli/Cargo.toml index 8b0d7d46383..ea49de44b9a 100644 --- a/client_cli/Cargo.toml +++ b/client_cli/Cargo.toml @@ -22,8 +22,12 @@ is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledg is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" } maintenance = { status = "actively-developed" } +[[bin]] +name = "iroha" +path = "src/main.rs" + [dependencies] -iroha_client = { workspace = true } +iroha = { workspace = true } iroha_primitives = { workspace = true } iroha_config_base = { workspace = true } diff --git a/client_cli/README.md b/client_cli/README.md index 9cb7fdf4d29..cc1e45cd9d6 100644 --- a/client_cli/README.md +++ b/client_cli/README.md @@ -1,7 +1,7 @@ # Iroha CLI Client With the Iroha CLI Client, you can interact with Iroha Peers Web API. -It is a "thin" wrapper around functionality exposed in the `iroha_client` crate. Specifically, it should be used as a reference for using `iroha_client`'s features, and not as a production-ready client. As such, the CLI client is not guaranteed to support all features supported by the client library. +It is a "thin" wrapper around functionality exposed in the `iroha` crate. Specifically, it should be used as a reference for using `iroha`'s features, and not as a production-ready client. As such, the CLI client is not guaranteed to support all features supported by the client library. ## Features @@ -18,7 +18,7 @@ Build Iroha and its binaries: cargo build ``` -The above command will produce the `iroha_client_cli` ELF executable file for Linux/BSD, the `iroha_client_cli` executable for MacOS, and the `iroha_client_cli.exe` executable for Windows, depending on your platform and configuration. +The above command will produce the `iroha` ELF executable file for Linux/BSD, the `iroha` executable for MacOS, and the `iroha.exe` executable for Windows, depending on your platform and configuration. Check [build and installation instructions](https://hyperledger.github.io/iroha-2-docs/guide/build-and-install.html) for more details. @@ -27,7 +27,7 @@ Check [build and installation instructions](https://hyperledger.github.io/iroha- Run Iroha Client CLI: ``` -iroha_client_cli [OPTIONS] +iroha [OPTIONS] ``` ### Options @@ -48,7 +48,7 @@ iroha_client_cli [OPTIONS] | `json` | Submit multi-instructions as JSON | | `peer` | Execute commands related to peer administration and networking | | `wasm` | Execute commands related to WASM | -| `help` | Print the help message for `iroha_client_cli` and/or the current subcommand other than `help` subcommand | +| `help` | Print the help message for `iroha` and/or the current subcommand other than `help` subcommand | Refer to [Iroha Special Instructions](https://hyperledger.github.io/iroha-2-docs/guide/blockchain/instructions.html) for more information about Iroha instructions such as register, mint, grant, and so on. @@ -56,14 +56,14 @@ Check the [Bash guide in Iroha Tutorial](https://hyperledger.github.io/iroha-2-d ## Examples -:grey_exclamation: All examples below are Unix-oriented. If you're working on Windows, we would highly encourage you to consider using WSL, as most documentation assumes a POSIX-like shell running on your system. Please be advised that the differences in the syntax may go beyond executing `iroha_client_cli.exe` instead of `iroha_client_cli`. +:grey_exclamation: All examples below are Unix-oriented. If you're working on Windows, we would highly encourage you to consider using WSL, as most documentation assumes a POSIX-like shell running on your system. Please be advised that the differences in the syntax may go beyond executing `iroha.exe` instead of `iroha`. ```bash -./iroha_client_cli domain register --id="Soramitsu" -./iroha_client_cli account register --id="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" -./iroha_client_cli asset register --id="XOR#Soramitsu" --value-type=Numeric -./iroha_client_cli asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 -./iroha_client_cli asset get --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" +./iroha domain register --id="Soramitsu" +./iroha account register --id="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" +./iroha asset register --id="XOR#Soramitsu" --value-type=Numeric +./iroha asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 +./iroha asset get --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" ``` In this section we will show you how to use Iroha CLI Client to do the following: @@ -89,7 +89,7 @@ Let's start with domain creation. To create a domain, you need to specify the en For the `domain` entity, you only need to provide the `id` argument as a string that doesn't contain the `@` and `#` symbols. ```bash -./iroha_client_cli domain register --id="Soramitsu" +./iroha domain register --id="Soramitsu" ``` Now you have a domain without any accounts. @@ -99,7 +99,7 @@ Now you have a domain without any accounts. Let's create a new account. Like in the previous example, specify the entity type (`account`) and the command (`register`). Then define the value of the `id` argument in "signatory@domain" format, where signatory is the account's public key in multihash representation. ```bash -./iroha_client_cli account register --id="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" +./iroha account register --id="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" ``` ### Mint Asset to Account @@ -111,8 +111,8 @@ To do so, you must first register an Asset Definition and only then add some Ass Every asset has its own value spec. In this example, it is defined as `Numeric`, a 96-bit unsigned decimal. We also support `Store` for key-value structured data. ```bash -./iroha_client_cli asset register --id="XOR#Soramitsu" --value-type=Numeric -./iroha_client_cli asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 +./iroha asset register --id="XOR#Soramitsu" --value-type=Numeric +./iroha asset mint --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 ``` You created `XOR#Soramitsu`, an asset of type `Numeric`, and then gave `1010` units of this asset to the account `ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu`. @@ -133,7 +133,7 @@ Let's use Get Account Assets Query as an example. To know how many units of a particular asset an account has, use `asset get` with the specified account and asset: ```bash -./iroha_client_cli asset get --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" +./iroha asset get --account="ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu" --asset="XOR#Soramitsu" ``` This query returns the quantity of `XOR#Soramitsu` asset for the `ed01204A3C5A6B77BBE439969F95F0AA4E01AE31EC45A0D68C131B2C622751FCC5E3B6@Soramitsu` account. @@ -143,21 +143,21 @@ It's possible to filter based on either account, asset or domain id by using the Generally it looks like this: ```bash -./iroha_client_cli ENTITY list filter PREDICATE +./iroha ENTITY list filter PREDICATE ``` -Where ENTITY is asset, account or domain and PREDICATE is condition used for filtering serialized using JSON5 (check `iroha_client::data_model::predicate::value::ValuePredicate` type). +Where ENTITY is asset, account or domain and PREDICATE is condition used for filtering serialized using JSON5 (check `iroha::data_model::predicate::value::ValuePredicate` type). Examples: ```bash # Filter domains by id -./iroha_client_cli domain list filter '{"Identifiable": {"Is": "wonderland"}}' +./iroha domain list filter '{"Identifiable": {"Is": "wonderland"}}' # Filter accounts by domain -./iroha_client_cli account list filter '{"Identifiable": {"EndsWith": "@wonderland"}}' +./iroha account list filter '{"Identifiable": {"EndsWith": "@wonderland"}}' # It is possible to combine filters using "Or" or "And" # Filter asset by domain -./iroha_client_cli asset list filter '{"Or": [{"Identifiable": {"Contains": "#wonderland#"}}, {"And": [{"Identifiable": {"Contains": "##"}}, {"Identifiable": {"EndsWith": "@wonderland"}}]}]}' +./iroha asset list filter '{"Or": [{"Identifiable": {"Contains": "#wonderland#"}}, {"And": [{"Identifiable": {"Contains": "##"}}, {"Identifiable": {"EndsWith": "@wonderland"}}]}]}' ``` ### Execute WASM transaction @@ -165,23 +165,23 @@ Examples: Use `--file` to specify a path to the WASM file: ```bash -./iroha_client_cli wasm --file=/path/to/file.wasm +./iroha wasm --file=/path/to/file.wasm ``` Or skip `--file` to read WASM from standard input: ```bash -cat /path/to/file.wasm | ./iroha_client_cli wasm +cat /path/to/file.wasm | ./iroha wasm ``` These subcommands submit the provided wasm binary as an `Executable` to be executed outside a trigger context. ### Execute Multi-instruction Transactions -The reference implementation of the Rust client, `iroha_client_cli`, is often used for diagnosing problems in other implementations. +The reference implementation of the Rust client, `iroha`, is often used for diagnosing problems in other implementations. To test transactions in the JSON format (used in the genesis block and by other SDKs), pipe the transaction into the client and add the `json` subcommand to the arguments: ```bash -cat /path/to/file.json | ./iroha_client_cli json +cat /path/to/file.json | ./iroha json ``` diff --git a/client_cli/pytests/README.md b/client_cli/pytests/README.md index 20034f78449..df8a1c90322 100644 --- a/client_cli/pytests/README.md +++ b/client_cli/pytests/README.md @@ -58,7 +58,7 @@ The test model has the following structure: # Note: make sure you have installed packages from `./scripts/requirements.txt` ``` - By default, this builds `irohad`, `iroha_client_cli`, and `kagami` binaries, and runs four peers with their API exposed through the `8080`-`8083` ports.\ + By default, this builds `irohad`, `iroha`, and `kagami` binaries, and runs four peers with their API exposed through the `8080`-`8083` ports.\ This behavior can be reconfigured. You can run `./scripts/test_env.py --help` to see the list of available commands and options. 2. Install and configure [Poetry](https://python-poetry.org/).\ @@ -88,7 +88,7 @@ The test model has the following structure: ### Custom Test Environment with Docker Compose -By default, we provide the [`test_env.py`](../../scripts/test_env.py) script to set up a test environment. This environment is composed of a running network of Iroha peers and an `iroha_client_cli` configuration to interact with it. +By default, we provide the [`test_env.py`](../../scripts/test_env.py) script to set up a test environment. This environment is composed of a running network of Iroha peers and an Iroha client configuration to interact with it. However, if for any reason this approach is inconvenient, it is possible to set up a custom network of Iroha peers using the provided Docker Compose configurations. @@ -100,26 +100,26 @@ To do so, perform the following steps: docker-compose -f docker-compose.dev.yml up ``` -2. Build the `iroha_client_cli` binary: +2. Build the Iroha client CLI binary: ```bash - cargo build --bin iroha_client_cli + cargo build --bin iroha ``` -3. Create a new directory, then copy the `iroha_client_cli` binary and its `client.toml` configuration file into it: +3. Create a new directory, then copy the `iroha` binary and `client.toml` configuration file into it: ```shell # Create a new directory: mkdir test # Copy the files: cp configs/swarm/client.toml test - cp target/debug/iroha_client_cli test + cp target/debug/iroha test ``` 4. Proceed with _Step 2_ of the [Using Test Suites](#using-test-suites) instructions. > [!NOTE] -> Don't forget to specify the path to the directory created for the `iroha_client_cli` binary and its `client.toml` configuration file (see Step 3) in the `CLIENT_CLI_DIR` variable of the `.env` file. +> Don't forget to specify the path to the directory created for the `iroha` binary and its `client.toml` configuration file (see Step 3) in the `CLIENT_CLI_DIR` variable of the `.env` file. > For details, see [Tests Configuration](#tests-configuration) below. ### Poetry Configuration @@ -156,7 +156,7 @@ Tests are configured via environment variables. These variables can be optionall The variables: -- `CLIENT_CLI_DIR` — Specifies a path to a directory containing the `iroha_client_cli` binary and its `config.json` configuration file.\ +- `CLIENT_CLI_DIR` — Specifies a path to a directory containing the `iroha` binary and its `config.json` configuration file.\ Set to `/client_cli`, by default. - `TORII_API_PORT_MIN`/`TORII_API_PORT_MAX` — This pair specifies the range of local ports through which the Iroha 2 peers are deployed. A randomly selected port from the specified range is used for each test.\ Set to `8080` and `8083` respectively, by default. diff --git a/client_cli/src/main.rs b/client_cli/src/main.rs index d8a8eab7fe6..281258b5060 100644 --- a/client_cli/src/main.rs +++ b/client_cli/src/main.rs @@ -10,7 +10,7 @@ use std::{ use erased_serde::Serialize; use error_stack::{fmt::ColorMode, IntoReportCompat, ResultExt}; use eyre::{eyre, Error, Result, WrapErr}; -use iroha_client::{ +use iroha::{ client::{Client, QueryResult}, config::Config, data_model::{metadata::MetadataValueBox, prelude::*}, @@ -80,7 +80,7 @@ impl FromStr for MetadataValueArg { /// Iroha CLI Client provides an ability to interact with Iroha Peers Web API without direct network usage. #[derive(clap::Parser, Debug)] -#[command(name = "iroha_client_cli", version = concat!("version=", env!("CARGO_PKG_VERSION"), " git_commit_sha=", env!("VERGEN_GIT_SHA")), author)] +#[command(name = "iroha", version = concat!("version=", env!("CARGO_PKG_VERSION"), " git_commit_sha=", env!("VERGEN_GIT_SHA")), author)] struct Args { /// Path to the configuration file #[arg(short, long, value_name("PATH"), value_hint(clap::ValueHint::FilePath))] @@ -239,24 +239,22 @@ fn submit( metadata: UnlimitedMetadata, context: &mut dyn RunContext, ) -> Result<()> { - let iroha_client = context.client_from_config(); + let iroha = context.client_from_config(); let instructions = instructions.into(); - let tx = iroha_client.build_transaction(instructions, metadata); + let tx = iroha.build_transaction(instructions, metadata); #[cfg(not(debug_assertions))] let err_msg = "Failed to submit transaction."; #[cfg(debug_assertions)] let err_msg = format!("Failed to submit transaction {tx:?}"); - let hash = iroha_client - .submit_transaction_blocking(&tx) - .wrap_err(err_msg)?; + let hash = iroha.submit_transaction_blocking(&tx).wrap_err(err_msg)?; context.print_data(&hash)?; Ok(()) } mod filter { - use iroha_client::data_model::query::predicate::PredicateBox; + use iroha::data_model::query::predicate::PredicateBox; use super::*; @@ -275,7 +273,7 @@ mod filter { mod events { - use iroha_client::data_model::events::pipeline::{BlockEventFilter, TransactionEventFilter}; + use iroha::data_model::events::pipeline::{BlockEventFilter, TransactionEventFilter}; use super::*; @@ -308,9 +306,9 @@ mod events { fn listen(filter: impl Into, context: &mut dyn RunContext) -> Result<()> { let filter = filter.into(); - let iroha_client = context.client_from_config(); + let iroha = context.client_from_config(); eprintln!("Listening to events with filter: {filter:?}"); - iroha_client + iroha .listen_for_events([filter]) .wrap_err("Failed to listen for events.")? .try_for_each(|event| context.print_data(&event?))?; @@ -338,9 +336,9 @@ mod blocks { } fn listen(height: NonZeroU64, context: &mut dyn RunContext) -> Result<()> { - let iroha_client = context.client_from_config(); + let iroha = context.client_from_config(); eprintln!("Listening to blocks from height: {height}"); - iroha_client + iroha .listen_for_blocks(height) .wrap_err("Failed to listen for blocks.")? .try_for_each(|event| context.print_data(&event?))?; @@ -349,7 +347,7 @@ mod blocks { } mod domain { - use iroha_client::client; + use iroha::client; use super::*; @@ -387,7 +385,7 @@ mod domain { impl RunArgs for Register { fn run(self, context: &mut dyn RunContext) -> Result<()> { let Self { id, metadata } = self; - let create_domain = iroha_client::data_model::isi::Register::domain(Domain::new(id)); + let create_domain = iroha::data_model::isi::Register::domain(Domain::new(id)); submit([create_domain], metadata.load()?, context).wrap_err("Failed to create domain") } } @@ -444,14 +442,14 @@ mod domain { to, metadata, } = self; - let transfer_domain = iroha_client::data_model::isi::Transfer::domain(from, id, to); + let transfer_domain = iroha::data_model::isi::Transfer::domain(from, id, to); submit([transfer_domain], metadata.load()?, context) .wrap_err("Failed to transfer domain") } } mod metadata { - use iroha_client::data_model::domain::DomainId; + use iroha::data_model::domain::DomainId; use super::*; @@ -521,7 +519,7 @@ mod domain { mod account { use std::fmt::Debug; - use iroha_client::client::{self}; + use iroha::client::{self}; use super::{Permission as DataModelPermission, *}; @@ -563,7 +561,7 @@ mod account { impl RunArgs for Register { fn run(self, context: &mut dyn RunContext) -> Result<()> { let Self { id, metadata } = self; - let create_account = iroha_client::data_model::isi::Register::account(Account::new(id)); + let create_account = iroha::data_model::isi::Register::account(Account::new(id)); submit([create_account], metadata.load()?, context) .wrap_err("Failed to register account") } @@ -634,7 +632,7 @@ mod account { permission, metadata, } = self; - let grant = iroha_client::data_model::isi::Grant::permission(permission.0, id); + let grant = iroha::data_model::isi::Grant::permission(permission.0, id); submit([grant], metadata.load()?, context) .wrap_err("Failed to grant the permission to the account") } @@ -662,7 +660,7 @@ mod account { } mod asset { - use iroha_client::{ + use iroha::{ client::{self, asset}, data_model::{asset::AssetDefinition, name::Name}, }; @@ -731,7 +729,7 @@ mod asset { asset_definition = asset_definition.mintable_once(); } let create_asset_definition = - iroha_client::data_model::isi::Register::asset_definition(asset_definition); + iroha::data_model::isi::Register::asset_definition(asset_definition); submit([create_asset_definition], metadata.load()?, context) .wrap_err("Failed to register asset") } @@ -757,7 +755,7 @@ mod asset { quantity, metadata, } = self; - let mint_asset = iroha_client::data_model::isi::Mint::asset_numeric(quantity, asset_id); + let mint_asset = iroha::data_model::isi::Mint::asset_numeric(quantity, asset_id); submit([mint_asset], metadata.load()?, context) .wrap_err("Failed to mint asset of type `Numeric`") } @@ -783,7 +781,7 @@ mod asset { quantity, metadata, } = self; - let burn_asset = iroha_client::data_model::isi::Burn::asset_numeric(quantity, asset_id); + let burn_asset = iroha::data_model::isi::Burn::asset_numeric(quantity, asset_id); submit([burn_asset], metadata.load()?, context) .wrap_err("Failed to burn asset of type `Numeric`") } @@ -814,7 +812,7 @@ mod asset { metadata, } = self; let transfer_asset = - iroha_client::data_model::isi::Transfer::asset_numeric(asset_id, quantity, to); + iroha::data_model::isi::Transfer::asset_numeric(asset_id, quantity, to); submit([transfer_asset], metadata.load()?, context).wrap_err("Failed to transfer asset") } } @@ -830,8 +828,8 @@ mod asset { impl RunArgs for Get { fn run(self, context: &mut dyn RunContext) -> Result<()> { let Self { asset_id } = self; - let iroha_client = context.client_from_config(); - let asset = iroha_client + let iroha = context.client_from_config(); + let asset = iroha .request(asset::by_id(asset_id)) .wrap_err("Failed to get asset.")?; context.print_data(&asset)?; @@ -887,7 +885,7 @@ mod asset { value: MetadataValueArg { value }, } = self; - let set = iroha_client::data_model::isi::SetKeyValue::asset(asset_id, key, value); + let set = iroha::data_model::isi::SetKeyValue::asset(asset_id, key, value); submit([set], UnlimitedMetadata::default(), context)?; Ok(()) } @@ -905,7 +903,7 @@ mod asset { impl RunArgs for RemoveKeyValue { fn run(self, context: &mut dyn RunContext) -> Result<()> { let Self { asset_id, key } = self; - let remove = iroha_client::data_model::isi::RemoveKeyValue::asset(asset_id, key); + let remove = iroha::data_model::isi::RemoveKeyValue::asset(asset_id, key); submit([remove], UnlimitedMetadata::default(), context)?; Ok(()) } @@ -977,7 +975,7 @@ mod peer { metadata, } = self; let register_peer = - iroha_client::data_model::isi::Register::peer(Peer::new(PeerId::new(address, key))); + iroha::data_model::isi::Register::peer(Peer::new(PeerId::new(address, key))); submit([register_peer], metadata.load()?, context).wrap_err("Failed to register peer") } } @@ -1003,7 +1001,7 @@ mod peer { metadata, } = self; let unregister_peer = - iroha_client::data_model::isi::Unregister::peer(PeerId::new(address, key)); + iroha::data_model::isi::Unregister::peer(PeerId::new(address, key)); submit([unregister_peer], metadata.load()?, context) .wrap_err("Failed to unregister peer") } diff --git a/core/src/smartcontracts/isi/triggers/set.rs b/core/src/smartcontracts/isi/triggers/set.rs index fcd5ea90efa..955d4229b96 100644 --- a/core/src/smartcontracts/isi/triggers/set.rs +++ b/core/src/smartcontracts/isi/triggers/set.rs @@ -150,7 +150,7 @@ pub struct SetView<'set> { /// Entry in wasm smart-contracts map #[derive(Debug, Clone, Serialize)] -struct WasmSmartContractEntry { +pub struct WasmSmartContractEntry { /// Original wasm binary blob original_contract: WasmSmartContract, /// Compiled with [`wasmtime`] smart-contract diff --git a/core/test_network/Cargo.toml b/core/test_network/Cargo.toml index 6241fbf5a44..410919ef7aa 100644 --- a/core/test_network/Cargo.toml +++ b/core/test_network/Cargo.toml @@ -10,7 +10,7 @@ license.workspace = true [dependencies] iroha_core = { workspace = true } irohad = { workspace = true, features = ["test-network"] } -iroha_client = { workspace = true } +iroha = { workspace = true } iroha_crypto = { workspace = true } iroha_config = { workspace = true } diff --git a/core/test_network/src/lib.rs b/core/test_network/src/lib.rs index e25a25baf93..4805059cea1 100644 --- a/core/test_network/src/lib.rs +++ b/core/test_network/src/lib.rs @@ -6,8 +6,7 @@ use std::{collections::BTreeMap, ops::Deref, path::Path, sync::Arc, thread}; use eyre::Result; use futures::{prelude::*, stream::FuturesUnordered}; -use irohad::{Iroha, ToriiStarted}; -use iroha_client::{ +use iroha::{ client::{Client, QueryOutput}, config::Config as ClientConfig, data_model::{isi::Instruction, peer::Peer as DataModelPeer, prelude::*, query::Query, Level}, @@ -22,6 +21,7 @@ use iroha_primitives::{ addr::{socket_addr, SocketAddr}, unique_vec::UniqueVec, }; +use irohad::{Iroha, ToriiStarted}; use rand::{seq::IteratorRandom, thread_rng}; use serde_json::json; use tempfile::TempDir; @@ -813,7 +813,7 @@ impl TestConfig for Config { impl TestClientConfig for ClientConfig { fn test(api_address: &SocketAddr) -> Self { - iroha_client::samples::get_client_config( + iroha::samples::get_client_config( get_chain_id(), get_key_pair(Signatory::Alice), format!("http://{api_address}") diff --git a/data_model/src/permission.rs b/data_model/src/permission.rs index e5c24fe2ea5..2233b67bea3 100644 --- a/data_model/src/permission.rs +++ b/data_model/src/permission.rs @@ -108,7 +108,7 @@ impl Permission { /// Only used in tests #[cfg(debug_assertions)] // TODO: Remove after integration tests have been moved to python tests - #[deprecated(note = "Will be removed after integration tests are removed from iroha_client")] + #[deprecated(note = "Will be removed after integration tests are removed from Iroha client")] pub fn from_str_unchecked(definition_id: PermissionId, payload: &str) -> Self { Self { definition_id, diff --git a/flake.nix b/flake.nix index 185837f8a00..7136e93ffcc 100755 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ allBinaries = [ "irohad" - "iroha_client_cli" + "iroha" "kagami" "kura_inspector" "parity_scale_cli" diff --git a/scripts/test_env.py b/scripts/test_env.py index 688c1ac2025..900ee79d46e 100755 --- a/scripts/test_env.py +++ b/scripts/test_env.py @@ -168,7 +168,7 @@ def run(self, submit_genesis: bool = False): stderr_file = open(self.peer_dir / ".stderr", "w") # These processes are created detached from the parent process already subprocess.Popen([self.name, "--config", self.config_path] + (["--submit-genesis"] if submit_genesis else []), - executable=self.out_dir / "peers/iroha", stdout=stdout_file, stderr=stderr_file) + executable=self.out_dir / "peers/irohad", stdout=stdout_file, stderr=stderr_file) def pos_int(arg): if int(arg) > 0: @@ -218,7 +218,7 @@ def main(args: argparse.Namespace): def setup(args: argparse.Namespace): logging.info(f"Starting Iroha network with {args.n_peers} peers...") os.makedirs(args.out_dir, exist_ok=True) - copy_or_prompt_build_bin("iroha_client_cli", args.root_dir, args.out_dir) + copy_or_prompt_build_bin("iroha", args.root_dir, args.out_dir) with open(os.path.join(args.out_dir, "metadata.json"), "w") as f: f.write('{"comment":{"String": "Hello Meta!"}}') shutil.copy2(pathlib.Path(args.root_dir) / SWARM_CONFIGS_DIRECTORY / "client.toml", args.out_dir)