use color_eyre::eyre::Result;
use zebra_chain::parameters::Network::{self, *};
use zebra_test::prelude::*;
use crate::common::{
sync::{create_cached_database_height, STOP_AT_HEIGHT_REGEX},
test_type::TestType::*,
};
#[tracing::instrument]
fn create_cached_database(network: Network) -> Result<()> {
let height = network.mandatory_checkpoint_height();
let checkpoint_stop_regex =
format!("{STOP_AT_HEIGHT_REGEX}.*commit checkpoint-verified request");
create_cached_database_height(
&network,
height,
true,
&checkpoint_stop_regex,
)
}
#[tracing::instrument]
fn sync_past_mandatory_checkpoint(network: Network) -> Result<()> {
let height = network.mandatory_checkpoint_height() + (32_257 + 1200);
let full_validation_stop_regex =
format!("{STOP_AT_HEIGHT_REGEX}.*commit contextually-verified request");
create_cached_database_height(
&network,
height.unwrap(),
false,
&full_validation_stop_regex,
)
}
#[test]
#[ignore]
fn sync_to_mandatory_checkpoint_mainnet() -> Result<()> {
sync_to_mandatory_checkpoint_for_network(Mainnet)
}
#[test]
#[ignore]
fn sync_to_mandatory_checkpoint_testnet() -> Result<()> {
sync_to_mandatory_checkpoint_for_network(Network::new_default_testnet())
}
fn sync_to_mandatory_checkpoint_for_network(network: Network) -> Result<()> {
let _init_guard = zebra_test::init();
create_cached_database(network)
}
#[allow(dead_code)]
#[test]
#[ignore]
fn sync_past_mandatory_checkpoint_mainnet() -> Result<()> {
let _init_guard = zebra_test::init();
let network = Mainnet;
sync_past_mandatory_checkpoint(network)
}
#[allow(dead_code)]
#[test]
#[ignore]
fn sync_past_mandatory_checkpoint_testnet() -> Result<()> {
let _init_guard = zebra_test::init();
let network = Network::new_default_testnet();
sync_past_mandatory_checkpoint(network)
}
#[test]
#[ignore]
fn sync_update_mainnet() -> Result<()> {
crate::common::lightwalletd::lwd_integration_test(UpdateZebraCachedStateNoRpc)
}