Skip to main content

tidecoin_node_parity/
fixtures.rs

1// SPDX-License-Identifier: CC0-1.0
2
3use std::path::{Path, PathBuf};
4
5/// Environment variable pointing at the Tidecoin node checkout.
6pub const TIDECOIN_NODE_REPO_ENV: &str = "TIDECOIN_NODE_REPO";
7
8/// Returns the configured Tidecoin node checkout path.
9///
10/// Panics with a clear message if the environment variable is missing.
11pub fn node_repo_dir() -> PathBuf {
12    std::env::var_os(TIDECOIN_NODE_REPO_ENV)
13        .map(PathBuf::from)
14        .unwrap_or_else(|| {
15            panic!(
16                "missing {TIDECOIN_NODE_REPO_ENV}; set it to the Tidecoin node checkout used for node-backed validation"
17            )
18        })
19}
20
21/// Returns the `src/test/data` directory under the configured Tidecoin node checkout.
22pub fn test_data_dir() -> PathBuf {
23    node_repo_dir().join("src/test/data")
24}
25
26/// Returns a path under the Tidecoin node `src/test/data` directory.
27pub fn test_data_path(name: &str) -> PathBuf {
28    test_data_dir().join(name)
29}
30
31/// Panics if the configured Tidecoin node checkout does not contain `src/`.
32pub fn assert_node_src_exists(node_repo: &Path) {
33    let node_src = node_repo.join("src");
34    assert!(
35        node_src.exists(),
36        "tidecoin-node-validation requires Tidecoin node sources at {}",
37        node_repo.display()
38    );
39}