mysten_common/
lib.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use once_cell::sync::Lazy;
5use tracing::warn;
6
7pub mod assert_reachable;
8pub mod backoff;
9pub mod decay_moving_average;
10pub mod logging;
11pub mod moving_window;
12pub mod random;
13pub mod random_util;
14pub mod rpc_format;
15pub mod sync;
16pub mod zip_debug_eq;
17
18pub use random_util::tempdir;
19pub use zip_debug_eq::ZipDebugEqIteratorExt;
20
21#[inline(always)]
22pub fn in_integration_test() -> bool {
23    in_antithesis() || cfg!(msim)
24}
25
26#[inline(always)]
27pub fn in_antithesis() -> bool {
28    static IN_ANTITHESIS: Lazy<bool> = Lazy::new(|| {
29        let in_antithesis = std::env::var("ANTITHESIS_OUTPUT_DIR").is_ok();
30        if in_antithesis {
31            warn!("Detected that we are running in antithesis");
32        }
33        in_antithesis
34    });
35    *IN_ANTITHESIS
36}
37
38#[inline(always)]
39pub fn in_test_configuration() -> bool {
40    in_antithesis() || cfg!(msim) || cfg!(debug_assertions)
41}