converted zebrad -- all crate tests pass
This commit is contained in:
parent
3063bca62e
commit
64c6384d04
|
@ -441,7 +441,7 @@ impl Application for ZebradApp {
|
|||
tracing_config.flamegraph = None;
|
||||
}
|
||||
components.push(Box::new(Tracing::new(
|
||||
config.network.network,
|
||||
&config.network.network,
|
||||
tracing_config,
|
||||
command.cmd().uses_intro(),
|
||||
)?));
|
||||
|
|
|
@ -97,7 +97,7 @@ impl CopyStateCmd {
|
|||
|
||||
info!(?base_config, "state copy base config");
|
||||
|
||||
self.copy(base_config.network.network, source_config, target_config)
|
||||
self.copy(&base_config.network.network, source_config, target_config)
|
||||
.await
|
||||
.map_err(|e| eyre!(e))
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl CopyStateCmd {
|
|||
/// then copy from the source to the target state.
|
||||
async fn copy(
|
||||
&self,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
source_config: old_zs::Config,
|
||||
target_config: new_zs::Config,
|
||||
) -> Result<(), BoxError> {
|
||||
|
|
|
@ -235,7 +235,7 @@ impl StartCmd {
|
|||
sync_status.clone(),
|
||||
address_book.clone(),
|
||||
latest_chain_tip.clone(),
|
||||
config.network.network,
|
||||
config.network.network.clone(),
|
||||
);
|
||||
|
||||
// Start concurrent tasks which don't add load to other tasks
|
||||
|
@ -267,7 +267,7 @@ impl StartCmd {
|
|||
info!("spawning progress logging task");
|
||||
let progress_task_handle = tokio::spawn(
|
||||
show_block_chain_progress(
|
||||
config.network.network,
|
||||
config.network.network.clone(),
|
||||
latest_chain_tip.clone(),
|
||||
sync_status.clone(),
|
||||
)
|
||||
|
@ -277,7 +277,7 @@ impl StartCmd {
|
|||
// Spawn never ending end of support task.
|
||||
info!("spawning end of support checking task");
|
||||
let end_of_support_task_handle = tokio::spawn(
|
||||
sync::end_of_support::start(config.network.network, latest_chain_tip.clone())
|
||||
sync::end_of_support::start(config.network.network.clone(), latest_chain_tip.clone())
|
||||
.in_current_span(),
|
||||
);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ impl TipHeightCmd {
|
|||
|
||||
// UTXO verification isn't used here: we're not updating the state.
|
||||
let (_state_service, _read_state_service, latest_chain_tip, _chain_tip_change) =
|
||||
zebra_state::init(config, self.network, Height::MAX, 0);
|
||||
zebra_state::init(config, &self.network, Height::MAX, 0);
|
||||
|
||||
latest_chain_tip
|
||||
}
|
||||
|
|
|
@ -1057,7 +1057,7 @@ fn add_some_stuff_to_mempool(
|
|||
network: Network,
|
||||
) -> Vec<VerifiedUnminedTx> {
|
||||
// get the genesis block coinbase transaction from the Zcash blockchain.
|
||||
let genesis_transactions: Vec<_> = unmined_transactions_in_blocks(..=0, network)
|
||||
let genesis_transactions: Vec<_> = unmined_transactions_in_blocks(..=0, &network)
|
||||
.take(1)
|
||||
.collect();
|
||||
|
||||
|
|
|
@ -646,7 +646,7 @@ async fn setup(
|
|||
|
||||
// Network
|
||||
let network_config = NetworkConfig {
|
||||
network,
|
||||
network: network.clone(),
|
||||
listen_addr: config_listen_addr,
|
||||
|
||||
// Stop Zebra making outbound connections
|
||||
|
|
|
@ -15,7 +15,7 @@ mod vectors;
|
|||
|
||||
pub fn unmined_transactions_in_blocks(
|
||||
block_height_range: impl RangeBounds<u32>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> impl DoubleEndedIterator<Item = VerifiedUnminedTx> {
|
||||
let blocks = network.block_iter();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ fn mempool_storage_crud_exact_mainnet() {
|
|||
});
|
||||
|
||||
// Get one (1) unmined transaction
|
||||
let unmined_tx = unmined_transactions_in_blocks(.., network)
|
||||
let unmined_tx = unmined_transactions_in_blocks(.., &network)
|
||||
.next()
|
||||
.expect("at least one unmined transaction");
|
||||
|
||||
|
@ -69,7 +69,7 @@ fn mempool_storage_basic() -> Result<()> {
|
|||
|
||||
fn mempool_storage_basic_for_network(network: Network) -> Result<()> {
|
||||
// Get transactions from the first 10 blocks of the Zcash blockchain
|
||||
let unmined_transactions: Vec<_> = unmined_transactions_in_blocks(..=10, network).collect();
|
||||
let unmined_transactions: Vec<_> = unmined_transactions_in_blocks(..=10, &network).collect();
|
||||
|
||||
assert!(
|
||||
MEMPOOL_TX_COUNT < unmined_transactions.len(),
|
||||
|
@ -162,7 +162,7 @@ fn mempool_storage_crud_same_effects_mainnet() {
|
|||
});
|
||||
|
||||
// Get one (1) unmined transaction
|
||||
let unmined_tx_1 = unmined_transactions_in_blocks(.., network)
|
||||
let unmined_tx_1 = unmined_transactions_in_blocks(.., &network)
|
||||
.next()
|
||||
.expect("at least one unmined transaction");
|
||||
|
||||
|
@ -193,7 +193,7 @@ fn mempool_storage_crud_same_effects_mainnet() {
|
|||
);
|
||||
|
||||
// Get a different unmined transaction
|
||||
let unmined_tx_2 = unmined_transactions_in_blocks(1.., network)
|
||||
let unmined_tx_2 = unmined_transactions_in_blocks(1.., &network)
|
||||
.find(|tx| {
|
||||
tx.transaction
|
||||
.transaction
|
||||
|
|
|
@ -129,7 +129,7 @@ proptest! {
|
|||
|
||||
for (fake_chain_tip, transaction) in fake_chain_tips.iter().zip(transactions.iter_mut()) {
|
||||
// Obtain a new chain tip based on the previous one.
|
||||
let chain_tip = fake_chain_tip.to_chain_tip_block(&previous_chain_tip, network);
|
||||
let chain_tip = fake_chain_tip.to_chain_tip_block(&previous_chain_tip, &network);
|
||||
|
||||
// Adjust the transaction expiry height based on the new chain
|
||||
// tip height so that the mempool does not evict the transaction
|
||||
|
@ -319,7 +319,7 @@ impl FakeChainTip {
|
|||
/// Returns a new [`ChainTipBlock`] placed on top of the previous block if
|
||||
/// the chain is supposed to grow. Otherwise returns a [`ChainTipBlock`]
|
||||
/// that does not reference the previous one.
|
||||
fn to_chain_tip_block(&self, previous: &ChainTipBlock, network: Network) -> ChainTipBlock {
|
||||
fn to_chain_tip_block(&self, previous: &ChainTipBlock, network: &Network) -> ChainTipBlock {
|
||||
match self {
|
||||
Self::Grow(chain_tip_block) => {
|
||||
let height = block::Height(previous.height.0 + 1);
|
||||
|
|
|
@ -44,7 +44,7 @@ async fn mempool_service_basic_single() -> Result<(), Report> {
|
|||
let network = Network::Mainnet;
|
||||
|
||||
// get the genesis block transactions from the Zcash blockchain.
|
||||
let mut unmined_transactions = unmined_transactions_in_blocks(1..=10, network);
|
||||
let mut unmined_transactions = unmined_transactions_in_blocks(1..=10, &network);
|
||||
let genesis_transaction = unmined_transactions
|
||||
.next()
|
||||
.expect("Missing genesis transaction");
|
||||
|
@ -56,7 +56,7 @@ async fn mempool_service_basic_single() -> Result<(), Report> {
|
|||
let cost_limit = more_transactions.iter().map(|tx| tx.cost()).sum();
|
||||
|
||||
let (mut service, _peer_set, _state_service, _chain_tip_change, _tx_verifier, mut recent_syncs) =
|
||||
setup(network, cost_limit, true).await;
|
||||
setup(&network, cost_limit, true).await;
|
||||
|
||||
// Enable the mempool
|
||||
service.enable(&mut recent_syncs).await;
|
||||
|
@ -187,7 +187,7 @@ async fn mempool_queue_single() -> Result<(), Report> {
|
|||
let network = Network::Mainnet;
|
||||
|
||||
// Get transactions to use in the test
|
||||
let unmined_transactions = unmined_transactions_in_blocks(1..=10, network);
|
||||
let unmined_transactions = unmined_transactions_in_blocks(1..=10, &network);
|
||||
let mut transactions = unmined_transactions.collect::<Vec<_>>();
|
||||
// Split unmined_transactions into:
|
||||
// [transactions..., new_tx]
|
||||
|
@ -203,7 +203,7 @@ async fn mempool_queue_single() -> Result<(), Report> {
|
|||
.sum();
|
||||
|
||||
let (mut service, _peer_set, _state_service, _chain_tip_change, _tx_verifier, mut recent_syncs) =
|
||||
setup(network, cost_limit, true).await;
|
||||
setup(&network, cost_limit, true).await;
|
||||
|
||||
// Enable the mempool
|
||||
service.enable(&mut recent_syncs).await;
|
||||
|
@ -277,10 +277,10 @@ async fn mempool_service_disabled() -> Result<(), Report> {
|
|||
let network = Network::Mainnet;
|
||||
|
||||
let (mut service, _peer_set, _state_service, _chain_tip_change, _tx_verifier, mut recent_syncs) =
|
||||
setup(network, u64::MAX, true).await;
|
||||
setup(&network, u64::MAX, true).await;
|
||||
|
||||
// get the genesis block transactions from the Zcash blockchain.
|
||||
let mut unmined_transactions = unmined_transactions_in_blocks(1..=10, network);
|
||||
let mut unmined_transactions = unmined_transactions_in_blocks(1..=10, &network);
|
||||
let genesis_transaction = unmined_transactions
|
||||
.next()
|
||||
.expect("Missing genesis transaction");
|
||||
|
@ -398,7 +398,7 @@ async fn mempool_cancel_mined() -> Result<(), Report> {
|
|||
mut chain_tip_change,
|
||||
_tx_verifier,
|
||||
mut recent_syncs,
|
||||
) = setup(network, u64::MAX, true).await;
|
||||
) = setup(&network, u64::MAX, true).await;
|
||||
|
||||
// Enable the mempool
|
||||
mempool.enable(&mut recent_syncs).await;
|
||||
|
@ -513,7 +513,7 @@ async fn mempool_cancel_downloads_after_network_upgrade() -> Result<(), Report>
|
|||
mut chain_tip_change,
|
||||
_tx_verifier,
|
||||
mut recent_syncs,
|
||||
) = setup(network, u64::MAX, true).await;
|
||||
) = setup(&network, u64::MAX, true).await;
|
||||
|
||||
// Enable the mempool
|
||||
mempool.enable(&mut recent_syncs).await;
|
||||
|
@ -600,10 +600,10 @@ async fn mempool_failed_verification_is_rejected() -> Result<(), Report> {
|
|||
_chain_tip_change,
|
||||
mut tx_verifier,
|
||||
mut recent_syncs,
|
||||
) = setup(network, u64::MAX, true).await;
|
||||
) = setup(&network, u64::MAX, true).await;
|
||||
|
||||
// Get transactions to use in the test
|
||||
let mut unmined_transactions = unmined_transactions_in_blocks(1..=2, network);
|
||||
let mut unmined_transactions = unmined_transactions_in_blocks(1..=2, &network);
|
||||
let rejected_tx = unmined_transactions.next().unwrap().clone();
|
||||
|
||||
// Enable the mempool
|
||||
|
@ -675,10 +675,10 @@ async fn mempool_failed_download_is_not_rejected() -> Result<(), Report> {
|
|||
_chain_tip_change,
|
||||
_tx_verifier,
|
||||
mut recent_syncs,
|
||||
) = setup(network, u64::MAX, true).await;
|
||||
) = setup(&network, u64::MAX, true).await;
|
||||
|
||||
// Get transactions to use in the test
|
||||
let mut unmined_transactions = unmined_transactions_in_blocks(1..=2, network);
|
||||
let mut unmined_transactions = unmined_transactions_in_blocks(1..=2, &network);
|
||||
let rejected_valid_tx = unmined_transactions.next().unwrap().clone();
|
||||
|
||||
// Enable the mempool
|
||||
|
@ -760,7 +760,7 @@ async fn mempool_reverifies_after_tip_change() -> Result<(), Report> {
|
|||
mut chain_tip_change,
|
||||
mut tx_verifier,
|
||||
mut recent_syncs,
|
||||
) = setup(network, u64::MAX, true).await;
|
||||
) = setup(&network, u64::MAX, true).await;
|
||||
|
||||
// Enable the mempool
|
||||
mempool.enable(&mut recent_syncs).await;
|
||||
|
@ -909,7 +909,7 @@ async fn mempool_reverifies_after_tip_change() -> Result<(), Report> {
|
|||
|
||||
/// Create a new [`Mempool`] instance using mocked services.
|
||||
async fn setup(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
tx_cost_limit: u64,
|
||||
should_commit_genesis_block: bool,
|
||||
) -> (
|
||||
|
|
|
@ -51,7 +51,7 @@ pub async fn start(
|
|||
loop {
|
||||
if network == Network::Mainnet {
|
||||
if let Some(tip_height) = latest_chain_tip.best_tip_height() {
|
||||
check(tip_height, network);
|
||||
check(tip_height, &network);
|
||||
}
|
||||
} else {
|
||||
info!("Release always valid in Testnet");
|
||||
|
@ -61,7 +61,7 @@ pub async fn start(
|
|||
}
|
||||
|
||||
/// Check if the current release is too old and panic if so.
|
||||
pub fn check(tip_height: Height, network: Network) {
|
||||
pub fn check(tip_height: Height, network: &Network) {
|
||||
info!("Checking if Zebra release is inside support range ...");
|
||||
|
||||
// Get the current block spacing
|
||||
|
|
|
@ -149,7 +149,7 @@ fn request_genesis_is_rate_limited() {
|
|||
});
|
||||
|
||||
// create an empty latest chain tip
|
||||
let (_sender, latest_chain_tip, _change) = ChainTipSender::new(None, &network::Mainnet);
|
||||
let (_sender, latest_chain_tip, _change) = ChainTipSender::new(None, &Network::Mainnet);
|
||||
|
||||
// create a verifier service that will always panic as it will never be called
|
||||
let verifier_service =
|
||||
|
|
|
@ -80,7 +80,11 @@ impl Tracing {
|
|||
//
|
||||
// This method should only print to stderr, because stdout is for tracing logs.
|
||||
#[allow(clippy::print_stdout, clippy::print_stderr, clippy::unwrap_in_result)]
|
||||
pub fn new(network: Network, config: Config, uses_intro: bool) -> Result<Self, FrameworkError> {
|
||||
pub fn new(
|
||||
network: &Network,
|
||||
config: Config,
|
||||
uses_intro: bool,
|
||||
) -> Result<Self, FrameworkError> {
|
||||
// Only use color if tracing output is being sent to a terminal or if it was explicitly
|
||||
// forced to.
|
||||
let use_color = config.use_color_stdout();
|
||||
|
|
|
@ -220,7 +220,7 @@ fn generate_no_args() -> Result<()> {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
let child = testdir()?
|
||||
.with_config(&mut default_test_config(Mainnet)?)?
|
||||
.with_config(&mut default_test_config(&Mainnet)?)?
|
||||
.spawn_child(args!["generate"])?;
|
||||
|
||||
let output = child.wait_with_output()?;
|
||||
|
@ -282,7 +282,7 @@ fn generate_args() -> Result<()> {
|
|||
fn help_no_args() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(Mainnet)?)?;
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(&Mainnet)?)?;
|
||||
|
||||
let child = testdir.spawn_child(args!["help"])?;
|
||||
let output = child.wait_with_output()?;
|
||||
|
@ -327,7 +327,7 @@ fn start_no_args() -> Result<()> {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
// start caches state, so run one of the start tests with persistent state
|
||||
let testdir = testdir()?.with_config(&mut persistent_test_config(Mainnet)?)?;
|
||||
let testdir = testdir()?.with_config(&mut persistent_test_config(&Mainnet)?)?;
|
||||
|
||||
let mut child = testdir.spawn_child(args!["-v", "start"])?;
|
||||
|
||||
|
@ -354,7 +354,7 @@ fn start_no_args() -> Result<()> {
|
|||
fn start_args() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(Mainnet)?)?;
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(&Mainnet)?)?;
|
||||
let testdir = &testdir;
|
||||
|
||||
let mut child = testdir.spawn_child(args!["start"])?;
|
||||
|
@ -379,7 +379,7 @@ fn start_args() -> Result<()> {
|
|||
#[tokio::test]
|
||||
async fn db_init_outside_future_executor() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
let config = default_test_config(Mainnet)?;
|
||||
let config = default_test_config(&Mainnet)?;
|
||||
|
||||
let start = Instant::now();
|
||||
|
||||
|
@ -409,7 +409,7 @@ async fn db_init_outside_future_executor() -> Result<()> {
|
|||
fn persistent_mode() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
let testdir = testdir()?.with_config(&mut persistent_test_config(Mainnet)?)?;
|
||||
let testdir = testdir()?.with_config(&mut persistent_test_config(&Mainnet)?)?;
|
||||
let testdir = &testdir;
|
||||
|
||||
let mut child = testdir.spawn_child(args!["-v", "start"])?;
|
||||
|
@ -474,7 +474,7 @@ fn ephemeral(cache_dir_config: EphemeralConfig, cache_dir_check: EphemeralCheck)
|
|||
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
let run_dir = testdir()?;
|
||||
|
||||
let ignored_cache_dir = run_dir.path().join("state");
|
||||
|
@ -564,7 +564,7 @@ fn ephemeral(cache_dir_config: EphemeralConfig, cache_dir_check: EphemeralCheck)
|
|||
fn version_no_args() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(Mainnet)?)?;
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(&Mainnet)?)?;
|
||||
|
||||
let child = testdir.spawn_child(args!["--version"])?;
|
||||
let output = child.wait_with_output()?;
|
||||
|
@ -585,7 +585,7 @@ fn version_no_args() -> Result<()> {
|
|||
fn version_args() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(Mainnet)?)?;
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(&Mainnet)?)?;
|
||||
let testdir = &testdir;
|
||||
|
||||
// unrecognized option `-f`
|
||||
|
@ -639,7 +639,7 @@ fn app_no_args() -> Result<()> {
|
|||
let _init_guard = zebra_test::init();
|
||||
|
||||
// start caches state, so run one of the start tests with persistent state
|
||||
let testdir = testdir()?.with_config(&mut persistent_test_config(Mainnet)?)?;
|
||||
let testdir = testdir()?.with_config(&mut persistent_test_config(&Mainnet)?)?;
|
||||
|
||||
tracing::info!(?testdir, "running zebrad with no config (default settings)");
|
||||
|
||||
|
@ -1030,7 +1030,7 @@ fn stored_configs_work() -> Result<()> {
|
|||
fn sync_one_checkpoint_mainnet() -> Result<()> {
|
||||
sync_until(
|
||||
TINY_CHECKPOINT_TEST_HEIGHT,
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
STOP_AT_HEIGHT_REGEX,
|
||||
TINY_CHECKPOINT_TIMEOUT,
|
||||
None,
|
||||
|
@ -1051,7 +1051,7 @@ fn sync_one_checkpoint_mainnet() -> Result<()> {
|
|||
fn sync_one_checkpoint_testnet() -> Result<()> {
|
||||
sync_until(
|
||||
TINY_CHECKPOINT_TEST_HEIGHT,
|
||||
Testnet,
|
||||
&Testnet,
|
||||
STOP_AT_HEIGHT_REGEX,
|
||||
TINY_CHECKPOINT_TIMEOUT,
|
||||
None,
|
||||
|
@ -1078,7 +1078,7 @@ fn restart_stop_at_height() -> Result<()> {
|
|||
fn restart_stop_at_height_for_network(network: Network, height: block::Height) -> Result<()> {
|
||||
let reuse_tempdir = sync_until(
|
||||
height,
|
||||
network,
|
||||
&network,
|
||||
STOP_AT_HEIGHT_REGEX,
|
||||
TINY_CHECKPOINT_TIMEOUT,
|
||||
None,
|
||||
|
@ -1092,7 +1092,7 @@ fn restart_stop_at_height_for_network(network: Network, height: block::Height) -
|
|||
// sync, rather than stopping immediately at the configured height
|
||||
sync_until(
|
||||
height,
|
||||
network,
|
||||
&network,
|
||||
"state is already at the configured height",
|
||||
STOP_ON_LOAD_TIMEOUT,
|
||||
reuse_tempdir,
|
||||
|
@ -1111,7 +1111,7 @@ fn restart_stop_at_height_for_network(network: Network, height: block::Height) -
|
|||
fn activate_mempool_mainnet() -> Result<()> {
|
||||
sync_until(
|
||||
block::Height(TINY_CHECKPOINT_TEST_HEIGHT.0 + 1),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
STOP_AT_HEIGHT_REGEX,
|
||||
TINY_CHECKPOINT_TIMEOUT,
|
||||
None,
|
||||
|
@ -1133,7 +1133,7 @@ fn activate_mempool_mainnet() -> Result<()> {
|
|||
fn sync_large_checkpoints_mainnet() -> Result<()> {
|
||||
let reuse_tempdir = sync_until(
|
||||
LARGE_CHECKPOINT_TEST_HEIGHT,
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
STOP_AT_HEIGHT_REGEX,
|
||||
LARGE_CHECKPOINT_TIMEOUT,
|
||||
None,
|
||||
|
@ -1145,7 +1145,7 @@ fn sync_large_checkpoints_mainnet() -> Result<()> {
|
|||
// if this sync fails, see the failure notes in `restart_stop_at_height`
|
||||
sync_until(
|
||||
(LARGE_CHECKPOINT_TEST_HEIGHT - 1).unwrap(),
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
"previous state height is greater than the stop height",
|
||||
STOP_ON_LOAD_TIMEOUT,
|
||||
reuse_tempdir,
|
||||
|
@ -1169,7 +1169,7 @@ fn sync_large_checkpoints_mainnet() -> Result<()> {
|
|||
fn sync_large_checkpoints_mempool_mainnet() -> Result<()> {
|
||||
sync_until(
|
||||
MEDIUM_CHECKPOINT_TEST_HEIGHT,
|
||||
Mainnet,
|
||||
&Mainnet,
|
||||
STOP_AT_HEIGHT_REGEX,
|
||||
LARGE_CHECKPOINT_TIMEOUT,
|
||||
None,
|
||||
|
@ -1188,7 +1188,7 @@ fn create_cached_database(network: Network) -> Result<()> {
|
|||
format!("{STOP_AT_HEIGHT_REGEX}.*commit checkpoint-verified request");
|
||||
|
||||
create_cached_database_height(
|
||||
network,
|
||||
&network,
|
||||
height,
|
||||
// Use checkpoints to increase sync performance while caching the database
|
||||
true,
|
||||
|
@ -1204,7 +1204,7 @@ fn sync_past_mandatory_checkpoint(network: Network) -> Result<()> {
|
|||
format!("{STOP_AT_HEIGHT_REGEX}.*commit contextually-verified request");
|
||||
|
||||
create_cached_database_height(
|
||||
network,
|
||||
&network,
|
||||
height.unwrap(),
|
||||
// Test full validation by turning checkpoints off
|
||||
false,
|
||||
|
@ -1232,7 +1232,7 @@ fn full_sync_test(network: Network, timeout_argument_name: &str) -> Result<()> {
|
|||
// - the path from ZEBRA_CACHED_STATE_DIR
|
||||
if let Some(_timeout_minutes) = timeout_argument {
|
||||
create_cached_database_height(
|
||||
network,
|
||||
&network,
|
||||
// Just keep going until we reach the chain tip
|
||||
block::Height::MAX,
|
||||
// Use the checkpoints to sync quickly, then do full validation until the chain tip
|
||||
|
@ -1502,7 +1502,7 @@ async fn rpc_endpoint(parallel_cpu_threads: bool) -> Result<()> {
|
|||
|
||||
// Write a configuration that has RPC listen_addr set
|
||||
// [Note on port conflict](#Note on port conflict)
|
||||
let mut config = random_known_rpc_port_config(parallel_cpu_threads, Mainnet)?;
|
||||
let mut config = random_known_rpc_port_config(parallel_cpu_threads, &Mainnet)?;
|
||||
|
||||
let dir = testdir()?.with_config(&mut config)?;
|
||||
let mut child = dir.spawn_child(args!["start"])?;
|
||||
|
@ -1561,7 +1561,7 @@ async fn rpc_endpoint_client_content_type() -> Result<()> {
|
|||
|
||||
// Write a configuration that has RPC listen_addr set
|
||||
// [Note on port conflict](#Note on port conflict)
|
||||
let mut config = random_known_rpc_port_config(true, Mainnet)?;
|
||||
let mut config = random_known_rpc_port_config(true, &Mainnet)?;
|
||||
|
||||
let dir = testdir()?.with_config(&mut config)?;
|
||||
let mut child = dir.spawn_child(args!["start"])?;
|
||||
|
@ -1647,7 +1647,7 @@ fn non_blocking_logger() -> Result<()> {
|
|||
|
||||
// Write a configuration that has RPC listen_addr set
|
||||
// [Note on port conflict](#Note on port conflict)
|
||||
let mut config = random_known_rpc_port_config(false, Mainnet)?;
|
||||
let mut config = random_known_rpc_port_config(false, &Mainnet)?;
|
||||
config.tracing.filter = Some("trace".to_string());
|
||||
config.tracing.buffer_limit = 100;
|
||||
let zebra_rpc_address = config.rpc.listen_addr.unwrap();
|
||||
|
@ -1839,9 +1839,12 @@ fn lightwalletd_integration_test(test_type: TestType) -> Result<()> {
|
|||
}
|
||||
|
||||
// Launch zebra with peers and using a predefined zebrad state path.
|
||||
let (mut zebrad, zebra_rpc_address) = if let Some(zebrad_and_address) =
|
||||
spawn_zebrad_for_rpc(network, test_name, test_type, use_internet_connection)?
|
||||
{
|
||||
let (mut zebrad, zebra_rpc_address) = if let Some(zebrad_and_address) = spawn_zebrad_for_rpc(
|
||||
network.clone(),
|
||||
test_name,
|
||||
test_type,
|
||||
use_internet_connection,
|
||||
)? {
|
||||
tracing::info!(
|
||||
?test_type,
|
||||
"running lightwalletd & zebrad integration test, launching zebrad...",
|
||||
|
@ -2083,7 +2086,7 @@ fn zebra_zcash_listener_conflict() -> Result<()> {
|
|||
let listen_addr = format!("127.0.0.1:{port}");
|
||||
|
||||
// Write a configuration that has our created network listen_addr
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
config.network.listen_addr = listen_addr.parse().unwrap();
|
||||
let dir1 = testdir()?.with_config(&mut config)?;
|
||||
let regex1 = regex::escape(&format!("Opened Zcash protocol endpoint at {listen_addr}"));
|
||||
|
@ -2175,7 +2178,7 @@ fn zebra_rpc_conflict() -> Result<()> {
|
|||
// [Note on port conflict](#Note on port conflict)
|
||||
//
|
||||
// This is the required setting to detect port conflicts.
|
||||
let mut config = random_known_rpc_port_config(false, Mainnet)?;
|
||||
let mut config = random_known_rpc_port_config(false, &Mainnet)?;
|
||||
|
||||
let dir1 = testdir()?.with_config(&mut config)?;
|
||||
let regex1 = regex::escape(&format!(
|
||||
|
@ -2202,7 +2205,7 @@ fn zebra_state_conflict() -> Result<()> {
|
|||
|
||||
// A persistent config has a fixed temp state directory, but asks the OS to
|
||||
// automatically choose an unused port
|
||||
let mut config = persistent_test_config(Mainnet)?;
|
||||
let mut config = persistent_test_config(&Mainnet)?;
|
||||
let dir_conflict = testdir()?.with_config(&mut config)?;
|
||||
|
||||
// Windows problems with this match will be worked on at #1654
|
||||
|
@ -2367,7 +2370,7 @@ fn delete_old_databases() -> Result<()> {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
let run_dir = testdir()?;
|
||||
let cache_dir = run_dir.path().join("state");
|
||||
|
||||
|
@ -2483,7 +2486,7 @@ async fn submit_block() -> Result<()> {
|
|||
#[test]
|
||||
fn end_of_support_is_checked_at_start() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(Mainnet)?)?;
|
||||
let testdir = testdir()?.with_config(&mut default_test_config(&Mainnet)?)?;
|
||||
let mut child = testdir.spawn_child(args!["start"])?;
|
||||
|
||||
// Give enough time to start up the eos task.
|
||||
|
@ -2594,7 +2597,7 @@ async fn state_format_test(
|
|||
|
||||
// # Create a new state and check it has the current version
|
||||
|
||||
let zebrad = spawn_zebrad_without_rpc(network, test_name, false, false, None, false)?;
|
||||
let zebrad = spawn_zebrad_without_rpc(network.clone(), test_name, false, false, None, false)?;
|
||||
|
||||
// Skip the test unless it has the required state and environmental variables.
|
||||
let Some(mut zebrad) = zebrad else {
|
||||
|
@ -2643,7 +2646,7 @@ async fn state_format_test(
|
|||
tracing::info!(?network, "running {test_name} using zebra-state");
|
||||
|
||||
let config = UseAnyState
|
||||
.zebrad_config(test_name, false, Some(dir.path()), network)
|
||||
.zebrad_config(test_name, false, Some(dir.path()), &network)
|
||||
.expect("already checked config")?;
|
||||
|
||||
zebra_state::write_state_database_format_version_to_disk(
|
||||
|
@ -2675,8 +2678,9 @@ async fn state_format_test(
|
|||
expect_newer_version = false;
|
||||
}
|
||||
|
||||
let mut zebrad = spawn_zebrad_without_rpc(network, test_name, false, false, dir, false)?
|
||||
.expect("unexpectedly missing required state or env vars");
|
||||
let mut zebrad =
|
||||
spawn_zebrad_without_rpc(network.clone(), test_name, false, false, dir, false)?
|
||||
.expect("unexpectedly missing required state or env vars");
|
||||
|
||||
tracing::info!(?network, "running {test_name} using zebrad");
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ pub fn wait_for_state_version_upgrade<T>(
|
|||
/// Starts a state service using the provided `cache_dir` as the directory with the chain state.
|
||||
#[tracing::instrument(skip(cache_dir))]
|
||||
pub async fn start_state_service_with_cache_dir(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
cache_dir: impl Into<PathBuf>,
|
||||
) -> Result<(
|
||||
BoxStateService,
|
||||
|
@ -144,7 +144,7 @@ pub async fn start_state_service_with_cache_dir(
|
|||
/// Loads the chain tip height from the state stored in a specified directory.
|
||||
#[tracing::instrument]
|
||||
pub async fn load_tip_height_from_state_directory(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
state_path: &Path,
|
||||
) -> Result<block::Height> {
|
||||
let (_state_service, _read_state_service, latest_chain_tip, _chain_tip_change) =
|
||||
|
@ -168,7 +168,7 @@ pub async fn load_tip_height_from_state_directory(
|
|||
///
|
||||
/// If the provided `test_type` doesn't need an rpc server and cached state, or if `max_num_blocks` is 0
|
||||
pub async fn get_future_blocks(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
test_type: TestType,
|
||||
test_name: &str,
|
||||
max_num_blocks: u32,
|
||||
|
@ -199,7 +199,7 @@ pub async fn get_future_blocks(
|
|||
///
|
||||
/// If the provided `test_type` doesn't need an rpc server and cached state, or if `max_num_blocks` is 0
|
||||
pub async fn get_raw_future_blocks(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
test_type: TestType,
|
||||
test_name: &str,
|
||||
max_num_blocks: u32,
|
||||
|
@ -216,7 +216,7 @@ pub async fn get_raw_future_blocks(
|
|||
|
||||
let should_sync = true;
|
||||
let (zebrad, zebra_rpc_address) =
|
||||
spawn_zebrad_for_rpc(network, test_name, test_type, should_sync)?
|
||||
spawn_zebrad_for_rpc(network.clone(), test_name, test_type, should_sync)?
|
||||
.ok_or_else(|| eyre!("get_raw_future_blocks requires a cached state"))?;
|
||||
let rpc_address = zebra_rpc_address.expect("test type must have RPC port");
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ use crate::common::cached_state::DATABASE_FORMAT_CHECK_INTERVAL;
|
|||
/// - an ephemeral state,
|
||||
/// - the minimum syncer lookahead limit, and
|
||||
/// - shorter task intervals, to improve test coverage.
|
||||
pub fn default_test_config(net: Network) -> Result<ZebradConfig> {
|
||||
pub fn default_test_config(net: &Network) -> Result<ZebradConfig> {
|
||||
const TEST_DURATION: Duration = Duration::from_secs(30);
|
||||
|
||||
let network = zebra_network::Config {
|
||||
network: net,
|
||||
network: net.clone(),
|
||||
// The OS automatically chooses an unused port.
|
||||
listen_addr: "127.0.0.1:0".parse()?,
|
||||
crawl_new_peer_interval: TEST_DURATION,
|
||||
|
@ -113,7 +113,7 @@ pub fn default_test_config(net: Network) -> Result<ZebradConfig> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn persistent_test_config(network: Network) -> Result<ZebradConfig> {
|
||||
pub fn persistent_test_config(network: &Network) -> Result<ZebradConfig> {
|
||||
let mut config = default_test_config(network)?;
|
||||
config.state.ephemeral = false;
|
||||
Ok(config)
|
||||
|
@ -142,7 +142,7 @@ pub fn config_file_full_path(config_file: PathBuf) -> PathBuf {
|
|||
/// Set `parallel_cpu_threads` to true to auto-configure based on the number of CPU cores.
|
||||
pub fn random_known_rpc_port_config(
|
||||
parallel_cpu_threads: bool,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> Result<ZebradConfig> {
|
||||
// [Note on port conflict](#Note on port conflict)
|
||||
let listen_port = random_known_port();
|
||||
|
|
|
@ -78,14 +78,14 @@ pub(crate) async fn run() -> Result<()> {
|
|||
|
||||
let should_sync = true;
|
||||
let (zebrad, zebra_rpc_address) =
|
||||
spawn_zebrad_for_rpc(network, test_name, test_type, should_sync)?
|
||||
spawn_zebrad_for_rpc(network.clone(), test_name, test_type, should_sync)?
|
||||
.ok_or_else(|| eyre!("getblocktemplate test requires a cached state"))?;
|
||||
|
||||
let rpc_address = zebra_rpc_address.expect("test type must have RPC port");
|
||||
|
||||
let mut zebrad = check_sync_logs_until(
|
||||
zebrad,
|
||||
network,
|
||||
&network,
|
||||
SYNC_FINISHED_REGEX,
|
||||
MempoolBehavior::ShouldAutomaticallyActivate,
|
||||
true,
|
||||
|
|
|
@ -42,7 +42,7 @@ pub(crate) async fn run() -> Result<()> {
|
|||
);
|
||||
|
||||
let raw_blocks: Vec<String> =
|
||||
get_raw_future_blocks(network, test_type, test_name, MAX_NUM_FUTURE_BLOCKS).await?;
|
||||
get_raw_future_blocks(&network, test_type, test_name, MAX_NUM_FUTURE_BLOCKS).await?;
|
||||
|
||||
tracing::info!("got raw future blocks, spawning isolated zebrad...",);
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ pub fn spawn_zebrad_for_rpc<S: AsRef<str> + Debug>(
|
|||
|
||||
// Get the zebrad config
|
||||
let config = test_type
|
||||
.zebrad_config(test_name, use_internet_connection, None, network)
|
||||
.zebrad_config(test_name, use_internet_connection, None, &network)
|
||||
.expect("already checked config")?;
|
||||
|
||||
let (zebrad_failure_messages, zebrad_ignore_messages) = test_type.zebrad_failure_messages();
|
||||
|
@ -314,7 +314,7 @@ where
|
|||
test_name,
|
||||
use_internet_connection,
|
||||
replace_cache_dir,
|
||||
network,
|
||||
&network,
|
||||
)
|
||||
.expect("already checked config")?;
|
||||
|
||||
|
@ -353,7 +353,7 @@ pub fn can_spawn_zebrad_for_test_type<S: AsRef<str> + Debug>(
|
|||
// Check if we have any necessary cached states for the zebrad config.
|
||||
// The cache_dir and network values don't matter here.
|
||||
test_type
|
||||
.zebrad_config(test_name, true, None, Mainnet)
|
||||
.zebrad_config(test_name, true, None, &Mainnet)
|
||||
.is_some()
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ impl MempoolBehavior {
|
|||
#[tracing::instrument(skip(reuse_tempdir))]
|
||||
pub fn sync_until(
|
||||
height: Height,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
stop_regex: &str,
|
||||
timeout: Duration,
|
||||
// Test Settings
|
||||
|
@ -298,7 +298,7 @@ pub fn sync_until(
|
|||
#[tracing::instrument(skip(zebrad))]
|
||||
pub fn check_sync_logs_until(
|
||||
mut zebrad: TestChild<TempDir>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
stop_regex: &str,
|
||||
// Test Settings
|
||||
mempool_behavior: MempoolBehavior,
|
||||
|
@ -328,7 +328,7 @@ pub fn check_sync_logs_until(
|
|||
}
|
||||
|
||||
/// Returns a test config for caching Zebra's state up to the mandatory checkpoint.
|
||||
pub fn cached_mandatory_checkpoint_test_config(network: Network) -> Result<ZebradConfig> {
|
||||
pub fn cached_mandatory_checkpoint_test_config(network: &Network) -> Result<ZebradConfig> {
|
||||
let mut config = persistent_test_config(network)?;
|
||||
config.state.cache_dir = "/zebrad-cache".into();
|
||||
|
||||
|
@ -365,7 +365,7 @@ pub fn cached_mandatory_checkpoint_test_config(network: Network) -> Result<Zebra
|
|||
#[allow(clippy::print_stderr)]
|
||||
#[tracing::instrument]
|
||||
pub fn create_cached_database_height(
|
||||
network: Network,
|
||||
network: &Network,
|
||||
height: Height,
|
||||
checkpoint_sync: bool,
|
||||
stop_regex: &str,
|
||||
|
|
|
@ -177,7 +177,7 @@ impl TestType {
|
|||
test_name: Str,
|
||||
use_internet_connection: bool,
|
||||
replace_cache_dir: Option<&Path>,
|
||||
network: Network,
|
||||
network: &Network,
|
||||
) -> Option<Result<ZebradConfig>> {
|
||||
let config = if self.needs_zebra_rpc_server() {
|
||||
// This is what we recommend our users configure.
|
||||
|
|
|
@ -18,7 +18,7 @@ fn end_of_support_panic() {
|
|||
// We are in panic
|
||||
let panic = ESTIMATED_RELEASE_HEIGHT + (EOS_PANIC_AFTER * ESTIMATED_BLOCKS_PER_DAY) + 1;
|
||||
|
||||
end_of_support::check(Height(panic), Network::Mainnet);
|
||||
end_of_support::check(Height(panic), &Network::Mainnet);
|
||||
}
|
||||
|
||||
/// Test that the `end_of_support` function is working as expected.
|
||||
|
@ -29,7 +29,7 @@ fn end_of_support_function() {
|
|||
let no_warn = ESTIMATED_RELEASE_HEIGHT + (EOS_PANIC_AFTER * ESTIMATED_BLOCKS_PER_DAY)
|
||||
- (30 * ESTIMATED_BLOCKS_PER_DAY);
|
||||
|
||||
end_of_support::check(Height(no_warn), Network::Mainnet);
|
||||
end_of_support::check(Height(no_warn), &Network::Mainnet);
|
||||
assert!(logs_contain(
|
||||
"Checking if Zebra release is inside support range ..."
|
||||
));
|
||||
|
@ -38,7 +38,7 @@ fn end_of_support_function() {
|
|||
// We are in warn range
|
||||
let warn = ESTIMATED_RELEASE_HEIGHT + (EOS_PANIC_AFTER * 1152) - (3 * ESTIMATED_BLOCKS_PER_DAY);
|
||||
|
||||
end_of_support::check(Height(warn), Network::Mainnet);
|
||||
end_of_support::check(Height(warn), &Network::Mainnet);
|
||||
assert!(logs_contain(
|
||||
"Checking if Zebra release is inside support range ..."
|
||||
));
|
||||
|
@ -59,7 +59,7 @@ fn end_of_support_date() {
|
|||
// Get the last one we have and use it as tip.
|
||||
let higher_checkpoint = list.max_height();
|
||||
|
||||
end_of_support::check(higher_checkpoint, Network::Mainnet);
|
||||
end_of_support::check(higher_checkpoint, &Network::Mainnet);
|
||||
assert!(logs_contain(
|
||||
"Checking if Zebra release is inside support range ..."
|
||||
));
|
||||
|
|
Loading…
Reference in New Issue