change(test): Stop requiring cached lightwalletd state for the send transaction test (#4302)
* Expect a Zebra cached state with at least a million blocks * Set the zebrad timeout and failure messages based on the test type * Temporarily stop requiring cached lightwalletd state for the send transaction tests
This commit is contained in:
parent
d0e81001bc
commit
5cd1133584
|
@ -1163,8 +1163,7 @@ fn lightwalletd_integration_test(test_type: LightwalletdTestType) -> Result<()>
|
||||||
}
|
}
|
||||||
|
|
||||||
if test_type.needs_lightwalletd_cached_state() {
|
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]{7} blocks in cache")?;
|
||||||
lightwalletd.expect_stdout_line_matches("Found [0-9]{6,7} blocks in cache")?;
|
|
||||||
} else if !test_type.allow_lightwalletd_cached_state() {
|
} else if !test_type.allow_lightwalletd_cached_state() {
|
||||||
// Timeout the test if we're somehow accidentally using a cached state in our temp dir
|
// 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")?;
|
lightwalletd.expect_stdout_line_matches("Found 0 blocks in cache")?;
|
||||||
|
@ -1487,11 +1486,8 @@ async fn fully_synced_rpc_test() -> Result<()> {
|
||||||
|
|
||||||
let network = Network::Mainnet;
|
let network = Network::Mainnet;
|
||||||
|
|
||||||
let (_zebrad, zebra_rpc_address) = spawn_zebrad_for_rpc_without_initial_peers(
|
let (_zebrad, zebra_rpc_address) =
|
||||||
network,
|
spawn_zebrad_for_rpc_without_initial_peers(network, cached_state_path.unwrap(), test_type)?;
|
||||||
cached_state_path.unwrap(),
|
|
||||||
test_type.zebrad_timeout(),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// Make a getblock test that works only on synced node (high block number).
|
// 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
|
// The block is before the mandatory checkpoint, so the checkpoint cached state can be used
|
||||||
|
|
|
@ -18,15 +18,12 @@ use color_eyre::eyre::Result;
|
||||||
use zebra_chain::parameters::Network;
|
use zebra_chain::parameters::Network;
|
||||||
use zebra_test::{
|
use zebra_test::{
|
||||||
args,
|
args,
|
||||||
command::{Arguments, TestDirExt, NO_MATCHES_REGEX_ITER},
|
command::{Arguments, TestDirExt},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use zebrad::config::ZebradConfig;
|
use zebrad::config::ZebradConfig;
|
||||||
|
|
||||||
use crate::common::{
|
use crate::common::lightwalletd::{random_known_rpc_port_config, LightwalletdTestType};
|
||||||
failure_messages::{PROCESS_FAILURE_MESSAGES, ZEBRA_FAILURE_MESSAGES},
|
|
||||||
lightwalletd::random_known_rpc_port_config,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// After we launch `zebrad`, wait this long for the command to start up,
|
/// 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.
|
/// 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<P: ZebradTestDirExt>(
|
pub fn spawn_zebrad_for_rpc_without_initial_peers<P: ZebradTestDirExt>(
|
||||||
network: Network,
|
network: Network,
|
||||||
zebra_directory: P,
|
zebra_directory: P,
|
||||||
timeout: Duration,
|
test_type: LightwalletdTestType,
|
||||||
) -> Result<(TestChild<P>, SocketAddr)> {
|
) -> Result<(TestChild<P>, SocketAddr)> {
|
||||||
let mut config = random_known_rpc_port_config()
|
let mut config = random_known_rpc_port_config()
|
||||||
.expect("Failed to create a config file with a known RPC listener port");
|
.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<P: ZebradTestDirExt>(
|
||||||
config.network.network = network;
|
config.network.network = network;
|
||||||
config.mempool.debug_enable_at_height = Some(0);
|
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
|
let mut zebrad = zebra_directory
|
||||||
.with_config(&mut config)?
|
.with_config(&mut config)?
|
||||||
.spawn_child(args!["start"])?
|
.spawn_child(args!["start"])?
|
||||||
.bypass_test_capture(true)
|
.bypass_test_capture(true)
|
||||||
.with_timeout(timeout)
|
.with_timeout(test_type.zebrad_timeout())
|
||||||
.with_failure_regex_iter(
|
.with_failure_regex_iter(zebrad_failure_messages, zebrad_ignore_messages);
|
||||||
// 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(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let rpc_address = config.rpc.listen_addr.unwrap();
|
let rpc_address = config.rpc.listen_addr.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,6 @@ pub const ZEBRA_TEST_LIGHTWALLETD: &str = "ZEBRA_TEST_LIGHTWALLETD";
|
||||||
/// by skipping the lightwalletd initial sync.
|
/// by skipping the lightwalletd initial sync.
|
||||||
pub const LIGHTWALLETD_DATA_DIR_VAR: &str = "LIGHTWALLETD_DATA_DIR";
|
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?
|
/// Should we skip Zebra lightwalletd integration tests?
|
||||||
#[allow(clippy::print_stderr)]
|
#[allow(clippy::print_stderr)]
|
||||||
pub fn zebra_skip_lightwalletd_tests() -> bool {
|
pub fn zebra_skip_lightwalletd_tests() -> bool {
|
||||||
|
@ -378,9 +375,7 @@ impl LightwalletdTestType {
|
||||||
// lightwalletd state failures
|
// lightwalletd state failures
|
||||||
if self.needs_lightwalletd_cached_state() {
|
if self.needs_lightwalletd_cached_state() {
|
||||||
// Fail if we need a cached lightwalletd state, but it isn't near the tip
|
// Fail if we need a cached lightwalletd state, but it isn't near the tip
|
||||||
//
|
lightwalletd_failure_messages.push("Found [0-9]{1,6} blocks in cache".to_string());
|
||||||
// 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());
|
|
||||||
}
|
}
|
||||||
if !self.allow_lightwalletd_cached_state() {
|
if !self.allow_lightwalletd_cached_state() {
|
||||||
// Fail if we need an empty lightwalletd state, but it has blocks
|
// Fail if we need an empty lightwalletd state, but it has blocks
|
||||||
|
|
|
@ -36,8 +36,7 @@ use crate::common::{
|
||||||
lightwalletd::{
|
lightwalletd::{
|
||||||
wallet_grpc::{self, connect_to_lightwalletd, spawn_lightwalletd_with_rpc_server},
|
wallet_grpc::{self, connect_to_lightwalletd, spawn_lightwalletd_with_rpc_server},
|
||||||
zebra_skip_lightwalletd_tests,
|
zebra_skip_lightwalletd_tests,
|
||||||
LightwalletdTestType::UpdateCachedState,
|
LightwalletdTestType::*,
|
||||||
LIGHTWALLETD_TEST_TIMEOUT,
|
|
||||||
},
|
},
|
||||||
sync::perform_full_sync_starting_from,
|
sync::perform_full_sync_starting_from,
|
||||||
};
|
};
|
||||||
|
@ -53,7 +52,12 @@ pub async fn run() -> Result<()> {
|
||||||
|
|
||||||
// We want a zebra state dir and a lightwalletd data dir in place,
|
// We want a zebra state dir and a lightwalletd data dir in place,
|
||||||
// so `UpdateCachedState` can be used as our test type
|
// 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());
|
let cached_state_path = test_type.zebrad_state_path("send_transaction_tests".to_string());
|
||||||
if cached_state_path.is_none() {
|
if cached_state_path.is_none() {
|
||||||
|
@ -71,11 +75,8 @@ pub async fn run() -> Result<()> {
|
||||||
let (transactions, partial_sync_path) =
|
let (transactions, partial_sync_path) =
|
||||||
load_transactions_from_a_future_block(network, cached_state_path.unwrap()).await?;
|
load_transactions_from_a_future_block(network, cached_state_path.unwrap()).await?;
|
||||||
|
|
||||||
let (_zebrad, zebra_rpc_address) = spawn_zebrad_for_rpc_without_initial_peers(
|
let (_zebrad, zebra_rpc_address) =
|
||||||
Network::Mainnet,
|
spawn_zebrad_for_rpc_without_initial_peers(Network::Mainnet, partial_sync_path, test_type)?;
|
||||||
partial_sync_path,
|
|
||||||
LIGHTWALLETD_TEST_TIMEOUT,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let (_lightwalletd, lightwalletd_rpc_port) = spawn_lightwalletd_with_rpc_server(
|
let (_lightwalletd, lightwalletd_rpc_port) = spawn_lightwalletd_with_rpc_server(
|
||||||
zebra_rpc_address,
|
zebra_rpc_address,
|
||||||
|
|
|
@ -47,7 +47,6 @@ use crate::common::{
|
||||||
},
|
},
|
||||||
zebra_skip_lightwalletd_tests,
|
zebra_skip_lightwalletd_tests,
|
||||||
LightwalletdTestType::UpdateCachedState,
|
LightwalletdTestType::UpdateCachedState,
|
||||||
LIGHTWALLETD_TEST_TIMEOUT,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,11 +79,8 @@ pub async fn run() -> Result<()> {
|
||||||
let network = Network::Mainnet;
|
let network = Network::Mainnet;
|
||||||
|
|
||||||
// Launch zebra using a predefined zebrad state path
|
// Launch zebra using a predefined zebrad state path
|
||||||
let (_zebrad, zebra_rpc_address) = spawn_zebrad_for_rpc_without_initial_peers(
|
let (_zebrad, zebra_rpc_address) =
|
||||||
network,
|
spawn_zebrad_for_rpc_without_initial_peers(network, zebrad_state_path.unwrap(), test_type)?;
|
||||||
zebrad_state_path.unwrap(),
|
|
||||||
LIGHTWALLETD_TEST_TIMEOUT,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// Launch lightwalletd
|
// Launch lightwalletd
|
||||||
let (_lightwalletd, lightwalletd_rpc_port) = spawn_lightwalletd_with_rpc_server(
|
let (_lightwalletd, lightwalletd_rpc_port) = spawn_lightwalletd_with_rpc_server(
|
||||||
|
|
Loading…
Reference in New Issue