Skip to content

Commit

Permalink
Merge of #9251
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Feb 13, 2025
2 parents 39017c0 + 6428fd0 commit 8072429
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ run_tests() {
--package zebra-state \
-- --nocapture --include-ignored with_fake_activation_heights

elif [[ "${TEST_SCAN_TASK_COMMANDS}" -eq "1" ]]; then
elif [[ "${TEST_SCANNER}" -eq "1" ]]; then
# Test the scanner.
exec cargo test --locked --release --package zebra-scan \
-- --nocapture --include-ignored scan_task_commands scan_start_where_left
Expand Down
15 changes: 9 additions & 6 deletions zebra-scan/tests/scan_task_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use std::{fs, time::Duration};

use color_eyre::{eyre::eyre, Result};
use color_eyre::Result;
use tokio::sync::mpsc::error::TryRecvError;
use tower::{util::BoxService, Service};

Expand Down Expand Up @@ -61,7 +61,7 @@ pub(crate) async fn run() -> Result<()> {

let zebrad_state_path = match std::env::var_os("ZEBRA_CACHE_DIR") {
None => {
tracing::error!("ZEBRA_CACHE_DIR is not set");
tracing::warn!("env var ZEBRA_CACHE_DIR is not set, skipping test");
return Ok(());
}
Some(path) => std::path::PathBuf::from(path),
Expand All @@ -87,9 +87,10 @@ pub(crate) async fn run() -> Result<()> {

let (read_state, _, _) = zebra_state::init_read_only(state_config.clone(), &network);

let chain_tip_height = latest_chain_tip
.best_tip_height()
.ok_or_else(|| eyre!("State directory doesn't have a chain tip block"))?;
let Some(chain_tip_height) = latest_chain_tip.best_tip_height() else {
tracing::warn!("chain could not be loaded from cached state, skipping test");
return Ok(());
};

let sapling_activation_height = NetworkUpgrade::Sapling
.activation_height(&network)
Expand All @@ -111,7 +112,9 @@ pub(crate) async fn run() -> Result<()> {
let storage = Storage::new(&scan_config, &network, false);
let mut scan_task = ScanTask::spawn(storage, read_state, chain_tip_change);

tracing::info!("started scan task, sending register/subscribe keys messages with zecpages key to start scanning for a new key",);
tracing::info!(
"started scan task, sending register/subscribe keys messages with zecpages key to start scanning for a new key",
);

let keys = [ZECPAGES_SAPLING_VIEWING_KEY.to_string()];
scan_task.register_keys(
Expand Down
18 changes: 10 additions & 8 deletions zebra-scan/tests/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,22 @@ async fn scan_binary_starts() -> Result<()> {
#[tokio::test]
#[cfg(not(target_os = "windows"))]
async fn scan_start_where_left() -> Result<()> {
use ZECPAGES_SAPLING_VIEWING_KEY;

let _init_guard = zebra_test::init();

let Ok(zebrad_cachedir) = std::env::var("ZEBRA_CACHE_DIR") else {
tracing::info!("skipping scan_start_where_left test due to missing cached state, \
please set a ZEBRA_CACHE_DIR env var with a populated and valid path to run this test");
let Ok(zebrad_cache_dir) = std::env::var("ZEBRA_CACHE_DIR") else {
tracing::warn!("env var ZEBRA_CACHE_DIR is not set, skipping test");
return Ok(());
};

if !Path::new(&zebrad_cache_dir).join("state").is_dir() {
tracing::warn!("cache dir does not contain cached state, skipping test");
return Ok(());
}

// Logs the network as zebrad would as part of the metadata when starting up.
// This is currently needed for the 'Check startup logs' step in CI to pass.
let network = zebra_chain::parameters::Network::Mainnet;
tracing::info!("Zcash network: {network}");
let mainnet = zebra_chain::parameters::Network::Mainnet;
tracing::info!("Zcash network: {mainnet}");

let scanning_cache_dir = testdir()?.path().join("scanner").to_path_buf();

Expand All @@ -164,7 +166,7 @@ async fn scan_start_where_left() -> Result<()> {
let rpc_listen_addr = "127.0.0.1:18232";
let args = args![
"--zebrad-cache-dir",
zebrad_cachedir,
zebrad_cache_dir,
"--scanning-cache-dir",
scanning_cache_dir.to_str().unwrap(),
"--sapling-keys-to-scan",
Expand Down

0 comments on commit 8072429

Please sign in to comment.