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 sync;
15
16pub use random_util::tempdir;
17
18#[inline(always)]
19pub fn in_integration_test() -> bool {
20    in_antithesis() || cfg!(msim)
21}
22
23#[inline(always)]
24pub fn in_antithesis() -> bool {
25    static IN_ANTITHESIS: Lazy<bool> = Lazy::new(|| {
26        let in_antithesis = std::env::var("ANTITHESIS_OUTPUT_DIR").is_ok();
27        if in_antithesis {
28            warn!("Detected that we are running in antithesis");
29        }
30        in_antithesis
31    });
32    *IN_ANTITHESIS
33}
34
35#[inline(always)]
36pub fn in_test_configuration() -> bool {
37    in_antithesis() || cfg!(msim) || cfg!(debug_assertions)
38}