From 1b4c66c3c31e8c780ea73c258babe25a97576a11 Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 5 May 2022 11:56:01 +1000 Subject: [PATCH 1/3] Expect a Zebra cached state with at least a million blocks --- zebrad/tests/acceptance.rs | 3 +-- zebrad/tests/common/lightwalletd.rs | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index a0853518543..5867f710fca 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -1163,8 +1163,7 @@ fn lightwalletd_integration_test(test_type: LightwalletdTestType) -> Result<()> } if test_type.needs_lightwalletd_cached_state() { - // TODO: expect `[0-9]{7}` when we're using the tip cached state (#4155) - lightwalletd.expect_stdout_line_matches("Found [0-9]{6,7} blocks in cache")?; + lightwalletd.expect_stdout_line_matches("Found [0-9]{7} blocks in cache")?; } else if !test_type.allow_lightwalletd_cached_state() { // Timeout the test if we're somehow accidentally using a cached state in our temp dir lightwalletd.expect_stdout_line_matches("Found 0 blocks in cache")?; diff --git a/zebrad/tests/common/lightwalletd.rs b/zebrad/tests/common/lightwalletd.rs index e7ec71f7f70..7c894122168 100644 --- a/zebrad/tests/common/lightwalletd.rs +++ b/zebrad/tests/common/lightwalletd.rs @@ -378,9 +378,7 @@ impl LightwalletdTestType { // lightwalletd state failures if self.needs_lightwalletd_cached_state() { // Fail if we need a cached lightwalletd state, but it isn't near the tip - // - // TODO: fail on `[0-9]{1,6}` when we're using the tip cached state (#4155) - lightwalletd_failure_messages.push("Found [0-9]{1,5} blocks in cache".to_string()); + lightwalletd_failure_messages.push("Found [0-9]{1,6} blocks in cache".to_string()); } if !self.allow_lightwalletd_cached_state() { // Fail if we need an empty lightwalletd state, but it has blocks From 17d97ee40db7612473883c23a9ef36337d2ce73d Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 5 May 2022 12:09:57 +1000 Subject: [PATCH 2/3] Set the zebrad timeout and failure messages based on the test type --- zebrad/tests/acceptance.rs | 7 ++---- zebrad/tests/common/launch.rs | 22 ++++++------------- zebrad/tests/common/lightwalletd.rs | 3 --- .../lightwalletd/send_transaction_test.rs | 10 +++------ .../common/lightwalletd/wallet_grpc_test.rs | 8 ++----- 5 files changed, 14 insertions(+), 36 deletions(-) diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index 5867f710fca..6f201ea69cd 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -1486,11 +1486,8 @@ async fn fully_synced_rpc_test() -> Result<()> { let network = Network::Mainnet; - let (_zebrad, zebra_rpc_address) = spawn_zebrad_for_rpc_without_initial_peers( - network, - cached_state_path.unwrap(), - test_type.zebrad_timeout(), - )?; + let (_zebrad, zebra_rpc_address) = + spawn_zebrad_for_rpc_without_initial_peers(network, cached_state_path.unwrap(), test_type)?; // Make a getblock test that works only on synced node (high block number). // The block is before the mandatory checkpoint, so the checkpoint cached state can be used diff --git a/zebrad/tests/common/launch.rs b/zebrad/tests/common/launch.rs index 1221b6c51d3..6e673e6c7f9 100644 --- a/zebrad/tests/common/launch.rs +++ b/zebrad/tests/common/launch.rs @@ -18,15 +18,12 @@ use color_eyre::eyre::Result; use zebra_chain::parameters::Network; use zebra_test::{ args, - command::{Arguments, TestDirExt, NO_MATCHES_REGEX_ITER}, + command::{Arguments, TestDirExt}, prelude::*, }; use zebrad::config::ZebradConfig; -use crate::common::{ - failure_messages::{PROCESS_FAILURE_MESSAGES, ZEBRA_FAILURE_MESSAGES}, - lightwalletd::random_known_rpc_port_config, -}; +use crate::common::lightwalletd::{random_known_rpc_port_config, LightwalletdTestType}; /// After we launch `zebrad`, wait this long for the command to start up, /// take the actions expected by the tests, and log the expected logs. @@ -198,7 +195,7 @@ where pub fn spawn_zebrad_for_rpc_without_initial_peers( network: Network, zebra_directory: P, - timeout: Duration, + test_type: LightwalletdTestType, ) -> Result<(TestChild

, SocketAddr)> { let mut config = random_known_rpc_port_config() .expect("Failed to create a config file with a known RPC listener port"); @@ -209,19 +206,14 @@ pub fn spawn_zebrad_for_rpc_without_initial_peers( config.network.network = network; config.mempool.debug_enable_at_height = Some(0); + let (zebrad_failure_messages, zebrad_ignore_messages) = test_type.zebrad_failure_messages(); + let mut zebrad = zebra_directory .with_config(&mut config)? .spawn_child(args!["start"])? .bypass_test_capture(true) - .with_timeout(timeout) - .with_failure_regex_iter( - // TODO: replace with a function that returns the full list and correct return type - ZEBRA_FAILURE_MESSAGES - .iter() - .chain(PROCESS_FAILURE_MESSAGES) - .cloned(), - NO_MATCHES_REGEX_ITER.iter().cloned(), - ); + .with_timeout(test_type.zebrad_timeout()) + .with_failure_regex_iter(zebrad_failure_messages, zebrad_ignore_messages); let rpc_address = config.rpc.listen_addr.unwrap(); diff --git a/zebrad/tests/common/lightwalletd.rs b/zebrad/tests/common/lightwalletd.rs index 7c894122168..87325012b8d 100644 --- a/zebrad/tests/common/lightwalletd.rs +++ b/zebrad/tests/common/lightwalletd.rs @@ -58,9 +58,6 @@ pub const ZEBRA_TEST_LIGHTWALLETD: &str = "ZEBRA_TEST_LIGHTWALLETD"; /// by skipping the lightwalletd initial sync. pub const LIGHTWALLETD_DATA_DIR_VAR: &str = "LIGHTWALLETD_DATA_DIR"; -/// The maximum time that a `lightwalletd` integration test is expected to run. -pub const LIGHTWALLETD_TEST_TIMEOUT: Duration = Duration::from_secs(60 * 60); - /// Should we skip Zebra lightwalletd integration tests? #[allow(clippy::print_stderr)] pub fn zebra_skip_lightwalletd_tests() -> bool { diff --git a/zebrad/tests/common/lightwalletd/send_transaction_test.rs b/zebrad/tests/common/lightwalletd/send_transaction_test.rs index d20ae587cfc..1657e19e072 100644 --- a/zebrad/tests/common/lightwalletd/send_transaction_test.rs +++ b/zebrad/tests/common/lightwalletd/send_transaction_test.rs @@ -36,8 +36,7 @@ use crate::common::{ lightwalletd::{ wallet_grpc::{self, connect_to_lightwalletd, spawn_lightwalletd_with_rpc_server}, zebra_skip_lightwalletd_tests, - LightwalletdTestType::UpdateCachedState, - LIGHTWALLETD_TEST_TIMEOUT, + LightwalletdTestType::*, }, sync::perform_full_sync_starting_from, }; @@ -71,11 +70,8 @@ pub async fn run() -> Result<()> { let (transactions, partial_sync_path) = load_transactions_from_a_future_block(network, cached_state_path.unwrap()).await?; - let (_zebrad, zebra_rpc_address) = spawn_zebrad_for_rpc_without_initial_peers( - Network::Mainnet, - partial_sync_path, - LIGHTWALLETD_TEST_TIMEOUT, - )?; + let (_zebrad, zebra_rpc_address) = + spawn_zebrad_for_rpc_without_initial_peers(Network::Mainnet, partial_sync_path, test_type)?; let (_lightwalletd, lightwalletd_rpc_port) = spawn_lightwalletd_with_rpc_server( zebra_rpc_address, diff --git a/zebrad/tests/common/lightwalletd/wallet_grpc_test.rs b/zebrad/tests/common/lightwalletd/wallet_grpc_test.rs index 49435bbb351..c130a898c97 100644 --- a/zebrad/tests/common/lightwalletd/wallet_grpc_test.rs +++ b/zebrad/tests/common/lightwalletd/wallet_grpc_test.rs @@ -47,7 +47,6 @@ use crate::common::{ }, zebra_skip_lightwalletd_tests, LightwalletdTestType::UpdateCachedState, - LIGHTWALLETD_TEST_TIMEOUT, }, }; @@ -80,11 +79,8 @@ pub async fn run() -> Result<()> { let network = Network::Mainnet; // Launch zebra using a predefined zebrad state path - let (_zebrad, zebra_rpc_address) = spawn_zebrad_for_rpc_without_initial_peers( - network, - zebrad_state_path.unwrap(), - LIGHTWALLETD_TEST_TIMEOUT, - )?; + let (_zebrad, zebra_rpc_address) = + spawn_zebrad_for_rpc_without_initial_peers(network, zebrad_state_path.unwrap(), test_type)?; // Launch lightwalletd let (_lightwalletd, lightwalletd_rpc_port) = spawn_lightwalletd_with_rpc_server( From f6b29b151ebbb8f5046c0c1575f02b12d8264be7 Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 5 May 2022 12:10:28 +1000 Subject: [PATCH 3/3] Temporarily stop requiring cached lightwalletd state for the send transaction tests --- zebrad/tests/common/lightwalletd/send_transaction_test.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zebrad/tests/common/lightwalletd/send_transaction_test.rs b/zebrad/tests/common/lightwalletd/send_transaction_test.rs index 1657e19e072..7cb2731f38b 100644 --- a/zebrad/tests/common/lightwalletd/send_transaction_test.rs +++ b/zebrad/tests/common/lightwalletd/send_transaction_test.rs @@ -52,7 +52,12 @@ pub async fn run() -> Result<()> { // We want a zebra state dir and a lightwalletd data dir in place, // so `UpdateCachedState` can be used as our test type - let test_type = UpdateCachedState; + // + // But for now, we don't want to require the cached state, because it's not ready yet. + // TODO: use `UpdateCachedState` + let test_type = FullSyncFromGenesis { + allow_lightwalletd_cached_state: true, + }; let cached_state_path = test_type.zebrad_state_path("send_transaction_tests".to_string()); if cached_state_path.is_none() {