Skip to content

Commit

Permalink
Added glossary entries.
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr <a-p-petrosyan@yandex.ru>
  • Loading branch information
appetrosyan committed Nov 23, 2021
1 parent 2db2041 commit 15d74ba
Show file tree
Hide file tree
Showing 19 changed files with 303 additions and 351 deletions.
37 changes: 15 additions & 22 deletions client/benches/torii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,28 @@
use std::thread;

use criterion::{criterion_group, criterion_main, Criterion, Throughput};
use iroha_client::{
client::{asset, Client},
config::Configuration as ClientConfiguration,
};
use iroha_client::client::{asset, Client};
use iroha_core::{
config::Configuration,
genesis::{GenesisNetwork, GenesisNetworkTrait},
prelude::*,
samples::get_config,
};
use iroha_data_model::prelude::*;
use test_network::{Peer as TestPeer, TestRuntime};
use test_network::{get_key_pair, Peer as TestPeer, TestRuntime};
use tokio::runtime::Runtime;

const CONFIGURATION_PATH: &str = "../configs/test_config.json";
const CLIENT_CONFIGURATION_PATH: &str = "../configs/test_client_config.json";
const GENESIS_PATH: &str = "../configs/genesis.json";
const MINIMUM_SUCCESS_REQUEST_RATIO: f32 = 0.9;

fn query_requests(criterion: &mut Criterion) {
let mut configuration =
Configuration::from_path(CONFIGURATION_PATH).expect("Failed to load configuration.");
let mut peer = <TestPeer>::new().expect("Failed to create peer");
let configuration = get_config(
std::iter::once(peer.id.clone()).collect(),
Some(get_key_pair()),
);
let rt = Runtime::test();
configuration.sumeragi.trusted_peers.peers = std::iter::once(peer.id.clone()).collect();
let genesis = GenesisNetwork::from_configuration(
true,
GENESIS_PATH,
("alice", "wonderland", &get_key_pair().public_key).into(),
&configuration.genesis,
configuration.sumeragi.max_instruction_number,
)
Expand Down Expand Up @@ -61,8 +56,7 @@ fn query_requests(criterion: &mut Criterion) {
Value::U32(quantity),
IdBox::AssetId(AssetId::new(asset_definition_id, account_id.clone())),
);
let mut client_config = ClientConfiguration::from_path(CLIENT_CONFIGURATION_PATH)
.expect("Failed to load configuration.");
let mut client_config = iroha_client::samples::get_client_config(&get_key_pair());
client_config.torii_api_url = peer.api_address.clone();
let mut iroha_client = Client::new(&client_config);
let _ = iroha_client
Expand Down Expand Up @@ -104,15 +98,15 @@ fn query_requests(criterion: &mut Criterion) {
}

fn instruction_submits(criterion: &mut Criterion) {
let mut configuration =
Configuration::from_path(CONFIGURATION_PATH).expect("Failed to load configuration.");
let rt = Runtime::test();
let mut peer = <TestPeer>::new().expect("Failed to create peer");
configuration.sumeragi.trusted_peers.peers = std::iter::once(peer.id.clone()).collect();

let configuration = get_config(
std::iter::once(peer.id.clone()).collect(),
Some(get_key_pair()),
);
let genesis = GenesisNetwork::from_configuration(
true,
GENESIS_PATH,
("alice", "wonderland", &configuration.public_key).into(),
&configuration.genesis,
configuration.sumeragi.max_instruction_number,
)
Expand All @@ -135,8 +129,7 @@ fn instruction_submits(criterion: &mut Criterion) {
.into(),
));
let asset_definition_id = AssetDefinitionId::new("xor", domain_name);
let mut client_config = ClientConfiguration::from_path(CLIENT_CONFIGURATION_PATH)
.expect("Failed to load configuration.");
let mut client_config = iroha_client::samples::get_client_config(&get_key_pair());
client_config.torii_api_url = peer.api_address.clone();
let mut iroha_client = Client::new(&client_config);
let _ = iroha_client
Expand Down
35 changes: 19 additions & 16 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ pub mod client;
pub mod config;
pub use config::Configuration;
mod http_client;

/// Module containing sample configurations for tests and benchmarks.
pub mod samples {
use super::Configuration;
use iroha_core::prelude::KeyPair;
/// Get sample client configuration.
pub fn get_client_config(key_pair: &KeyPair) -> Configuration {
let (public_key, private_key) = key_pair.clone().into();
Configuration {
public_key,
private_key,
account_id: iroha_data_model::prelude::AccountId{
name: "alice".to_string(),
domain_name: "wonderland".to_string(),
},
torii_api_url: iroha_core::torii::config::DEFAULT_TORII_API_URL.to_string(),
..Configuration::default()
}
}
use iroha_core::prelude::KeyPair;

use super::Configuration;
/// Get sample client configuration.
pub fn get_client_config(key_pair: &KeyPair) -> Configuration {
let (public_key, private_key) = key_pair.clone().into();
Configuration {
public_key,
private_key,
account_id: iroha_data_model::prelude::AccountId {
name: "alice".to_owned(),
domain_name: "wonderland".to_owned(),
},
torii_api_url: iroha_core::torii::config::DEFAULT_TORII_API_URL.to_owned(),
..Configuration::default()
}
}
}
14 changes: 0 additions & 14 deletions client/src/samples.rs

This file was deleted.

2 changes: 1 addition & 1 deletion configs/peer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
"payload": "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"
}
}
}
}
2 changes: 1 addition & 1 deletion configs/peer/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@
]
}
]
}
}
2 changes: 1 addition & 1 deletion configs/peer/trusted_peers.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"address": "127.0.0.1:1340",
"public_key": "ed01208e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f"
}
]
]
3 changes: 2 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ pin-project = "1"


[dev-dependencies]
test_network = { version = "=0.1.0", path = "./test_network" }

hex-literal = "0.2.1"
tempfile = "3"
criterion = "0.3"
hex = "0.4.0"
unique_port = "0.1.0"
byte-unit = "4.0.12"
once_cell = "1"
test_network = { version = "=0.1.0", path = "./test_network" }

[[bench]]
name = "sumeragi"
Expand Down
8 changes: 5 additions & 3 deletions core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
block_sync::config::BlockSyncConfiguration,
genesis::config::GenesisConfiguration,
kura::config::KuraConfiguration,
queue::config::QueueConfiguration,
queue::Configuration as QueueConfiguration,
sumeragi::config::{SumeragiConfiguration, TrustedPeers},
torii::config::ToriiConfiguration,
wsv::config::Configuration as WorldStateViewConfiguration,
Expand Down Expand Up @@ -139,10 +139,11 @@ mod tests {

use super::*;

const CONFIGURATION_PATH: &str = "../configs/test_config.json";
const TRUSTED_PEERS_PATH: &str = "../configs/test_trusted_peers.json";
const CONFIGURATION_PATH: &str = "../configs/peer/config.json";
const TRUSTED_PEERS_PATH: &str = "../configs/peer/trusted_peers.json";

#[test]
#[ignore = "We shouldn't be testing `serde`"]
fn parse_example_json() -> Result<()> {
let configuration = Configuration::from_path(CONFIGURATION_PATH)
.wrap_err("Failed to read configuration from example config")?;
Expand All @@ -152,6 +153,7 @@ mod tests {
}

#[test]
#[ignore = "We shouldn't be testing `serde`"]
fn parse_example_trusted_peers_json() -> Result<(), String> {
let mut configuration = Configuration::from_path(CONFIGURATION_PATH)
.map_err(|e| format!("Failed to read configuration from example config: {}", e))?;
Expand Down
Loading

0 comments on commit 15d74ba

Please sign in to comment.