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