Skip to content

Commit

Permalink
[test]: fix config tests (linked #4079)
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Balashov <[email protected]>
  • Loading branch information
0x009922 committed Nov 24, 2023
1 parent 529cc2c commit 664e588
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
36 changes: 22 additions & 14 deletions client/tests/integration/config.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
use iroha_data_model::Level;
use test_network::*;

use super::{Builder, Configuration, ConfigurationProxy};
use super::Configuration;

#[test]
fn get_config() {
fn config_endpoints() {
// The underscored variables must not be dropped until end of closure.
let (_dont_drop, _dont_drop_either, test_client) =
<PeerBuilder>::new().with_port(10_685).start_with_runtime();
wait_for_genesis_committed(&vec![test_client.clone()], 0);
let test_cfg = Configuration::test();
const NEW_LOG_LEVEL: Level = Level::TRACE;

let field = test_client.get_config_docs(&["torii"]).unwrap().unwrap();
assert!(field.contains("IROHA_TORII"));
// Just to be sure this test suite is not useless
assert_ne!(test_cfg.logger.max_log_level.value(), NEW_LOG_LEVEL);

let test = Configuration::test();
let cfg_proxy: ConfigurationProxy =
serde_json::from_value(test_client.get_config_value().unwrap()).unwrap();
// Retrieving through API
let mut dto = test_client.get_config().unwrap();
assert_eq!(
cfg_proxy.block_sync.unwrap().build().unwrap(),
test.block_sync
);
assert_eq!(cfg_proxy.network.unwrap().build().unwrap(), test.network);
assert_eq!(
cfg_proxy.telemetry.unwrap().build().unwrap(),
*test.telemetry
dto.logger.max_log_level,
test_cfg.logger.max_log_level.value()
);

// Updating the log level
dto.logger.max_log_level = NEW_LOG_LEVEL;
test_client.set_config(dto).unwrap();

// FIXME: The updated value is not reflected
// https://github.com/hyperledger/iroha/issues/4079

// // Checking the updated value
// let dto = test_client.get_config().unwrap();
// assert_eq!(dto.logger.max_log_level, NEW_LOG_LEVEL);
}
7 changes: 4 additions & 3 deletions config/src/client_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use super::{iroha::Configuration as BaseConfiguration, logger::Configuration as
/// Subset of [`super::iroha`] configuration.
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
pub struct ConfigurationDTO {
logger: Logger,
#[allow(missing_docs)]
pub logger: Logger,
}

impl From<&'_ BaseConfiguration> for ConfigurationDTO {
Expand All @@ -41,9 +42,9 @@ impl ConfigurationDTO {

/// Subset of [`super::logger`] configuration.
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
struct Logger {
pub struct Logger {
#[allow(missing_docs)]
max_log_level: Level,
pub max_log_level: Level,
}

impl From<&'_ BaseLogger> for Logger {
Expand Down

0 comments on commit 664e588

Please sign in to comment.