From 9975d5077d00df35936e78bfa1c4627ed3972b5b Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 15 Jun 2022 05:05:02 -0300 Subject: [PATCH] doc(tests): full sync and lightwalletd tests (#4523) * document full sync and lightwalletd tests * clippy * upgrade error * move env variables Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- zebrad/tests/acceptance.rs | 93 +++++++++++++++++++++++++++-- zebrad/tests/common/lightwalletd.rs | 3 +- 2 files changed, 89 insertions(+), 7 deletions(-) diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index 5fef4b6c..7c4e9022 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -20,6 +20,88 @@ //! If it does not have any IPv4 interfaces, IPv4 localhost is not on `127.0.0.1`, //! or you have poor network connectivity, //! skip all the network tests by setting the `ZEBRA_SKIP_NETWORK_TESTS` environmental variable. +//! +//! ## Large/full sync tests +//! +//! This file has sync tests that are marked as ignored because they take too much time to run. +//! Some of them require environment variables or directories to be present: +//! +//! - `FULL_SYNC_MAINNET_TIMEOUT_MINUTES` env variable: The total number of minutes we +//! will allow this test to run or give up. Value for the Mainnet full sync tests. +//! - `FULL_SYNC_TESTNET_TIMEOUT_MINUTES` env variable: The total number of minutes we +//! will allow this test to run or give up. Value for the Testnet ful sync tests. +//! - `/zebrad-cache` directory: For some sync tests, this needs to be created in +//! the file system, the created directory should have write permissions. +//! +//! Here are some examples on how to run each of the tests: +//! +//! ```console +//! $ cargo test sync_large_checkpoints_mainnet -- --ignored --nocapture +//! +//! $ cargo test sync_large_checkpoints_mempool_mainnet -- --ignored --nocapture +//! +//! $ sudo mkdir /zebrad-cache +//! $ sudo chmod 777 /zebrad-cache +//! $ export FULL_SYNC_MAINNET_TIMEOUT_MINUTES=600 +//! $ cargo test full_sync_mainnet -- --ignored --nocapture +//! +//! $ sudo mkdir /zebrad-cache +//! $ sudo chmod 777 /zebrad-cache +//! $ export FULL_SYNC_TESTNET_TIMEOUT_MINUTES=600 +//! $ cargo test full_sync_testnet -- --ignored --nocapture +//! ``` +//! +//! Please refer to the documentation of each test for more information. +//! +//! ## Lightwalletd tests +//! +//! The lightwalletd software is an interface service that uses zebrad or zcashd RPC methods to serve wallets or other applications with blockchain content in an efficient manner. +//! There are several versions of lightwalled in the form of different forks. The original +//! repo is but Zecwallet Lite uses a custom fork: . +//! The custom fork from adityapk00 is the one Zebra use for this tests: +//! +//! Zebra lightwalletd tests are not all marked as ignored but none will run unless +//! at least the `ZEBRA_TEST_LIGHTWALLETD` environment variable is present: +//! +//! - `ZEBRA_TEST_LIGHTWALLETD` env variable: Needs to be present to run any of the lightwalletd tests. +//! - `ZEBRA_CACHED_STATE_DIR` env var: The path to a zebra blockchain database. +//! - `LIGHTWALLETD_DATA_DIR` env variable. The path to a lightwalletd database. +//! - `--features lightwalletd-grpc-tests` cargo flag. The flag given to cargo to build the source code of the running test. +//! +//! Here are some examples of running each test: +//! +//! ```console +//! $ export ZEBRA_TEST_LIGHTWALLETD=true +//! $ cargo test lightwalletd_integration -- --nocapture +//! +//! $ export ZEBRA_TEST_LIGHTWALLETD=true +//! $ export ZEBRA_CACHED_STATE_DIR="/path/to/zebra/chain" +//! $ export LIGHTWALLETD_DATA_DIR="/path/to/lightwalletd/database" +//! $ cargo test lightwalletd_update_sync -- --nocapture +//! +//! $ export ZEBRA_TEST_LIGHTWALLETD=true +//! $ export ZEBRA_CACHED_STATE_DIR="/path/to/zebra/chain" +//! $ cargo test lightwalletd_full_sync -- --ignored --nocapture +//! +//! $ export ZEBRA_TEST_LIGHTWALLETD=true +//! $ cargo test lightwalletd_test_suite -- --ignored --nocapture +//! +//! $ export ZEBRA_TEST_LIGHTWALLETD=true +//! $ export ZEBRA_CACHED_STATE_DIR="/path/to/zebra/chain" +//! $ cargo test fully_synced_rpc_test -- --ignored --nocapture +//! +//! $ export ZEBRA_TEST_LIGHTWALLETD=true +//! $ export ZEBRA_CACHED_STATE_DIR="/path/to/zebra/chain" +//! $ export LIGHTWALLETD_DATA_DIR="/path/to/lightwalletd/database" +//! $ cargo test sending_transactions_using_lightwalletd --features lightwalletd-grpc-tests -- --ignored --nocapture +//! +//! $ export ZEBRA_TEST_LIGHTWALLETD=true +//! $ export ZEBRA_CACHED_STATE_DIR="/path/to/zebra/chain" +//! $ export LIGHTWALLETD_DATA_DIR="/path/to/lightwalletd/database" +//! $ cargo test lightwalletd_wallet_grpc_tests --features lightwalletd-grpc-tests -- --ignored --nocapture +//! ``` +//! +//! Please refer to the documentation of each test for more information. use std::{collections::HashSet, convert::TryInto, env, path::PathBuf}; @@ -675,6 +757,7 @@ fn sync_past_mandatory_checkpoint(network: Network) -> Result<()> { /// The timeout is specified using an environment variable, with the name configured by the /// `timeout_argument_name` parameter. The value of the environment variable must the number of /// minutes specified as an integer. +#[allow(clippy::print_stderr)] fn full_sync_test(network: Network, timeout_argument_name: &str) -> Result<()> { let timeout_argument: Option = env::var(timeout_argument_name) .ok() @@ -698,11 +781,10 @@ fn full_sync_test(network: Network, timeout_argument_name: &str) -> Result<()> { SYNC_FINISHED_REGEX_TMP_STOP_EARLY, ) } else { - tracing::info!( - ?network, - "skipped full sync test, \ - set the {:?} environmental variable to run the test", - timeout_argument_name, + eprintln!( + "Skipped full sync test for {}, \ + set the {:?} environmental variable to run the test", + network, timeout_argument_name, ); Ok(()) @@ -1518,7 +1600,6 @@ async fn fully_synced_rpc_test() -> Result<()> { let cached_state_path = test_type.zebrad_state_path("fully_synced_rpc_test".to_string()); if cached_state_path.is_none() { - tracing::info!("skipping fully synced zebrad RPC test"); return Ok(()); }; diff --git a/zebrad/tests/common/lightwalletd.rs b/zebrad/tests/common/lightwalletd.rs index 552f9578..fb75e53b 100644 --- a/zebrad/tests/common/lightwalletd.rs +++ b/zebrad/tests/common/lightwalletd.rs @@ -266,11 +266,12 @@ impl LightwalletdTestType { } /// Returns the Zebra state path for this test, if set. + #[allow(clippy::print_stderr)] pub fn zebrad_state_path(&self, test_name: String) -> Option { match env::var_os(ZEBRA_CACHED_STATE_DIR) { Some(path) => Some(path.into()), None => { - tracing::info!( + eprintln!( "skipped {test_name:?} {self:?} lightwalletd test, \ set the {ZEBRA_CACHED_STATE_DIR:?} environment variable to run the test", );