Skip to content

Commit

Permalink
[test]: fix tests, validate addrs only in release
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
  • Loading branch information
0x009922 committed Apr 19, 2024
1 parent 69522d2 commit 5af02bf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cli/src/lib.rs
Expand Up @@ -659,8 +659,14 @@ pub fn read_config_and_genesis(
fn validate_config(config: &Config, submit_genesis: bool) -> Result<(), ConfigError> {
let mut emitter = Emitter::new();

validate_try_bind_address(&mut emitter, &config.network.address);
validate_try_bind_address(&mut emitter, &config.torii.address);
// These cause race condition in tests, due to them actually binding TCP listeners
// Since these validations are primarily for the convenience of the end user,
// it seems a fine compromise to run it only in release mode
#[cfg(release)]
{
validate_try_bind_address(&mut emitter, &config.network.address);
validate_try_bind_address(&mut emitter, &config.torii.address);
}
validate_directory_path(&mut emitter, &config.kura.store_dir);
// maybe validate only if snapshot mode is enabled
validate_directory_path(&mut emitter, &config.snapshot.store_dir);
Expand Down Expand Up @@ -738,6 +744,7 @@ fn validate_directory_path(emitter: &mut Emitter<ConfigError>, path: &WithOrigin
}
}

#[cfg(release)]
fn validate_try_bind_address(emitter: &mut Emitter<ConfigError>, value: &WithOrigin<SocketAddr>) {
use std::net::TcpListener;

Expand Down Expand Up @@ -935,7 +942,6 @@ mod tests {
}

#[test]
#[ignore] // FIXME
fn fails_with_no_trusted_peers_and_submit_role() -> eyre::Result<()> {
// Given

Expand Down

0 comments on commit 5af02bf

Please sign in to comment.