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