From 05c2143cff286fe91744cbf054a6646a11729fc1 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 13:29:28 -0600 Subject: [PATCH 01/26] migrate testutils --- Cargo.lock | 27 ------------------- Cargo.toml | 1 - darkside-tests/Cargo.toml | 1 - libtonode-tests/Cargo.toml | 1 - zingocli/Cargo.toml | 3 +-- zingolib/Cargo.toml | 4 +-- zingolib/src/lib.rs | 2 ++ .../src/lib.rs => zingolib/src/testutils.rs | 0 .../src/testutils}/assertions.rs | 0 .../src/testutils}/chain_generics.rs | 0 .../chain_generics/conduct_chain.rs | 0 .../src/testutils}/chain_generics/fixtures.rs | 0 .../chain_generics/with_assertions.rs | 0 .../src/testutils}/fee_tables.rs | 0 .../src/testutils}/grpc_proxy.rs | 0 .../src/testutils}/interrupts.rs | 0 .../src/testutils}/lightclient.rs | 0 .../src => zingolib/src/testutils}/macros.rs | 0 .../src => zingolib/src/testutils}/paths.rs | 0 .../src => zingolib/src/testutils}/regtest.rs | 0 20 files changed, 5 insertions(+), 34 deletions(-) rename zingo-testutils/src/lib.rs => zingolib/src/testutils.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/assertions.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/chain_generics.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/chain_generics/conduct_chain.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/chain_generics/fixtures.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/chain_generics/with_assertions.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/fee_tables.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/grpc_proxy.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/interrupts.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/lightclient.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/macros.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/paths.rs (100%) rename {zingo-testutils/src => zingolib/src/testutils}/regtest.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 9b31fb101..edd2abaf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -678,7 +678,6 @@ dependencies = [ "tower", "zcash_client_backend", "zcash_primitives", - "zingo-testutils", "zingo-testvectors", "zingoconfig", "zingolib", @@ -1619,7 +1618,6 @@ dependencies = [ "zcash_client_backend", "zcash_primitives", "zingo-status", - "zingo-testutils", "zingo-testvectors", "zingoconfig", "zingolib", @@ -4170,7 +4168,6 @@ dependencies = [ "log", "rustyline", "shellwords", - "zingo-testutils", "zingoconfig", "zingolib", ] @@ -4224,30 +4221,6 @@ dependencies = [ "zingo-netutils", ] -[[package]] -name = "zingo-testutils" -version = "0.1.0" -dependencies = [ - "http 0.2.12", - "incrementalmerkletree", - "json", - "log", - "nonempty", - "orchard", - "portpicker", - "tempdir", - "tokio", - "tonic", - "zcash_address", - "zcash_client_backend", - "zcash_primitives", - "zingo-netutils", - "zingo-status", - "zingo-testvectors", - "zingoconfig", - "zingolib", -] - [[package]] name = "zingo-testvectors" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 7fa8ff919..2108128fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ # This doesn't account for all dependency relations, for example, zingocli depends on zingoconfig directly (for now). [workspace] members = [ - "zingo-testutils", "libtonode-tests", "darkside-tests", "zingocli", diff --git a/darkside-tests/Cargo.toml b/darkside-tests/Cargo.toml index f7c6d7661..6fd24f45e 100644 --- a/darkside-tests/Cargo.toml +++ b/darkside-tests/Cargo.toml @@ -9,7 +9,6 @@ chain_generic_tests = [] [dependencies] zingolib = { path = "../zingolib", features = ["darkside_tests"] } -zingo-testutils = { path = "../zingo-testutils" } zingo-testvectors = { path = "../zingo-testvectors" } zingoconfig = { path = "../zingoconfig" } tokio = { workspace = true, features = ["full"] } diff --git a/libtonode-tests/Cargo.toml b/libtonode-tests/Cargo.toml index e82090b05..b18da45f1 100644 --- a/libtonode-tests/Cargo.toml +++ b/libtonode-tests/Cargo.toml @@ -10,7 +10,6 @@ chain_generic_tests = [] [dependencies] zingolib = { path = "../zingolib", features = ["deprecations", "test-elevation"] } zingo-status = { path = "../zingo-status" } -zingo-testutils = { path = "../zingo-testutils" } zingo-testvectors = { path = "../zingo-testvectors" } zingoconfig = { path = "../zingoconfig" } diff --git a/zingocli/Cargo.toml b/zingocli/Cargo.toml index 8aede2e07..1bdf2d839 100644 --- a/zingocli/Cargo.toml +++ b/zingocli/Cargo.toml @@ -4,9 +4,8 @@ version = "0.2.0" edition = "2021" [dependencies] -zingolib = { path = "../zingolib/", features = ["deprecations"] } +zingolib = { path = "../zingolib/", features = ["deprecations", "test-elevation"] } zingoconfig = { path = "../zingoconfig/" } -zingo-testutils = { path = "../zingo-testutils" } clap = { workspace = true } http = { workspace = true } diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index cd3e86785..c62581e4c 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" deprecations = ["lightclient-deprecated"] lightclient-deprecated = [] darkside_tests = [] -test-elevation = [] +test-elevation = ["portpicker"] [dependencies] zingoconfig = { path = "../zingoconfig" } @@ -72,9 +72,9 @@ thiserror = { workspace = true } hdwallet = { workspace = true } chrono = { workspace = true } enum_dispatch = { workspace = true } +portpicker = { workspace = true, optional = true } [dev-dependencies] -portpicker = { workspace = true } tempfile = { workspace = true } concat-idents = { workspace = true } zingo-testvectors = { path = "../zingo-testvectors" } diff --git a/zingolib/src/lib.rs b/zingolib/src/lib.rs index afb785ff2..63b554219 100644 --- a/zingolib/src/lib.rs +++ b/zingolib/src/lib.rs @@ -18,6 +18,8 @@ pub mod wallet; #[cfg(test)] pub mod mocks; +#[cfg(feature = "test-elevation")] +pub mod testutils; // This line includes the generated `git_description()` function directly into this scope. include!(concat!(env!("OUT_DIR"), "/git_description.rs")); diff --git a/zingo-testutils/src/lib.rs b/zingolib/src/testutils.rs similarity index 100% rename from zingo-testutils/src/lib.rs rename to zingolib/src/testutils.rs diff --git a/zingo-testutils/src/assertions.rs b/zingolib/src/testutils/assertions.rs similarity index 100% rename from zingo-testutils/src/assertions.rs rename to zingolib/src/testutils/assertions.rs diff --git a/zingo-testutils/src/chain_generics.rs b/zingolib/src/testutils/chain_generics.rs similarity index 100% rename from zingo-testutils/src/chain_generics.rs rename to zingolib/src/testutils/chain_generics.rs diff --git a/zingo-testutils/src/chain_generics/conduct_chain.rs b/zingolib/src/testutils/chain_generics/conduct_chain.rs similarity index 100% rename from zingo-testutils/src/chain_generics/conduct_chain.rs rename to zingolib/src/testutils/chain_generics/conduct_chain.rs diff --git a/zingo-testutils/src/chain_generics/fixtures.rs b/zingolib/src/testutils/chain_generics/fixtures.rs similarity index 100% rename from zingo-testutils/src/chain_generics/fixtures.rs rename to zingolib/src/testutils/chain_generics/fixtures.rs diff --git a/zingo-testutils/src/chain_generics/with_assertions.rs b/zingolib/src/testutils/chain_generics/with_assertions.rs similarity index 100% rename from zingo-testutils/src/chain_generics/with_assertions.rs rename to zingolib/src/testutils/chain_generics/with_assertions.rs diff --git a/zingo-testutils/src/fee_tables.rs b/zingolib/src/testutils/fee_tables.rs similarity index 100% rename from zingo-testutils/src/fee_tables.rs rename to zingolib/src/testutils/fee_tables.rs diff --git a/zingo-testutils/src/grpc_proxy.rs b/zingolib/src/testutils/grpc_proxy.rs similarity index 100% rename from zingo-testutils/src/grpc_proxy.rs rename to zingolib/src/testutils/grpc_proxy.rs diff --git a/zingo-testutils/src/interrupts.rs b/zingolib/src/testutils/interrupts.rs similarity index 100% rename from zingo-testutils/src/interrupts.rs rename to zingolib/src/testutils/interrupts.rs diff --git a/zingo-testutils/src/lightclient.rs b/zingolib/src/testutils/lightclient.rs similarity index 100% rename from zingo-testutils/src/lightclient.rs rename to zingolib/src/testutils/lightclient.rs diff --git a/zingo-testutils/src/macros.rs b/zingolib/src/testutils/macros.rs similarity index 100% rename from zingo-testutils/src/macros.rs rename to zingolib/src/testutils/macros.rs diff --git a/zingo-testutils/src/paths.rs b/zingolib/src/testutils/paths.rs similarity index 100% rename from zingo-testutils/src/paths.rs rename to zingolib/src/testutils/paths.rs diff --git a/zingo-testutils/src/regtest.rs b/zingolib/src/testutils/regtest.rs similarity index 100% rename from zingo-testutils/src/regtest.rs rename to zingolib/src/testutils/regtest.rs From 1c4588ab75801f3fbbf6c1ca88441d18b7970e00 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 15:46:35 -0600 Subject: [PATCH 02/26] move regtest data --- zingolib/Cargo.toml | 6 +- zingolib/src/testutils.rs | 73 +++++++++--------- .../testutils/chain_generics/conduct_chain.rs | 2 +- .../src/testutils/chain_generics/fixtures.rs | 20 ++--- .../chain_generics/with_assertions.rs | 4 +- zingolib/src/testutils/lightclient.rs | 27 ++++--- .../src/testutils}/regtest/bin/.gitignore | 0 .../src/testutils}/regtest/bin/.gitkeep | 0 .../testutils}/regtest/conf/lightwalletd.yml | 0 .../src/testutils}/regtest/conf/zcash.conf | 0 .../blocks_1153/zcashd/regtest/.lock | 0 .../blocks_1153/zcashd/regtest/banlist.dat | Bin .../zcashd/regtest/blocks/blk00000.dat | Bin .../zcashd/regtest/blocks/index/000005.ldb | Bin .../zcashd/regtest/blocks/index/000006.log | Bin .../zcashd/regtest/blocks/index/CURRENT | 0 .../zcashd/regtest/blocks/index/LOCK | 0 .../regtest/blocks/index/MANIFEST-000004 | Bin .../zcashd/regtest/blocks/rev00000.dat | Bin .../zcashd/regtest/chainstate/000005.ldb | Bin .../zcashd/regtest/chainstate/000006.log | Bin .../zcashd/regtest/chainstate/CURRENT | 0 .../zcashd/regtest/chainstate/LOCK | 0 .../zcashd/regtest/chainstate/MANIFEST-000004 | Bin .../blocks_1153/zcashd/regtest/db.log | 0 .../zcashd/regtest/fee_estimates.dat | Bin .../blocks_1153/zcashd/regtest/peers.dat | Bin .../blocks_1153/zcashd/regtest/wallet.dat | Bin .../regtest/data/lightwalletd/.gitkeep | 0 .../regtest/data/regtestvectors/regtest/.lock | 0 .../data/regtestvectors/regtest/banlist.dat | Bin .../regtest/blocks/blk00000.dat | Bin .../regtest/blocks/index/000005.ldb | Bin .../regtest/blocks/index/000008.ldb | Bin .../regtest/blocks/index/000009.log | Bin .../regtest/blocks/index/CURRENT | 0 .../regtestvectors/regtest/blocks/index/LOCK | 0 .../regtestvectors/regtest/blocks/index/LOG | 0 .../regtest/blocks/index/LOG.old | 0 .../regtest/blocks/index/MANIFEST-000007 | Bin .../regtest/blocks/rev00000.dat | Bin .../regtest/chainstate/000005.ldb | Bin .../regtest/chainstate/000008.ldb | Bin .../regtest/chainstate/000009.log | Bin .../regtestvectors/regtest/chainstate/CURRENT | 0 .../regtestvectors/regtest/chainstate/LOCK | 0 .../regtestvectors/regtest/chainstate/LOG | 0 .../regtestvectors/regtest/chainstate/LOG.old | 0 .../regtest/chainstate/MANIFEST-000007 | Bin .../regtest/database/log.0000000001 | Bin .../data/regtestvectors/regtest/db.log | 0 .../regtestvectors/regtest/fee_estimates.dat | Bin .../data/regtestvectors/regtest/peers.dat | Bin .../data/regtestvectors/regtest/wallet.dat | Bin .../testutils}/regtest/data/zcashd/.gitkeep | 0 .../src/testutils}/regtest/logs/.gitignore | 0 .../src/testutils}/regtest/logs/.gitkeep | 0 .../regtest/logs/lightwalletd/.gitkeep | 0 .../testutils}/regtest/logs/zcashd/.gitkeep | 0 59 files changed, 64 insertions(+), 68 deletions(-) rename {zingo-testutils => zingolib/src/testutils}/regtest/bin/.gitignore (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/bin/.gitkeep (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/conf/lightwalletd.yml (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/conf/zcash.conf (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/.lock (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/banlist.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/blk00000.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000005.ldb (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000006.log (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/CURRENT (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/LOCK (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/MANIFEST-000004 (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/rev00000.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000005.ldb (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000006.log (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/CURRENT (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/LOCK (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/MANIFEST-000004 (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/db.log (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/fee_estimates.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/peers.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/chain_cache/blocks_1153/zcashd/regtest/wallet.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/lightwalletd/.gitkeep (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/.lock (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/banlist.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/blk00000.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/index/000005.ldb (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/index/000008.ldb (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/index/000009.log (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/index/CURRENT (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/index/LOCK (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/index/LOG (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/index/LOG.old (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/index/MANIFEST-000007 (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/blocks/rev00000.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/chainstate/000005.ldb (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/chainstate/000008.ldb (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/chainstate/000009.log (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/chainstate/CURRENT (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/chainstate/LOCK (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/chainstate/LOG (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/chainstate/LOG.old (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/chainstate/MANIFEST-000007 (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/database/log.0000000001 (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/db.log (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/fee_estimates.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/peers.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/regtestvectors/regtest/wallet.dat (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/data/zcashd/.gitkeep (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/logs/.gitignore (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/logs/.gitkeep (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/logs/lightwalletd/.gitkeep (100%) rename {zingo-testutils => zingolib/src/testutils}/regtest/logs/zcashd/.gitkeep (100%) diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index c62581e4c..5e6561cc4 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" deprecations = ["lightclient-deprecated"] lightclient-deprecated = [] darkside_tests = [] -test-elevation = ["portpicker"] +test-elevation = ["portpicker", "zingo-testvectors", "tempfile"] [dependencies] zingoconfig = { path = "../zingoconfig" } @@ -73,11 +73,11 @@ hdwallet = { workspace = true } chrono = { workspace = true } enum_dispatch = { workspace = true } portpicker = { workspace = true, optional = true } +zingo-testvectors = { path = "../zingo-testvectors", optional = true } +tempfile = { workspace = true, optional = true} [dev-dependencies] -tempfile = { workspace = true } concat-idents = { workspace = true } -zingo-testvectors = { path = "../zingo-testvectors" } [build-dependencies] build_utils = { workspace = true } diff --git a/zingolib/src/testutils.rs b/zingolib/src/testutils.rs index 52cf16cec..432bc5a90 100644 --- a/zingolib/src/testutils.rs +++ b/zingolib/src/testutils.rs @@ -5,6 +5,12 @@ pub mod interrupts; +use crate::wallet::data::summaries::{ + OrchardNoteSummary, SaplingNoteSummary, SpendSummary, TransactionSummary, + TransactionSummaryInterface as _, TransparentCoinSummary, +}; +use crate::wallet::keys::unified::WalletCapability; +use crate::wallet::WalletBase; use grpc_proxy::ProxyServer; pub use incrementalmerkletree; use std::cmp; @@ -17,21 +23,15 @@ use std::sync::Arc; use std::time::Duration; use tokio::task::JoinHandle; use zcash_address::unified::{Fvk, Ufvk}; -use zingolib::wallet::data::summaries::{ - OrchardNoteSummary, SaplingNoteSummary, SpendSummary, TransactionSummary, - TransactionSummaryInterface as _, TransparentCoinSummary, -}; -use zingolib::wallet::keys::unified::WalletCapability; -use zingolib::wallet::WalletBase; +use crate::lightclient::LightClient; use json::JsonValue; use log::debug; use regtest::RegtestManager; use tokio::time::sleep; use zingoconfig::{ChainType, ZingoConfig}; -use zingolib::lightclient::LightClient; -use crate::scenarios::setup::TestEnvironmentGenerator; +use scenarios::setup::TestEnvironmentGenerator; pub mod assertions; pub mod chain_generics; @@ -62,7 +62,7 @@ pub fn build_fvks_from_wallet_capability(wallet_capability: &WalletCapability) - .to_bytes(), ); let mut t_fvk_bytes = [0u8; 65]; - let t_ext_pk: zingolib::wallet::keys::extended_transparent::ExtendedPubKey = + let t_ext_pk: crate::wallet::keys::extended_transparent::ExtendedPubKey = (wallet_capability).try_into().unwrap(); t_fvk_bytes[0..32].copy_from_slice(&t_ext_pk.chain_code[..]); t_fvk_bytes[32..65].copy_from_slice(&t_ext_pk.public_key.serialize()[..]); @@ -261,7 +261,7 @@ pub async fn send_value_between_clients_and_sync( "recipient address is: {}", &recipient.do_addresses().await[0]["address"] ); - let txid = crate::lightclient::from_inputs::quick_send( + let txid = lightclient::from_inputs::quick_send( sender, vec![( &crate::get_base_address_macro!(recipient, address_type), @@ -363,7 +363,7 @@ where pub async fn load_wallet( dir: PathBuf, chaintype: ChainType, -) -> (zingolib::wallet::LightWallet, ZingoConfig) { +) -> (crate::wallet::LightWallet, ZingoConfig) { let wallet = dir.join("zingo-wallet.dat"); let lightwalletd_uri = TestEnvironmentGenerator::new(None).get_lightwalletd_uri(); let zingo_config = @@ -374,7 +374,7 @@ pub async fn load_wallet( let mut recording_reader = RecordingReader { from, read_lengths }; ( - zingolib::wallet::LightWallet::read_internal(&mut recording_reader, &zingo_config) + crate::wallet::LightWallet::read_internal(&mut recording_reader, &zingo_config) .await .unwrap(), zingo_config, @@ -670,16 +670,18 @@ pub mod scenarios { //! All scenarios have a default (i.e. faucet_default) which take minimal parameters and //! build the scenario with the most common settings. This simplifies test writing in //! most cases by removing the need for configuration. - use self::setup::ClientBuilder; use super::regtest::{ChildProcessHandler, RegtestManager}; - use crate::{get_base_address_macro, increase_height_and_wait_for_client}; + use crate::get_base_address_macro; + use crate::lightclient::LightClient; + use crate::testutils::increase_height_and_wait_for_client; + use setup::ClientBuilder; use zcash_client_backend::{PoolType, ShieldedProtocol}; use zingo_testvectors::{self, seeds::HOSPITAL_MUSEUM_SEED, BASE_HEIGHT}; - use zingolib::lightclient::LightClient; /// TODO: Add Doc Comment Here! pub mod setup { use super::BASE_HEIGHT; + use tempfile::TempDir; use zcash_client_backend::{PoolType, ShieldedProtocol}; use zingo_testvectors::{ seeds, REG_O_ADDR_FROM_ABANDONART, REG_T_ADDR_FROM_ABANDONART, @@ -688,9 +690,10 @@ pub mod scenarios { use super::super::paths::get_regtest_dir; use super::{ChildProcessHandler, RegtestManager}; + use crate::testutils::poll_server_height; + use crate::{lightclient::LightClient, wallet::WalletBase}; use std::path::PathBuf; use tokio::time::sleep; - use zingolib::{lightclient::LightClient, wallet::WalletBase}; /// TODO: Add Doc Comment Here! pub struct ScenarioBuilder { @@ -768,11 +771,7 @@ pub mod scenarios { self.regtest_manager .generate_n_blocks(BASE_HEIGHT - 1) .unwrap(); - while crate::poll_server_height(&self.regtest_manager) - .as_u32() - .unwrap() - < BASE_HEIGHT - { + while poll_server_height(&self.regtest_manager).as_u32().unwrap() < BASE_HEIGHT { sleep(std::time::Duration::from_millis(50)).await; } } @@ -925,9 +924,7 @@ pub mod scenarios { let lightwalletd_rpcservice_port = TestEnvironmentGenerator::pick_unused_port_to_string(set_lightwalletd_port); let regtest_manager = RegtestManager::new( - tempdir::TempDir::new("zingo_libtonode_test") - .unwrap() - .into_path(), + TempDir::new_in("zingo_libtonode_test").unwrap().into_path(), ); let server_uri = zingoconfig::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{lightwalletd_rpcservice_port}" @@ -1146,7 +1143,7 @@ pub mod scenarios { .unwrap(); let orchard_txid = if let Some(funds) = orchard_funds { Some( - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &faucet, vec![(&get_base_address_macro!(recipient, "unified"), funds, None)], ) @@ -1160,7 +1157,7 @@ pub mod scenarios { }; let sapling_txid = if let Some(funds) = sapling_funds { Some( - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &faucet, vec![(&get_base_address_macro!(recipient, "sapling"), funds, None)], ) @@ -1174,7 +1171,7 @@ pub mod scenarios { }; let transparent_txid = if let Some(funds) = transparent_funds { Some( - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &faucet, vec![( &get_base_address_macro!(recipient, "transparent"), @@ -1311,7 +1308,7 @@ pub mod scenarios { .build_client(HOSPITAL_MUSEUM_SEED.to_string(), 0, false, regtest_network) .await; faucet.do_sync(false).await.unwrap(); - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &faucet, vec![(&get_base_address_macro!(recipient, "unified"), value, None)], ) @@ -1351,7 +1348,7 @@ pub mod scenarios { .await .unwrap(); // received from a faucet - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &faucet, vec![(&get_base_address_macro!(recipient, "unified"), value, None)], ) @@ -1361,7 +1358,7 @@ pub mod scenarios { .await .unwrap(); // send to a faucet - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &recipient, vec![( &get_base_address_macro!(faucet, "unified"), @@ -1375,7 +1372,7 @@ pub mod scenarios { .await .unwrap(); // send to self sapling - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &recipient, vec![( &get_base_address_macro!(recipient, "sapling"), @@ -1419,7 +1416,7 @@ pub mod scenarios { .await .unwrap(); // received from a faucet to orchard - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &faucet, vec![( &get_base_address_macro!(recipient, "unified"), @@ -1433,7 +1430,7 @@ pub mod scenarios { .await .unwrap(); // received from a faucet to sapling - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &faucet, vec![( &get_base_address_macro!(recipient, "sapling"), @@ -1447,7 +1444,7 @@ pub mod scenarios { .await .unwrap(); // received from a faucet to transparent - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &faucet, vec![( &get_base_address_macro!(recipient, "transparent"), @@ -1461,7 +1458,7 @@ pub mod scenarios { .await .unwrap(); // send to a faucet - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &recipient, vec![( &get_base_address_macro!(faucet, "unified"), @@ -1475,7 +1472,7 @@ pub mod scenarios { .await .unwrap(); // send to self orchard - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &recipient, vec![( &get_base_address_macro!(recipient, "unified"), @@ -1489,7 +1486,7 @@ pub mod scenarios { .await .unwrap(); // send to self sapling - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &recipient, vec![( &get_base_address_macro!(recipient, "sapling"), @@ -1503,7 +1500,7 @@ pub mod scenarios { .await .unwrap(); // send to self transparent - crate::lightclient::from_inputs::quick_send( + super::lightclient::from_inputs::quick_send( &recipient, vec![( &get_base_address_macro!(recipient, "transparent"), diff --git a/zingolib/src/testutils/chain_generics/conduct_chain.rs b/zingolib/src/testutils/chain_generics/conduct_chain.rs index 5084546b6..893fdfc0b 100644 --- a/zingolib/src/testutils/chain_generics/conduct_chain.rs +++ b/zingolib/src/testutils/chain_generics/conduct_chain.rs @@ -3,7 +3,7 @@ //! lib-to-node, which links a lightserver to a zcashd in regtest mode. see `impl ConductChain for LibtoNode //! darkside, a mode for the lightserver which mocks zcashd. search 'impl ConductChain for DarksideScenario -use crate::{get_base_address_macro, lightclient::from_inputs}; +use testutils::lightclient::from_inputs; use zingolib::lightclient::LightClient; #[allow(async_fn_in_trait)] diff --git a/zingolib/src/testutils/chain_generics/fixtures.rs b/zingolib/src/testutils/chain_generics/fixtures.rs index 83e8f6a1f..56720169c 100644 --- a/zingolib/src/testutils/chain_generics/fixtures.rs +++ b/zingolib/src/testutils/chain_generics/fixtures.rs @@ -10,16 +10,16 @@ use zcash_client_backend::ShieldedProtocol::Orchard; use zcash_client_backend::ShieldedProtocol::Sapling; use zcash_primitives::transaction::fees::zip317::MARGINAL_FEE; -use zingolib::lightclient::LightClient; -use zingolib::wallet::notes::query::OutputSpendStatusQuery; -use zingolib::wallet::notes::{query::OutputPoolQuery, OutputInterface}; -use zingolib::wallet::{data::summaries::ValueTransferKind, notes::query::OutputQuery}; - -use crate::chain_generics::conduct_chain::ConductChain; -use crate::chain_generics::with_assertions; -use crate::fee_tables; -use crate::lightclient::from_inputs; -use crate::lightclient::get_base_address; +use crate::lightclient::LightClient; +use crate::wallet::notes::query::OutputSpendStatusQuery; +use crate::wallet::notes::{query::OutputPoolQuery, OutputInterface}; +use crate::wallet::{data::summaries::ValueTransferKind, notes::query::OutputQuery}; + +use crate::testutils::chain_generics::conduct_chain::ConductChain; +use crate::testutils::chain_generics::with_assertions; +use crate::testutils::fee_tables; +use crate::testutils::lightclient::from_inputs; +use crate::testutils::lightclient::get_base_address; /// Fixture for testing various vt transactions pub async fn create_various_value_transfers() diff --git a/zingolib/src/testutils/chain_generics/with_assertions.rs b/zingolib/src/testutils/chain_generics/with_assertions.rs index 024daaba8..92a3d2f39 100644 --- a/zingolib/src/testutils/chain_generics/with_assertions.rs +++ b/zingolib/src/testutils/chain_generics/with_assertions.rs @@ -1,9 +1,9 @@ //! lightclient functions with added assertions. used for tests. +use crate::lightclient::LightClient; use zcash_client_backend::PoolType; -use zingolib::lightclient::LightClient; -use crate::{ +use crate::testutils::{ assertions::{assert_recipient_total_lte_to_proposal_total, assert_record_fee_and_status}, chain_generics::conduct_chain::ConductChain, lightclient::{from_inputs, get_base_address}, diff --git a/zingolib/src/testutils/lightclient.rs b/zingolib/src/testutils/lightclient.rs index ca0b05a88..6563545e4 100644 --- a/zingolib/src/testutils/lightclient.rs +++ b/zingolib/src/testutils/lightclient.rs @@ -1,7 +1,7 @@ //! This mod is mostly to take inputs, raw data amd comvert it into lightclient actions //! (obvisouly) in a test environment. +use crate::{error::ZingoLibError, lightclient::LightClient}; use zcash_client_backend::{PoolType, ShieldedProtocol}; -use zingolib::{error::ZingoLibError, lightclient::LightClient}; /// Create a lightclient from the buffer of another pub async fn new_client_from_save_buffer( @@ -36,11 +36,11 @@ pub async fn get_fees_paid_by_client(client: &LightClient) -> u64 { /// Helpers to provide raw_receivers to lightclients for send and shield, etc. pub mod from_inputs { - use zingolib::lightclient::{send::send_with_proposal::QuickSendError, LightClient}; + use crate::lightclient::{send::send_with_proposal::QuickSendError, LightClient}; /// Panics if the address, amount or memo conversion fails. pub async fn quick_send( - quick_sender: &zingolib::lightclient::LightClient, + quick_sender: &crate::lightclient::LightClient, raw_receivers: Vec<(&str, u64, Option<&str>)>, ) -> Result, QuickSendError> { let request = transaction_request_from_send_inputs(quick_sender, raw_receivers) @@ -52,35 +52,34 @@ pub mod from_inputs { pub fn receivers_from_send_inputs( raw_receivers: Vec<(&str, u64, Option<&str>)>, chain: &zingoconfig::ChainType, - ) -> zingolib::data::receivers::Receivers { + ) -> crate::data::receivers::Receivers { raw_receivers .into_iter() .map(|(address, amount, memo)| { - let recipient_address = - zingolib::utils::conversion::address_from_str(address, chain) - .expect("should be a valid address"); - let amount = zingolib::utils::conversion::zatoshis_from_u64(amount) + let recipient_address = crate::utils::conversion::address_from_str(address, chain) + .expect("should be a valid address"); + let amount = crate::utils::conversion::zatoshis_from_u64(amount) .expect("should be inside the range of valid zatoshis"); let memo = memo.map(|memo| { - zingolib::wallet::utils::interpret_memo_string(memo.to_string()) + crate::wallet::utils::interpret_memo_string(memo.to_string()) .expect("should be able to interpret memo") }); - zingolib::data::receivers::Receiver::new(recipient_address, amount, memo) + crate::data::receivers::Receiver::new(recipient_address, amount, memo) }) .collect() } /// Creates a [`zcash_client_backend::zip321::TransactionRequest`] from rust primitives for simplified test writing. pub fn transaction_request_from_send_inputs( - requester: &zingolib::lightclient::LightClient, + requester: &crate::lightclient::LightClient, raw_receivers: Vec<(&str, u64, Option<&str>)>, ) -> Result< zcash_client_backend::zip321::TransactionRequest, zcash_client_backend::zip321::Zip321Error, > { let receivers = receivers_from_send_inputs(raw_receivers, &requester.config().chain); - zingolib::data::receivers::transaction_request_from_receivers(receivers) + crate::data::receivers::transaction_request_from_receivers(receivers) } /// Panics if the address, amount or memo conversion fails. @@ -88,8 +87,8 @@ pub mod from_inputs { proposer: &LightClient, raw_receivers: Vec<(&str, u64, Option<&str>)>, ) -> Result< - zingolib::data::proposal::ProportionalFeeProposal, - zingolib::lightclient::propose::ProposeSendError, + crate::data::proposal::ProportionalFeeProposal, + crate::lightclient::propose::ProposeSendError, > { let request = transaction_request_from_send_inputs(proposer, raw_receivers) .expect("should be able to create a transaction request as receivers are valid."); diff --git a/zingo-testutils/regtest/bin/.gitignore b/zingolib/src/testutils/regtest/bin/.gitignore similarity index 100% rename from zingo-testutils/regtest/bin/.gitignore rename to zingolib/src/testutils/regtest/bin/.gitignore diff --git a/zingo-testutils/regtest/bin/.gitkeep b/zingolib/src/testutils/regtest/bin/.gitkeep similarity index 100% rename from zingo-testutils/regtest/bin/.gitkeep rename to zingolib/src/testutils/regtest/bin/.gitkeep diff --git a/zingo-testutils/regtest/conf/lightwalletd.yml b/zingolib/src/testutils/regtest/conf/lightwalletd.yml similarity index 100% rename from zingo-testutils/regtest/conf/lightwalletd.yml rename to zingolib/src/testutils/regtest/conf/lightwalletd.yml diff --git a/zingo-testutils/regtest/conf/zcash.conf b/zingolib/src/testutils/regtest/conf/zcash.conf similarity index 100% rename from zingo-testutils/regtest/conf/zcash.conf rename to zingolib/src/testutils/regtest/conf/zcash.conf diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/.lock b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/.lock similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/.lock rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/.lock diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/banlist.dat b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/banlist.dat similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/banlist.dat rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/banlist.dat diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/blk00000.dat b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/blk00000.dat similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/blk00000.dat rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/blk00000.dat diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000005.ldb b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000005.ldb similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000005.ldb rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000005.ldb diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000006.log b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000006.log similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000006.log rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/000006.log diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/CURRENT b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/CURRENT similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/CURRENT rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/CURRENT diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/LOCK b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/LOCK similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/LOCK rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/LOCK diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/MANIFEST-000004 b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/MANIFEST-000004 similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/MANIFEST-000004 rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/index/MANIFEST-000004 diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/rev00000.dat b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/rev00000.dat similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/rev00000.dat rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/blocks/rev00000.dat diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000005.ldb b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000005.ldb similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000005.ldb rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000005.ldb diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000006.log b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000006.log similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000006.log rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/000006.log diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/CURRENT b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/CURRENT similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/CURRENT rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/CURRENT diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/LOCK b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/LOCK similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/LOCK rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/LOCK diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/MANIFEST-000004 b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/MANIFEST-000004 similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/MANIFEST-000004 rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/chainstate/MANIFEST-000004 diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/db.log b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/db.log similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/db.log rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/db.log diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/fee_estimates.dat b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/fee_estimates.dat similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/fee_estimates.dat rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/fee_estimates.dat diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/peers.dat b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/peers.dat similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/peers.dat rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/peers.dat diff --git a/zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/wallet.dat b/zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/wallet.dat similarity index 100% rename from zingo-testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/wallet.dat rename to zingolib/src/testutils/regtest/data/chain_cache/blocks_1153/zcashd/regtest/wallet.dat diff --git a/zingo-testutils/regtest/data/lightwalletd/.gitkeep b/zingolib/src/testutils/regtest/data/lightwalletd/.gitkeep similarity index 100% rename from zingo-testutils/regtest/data/lightwalletd/.gitkeep rename to zingolib/src/testutils/regtest/data/lightwalletd/.gitkeep diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/.lock b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/.lock similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/.lock rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/.lock diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/banlist.dat b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/banlist.dat similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/banlist.dat rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/banlist.dat diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/blk00000.dat b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/blk00000.dat similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/blk00000.dat rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/blk00000.dat diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/000005.ldb b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/000005.ldb similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/000005.ldb rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/000005.ldb diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/000008.ldb b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/000008.ldb similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/000008.ldb rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/000008.ldb diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/000009.log b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/000009.log similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/000009.log rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/000009.log diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/CURRENT b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/CURRENT similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/CURRENT rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/CURRENT diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/LOCK b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/LOCK similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/LOCK rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/LOCK diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/LOG b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/LOG similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/LOG rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/LOG diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/LOG.old b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/LOG.old similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/LOG.old rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/LOG.old diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/MANIFEST-000007 b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/MANIFEST-000007 similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/index/MANIFEST-000007 rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/index/MANIFEST-000007 diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/blocks/rev00000.dat b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/rev00000.dat similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/blocks/rev00000.dat rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/blocks/rev00000.dat diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/000005.ldb b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/000005.ldb similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/000005.ldb rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/000005.ldb diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/000008.ldb b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/000008.ldb similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/000008.ldb rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/000008.ldb diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/000009.log b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/000009.log similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/000009.log rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/000009.log diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/CURRENT b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/CURRENT similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/CURRENT rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/CURRENT diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/LOCK b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/LOCK similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/LOCK rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/LOCK diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/LOG b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/LOG similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/LOG rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/LOG diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/LOG.old b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/LOG.old similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/LOG.old rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/LOG.old diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/MANIFEST-000007 b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/MANIFEST-000007 similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/chainstate/MANIFEST-000007 rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/chainstate/MANIFEST-000007 diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/database/log.0000000001 b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/database/log.0000000001 similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/database/log.0000000001 rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/database/log.0000000001 diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/db.log b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/db.log similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/db.log rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/db.log diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/fee_estimates.dat b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/fee_estimates.dat similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/fee_estimates.dat rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/fee_estimates.dat diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/peers.dat b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/peers.dat similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/peers.dat rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/peers.dat diff --git a/zingo-testutils/regtest/data/regtestvectors/regtest/wallet.dat b/zingolib/src/testutils/regtest/data/regtestvectors/regtest/wallet.dat similarity index 100% rename from zingo-testutils/regtest/data/regtestvectors/regtest/wallet.dat rename to zingolib/src/testutils/regtest/data/regtestvectors/regtest/wallet.dat diff --git a/zingo-testutils/regtest/data/zcashd/.gitkeep b/zingolib/src/testutils/regtest/data/zcashd/.gitkeep similarity index 100% rename from zingo-testutils/regtest/data/zcashd/.gitkeep rename to zingolib/src/testutils/regtest/data/zcashd/.gitkeep diff --git a/zingo-testutils/regtest/logs/.gitignore b/zingolib/src/testutils/regtest/logs/.gitignore similarity index 100% rename from zingo-testutils/regtest/logs/.gitignore rename to zingolib/src/testutils/regtest/logs/.gitignore diff --git a/zingo-testutils/regtest/logs/.gitkeep b/zingolib/src/testutils/regtest/logs/.gitkeep similarity index 100% rename from zingo-testutils/regtest/logs/.gitkeep rename to zingolib/src/testutils/regtest/logs/.gitkeep diff --git a/zingo-testutils/regtest/logs/lightwalletd/.gitkeep b/zingolib/src/testutils/regtest/logs/lightwalletd/.gitkeep similarity index 100% rename from zingo-testutils/regtest/logs/lightwalletd/.gitkeep rename to zingolib/src/testutils/regtest/logs/lightwalletd/.gitkeep diff --git a/zingo-testutils/regtest/logs/zcashd/.gitkeep b/zingolib/src/testutils/regtest/logs/zcashd/.gitkeep similarity index 100% rename from zingo-testutils/regtest/logs/zcashd/.gitkeep rename to zingolib/src/testutils/regtest/logs/zcashd/.gitkeep From 3ee28242b14c0f72c567e356a2782312c54fafd3 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 15:56:56 -0600 Subject: [PATCH 03/26] finish porting testutils into zingolib --- zingolib/src/testutils/assertions.rs | 2 +- zingolib/src/testutils/chain_generics/conduct_chain.rs | 5 +++-- zingolib/src/testutils/grpc_proxy.rs | 2 +- zingolib/src/testutils/interrupts.rs | 2 +- zingolib/src/testutils/regtest.rs | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/zingolib/src/testutils/assertions.rs b/zingolib/src/testutils/assertions.rs index 7a5041812..7bacd535b 100644 --- a/zingolib/src/testutils/assertions.rs +++ b/zingolib/src/testutils/assertions.rs @@ -5,8 +5,8 @@ use nonempty::NonEmpty; use zcash_client_backend::proposal::Proposal; use zcash_primitives::transaction::TxId; +use crate::{lightclient::LightClient, wallet::notes::query::OutputQuery}; use zingo_status::confirmation_status::ConfirmationStatus; -use zingolib::{lightclient::LightClient, wallet::notes::query::OutputQuery}; /// currently checks: /// 1. len of txids == num steps diff --git a/zingolib/src/testutils/chain_generics/conduct_chain.rs b/zingolib/src/testutils/chain_generics/conduct_chain.rs index 893fdfc0b..2b51a3812 100644 --- a/zingolib/src/testutils/chain_generics/conduct_chain.rs +++ b/zingolib/src/testutils/chain_generics/conduct_chain.rs @@ -3,8 +3,9 @@ //! lib-to-node, which links a lightserver to a zcashd in regtest mode. see `impl ConductChain for LibtoNode //! darkside, a mode for the lightserver which mocks zcashd. search 'impl ConductChain for DarksideScenario -use testutils::lightclient::from_inputs; -use zingolib::lightclient::LightClient; +use crate::get_base_address_macro; +use crate::lightclient::LightClient; +use crate::testutils::lightclient::from_inputs; #[allow(async_fn_in_trait)] #[allow(opaque_hidden_inferred_bound)] diff --git a/zingolib/src/testutils/grpc_proxy.rs b/zingolib/src/testutils/grpc_proxy.rs index d3a6ba4c3..ed8a3a254 100644 --- a/zingolib/src/testutils/grpc_proxy.rs +++ b/zingolib/src/testutils/grpc_proxy.rs @@ -15,7 +15,7 @@ use zcash_client_backend::proto::{ }, }; -use crate::port_to_localhost_uri; +use super::port_to_localhost_uri; macro_rules! define_grpc_passthrough { (fn diff --git a/zingolib/src/testutils/interrupts.rs b/zingolib/src/testutils/interrupts.rs index 2d4a2b10a..d2c356502 100644 --- a/zingolib/src/testutils/interrupts.rs +++ b/zingolib/src/testutils/interrupts.rs @@ -1,6 +1,6 @@ //! TODO: Add Mod Description Here! -use zingolib::lightclient::LightClient; +use crate::lightclient::LightClient; /// TODO: Add Doc Comment Here! pub async fn sync_with_timeout_millis(lightclient: &LightClient, timeout: u64) -> Result<(), ()> { diff --git a/zingolib/src/testutils/regtest.rs b/zingolib/src/testutils/regtest.rs index 2a75f7a49..53efdfafa 100644 --- a/zingolib/src/testutils/regtest.rs +++ b/zingolib/src/testutils/regtest.rs @@ -206,7 +206,7 @@ pub fn launch_lightwalletd( fn write_zcash_conf(location: &PathBuf) { // This is the only data we need to supply *to* the zcashd, the other files are created by zcashd and lightwalletd use std::io::Write; - let conf_bytes: &'static [u8] = include_bytes!("../regtest/conf/zcash.conf"); + let conf_bytes: &'static [u8] = include_bytes!("./regtest/conf/zcash.conf"); File::create(location) .unwrap() .write_all(conf_bytes) From a93ec2c16730a0ff60c7b1b6a3e069eb590ec905 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 16:31:23 -0600 Subject: [PATCH 04/26] move testvectors into zingolib --- Cargo.toml | 2 -- zingoconfig/src/lib.rs => zingolib/src/config.rs | 0 .../src/lib.rs => zingolib/src/testvectors.rs | 0 .../zcashd/regtest/.lock | 0 .../zcashd/regtest/banlist.dat | Bin .../zcashd/regtest/blocks/blk00000.dat | Bin .../zcashd/regtest/blocks/index/000005.ldb | Bin .../zcashd/regtest/blocks/index/000006.log | Bin .../zcashd/regtest/blocks/index/CURRENT | 0 .../zcashd/regtest/blocks/index/LOCK | 0 .../zcashd/regtest/blocks/index/LOG | 0 .../zcashd/regtest/blocks/index/LOG.old | 0 .../zcashd/regtest/blocks/index/MANIFEST-000004 | Bin .../zcashd/regtest/blocks/rev00000.dat | Bin .../zcashd/regtest/chainstate/000005.ldb | Bin .../zcashd/regtest/chainstate/000006.log | Bin .../zcashd/regtest/chainstate/CURRENT | 0 .../zcashd/regtest/chainstate/LOCK | 0 .../zcashd/regtest/chainstate/LOG | 0 .../zcashd/regtest/chainstate/LOG.old | 0 .../zcashd/regtest/chainstate/MANIFEST-000004 | Bin .../zcashd/regtest/db.log | 0 .../zcashd/regtest/fee_estimates.dat | Bin .../zcashd/regtest/peers.dat | Bin .../zcashd/regtest/wallet.dat | Bin .../old_wallet_reorg_test_wallet/zingo-wallet.dat | Bin 26 files changed, 2 deletions(-) rename zingoconfig/src/lib.rs => zingolib/src/config.rs (100%) rename zingo-testvectors/src/lib.rs => zingolib/src/testvectors.rs (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/.lock (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/banlist.dat (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/blk00000.dat (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000005.ldb (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000006.log (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/CURRENT (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOCK (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG.old (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/MANIFEST-000004 (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/rev00000.dat (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000005.ldb (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000006.log (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/CURRENT (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOCK (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG.old (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/MANIFEST-000004 (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/db.log (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/fee_estimates.dat (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/peers.dat (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zcashd/regtest/wallet.dat (100%) rename {zingo-testvectors => zingolib/src/testvectors}/old_wallet_reorg_test_wallet/zingo-wallet.dat (100%) diff --git a/Cargo.toml b/Cargo.toml index 2108128fd..694cb74af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,6 @@ members = [ "darkside-tests", "zingocli", "zingolib", - "zingoconfig", - "zingo-testvectors", "zingo-netutils", "zingo-memo", "zingo-sync", diff --git a/zingoconfig/src/lib.rs b/zingolib/src/config.rs similarity index 100% rename from zingoconfig/src/lib.rs rename to zingolib/src/config.rs diff --git a/zingo-testvectors/src/lib.rs b/zingolib/src/testvectors.rs similarity index 100% rename from zingo-testvectors/src/lib.rs rename to zingolib/src/testvectors.rs diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/.lock b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/.lock similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/.lock rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/.lock diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/banlist.dat b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/banlist.dat similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/banlist.dat rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/banlist.dat diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/blk00000.dat b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/blk00000.dat similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/blk00000.dat rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/blk00000.dat diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000005.ldb b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000005.ldb similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000005.ldb rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000005.ldb diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000006.log b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000006.log similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000006.log rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/000006.log diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/CURRENT b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/CURRENT similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/CURRENT rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/CURRENT diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOCK b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOCK similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOCK rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOCK diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG.old b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG.old similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG.old rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/LOG.old diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/MANIFEST-000004 b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/MANIFEST-000004 similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/MANIFEST-000004 rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/index/MANIFEST-000004 diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/rev00000.dat b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/rev00000.dat similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/rev00000.dat rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/blocks/rev00000.dat diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000005.ldb b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000005.ldb similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000005.ldb rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000005.ldb diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000006.log b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000006.log similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000006.log rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/000006.log diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/CURRENT b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/CURRENT similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/CURRENT rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/CURRENT diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOCK b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOCK similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOCK rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOCK diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG.old b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG.old similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG.old rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/LOG.old diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/MANIFEST-000004 b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/MANIFEST-000004 similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/MANIFEST-000004 rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/chainstate/MANIFEST-000004 diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/db.log b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/db.log similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/db.log rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/db.log diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/fee_estimates.dat b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/fee_estimates.dat similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/fee_estimates.dat rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/fee_estimates.dat diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/peers.dat b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/peers.dat similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/peers.dat rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/peers.dat diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/wallet.dat b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/wallet.dat similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/wallet.dat rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zcashd/regtest/wallet.dat diff --git a/zingo-testvectors/old_wallet_reorg_test_wallet/zingo-wallet.dat b/zingolib/src/testvectors/old_wallet_reorg_test_wallet/zingo-wallet.dat similarity index 100% rename from zingo-testvectors/old_wallet_reorg_test_wallet/zingo-wallet.dat rename to zingolib/src/testvectors/old_wallet_reorg_test_wallet/zingo-wallet.dat From 5c0a106760bd83d3617431c6049f09ca35b091fa Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 16:43:10 -0600 Subject: [PATCH 05/26] start migrating config and testevectors into zingolib --- libtonode-tests/Cargo.toml | 2 -- zingo-testvectors/Cargo.toml | 11 ----------- zingolib/Cargo.toml | 5 ++--- zingolib/src/lib.rs | 3 +++ .../src/testvectors}/CHANGELOG.md | 0 5 files changed, 5 insertions(+), 16 deletions(-) delete mode 100644 zingo-testvectors/Cargo.toml rename {zingo-testvectors => zingolib/src/testvectors}/CHANGELOG.md (100%) diff --git a/libtonode-tests/Cargo.toml b/libtonode-tests/Cargo.toml index b18da45f1..11f99d60a 100644 --- a/libtonode-tests/Cargo.toml +++ b/libtonode-tests/Cargo.toml @@ -10,8 +10,6 @@ chain_generic_tests = [] [dependencies] zingolib = { path = "../zingolib", features = ["deprecations", "test-elevation"] } zingo-status = { path = "../zingo-status" } -zingo-testvectors = { path = "../zingo-testvectors" } -zingoconfig = { path = "../zingoconfig" } zcash_primitives = { workspace = true } orchard = { workspace = true } diff --git a/zingo-testvectors/Cargo.toml b/zingo-testvectors/Cargo.toml deleted file mode 100644 index a6dc45034..000000000 --- a/zingo-testvectors/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "zingo-testvectors" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -zingoconfig = { path = "../zingoconfig" } - -zcash_primitives = { workspace = true } diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index 5e6561cc4..fb2889d52 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -10,10 +10,10 @@ edition = "2021" deprecations = ["lightclient-deprecated"] lightclient-deprecated = [] darkside_tests = [] -test-elevation = ["portpicker", "zingo-testvectors", "tempfile"] +test-elevation = ["portpicker", "testvectors", "tempfile"] +testvectors = [] [dependencies] -zingoconfig = { path = "../zingoconfig" } zingo-memo = { path = "../zingo-memo" } zingo-status = { path = "../zingo-status" } zingo-netutils = { path = "../zingo-netutils" } @@ -73,7 +73,6 @@ hdwallet = { workspace = true } chrono = { workspace = true } enum_dispatch = { workspace = true } portpicker = { workspace = true, optional = true } -zingo-testvectors = { path = "../zingo-testvectors", optional = true } tempfile = { workspace = true, optional = true} [dev-dependencies] diff --git a/zingolib/src/lib.rs b/zingolib/src/lib.rs index 63b554219..07781be67 100644 --- a/zingolib/src/lib.rs +++ b/zingolib/src/lib.rs @@ -9,6 +9,7 @@ extern crate rust_embed; pub mod blaze; pub mod commands; +pub mod config; pub mod data; pub mod error; pub mod grpc_connector; @@ -20,6 +21,8 @@ pub mod wallet; pub mod mocks; #[cfg(feature = "test-elevation")] pub mod testutils; +#[cfg(feature = "testvectors")] +pub mod testvectors; // This line includes the generated `git_description()` function directly into this scope. include!(concat!(env!("OUT_DIR"), "/git_description.rs")); diff --git a/zingo-testvectors/CHANGELOG.md b/zingolib/src/testvectors/CHANGELOG.md similarity index 100% rename from zingo-testvectors/CHANGELOG.md rename to zingolib/src/testvectors/CHANGELOG.md From 0ed7dcc72e749cc974c725eb7f41a8fde8ad9b39 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 16:45:40 -0600 Subject: [PATCH 06/26] cargo check passes manifest validation --- Cargo.lock | 186 -------------------------------------- darkside-tests/Cargo.toml | 4 +- zingocli/Cargo.toml | 1 - 3 files changed, 1 insertion(+), 190 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index edd2abaf4..4d3f3e72c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,12 +122,6 @@ name = "append-only-vec" version = "0.1.2" source = "git+https://github.com/zancas/append-only-vec.git?branch=add_debug_impl#ec919c9c8f5429edbac69f0c2203dd01c861ce15" -[[package]] -name = "arc-swap" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" - [[package]] name = "arrayref" version = "0.3.7" @@ -678,8 +672,6 @@ dependencies = [ "tower", "zcash_client_backend", "zcash_primitives", - "zingo-testvectors", - "zingoconfig", "zingolib", ] @@ -692,23 +684,6 @@ dependencies = [ "powerfmt", ] -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "destructure_traitobject" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7" - [[package]] name = "digest" version = "0.9.0" @@ -729,15 +704,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs-next" version = "2.0.0" @@ -748,18 +714,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1293,12 +1247,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.29" @@ -1618,8 +1566,6 @@ dependencies = [ "zcash_client_backend", "zcash_primitives", "zingo-status", - "zingo-testvectors", - "zingoconfig", "zingolib", ] @@ -1650,43 +1596,6 @@ name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" -dependencies = [ - "serde", -] - -[[package]] -name = "log-mdc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" - -[[package]] -name = "log4rs" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0816135ae15bd0391cf284eab37e6e3ee0a6ee63d2ceeb659862bd8d0a984ca6" -dependencies = [ - "anyhow", - "arc-swap", - "chrono", - "derivative", - "fnv", - "humantime", - "libc", - "log", - "log-mdc", - "once_cell", - "parking_lot", - "rand 0.8.5", - "serde", - "serde-value", - "serde_json", - "serde_yaml", - "thiserror", - "thread-id", - "typemap-ors", - "winapi", -] [[package]] name = "matchit" @@ -1930,12 +1839,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "orchard" version = "0.8.0" @@ -1966,15 +1869,6 @@ dependencies = [ "zip32", ] -[[package]] -name = "ordered-float" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" -dependencies = [ - "num-traits", -] - [[package]] name = "overload" version = "0.1.1" @@ -2855,16 +2749,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-value" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" -dependencies = [ - "ordered-float", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.203" @@ -2899,19 +2783,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_yaml" -version = "0.9.34+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" -dependencies = [ - "indexmap 2.2.6", - "itoa", - "ryu", - "serde", - "unsafe-libyaml", -] - [[package]] name = "sha2" version = "0.9.9" @@ -3167,16 +3038,6 @@ dependencies = [ "syn 2.0.68", ] -[[package]] -name = "thread-id" -version = "4.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0ec81c46e9eb50deaa257be2f148adf052d1fb7701cfd55ccfab2525280b70b" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "thread_local" version = "1.1.8" @@ -3457,15 +3318,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "typemap-ors" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a68c24b707f02dd18f1e4ccceb9d49f2058c2fb86384ef9972592904d7a28867" -dependencies = [ - "unsafe-any-ors", -] - [[package]] name = "typenum" version = "1.17.0" @@ -3533,21 +3385,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "unsafe-any-ors" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a303d30665362d9680d7d91d78b23f5f899504d4f08b3c4cf08d055d87c0ad" -dependencies = [ - "destructure_traitobject", -] - -[[package]] -name = "unsafe-libyaml" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" - [[package]] name = "untrusted" version = "0.7.1" @@ -4168,7 +4005,6 @@ dependencies = [ "log", "rustyline", "shellwords", - "zingoconfig", "zingolib", ] @@ -4221,26 +4057,6 @@ dependencies = [ "zingo-netutils", ] -[[package]] -name = "zingo-testvectors" -version = "0.1.0" -dependencies = [ - "zcash_primitives", - "zingoconfig", -] - -[[package]] -name = "zingoconfig" -version = "0.1.0" -dependencies = [ - "dirs", - "http 0.2.12", - "log", - "log4rs", - "tempdir", - "zcash_primitives", -] - [[package]] name = "zingolib" version = "0.2.0" @@ -4302,8 +4118,6 @@ dependencies = [ "zingo-memo", "zingo-netutils", "zingo-status", - "zingo-testvectors", - "zingoconfig", "zip32", ] diff --git a/darkside-tests/Cargo.toml b/darkside-tests/Cargo.toml index 6fd24f45e..d734d5487 100644 --- a/darkside-tests/Cargo.toml +++ b/darkside-tests/Cargo.toml @@ -8,9 +8,7 @@ edition = "2021" chain_generic_tests = [] [dependencies] -zingolib = { path = "../zingolib", features = ["darkside_tests"] } -zingo-testvectors = { path = "../zingo-testvectors" } -zingoconfig = { path = "../zingoconfig" } +zingolib = { path = "../zingolib", features = ["darkside_tests", "testvectors"] } tokio = { workspace = true, features = ["full"] } json = { workspace = true } http = { workspace = true } diff --git a/zingocli/Cargo.toml b/zingocli/Cargo.toml index 1bdf2d839..2d7e14bcc 100644 --- a/zingocli/Cargo.toml +++ b/zingocli/Cargo.toml @@ -5,7 +5,6 @@ edition = "2021" [dependencies] zingolib = { path = "../zingolib/", features = ["deprecations", "test-elevation"] } -zingoconfig = { path = "../zingoconfig/" } clap = { workspace = true } http = { workspace = true } From 091675b89653f0c84c5d9d73e0607e9f1d749072 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 16:50:53 -0600 Subject: [PATCH 07/26] some zingoconfig --> crate::config --- zingolib/src/testutils.rs | 80 ++++++++++++++++----------------- zingolib/src/wallet/describe.rs | 4 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/zingolib/src/testutils.rs b/zingolib/src/testutils.rs index 432bc5a90..12a22cdda 100644 --- a/zingolib/src/testutils.rs +++ b/zingolib/src/testutils.rs @@ -24,12 +24,12 @@ use std::time::Duration; use tokio::task::JoinHandle; use zcash_address::unified::{Fvk, Ufvk}; +use crate::config::{ChainType, ZingoConfig}; use crate::lightclient::LightClient; use json::JsonValue; use log::debug; use regtest::RegtestManager; use tokio::time::sleep; -use zingoconfig::{ChainType, ZingoConfig}; use scenarios::setup::TestEnvironmentGenerator; @@ -367,7 +367,7 @@ pub async fn load_wallet( let wallet = dir.join("zingo-wallet.dat"); let lightwalletd_uri = TestEnvironmentGenerator::new(None).get_lightwalletd_uri(); let zingo_config = - zingoconfig::load_clientconfig(lightwalletd_uri, Some(dir), chaintype, true).unwrap(); + crate::config::load_clientconfig(lightwalletd_uri, Some(dir), chaintype, true).unwrap(); let from = std::fs::File::open(wallet).unwrap(); let read_lengths = vec![]; @@ -674,19 +674,19 @@ pub mod scenarios { use crate::get_base_address_macro; use crate::lightclient::LightClient; use crate::testutils::increase_height_and_wait_for_client; + use crate::testvectors::{seeds::HOSPITAL_MUSEUM_SEED, BASE_HEIGHT}; use setup::ClientBuilder; use zcash_client_backend::{PoolType, ShieldedProtocol}; - use zingo_testvectors::{self, seeds::HOSPITAL_MUSEUM_SEED, BASE_HEIGHT}; /// TODO: Add Doc Comment Here! pub mod setup { use super::BASE_HEIGHT; - use tempfile::TempDir; - use zcash_client_backend::{PoolType, ShieldedProtocol}; - use zingo_testvectors::{ + use crate::testvectors::{ seeds, REG_O_ADDR_FROM_ABANDONART, REG_T_ADDR_FROM_ABANDONART, REG_Z_ADDR_FROM_ABANDONART, }; + use tempfile::TempDir; + use zcash_client_backend::{PoolType, ShieldedProtocol}; use super::super::paths::get_regtest_dir; use super::{ChildProcessHandler, RegtestManager}; @@ -737,7 +737,7 @@ pub mod scenarios { fn configure_scenario( &mut self, mine_to_pool: Option, - regtest_network: &zingoconfig::RegtestNetwork, + regtest_network: &crate::config::RegtestNetwork, ) { let mine_to_address = match mine_to_pool { Some(PoolType::Shielded(ShieldedProtocol::Orchard)) => { @@ -778,7 +778,7 @@ pub mod scenarios { /// TODO: Add Doc Comment Here! pub async fn new_load_1153_saplingcb_regtest_chain( - regtest_network: &zingoconfig::RegtestNetwork, + regtest_network: &crate::config::RegtestNetwork, ) -> Self { let mut sb = ScenarioBuilder::build_scenario(None, None); let source = get_regtest_dir().join("data/chain_cache/blocks_1153/zcashd/regtest"); @@ -807,7 +807,7 @@ pub mod scenarios { mine_to_pool: Option, zingo_wallet_dir: Option, set_lightwalletd_port: Option, - regtest_network: &zingoconfig::RegtestNetwork, + regtest_network: &crate::config::RegtestNetwork, ) -> Self { let mut sb = if let Some(conf) = zingo_wallet_dir { ScenarioBuilder::build_scenario(Some(conf), set_lightwalletd_port) @@ -843,8 +843,8 @@ pub mod scenarios { pub fn make_unique_data_dir_and_load_config( &mut self, - regtest_network: zingoconfig::RegtestNetwork, - ) -> zingoconfig::ZingoConfig { + regtest_network: crate::config::RegtestNetwork, + ) -> crate::config::ZingoConfig { //! Each client requires a unique data_dir, we use the //! client_number counter for this. self.client_number += 1; @@ -860,13 +860,13 @@ pub mod scenarios { pub fn create_clientconfig( &self, conf_path: PathBuf, - regtest_network: zingoconfig::RegtestNetwork, - ) -> zingoconfig::ZingoConfig { + regtest_network: crate::config::RegtestNetwork, + ) -> crate::config::ZingoConfig { std::fs::create_dir(&conf_path).unwrap(); - zingoconfig::load_clientconfig( + crate::config::load_clientconfig( self.server_id.clone(), Some(conf_path), - zingoconfig::ChainType::Regtest(regtest_network), + crate::config::ChainType::Regtest(regtest_network), true, ) .unwrap() @@ -876,7 +876,7 @@ pub mod scenarios { pub async fn build_faucet( &mut self, overwrite: bool, - regtest_network: zingoconfig::RegtestNetwork, + regtest_network: crate::config::RegtestNetwork, ) -> LightClient { //! A "faucet" is a lightclient that receives mining rewards self.build_client( @@ -894,7 +894,7 @@ pub mod scenarios { mnemonic_phrase: String, birthday: u64, overwrite: bool, - regtest_network: zingoconfig::RegtestNetwork, + regtest_network: crate::config::RegtestNetwork, ) -> LightClient { let zingo_config = self.make_unique_data_dir_and_load_config(regtest_network); LightClient::create_from_wallet_base_async( @@ -926,7 +926,7 @@ pub mod scenarios { let regtest_manager = RegtestManager::new( TempDir::new_in("zingo_libtonode_test").unwrap().into_path(), ); - let server_uri = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_uri = crate::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{lightwalletd_rpcservice_port}" ))); Self { @@ -941,15 +941,15 @@ pub mod scenarios { pub(crate) fn create_zcash_conf( &self, mine_to_address: Option<&str>, - regtest_network: &zingoconfig::RegtestNetwork, + regtest_network: &crate::config::RegtestNetwork, ) -> PathBuf { let config = match mine_to_address { - Some(address) => zingo_testvectors::config_template_fillers::zcashd::funded( + Some(address) => crate::testvectors::config_template_fillers::zcashd::funded( address, &self.zcashd_rpcservice_port, regtest_network, ), - None => zingo_testvectors::config_template_fillers::zcashd::basic( + None => crate::testvectors::config_template_fillers::zcashd::basic( &self.zcashd_rpcservice_port, regtest_network, "", @@ -962,7 +962,7 @@ pub mod scenarios { pub(crate) fn create_lightwalletd_conf(&self) -> PathBuf { self.write_contents_and_return_path( "lightwalletd", - zingo_testvectors::config_template_fillers::lightwalletd::basic( + crate::testvectors::config_template_fillers::lightwalletd::basic( &self.lightwalletd_rpcservice_port, ), ) @@ -1007,7 +1007,7 @@ pub mod scenarios { /// TODO: Add Doc Comment Here! pub async fn unfunded_client( - regtest_network: zingoconfig::RegtestNetwork, + regtest_network: crate::config::RegtestNetwork, ) -> (RegtestManager, ChildProcessHandler, LightClient) { let mut scenario_builder = setup::ScenarioBuilder::build_configure_launch(None, None, None, ®test_network) @@ -1024,7 +1024,7 @@ pub mod scenarios { /// TODO: Add Doc Comment Here! pub async fn unfunded_client_default() -> (RegtestManager, ChildProcessHandler, LightClient) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); unfunded_client(regtest_network).await } @@ -1040,7 +1040,7 @@ pub mod scenarios { /// become interesting (e.g. without experimental features, or txindices) we'll create more setups. pub async fn faucet( mine_to_pool: PoolType, - regtest_network: zingoconfig::RegtestNetwork, + regtest_network: crate::config::RegtestNetwork, ) -> (RegtestManager, ChildProcessHandler, LightClient) { let mut sb = setup::ScenarioBuilder::build_configure_launch( Some(mine_to_pool), @@ -1060,7 +1060,7 @@ pub mod scenarios { /// TODO: Add Doc Comment Here! pub async fn faucet_default() -> (RegtestManager, ChildProcessHandler, LightClient) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); faucet( PoolType::Shielded(ShieldedProtocol::Orchard), regtest_network, @@ -1071,7 +1071,7 @@ pub mod scenarios { /// TODO: Add Doc Comment Here! pub async fn faucet_recipient( mine_to_pool: PoolType, - regtest_network: zingoconfig::RegtestNetwork, + regtest_network: crate::config::RegtestNetwork, ) -> ( RegtestManager, ChildProcessHandler, @@ -1112,7 +1112,7 @@ pub mod scenarios { LightClient, LightClient, ) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); faucet_recipient( PoolType::Shielded(ShieldedProtocol::Orchard), regtest_network, @@ -1126,7 +1126,7 @@ pub mod scenarios { sapling_funds: Option, transparent_funds: Option, mine_to_pool: PoolType, - regtest_network: zingoconfig::RegtestNetwork, + regtest_network: crate::config::RegtestNetwork, ) -> ( RegtestManager, ChildProcessHandler, @@ -1212,7 +1212,7 @@ pub mod scenarios { LightClient, String, ) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); let ( regtest_manager, cph, @@ -1241,7 +1241,7 @@ pub mod scenarios { /// TODO: Add Doc Comment Here! pub async fn custom_clients( mine_to_pool: PoolType, - regtest_network: zingoconfig::RegtestNetwork, + regtest_network: crate::config::RegtestNetwork, ) -> (RegtestManager, ChildProcessHandler, ClientBuilder) { let sb = setup::ScenarioBuilder::build_configure_launch( Some(mine_to_pool), @@ -1262,9 +1262,9 @@ pub mod scenarios { RegtestManager, ChildProcessHandler, ClientBuilder, - zingoconfig::RegtestNetwork, + crate::config::RegtestNetwork, ) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); let (regtest_manager, cph, client_builder) = custom_clients( PoolType::Shielded(ShieldedProtocol::Orchard), regtest_network, @@ -1275,7 +1275,7 @@ pub mod scenarios { /// TODO: Add Doc Comment Here! pub async fn unfunded_mobileclient() -> (RegtestManager, ChildProcessHandler) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); let scenario_builder = setup::ScenarioBuilder::build_configure_launch( None, None, @@ -1291,7 +1291,7 @@ pub mod scenarios { /// TODO: Add Doc Comment Here! pub async fn funded_orchard_mobileclient(value: u64) -> (RegtestManager, ChildProcessHandler) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); let mut scenario_builder = setup::ScenarioBuilder::build_configure_launch( Some(PoolType::Shielded(ShieldedProtocol::Sapling)), None, @@ -1328,7 +1328,7 @@ pub mod scenarios { pub async fn funded_orchard_with_3_txs_mobileclient( value: u64, ) -> (RegtestManager, ChildProcessHandler) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); let mut scenario_builder = setup::ScenarioBuilder::build_configure_launch( Some(PoolType::Shielded(ShieldedProtocol::Sapling)), None, @@ -1396,7 +1396,7 @@ pub mod scenarios { pub async fn funded_orchard_sapling_transparent_shielded_mobileclient( value: u64, ) -> (RegtestManager, ChildProcessHandler) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); let mut scenario_builder = setup::ScenarioBuilder::build_configure_launch( Some(PoolType::Shielded(ShieldedProtocol::Sapling)), None, @@ -1535,7 +1535,7 @@ pub mod scenarios { /// TODO: Add Doc Comment Here! pub async fn unsynced_basic() -> ChildProcessHandler { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); setup::ScenarioBuilder::new_load_1153_saplingcb_regtest_chain(®test_network) .await .child_process_handler @@ -1549,7 +1549,7 @@ pub mod scenarios { LightClient, LightClient, ) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); let mut sb = setup::ScenarioBuilder::new_load_1153_saplingcb_regtest_chain(®test_network) .await; @@ -1574,7 +1574,7 @@ pub mod scenarios { LightClient, LightClient, ) { - let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); + let regtest_network = crate::config::RegtestNetwork::all_upgrades_active(); let mut sb = setup::ScenarioBuilder::new_load_1153_saplingcb_regtest_chain(®test_network) .await; diff --git a/zingolib/src/wallet/describe.rs b/zingolib/src/wallet/describe.rs index e5b20f23e..9f7fee982 100644 --- a/zingolib/src/wallet/describe.rs +++ b/zingolib/src/wallet/describe.rs @@ -174,7 +174,7 @@ impl LightWallet { } /// TODO: Add Doc Comment Here! pub(crate) fn note_address( - network: &zingoconfig::ChainType, + network: &crate::config::ChainType, note: &D::WalletNote, wallet_capability: &WalletCapability, ) -> String @@ -292,8 +292,8 @@ mod tests { use orchard::note_encryption::OrchardDomain; use sapling_crypto::note_encryption::SaplingDomain; + use crate::config::ZingoConfigBuilder; use zingo_status::confirmation_status::ConfirmationStatus; - use zingoconfig::ZingoConfigBuilder; use crate::{ mocks::{orchard_note::OrchardCryptoNoteBuilder, SaplingCryptoNoteBuilder}, From 157b2a517eb24cd4f733e017bdb82399f3a9c710 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 16:52:03 -0600 Subject: [PATCH 08/26] more --- zingolib/src/testvectors.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zingolib/src/testvectors.rs b/zingolib/src/testvectors.rs index c70874d21..360dcf5b5 100644 --- a/zingolib/src/testvectors.rs +++ b/zingolib/src/testvectors.rs @@ -65,7 +65,7 @@ pub mod config_template_fillers { /// TODO: Add Doc Comment Here! pub fn basic( rpcport: &str, - regtest_network: &zingoconfig::RegtestNetwork, + regtest_network: &crate::config::RegtestNetwork, extra: &str, ) -> String { let overwinter_activation_height = regtest_network @@ -125,7 +125,7 @@ listen=0 pub fn funded( mineraddress: &str, rpcport: &str, - regtest_network: &zingoconfig::RegtestNetwork, + regtest_network: &crate::config::RegtestNetwork, ) -> String { basic(rpcport, regtest_network, &format!("\ @@ -138,7 +138,7 @@ minetolocalwallet=0 # This is set to false so that we can mine to a wallet, othe #[test] fn funded_zcashd_conf() { - let regtest_network = zingoconfig::RegtestNetwork::new(1, 2, 3, 4, 5, 6); + let regtest_network = crate::config::RegtestNetwork::new(1, 2, 3, 4, 5, 6); assert_eq!( funded( super::super::REG_Z_ADDR_FROM_ABANDONART, From f17ab7202259b45411841e47954e3539d2a551ec Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 17:30:18 -0600 Subject: [PATCH 09/26] WIP --- Cargo.lock | 28 +++++++++++++++++++ zingolib/Cargo.toml | 1 + .../blaze/block_management_reorg_detection.rs | 2 +- zingolib/src/blaze/trial_decryptions.rs | 4 +-- zingolib/src/commands.rs | 14 +++++----- zingolib/src/testutils/lightclient.rs | 2 +- .../src/wallet/keys/extended_transparent.rs | 3 +- .../src/wallet/transaction_records_by_id.rs | 6 ++-- 8 files changed, 44 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d3f3e72c..64750277f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -704,6 +704,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + [[package]] name = "dirs-next" version = "2.0.0" @@ -714,6 +723,18 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1839,6 +1860,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "orchard" version = "0.8.0" @@ -4070,6 +4097,7 @@ dependencies = [ "bytes 0.4.12", "chrono", "concat-idents", + "dirs", "enum_dispatch", "ff", "futures", diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index fb2889d52..767ba8d1c 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -74,6 +74,7 @@ chrono = { workspace = true } enum_dispatch = { workspace = true } portpicker = { workspace = true, optional = true } tempfile = { workspace = true, optional = true} +dirs.workspace = true [dev-dependencies] concat-idents = { workspace = true } diff --git a/zingolib/src/blaze/block_management_reorg_detection.rs b/zingolib/src/blaze/block_management_reorg_detection.rs index 05cbb2de3..3b2a32138 100644 --- a/zingolib/src/blaze/block_management_reorg_detection.rs +++ b/zingolib/src/blaze/block_management_reorg_detection.rs @@ -67,7 +67,7 @@ impl BlockManagementData { blocks_in_current_batch: Arc::new(RwLock::new(vec![])), existing_blocks: Arc::new(RwLock::new(vec![])), unverified_treestates: Arc::new(RwLock::new(vec![])), - batch_size: zingoconfig::BATCH_SIZE, + batch_size: crate::config::BATCH_SIZE, highest_verified_trees: None, sync_status, } diff --git a/zingolib/src/blaze/trial_decryptions.rs b/zingolib/src/blaze/trial_decryptions.rs index 7ff252a9a..cee4cc556 100644 --- a/zingolib/src/blaze/trial_decryptions.rs +++ b/zingolib/src/blaze/trial_decryptions.rs @@ -5,6 +5,7 @@ use crate::error::ZingoLibResult; +use crate::config::ZingoConfig; use crate::wallet::keys::unified::{External, Fvk as _, Ivk}; use crate::wallet::notes::ShieldedNoteInterface; use crate::wallet::{ @@ -35,7 +36,6 @@ use zcash_primitives::{ transaction::{Transaction, TxId}, }; use zingo_status::confirmation_status::ConfirmationStatus; -use zingoconfig::ZingoConfig; use super::syncdata::BlazeSyncData; @@ -264,7 +264,7 @@ impl TrialDecryptions { compact_block: &CompactBlock, ivk: D::IncomingViewingKey, height: BlockHeight, - config: &zingoconfig::ZingoConfig, + config: &crate::config::ZingoConfig, wc: &Arc, bsync_data: &Arc>, transaction_metadata_set: &Arc>, diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index 05a06a00f..ec7542ca1 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -198,19 +198,19 @@ impl Command for ParseAddressCommand { match args.len() { 1 => json::stringify_pretty( [ - zingoconfig::ChainType::Mainnet, - zingoconfig::ChainType::Testnet, - zingoconfig::ChainType::Regtest( - zingoconfig::RegtestNetwork::all_upgrades_active(), + crate::config::ChainType::Mainnet, + crate::config::ChainType::Testnet, + crate::config::ChainType::Regtest( + crate::config::RegtestNetwork::all_upgrades_active(), ), ] .iter() .find_map(|chain| Address::decode(chain, args[0]).zip(Some(chain))) .map(|(recipient_address, chain_name)| { let chain_name_string = match chain_name { - zingoconfig::ChainType::Mainnet => "main", - zingoconfig::ChainType::Testnet => "test", - zingoconfig::ChainType::Regtest(_) => "regtest", + crate::config::ChainType::Mainnet => "main", + crate::config::ChainType::Testnet => "test", + crate::config::ChainType::Regtest(_) => "regtest", }; match recipient_address { diff --git a/zingolib/src/testutils/lightclient.rs b/zingolib/src/testutils/lightclient.rs index 6563545e4..6adcf8fa9 100644 --- a/zingolib/src/testutils/lightclient.rs +++ b/zingolib/src/testutils/lightclient.rs @@ -51,7 +51,7 @@ pub mod from_inputs { /// Panics if the address, amount or memo conversion fails. pub fn receivers_from_send_inputs( raw_receivers: Vec<(&str, u64, Option<&str>)>, - chain: &zingoconfig::ChainType, + chain: &crate::config::ChainType, ) -> crate::data::receivers::Receivers { raw_receivers .into_iter() diff --git a/zingolib/src/wallet/keys/extended_transparent.rs b/zingolib/src/wallet/keys/extended_transparent.rs index 3f04e14e4..2583fae39 100644 --- a/zingolib/src/wallet/keys/extended_transparent.rs +++ b/zingolib/src/wallet/keys/extended_transparent.rs @@ -1,13 +1,12 @@ //! TODO: Add Mod Discription Here! use std::io; +use crate::config::ZingoConfig; use byteorder::{ReadBytesExt, WriteBytesExt}; use lazy_static::lazy_static; use ring::hmac::{self, Context, Key}; use secp256k1::{Error, PublicKey, Secp256k1, SecretKey, SignOnly}; use zcash_encoding::Vector; -use zcash_primitives::consensus::NetworkConstants; -use zingoconfig::ZingoConfig; use crate::wallet::traits::ReadableWriteable; diff --git a/zingolib/src/wallet/transaction_records_by_id.rs b/zingolib/src/wallet/transaction_records_by_id.rs index bee48b839..3d5b23631 100644 --- a/zingolib/src/wallet/transaction_records_by_id.rs +++ b/zingolib/src/wallet/transaction_records_by_id.rs @@ -21,10 +21,10 @@ use zcash_client_backend::wallet::NoteId; use zcash_note_encryption::Domain; use zcash_primitives::consensus::BlockHeight; -use zcash_primitives::transaction::TxId; -use zingoconfig::{ +use crate::config::{ ChainType, ZENNIES_FOR_ZINGO_DONATION_ADDRESS, ZENNIES_FOR_ZINGO_REGTEST_ADDRESS, }; +use zcash_primitives::transaction::TxId; pub mod trait_inputsource; @@ -354,7 +354,7 @@ impl TransactionRecordsById { /// Invalidates all those transactions which were broadcast but never 'confirmed' accepted by a miner. pub(crate) fn clear_expired_mempool(&mut self, latest_height: u64) { let cutoff = BlockHeight::from_u32( - (latest_height.saturating_sub(zingoconfig::MAX_REORG as u64)) as u32, + (latest_height.saturating_sub(crate::config::MAX_REORG as u64)) as u32, ); let txids_to_remove = self From ec93506033bef90ce76322417ae82afc3580e98e Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 17:33:23 -0600 Subject: [PATCH 10/26] more 'by hand' conversions --- zingolib/src/blaze/fetch_compact_blocks.rs | 2 +- zingolib/src/blaze/fetch_taddr_transactions.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zingolib/src/blaze/fetch_compact_blocks.rs b/zingolib/src/blaze/fetch_compact_blocks.rs index b204dae0f..710fea2f3 100644 --- a/zingolib/src/blaze/fetch_compact_blocks.rs +++ b/zingolib/src/blaze/fetch_compact_blocks.rs @@ -1,10 +1,10 @@ use std::{cmp::max, sync::Arc}; +use crate::config::ZingoConfig; use crate::grpc_connector::GrpcConnector; use log::debug; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use zcash_client_backend::proto::compact_formats::CompactBlock; -use zingoconfig::ZingoConfig; pub struct FetchCompactBlocks { config: ZingoConfig, } diff --git a/zingolib/src/blaze/fetch_taddr_transactions.rs b/zingolib/src/blaze/fetch_taddr_transactions.rs index 82af789de..cf2b47dae 100644 --- a/zingolib/src/blaze/fetch_taddr_transactions.rs +++ b/zingolib/src/blaze/fetch_taddr_transactions.rs @@ -9,11 +9,11 @@ use tokio::sync::mpsc::UnboundedReceiver; use tokio::sync::oneshot; use tokio::{sync::mpsc::UnboundedSender, task::JoinHandle}; +use crate::config::ZingoConfig; use zcash_primitives::consensus::BlockHeight; use zcash_primitives::consensus::BranchId; use zcash_primitives::consensus::Parameters; use zcash_primitives::transaction::Transaction; -use zingoconfig::ZingoConfig; pub struct FetchTaddrTransactions { wc: Arc, @@ -285,7 +285,7 @@ mod tests { 1, taddr_fetcher_transmitter, full_transaction_scanner_transmitter, - zingoconfig::Network::FakeMainnet, + crate::config::Network::FakeMainnet, ) .await; //Todo: Add regtest support From e8441c590789f13da23bdd25f040d552ad9f504e Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 17:40:56 -0600 Subject: [PATCH 11/26] use sed --- zingolib/src/blaze/syncdata.rs | 2 +- zingolib/src/commands/utils.rs | 6 +++--- zingolib/src/config.rs | 8 ++++---- zingolib/src/data/witness_trees.rs | 2 +- zingolib/src/lightclient.rs | 6 +++--- zingolib/src/lightclient/describe.rs | 2 +- zingolib/src/lightclient/propose.rs | 8 ++++---- zingolib/src/lightclient/read.rs | 2 +- zingolib/src/lightclient/send.rs | 2 +- zingolib/src/lightclient/sync.rs | 4 ++-- zingolib/src/mocks.rs | 2 +- zingolib/src/utils/conversion.rs | 2 +- zingolib/src/wallet.rs | 2 +- zingolib/src/wallet/data.rs | 2 +- zingolib/src/wallet/disk.rs | 2 +- zingolib/src/wallet/disk/testing.rs | 2 +- zingolib/src/wallet/keys.rs | 2 +- zingolib/src/wallet/keys/unified.rs | 2 +- zingolib/src/wallet/message.rs | 2 +- zingolib/src/wallet/send.rs | 2 +- zingolib/src/wallet/traits.rs | 2 +- zingolib/src/wallet/transaction_context.rs | 2 +- 22 files changed, 33 insertions(+), 33 deletions(-) diff --git a/zingolib/src/blaze/syncdata.rs b/zingolib/src/blaze/syncdata.rs index d716fe879..043d27f28 100644 --- a/zingolib/src/blaze/syncdata.rs +++ b/zingolib/src/blaze/syncdata.rs @@ -7,7 +7,7 @@ use zcash_client_backend::proto::service::TreeState; use super::{block_management_reorg_detection::BlockManagementData, sync_status::BatchSyncStatus}; use crate::wallet::data::BlockData; use crate::wallet::WalletOptions; -use zingoconfig::ZingoConfig; +use crate::config::ZingoConfig; pub struct BlazeSyncData { pub(crate) block_data: BlockManagementData, diff --git a/zingolib/src/commands/utils.rs b/zingolib/src/commands/utils.rs index 89267b3bb..dc7a6db15 100644 --- a/zingolib/src/commands/utils.rs +++ b/zingolib/src/commands/utils.rs @@ -8,7 +8,7 @@ use json::JsonValue; use zcash_client_backend::address::Address; use zcash_primitives::memo::MemoBytes; use zcash_primitives::transaction::components::amount::NonNegativeAmount; -use zingoconfig::ChainType; +use crate::config::ChainType; // Parse the send arguments for `do_send`. // The send arguments have two possible formats: @@ -219,7 +219,7 @@ fn memo_from_json(json_array: &JsonValue) -> Result, CommandEr #[cfg(test)] mod tests { - use zingoconfig::{ChainType, RegtestNetwork}; + use crate::config::{ChainType, RegtestNetwork}; use crate::{ commands::error::CommandError, @@ -297,7 +297,7 @@ mod tests { } mod fail_parse_send_args { - use zingoconfig::{ChainType, RegtestNetwork}; + use crate::config::{ChainType, RegtestNetwork}; use crate::commands::{error::CommandError, utils::parse_send_args}; diff --git a/zingolib/src/config.rs b/zingolib/src/config.rs index ded47e3df..6321c6607 100644 --- a/zingolib/src/config.rs +++ b/zingolib/src/config.rs @@ -163,7 +163,7 @@ impl ZingoConfigBuilder { /// Set the URI of the proxy server we download blockchain information from. /// # Examples /// ``` - /// use zingoconfig::ZingoConfigBuilder; + /// use crate::config::ZingoConfigBuilder; /// use http::Uri; /// assert_eq!(ZingoConfigBuilder::default().set_lightwalletd_uri(("https://zcash.mysideoftheweb.com:19067").parse::().unwrap()).lightwalletd_uri.clone().unwrap(), "https://zcash.mysideoftheweb.com:19067"); /// ``` @@ -178,8 +178,8 @@ impl ZingoConfigBuilder { /// Note "chain type" is not a formal standard. /// # Examples /// ``` - /// use zingoconfig::ZingoConfigBuilder; - /// use zingoconfig::ChainType::Testnet; + /// use crate::config::ZingoConfigBuilder; + /// use crate::config::ChainType::Testnet; /// assert_eq!(ZingoConfigBuilder::default().set_chain(Testnet).create().chain, Testnet); /// ``` pub fn set_chain(&mut self, chain: ChainType) -> &mut Self { @@ -190,7 +190,7 @@ impl ZingoConfigBuilder { /// Set the wallet directory where client transaction data will be stored in a wallet. /// # Examples /// ``` - /// use zingoconfig::ZingoConfigBuilder; + /// use crate::config::ZingoConfigBuilder; /// use tempdir::TempDir; /// let dir = TempDir::new("zingo_doc_test").unwrap().into_path(); /// let config = ZingoConfigBuilder::default().set_wallet_dir(dir.clone()).create(); diff --git a/zingolib/src/data/witness_trees.rs b/zingolib/src/data/witness_trees.rs index 31b47a964..41fb6d16b 100644 --- a/zingolib/src/data/witness_trees.rs +++ b/zingolib/src/data/witness_trees.rs @@ -19,7 +19,7 @@ use zcash_note_encryption::Domain; use zcash_primitives::consensus::BlockHeight; use zcash_primitives::merkle_tree::HashSer; -use zingoconfig::MAX_REORG; +use crate::config::MAX_REORG; /// TODO: Add Doc Comment Here! pub const COMMITMENT_TREE_LEVELS: u8 = 32; diff --git a/zingolib/src/lightclient.rs b/zingolib/src/lightclient.rs index d48848968..604ac0e6a 100644 --- a/zingolib/src/lightclient.rs +++ b/zingolib/src/lightclient.rs @@ -12,7 +12,7 @@ use zcash_primitives::{ memo::{Memo, MemoBytes}, }; -use zingoconfig::ZingoConfig; +use crate::config::ZingoConfig; use crate::{ blaze::syncdata::BlazeSyncData, @@ -254,7 +254,7 @@ pub mod instantiation { sync::{Mutex, RwLock}, }; - use zingoconfig::ZingoConfig; + use crate::config::ZingoConfig; use super::{LightClient, ZingoSaveBuffer}; use crate::{ @@ -635,7 +635,7 @@ async fn get_recent_median_price_from_gemini() -> Result { mod tests { use tokio::runtime::Runtime; use zingo_testvectors::seeds::CHIMNEY_BETTER_SEED; - use zingoconfig::{ChainType, RegtestNetwork, ZingoConfig}; + use crate::config::{ChainType, RegtestNetwork, ZingoConfig}; use crate::{lightclient::LightClient, wallet::WalletBase}; diff --git a/zingolib/src/lightclient/describe.rs b/zingolib/src/lightclient/describe.rs index 8e64f4523..c62e203e9 100644 --- a/zingolib/src/lightclient/describe.rs +++ b/zingolib/src/lightclient/describe.rs @@ -11,7 +11,7 @@ use zcash_primitives::{ memo::Memo, }; -use zingoconfig::margin_fee; +use crate::config::margin_fee; use super::{AccountBackupInfo, LightClient, PoolBalances, UserBalances}; use crate::{ diff --git a/zingolib/src/lightclient/propose.rs b/zingolib/src/lightclient/propose.rs index 8992d8dbe..c0ec42d25 100644 --- a/zingolib/src/lightclient/propose.rs +++ b/zingolib/src/lightclient/propose.rs @@ -11,8 +11,8 @@ use zcash_client_backend::ShieldedProtocol; use zcash_primitives::{memo::MemoBytes, transaction::components::amount::NonNegativeAmount}; use thiserror::Error; -use zingoconfig::ZENNIES_FOR_ZINGO_AMOUNT; -use zingoconfig::ZENNIES_FOR_ZINGO_DONATION_ADDRESS; +use crate::config::ZENNIES_FOR_ZINGO_AMOUNT; +use crate::config::ZENNIES_FOR_ZINGO_DONATION_ADDRESS; use crate::data::proposal::ProportionalFeeProposal; use crate::data::proposal::ProportionalFeeShieldProposal; @@ -23,7 +23,7 @@ use crate::lightclient::LightClient; use crate::wallet::send::change_memo_from_transaction_request; use crate::wallet::tx_map_and_maybe_trees::TxMapAndMaybeTrees; use crate::wallet::tx_map_and_maybe_trees::TxMapAndMaybeTreesTraitError; -use zingoconfig::ChainType; +use crate::config::ChainType; type GISKit = GreedyInputSelector< TxMapAndMaybeTrees, @@ -315,7 +315,7 @@ mod shielding { async fn create_basic_client() -> crate::lightclient::LightClient { crate::lightclient::LightClient::create_unconnected( - &zingoconfig::ZingoConfigBuilder::default().create(), + &crate::config::ZingoConfigBuilder::default().create(), crate::wallet::WalletBase::MnemonicPhrase( zingo_testvectors::seeds::HOSPITAL_MUSEUM_SEED.to_string(), ), diff --git a/zingolib/src/lightclient/read.rs b/zingolib/src/lightclient/read.rs index b262927d0..7689cad71 100644 --- a/zingolib/src/lightclient/read.rs +++ b/zingolib/src/lightclient/read.rs @@ -7,7 +7,7 @@ use std::{ }; use tokio::runtime::Runtime; -use zingoconfig::ZingoConfig; +use crate::config::ZingoConfig; use super::LightClient; use crate::wallet::LightWallet; diff --git a/zingolib/src/lightclient/send.rs b/zingolib/src/lightclient/send.rs index c5129e08b..bcb34f200 100644 --- a/zingolib/src/lightclient/send.rs +++ b/zingolib/src/lightclient/send.rs @@ -248,7 +248,7 @@ pub mod send_with_proposal { #[cfg(test)] mod tests { use zingo_testvectors::seeds::ABANDON_ART_SEED; - use zingoconfig::ZingoConfigBuilder; + use crate::config::ZingoConfigBuilder; use crate::{ lightclient::{send::send_with_proposal::CompleteAndBroadcastError, LightClient}, diff --git a/zingolib/src/lightclient/sync.rs b/zingolib/src/lightclient/sync.rs index fb9f7d371..a4e499819 100644 --- a/zingolib/src/lightclient/sync.rs +++ b/zingolib/src/lightclient/sync.rs @@ -26,7 +26,7 @@ use zcash_primitives::{ transaction::Transaction, }; -use zingoconfig::MAX_REORG; +use crate::config::MAX_REORG; static LOG_INIT: std::sync::Once = std::sync::Once::new(); @@ -314,7 +314,7 @@ impl LightClient { let mut latest_block_batches = vec![]; let mut prev = last_scanned_height; while latest_block_batches.is_empty() || prev != latest_blockid.height { - let batch = cmp::min(latest_blockid.height, prev + zingoconfig::BATCH_SIZE); + let batch = cmp::min(latest_blockid.height, prev + crate::config::BATCH_SIZE); prev = batch; latest_block_batches.push(batch); } diff --git a/zingolib/src/mocks.rs b/zingolib/src/mocks.rs index e9f36d92e..5310dcf22 100644 --- a/zingolib/src/mocks.rs +++ b/zingolib/src/mocks.rs @@ -360,7 +360,7 @@ pub mod proposal { }; use zcash_client_backend::wallet::NoteId; - use zingoconfig::{ChainType, RegtestNetwork}; + use crate::config::{ChainType, RegtestNetwork}; use crate::utils::conversion::address_from_str; use crate::utils::{build_method, build_method_push}; diff --git a/zingolib/src/utils/conversion.rs b/zingolib/src/utils/conversion.rs index fda1ae752..9093f2617 100644 --- a/zingolib/src/utils/conversion.rs +++ b/zingolib/src/utils/conversion.rs @@ -5,7 +5,7 @@ use thiserror::Error; use zcash_client_backend::address::Address; use zcash_primitives::transaction::{components::amount::NonNegativeAmount, TxId}; -use zingoconfig::ChainType; +use crate::config::ChainType; use super::error::ConversionError; diff --git a/zingolib/src/wallet.rs b/zingolib/src/wallet.rs index cb7caaa82..1789e0505 100644 --- a/zingolib/src/wallet.rs +++ b/zingolib/src/wallet.rs @@ -22,7 +22,7 @@ use zcash_primitives::zip339::Mnemonic; use zcash_client_backend::proto::service::TreeState; use zcash_encoding::Optional; -use zingoconfig::ZingoConfig; +use crate::config::ZingoConfig; use self::keys::unified::Fvk as _; use self::keys::unified::WalletCapability; diff --git a/zingolib/src/wallet/data.rs b/zingolib/src/wallet/data.rs index e836d866d..4700d3e80 100644 --- a/zingolib/src/wallet/data.rs +++ b/zingolib/src/wallet/data.rs @@ -455,7 +455,7 @@ pub mod summaries { use json::JsonValue; use zcash_primitives::{consensus::BlockHeight, memo::Memo, transaction::TxId}; use zingo_status::confirmation_status::ConfirmationStatus; - use zingoconfig::ChainType; + use crate::config::ChainType; use crate::{ error::BuildError, diff --git a/zingolib/src/wallet/disk.rs b/zingolib/src/wallet/disk.rs index 3e49252b5..9fd7ca4f8 100644 --- a/zingolib/src/wallet/disk.rs +++ b/zingolib/src/wallet/disk.rs @@ -15,7 +15,7 @@ use zcash_encoding::{Optional, Vector}; use zcash_primitives::consensus::BlockHeight; -use zingoconfig::ZingoConfig; +use crate::config::ZingoConfig; use crate::wallet::traits::ReadableWriteable; use crate::wallet::WalletOptions; diff --git a/zingolib/src/wallet/disk/testing.rs b/zingolib/src/wallet/disk/testing.rs index d8326c80c..3fd843f30 100644 --- a/zingolib/src/wallet/disk/testing.rs +++ b/zingolib/src/wallet/disk/testing.rs @@ -4,7 +4,7 @@ impl super::LightWallet { /// connects a wallet to TestNet server. pub async fn unsafe_from_buffer_testnet(data: &[u8]) -> Self { - let config = zingoconfig::ZingoConfig::create_testnet(); + let config = crate::config::ZingoConfig::create_testnet(); Self::read_internal(data, &config) .await .map_err(|e| format!("Cannot deserialize LightWallet file!: {}", e)) diff --git a/zingolib/src/wallet/keys.rs b/zingolib/src/wallet/keys.rs index 7d1e326d7..6cc19b13d 100644 --- a/zingolib/src/wallet/keys.rs +++ b/zingolib/src/wallet/keys.rs @@ -12,7 +12,7 @@ use zcash_client_backend::address; use zcash_primitives::{ consensus::NetworkConstants, legacy::TransparentAddress, zip32::ChildIndex, }; -use zingoconfig::{ChainType, ZingoConfig}; +use crate::config::{ChainType, ZingoConfig}; pub mod extended_transparent; pub mod unified; diff --git a/zingolib/src/wallet/keys/unified.rs b/zingolib/src/wallet/keys/unified.rs index 47d7bdfac..5ed5aa597 100644 --- a/zingolib/src/wallet/keys/unified.rs +++ b/zingolib/src/wallet/keys/unified.rs @@ -21,7 +21,7 @@ use zcash_client_backend::keys::{Era, UnifiedSpendingKey}; use zcash_encoding::{CompactSize, Vector}; use zcash_primitives::zip32::AccountId; use zcash_primitives::{legacy::TransparentAddress, zip32::DiversifierIndex}; -use zingoconfig::ZingoConfig; +use crate::config::ZingoConfig; use crate::wallet::traits::{DomainWalletExt, ReadableWriteable, Recipient}; diff --git a/zingolib/src/wallet/message.rs b/zingolib/src/wallet/message.rs index 5f73073d1..ea4a73c7d 100644 --- a/zingolib/src/wallet/message.rs +++ b/zingolib/src/wallet/message.rs @@ -18,7 +18,7 @@ use zcash_primitives::{ consensus::BlockHeight, memo::{Memo, MemoBytes}, }; -use zingoconfig::ChainType; +use crate::config::ChainType; pub struct Message { pub to: PaymentAddress, diff --git a/zingolib/src/wallet/send.rs b/zingolib/src/wallet/send.rs index 18ded2342..4d755dcf7 100644 --- a/zingolib/src/wallet/send.rs +++ b/zingolib/src/wallet/send.rs @@ -190,7 +190,7 @@ mod tests { memo::{Memo, MemoBytes}, transaction::components::amount::NonNegativeAmount, }; - use zingoconfig::ChainType; + use crate::config::ChainType; use crate::data::receivers::{transaction_request_from_receivers, Receivers}; diff --git a/zingolib/src/wallet/traits.rs b/zingolib/src/wallet/traits.rs index afc9e1d73..df5f58dc5 100644 --- a/zingolib/src/wallet/traits.rs +++ b/zingolib/src/wallet/traits.rs @@ -51,7 +51,7 @@ use zcash_primitives::{ }, }; use zingo_status::confirmation_status::ConfirmationStatus; -use zingoconfig::ChainType; +use crate::config::ChainType; /// This provides a uniform `.to_bytes` to types that might require it in a generic context. pub trait ToBytes { diff --git a/zingolib/src/wallet/transaction_context.rs b/zingolib/src/wallet/transaction_context.rs index 3939da389..02177f3f9 100644 --- a/zingolib/src/wallet/transaction_context.rs +++ b/zingolib/src/wallet/transaction_context.rs @@ -5,7 +5,7 @@ use tokio::sync::RwLock; use zcash_client_backend::ShieldedProtocol; use zcash_primitives::{consensus::BlockHeight, transaction::TxId}; -use zingoconfig::ZingoConfig; +use crate::config::ZingoConfig; use crate::wallet::{keys::unified::WalletCapability, tx_map_and_maybe_trees::TxMapAndMaybeTrees}; From e21124f743092cb76f5b5438e3ae791634abef1f Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 17:43:12 -0600 Subject: [PATCH 12/26] pass cargo check --- Cargo.lock | 133 ++++++++++++++++++ zingolib/Cargo.toml | 1 + .../src/wallet/keys/extended_transparent.rs | 1 + 3 files changed, 135 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 64750277f..2858ee4a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,6 +122,12 @@ name = "append-only-vec" version = "0.1.2" source = "git+https://github.com/zancas/append-only-vec.git?branch=add_debug_impl#ec919c9c8f5429edbac69f0c2203dd01c861ce15" +[[package]] +name = "arc-swap" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" + [[package]] name = "arrayref" version = "0.3.7" @@ -684,6 +690,23 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "destructure_traitobject" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7" + [[package]] name = "digest" version = "0.9.0" @@ -1268,6 +1291,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.14.29" @@ -1617,6 +1646,43 @@ name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +dependencies = [ + "serde", +] + +[[package]] +name = "log-mdc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" + +[[package]] +name = "log4rs" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0816135ae15bd0391cf284eab37e6e3ee0a6ee63d2ceeb659862bd8d0a984ca6" +dependencies = [ + "anyhow", + "arc-swap", + "chrono", + "derivative", + "fnv", + "humantime", + "libc", + "log", + "log-mdc", + "once_cell", + "parking_lot", + "rand 0.8.5", + "serde", + "serde-value", + "serde_json", + "serde_yaml", + "thiserror", + "thread-id", + "typemap-ors", + "winapi", +] [[package]] name = "matchit" @@ -1896,6 +1962,15 @@ dependencies = [ "zip32", ] +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + [[package]] name = "overload" version = "0.1.1" @@ -2776,6 +2851,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.203" @@ -2810,6 +2895,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.2.6", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sha2" version = "0.9.9" @@ -3065,6 +3163,16 @@ dependencies = [ "syn 2.0.68", ] +[[package]] +name = "thread-id" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe8f25bbdd100db7e1d34acf7fd2dc59c4bf8f7483f505eaa7d4f12f76cc0ea" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -3345,6 +3453,15 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typemap-ors" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a68c24b707f02dd18f1e4ccceb9d49f2058c2fb86384ef9972592904d7a28867" +dependencies = [ + "unsafe-any-ors", +] + [[package]] name = "typenum" version = "1.17.0" @@ -3412,6 +3529,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "unsafe-any-ors" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a303d30665362d9680d7d91d78b23f5f899504d4f08b3c4cf08d055d87c0ad" +dependencies = [ + "destructure_traitobject", +] + +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "untrusted" version = "0.7.1" @@ -4112,6 +4244,7 @@ dependencies = [ "jubjub", "lazy_static", "log", + "log4rs", "nonempty", "orchard", "portpicker", diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index 767ba8d1c..b605411b2 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -75,6 +75,7 @@ enum_dispatch = { workspace = true } portpicker = { workspace = true, optional = true } tempfile = { workspace = true, optional = true} dirs.workspace = true +log4rs.workspace = true [dev-dependencies] concat-idents = { workspace = true } diff --git a/zingolib/src/wallet/keys/extended_transparent.rs b/zingolib/src/wallet/keys/extended_transparent.rs index 2583fae39..16e378ca6 100644 --- a/zingolib/src/wallet/keys/extended_transparent.rs +++ b/zingolib/src/wallet/keys/extended_transparent.rs @@ -1,5 +1,6 @@ //! TODO: Add Mod Discription Here! use std::io; +use zcash_primitives::consensus::NetworkConstants; use crate::config::ZingoConfig; use byteorder::{ReadBytesExt, WriteBytesExt}; From 745faf0d17a388bd743f47baed30e09d99ad78cc Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 18:14:43 -0600 Subject: [PATCH 13/26] wip --- zingocli/src/lib.rs | 16 +++++++++------- zingolib/Cargo.toml | 4 +++- zingolib/src/lib.rs | 6 +++--- zingolib/src/lightclient.rs | 2 +- zingolib/src/lightclient/propose.rs | 2 +- zingolib/src/lightclient/send.rs | 15 +++++++-------- zingolib/src/mocks.rs | 2 +- zingolib/src/utils.rs | 2 -- 8 files changed, 25 insertions(+), 24 deletions(-) diff --git a/zingocli/src/lib.rs b/zingocli/src/lib.rs index b0e8be48d..4d75693a2 100644 --- a/zingocli/src/lib.rs +++ b/zingocli/src/lib.rs @@ -11,8 +11,8 @@ use std::sync::Arc; use log::{error, info}; use clap::{self, Arg}; -use zingo_testutils::regtest; -use zingoconfig::ChainType; +use zingolib::config::ChainType; +use zingolib::testutils::regtest; use zingolib::wallet::WalletBase; use zingolib::{commands, lightclient::LightClient}; @@ -56,7 +56,7 @@ pub fn build_clap_app() -> clap::ArgMatches { .value_name("server") .help("Lightwalletd server to connect to.") .value_parser(parse_uri) - .default_value(zingoconfig::DEFAULT_LIGHTWALLETD_SERVER)) + .default_value(zingolib::config::DEFAULT_LIGHTWALLETD_SERVER)) .arg(Arg::new("data-dir") .long("data-dir") .value_name("data-dir") @@ -348,16 +348,18 @@ If you don't remember the block height, you can pass '--birthday 0' to scan from } else { None }; - let server = zingoconfig::construct_lightwalletd_uri(server); + let server = zingolib::config::construct_lightwalletd_uri(server); let chaintype = if let Some(chain) = matches.get_one::("chain") { match chain.as_str() { "mainnet" => ChainType::Mainnet, "testnet" => ChainType::Testnet, - "regtest" => ChainType::Regtest(zingoconfig::RegtestNetwork::all_upgrades_active()), + "regtest" => { + ChainType::Regtest(zingolib::config::RegtestNetwork::all_upgrades_active()) + } _ => return Err(chain.clone()), } } else if is_regtest { - ChainType::Regtest(zingoconfig::RegtestNetwork::all_upgrades_active()) + ChainType::Regtest(zingolib::config::RegtestNetwork::all_upgrades_active()) } else { ChainType::Mainnet }; @@ -403,7 +405,7 @@ pub fn startup( } else { filled_template.data_dir.clone() }; - let config = zingoconfig::load_clientconfig( + let config = zingolib::config::load_clientconfig( filled_template.server.clone(), Some(data_dir), filled_template.chaintype, diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index b605411b2..8cf157cc3 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -12,6 +12,8 @@ lightclient-deprecated = [] darkside_tests = [] test-elevation = ["portpicker", "testvectors", "tempfile"] testvectors = [] +tempfile = ["dep:tempfile"] +portpicker = ["dep:portpicker"] [dependencies] zingo-memo = { path = "../zingo-memo" } @@ -73,7 +75,7 @@ hdwallet = { workspace = true } chrono = { workspace = true } enum_dispatch = { workspace = true } portpicker = { workspace = true, optional = true } -tempfile = { workspace = true, optional = true} +tempfile = { workspace = true, optional = true } dirs.workspace = true log4rs.workspace = true diff --git a/zingolib/src/lib.rs b/zingolib/src/lib.rs index 07781be67..db341720b 100644 --- a/zingolib/src/lib.rs +++ b/zingolib/src/lib.rs @@ -18,10 +18,10 @@ pub mod utils; pub mod wallet; #[cfg(test)] -pub mod mocks; -#[cfg(feature = "test-elevation")] +pub(crate) mod mocks; +#[cfg(any(test, feature = "test-elevation"))] pub mod testutils; -#[cfg(feature = "testvectors")] +#[cfg(any(test, feature = "testvectors"))] pub mod testvectors; // This line includes the generated `git_description()` function directly into this scope. diff --git a/zingolib/src/lightclient.rs b/zingolib/src/lightclient.rs index 604ac0e6a..e5ca43da5 100644 --- a/zingolib/src/lightclient.rs +++ b/zingolib/src/lightclient.rs @@ -634,7 +634,7 @@ async fn get_recent_median_price_from_gemini() -> Result { #[cfg(test)] mod tests { use tokio::runtime::Runtime; - use zingo_testvectors::seeds::CHIMNEY_BETTER_SEED; + use crate::testvectors::seeds::CHIMNEY_BETTER_SEED; use crate::config::{ChainType, RegtestNetwork, ZingoConfig}; use crate::{lightclient::LightClient, wallet::WalletBase}; diff --git a/zingolib/src/lightclient/propose.rs b/zingolib/src/lightclient/propose.rs index c0ec42d25..580791d5d 100644 --- a/zingolib/src/lightclient/propose.rs +++ b/zingolib/src/lightclient/propose.rs @@ -317,7 +317,7 @@ mod shielding { crate::lightclient::LightClient::create_unconnected( &crate::config::ZingoConfigBuilder::default().create(), crate::wallet::WalletBase::MnemonicPhrase( - zingo_testvectors::seeds::HOSPITAL_MUSEUM_SEED.to_string(), + crate::testvectors::seeds::HOSPITAL_MUSEUM_SEED.to_string(), ), 0, ) diff --git a/zingolib/src/lightclient/send.rs b/zingolib/src/lightclient/send.rs index bcb34f200..97fbd3a9e 100644 --- a/zingolib/src/lightclient/send.rs +++ b/zingolib/src/lightclient/send.rs @@ -245,18 +245,17 @@ pub mod send_with_proposal { } } - #[cfg(test)] + #[cfg(all(test, feature = "testvectors"))] mod tests { - use zingo_testvectors::seeds::ABANDON_ART_SEED; - use crate::config::ZingoConfigBuilder; - - use crate::{ - lightclient::{send::send_with_proposal::CompleteAndBroadcastError, LightClient}, - mocks::ProposalBuilder, - }; #[tokio::test] async fn complete_and_broadcast() { + use crate::{ + config::ZingoConfigBuilder, + lightclient::{send::send_with_proposal::CompleteAndBroadcastError, LightClient}, + mocks::ProposalBuilder, + testvectors::seeds::ABANDON_ART_SEED, + }; let lc = LightClient::create_unconnected( &ZingoConfigBuilder::default().create(), crate::wallet::WalletBase::MnemonicPhrase(ABANDON_ART_SEED.to_string()), diff --git a/zingolib/src/mocks.rs b/zingolib/src/mocks.rs index 5310dcf22..1ff26dfe8 100644 --- a/zingolib/src/mocks.rs +++ b/zingolib/src/mocks.rs @@ -602,7 +602,7 @@ pub mod proposal { builder .recipient_address( address_from_str( - zingo_testvectors::REG_O_ADDR_FROM_ABANDONART, + crate::testvectors::REG_O_ADDR_FROM_ABANDONART, &ChainType::Regtest(RegtestNetwork::all_upgrades_active()), ) .unwrap(), diff --git a/zingolib/src/utils.rs b/zingolib/src/utils.rs index 63ed8d96b..c89ca94ac 100644 --- a/zingolib/src/utils.rs +++ b/zingolib/src/utils.rs @@ -12,7 +12,6 @@ macro_rules! build_method { } }; } -#[cfg(test)] // temporary test gate as no production builders use this macros yet macro_rules! build_method_push { ($name:ident, $localtype:ty) => { #[doc = "Push a $ty to the builder."] @@ -32,7 +31,6 @@ macro_rules! build_push_list { } pub(crate) use build_method; -#[cfg(test)] pub(crate) use build_method_push; #[cfg(test)] pub(crate) use build_push_list; From 4490c78021a9b35295a368ef15203459788facd0 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 18:37:24 -0600 Subject: [PATCH 14/26] wip --- zingocli/src/lib.rs | 2 +- zingolib/Cargo.toml | 2 +- zingolib/src/blaze/syncdata.rs | 2 +- zingolib/src/commands/utils.rs | 2 +- zingolib/src/lib.rs | 2 +- zingolib/src/lightclient.rs | 4 ++-- zingolib/src/lightclient/propose.rs | 4 ++-- zingolib/src/mocks.rs | 2 +- zingolib/src/wallet.rs | 2 +- zingolib/src/wallet/data.rs | 2 +- zingolib/src/wallet/disk.rs | 2 +- zingolib/src/wallet/keys.rs | 2 +- zingolib/src/wallet/keys/unified.rs | 2 +- zingolib/src/wallet/message.rs | 2 +- zingolib/src/wallet/send.rs | 2 +- zingolib/src/wallet/traits.rs | 2 +- zingolib/src/wallet/transaction_context.rs | 2 +- 17 files changed, 19 insertions(+), 19 deletions(-) diff --git a/zingocli/src/lib.rs b/zingocli/src/lib.rs index 4d75693a2..5f02fbb81 100644 --- a/zingocli/src/lib.rs +++ b/zingocli/src/lib.rs @@ -328,7 +328,7 @@ If you don't remember the block height, you can pass '--birthday 0' to scan from let data_dir = if let Some(dir) = matches.get_one::("data-dir") { PathBuf::from(dir.clone()) } else if is_regtest { - zingo_testutils::paths::get_regtest_dir() + zingolib::testutils::paths::get_regtest_dir() } else { PathBuf::from("wallets") }; diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index 8cf157cc3..ff329db93 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -13,7 +13,6 @@ darkside_tests = [] test-elevation = ["portpicker", "testvectors", "tempfile"] testvectors = [] tempfile = ["dep:tempfile"] -portpicker = ["dep:portpicker"] [dependencies] zingo-memo = { path = "../zingo-memo" } @@ -81,6 +80,7 @@ log4rs.workspace = true [dev-dependencies] concat-idents = { workspace = true } +tempfile = { workspace = true } [build-dependencies] build_utils = { workspace = true } diff --git a/zingolib/src/blaze/syncdata.rs b/zingolib/src/blaze/syncdata.rs index 043d27f28..4b55c8036 100644 --- a/zingolib/src/blaze/syncdata.rs +++ b/zingolib/src/blaze/syncdata.rs @@ -5,9 +5,9 @@ use tokio::sync::RwLock; use zcash_client_backend::proto::service::TreeState; use super::{block_management_reorg_detection::BlockManagementData, sync_status::BatchSyncStatus}; +use crate::config::ZingoConfig; use crate::wallet::data::BlockData; use crate::wallet::WalletOptions; -use crate::config::ZingoConfig; pub struct BlazeSyncData { pub(crate) block_data: BlockManagementData, diff --git a/zingolib/src/commands/utils.rs b/zingolib/src/commands/utils.rs index dc7a6db15..aeb1676f6 100644 --- a/zingolib/src/commands/utils.rs +++ b/zingolib/src/commands/utils.rs @@ -1,6 +1,7 @@ // Module containing utility functions for the commands interface use crate::commands::error::CommandError; +use crate::config::ChainType; use crate::data::receivers::Receivers; use crate::utils::conversion::{address_from_str, zatoshis_from_u64}; use crate::wallet; @@ -8,7 +9,6 @@ use json::JsonValue; use zcash_client_backend::address::Address; use zcash_primitives::memo::MemoBytes; use zcash_primitives::transaction::components::amount::NonNegativeAmount; -use crate::config::ChainType; // Parse the send arguments for `do_send`. // The send arguments have two possible formats: diff --git a/zingolib/src/lib.rs b/zingolib/src/lib.rs index db341720b..26f61c732 100644 --- a/zingolib/src/lib.rs +++ b/zingolib/src/lib.rs @@ -19,7 +19,7 @@ pub mod wallet; #[cfg(test)] pub(crate) mod mocks; -#[cfg(any(test, feature = "test-elevation"))] +#[cfg(feature = "test-elevation")] pub mod testutils; #[cfg(any(test, feature = "testvectors"))] pub mod testvectors; diff --git a/zingolib/src/lightclient.rs b/zingolib/src/lightclient.rs index e5ca43da5..6748995dd 100644 --- a/zingolib/src/lightclient.rs +++ b/zingolib/src/lightclient.rs @@ -633,9 +633,9 @@ async fn get_recent_median_price_from_gemini() -> Result { #[cfg(test)] mod tests { - use tokio::runtime::Runtime; - use crate::testvectors::seeds::CHIMNEY_BETTER_SEED; use crate::config::{ChainType, RegtestNetwork, ZingoConfig}; + use crate::testvectors::seeds::CHIMNEY_BETTER_SEED; + use tokio::runtime::Runtime; use crate::{lightclient::LightClient, wallet::WalletBase}; diff --git a/zingolib/src/lightclient/propose.rs b/zingolib/src/lightclient/propose.rs index 580791d5d..ff74b4e9d 100644 --- a/zingolib/src/lightclient/propose.rs +++ b/zingolib/src/lightclient/propose.rs @@ -10,10 +10,11 @@ use zcash_client_backend::zip321::Zip321Error; use zcash_client_backend::ShieldedProtocol; use zcash_primitives::{memo::MemoBytes, transaction::components::amount::NonNegativeAmount}; -use thiserror::Error; use crate::config::ZENNIES_FOR_ZINGO_AMOUNT; use crate::config::ZENNIES_FOR_ZINGO_DONATION_ADDRESS; +use thiserror::Error; +use crate::config::ChainType; use crate::data::proposal::ProportionalFeeProposal; use crate::data::proposal::ProportionalFeeShieldProposal; use crate::data::proposal::ZingoProposal; @@ -23,7 +24,6 @@ use crate::lightclient::LightClient; use crate::wallet::send::change_memo_from_transaction_request; use crate::wallet::tx_map_and_maybe_trees::TxMapAndMaybeTrees; use crate::wallet::tx_map_and_maybe_trees::TxMapAndMaybeTreesTraitError; -use crate::config::ChainType; type GISKit = GreedyInputSelector< TxMapAndMaybeTrees, diff --git a/zingolib/src/mocks.rs b/zingolib/src/mocks.rs index 1ff26dfe8..0ecb47ee3 100644 --- a/zingolib/src/mocks.rs +++ b/zingolib/src/mocks.rs @@ -359,8 +359,8 @@ pub mod proposal { components::amount::NonNegativeAmount, fees::zip317::FeeRule, }; - use zcash_client_backend::wallet::NoteId; use crate::config::{ChainType, RegtestNetwork}; + use zcash_client_backend::wallet::NoteId; use crate::utils::conversion::address_from_str; use crate::utils::{build_method, build_method_push}; diff --git a/zingolib/src/wallet.rs b/zingolib/src/wallet.rs index 1789e0505..96d773fe5 100644 --- a/zingolib/src/wallet.rs +++ b/zingolib/src/wallet.rs @@ -20,9 +20,9 @@ use std::{ use tokio::sync::RwLock; use zcash_primitives::zip339::Mnemonic; +use crate::config::ZingoConfig; use zcash_client_backend::proto::service::TreeState; use zcash_encoding::Optional; -use crate::config::ZingoConfig; use self::keys::unified::Fvk as _; use self::keys::unified::WalletCapability; diff --git a/zingolib/src/wallet/data.rs b/zingolib/src/wallet/data.rs index 4700d3e80..7db1ca14f 100644 --- a/zingolib/src/wallet/data.rs +++ b/zingolib/src/wallet/data.rs @@ -451,11 +451,11 @@ pub mod finsight { /// A "snapshot" of the state of the items in the wallet at the time the summary was constructed. /// Not to be used for internal logic in the system. pub mod summaries { + use crate::config::ChainType; use chrono::DateTime; use json::JsonValue; use zcash_primitives::{consensus::BlockHeight, memo::Memo, transaction::TxId}; use zingo_status::confirmation_status::ConfirmationStatus; - use crate::config::ChainType; use crate::{ error::BuildError, diff --git a/zingolib/src/wallet/disk.rs b/zingolib/src/wallet/disk.rs index 9fd7ca4f8..66bb45fa5 100644 --- a/zingolib/src/wallet/disk.rs +++ b/zingolib/src/wallet/disk.rs @@ -242,5 +242,5 @@ impl LightWallet { } } -#[cfg(any(test, feature = "test-elevation"))] +#[cfg(feature = "test-elevation")] pub mod testing; diff --git a/zingolib/src/wallet/keys.rs b/zingolib/src/wallet/keys.rs index 6cc19b13d..0fc2c6b6d 100644 --- a/zingolib/src/wallet/keys.rs +++ b/zingolib/src/wallet/keys.rs @@ -1,6 +1,7 @@ //! TODO: Add Mod Description Here! //! In all cases in this file "external_version" refers to a serialization version that is interpreted //! from a source outside of the code-base e.g. a wallet-file. +use crate::config::{ChainType, ZingoConfig}; use base58::ToBase58; use ripemd160::Digest; use sapling_crypto::{ @@ -12,7 +13,6 @@ use zcash_client_backend::address; use zcash_primitives::{ consensus::NetworkConstants, legacy::TransparentAddress, zip32::ChildIndex, }; -use crate::config::{ChainType, ZingoConfig}; pub mod extended_transparent; pub mod unified; diff --git a/zingolib/src/wallet/keys/unified.rs b/zingolib/src/wallet/keys/unified.rs index 5ed5aa597..800960b08 100644 --- a/zingolib/src/wallet/keys/unified.rs +++ b/zingolib/src/wallet/keys/unified.rs @@ -14,6 +14,7 @@ use sapling_crypto::note_encryption::SaplingDomain; use zcash_primitives::consensus::{BranchId, NetworkConstants, Parameters}; use zcash_primitives::zip339::Mnemonic; +use crate::config::ZingoConfig; use secp256k1::SecretKey; use zcash_address::unified::{Container, Encoding, Typecode, Ufvk}; use zcash_client_backend::address::UnifiedAddress; @@ -21,7 +22,6 @@ use zcash_client_backend::keys::{Era, UnifiedSpendingKey}; use zcash_encoding::{CompactSize, Vector}; use zcash_primitives::zip32::AccountId; use zcash_primitives::{legacy::TransparentAddress, zip32::DiversifierIndex}; -use crate::config::ZingoConfig; use crate::wallet::traits::{DomainWalletExt, ReadableWriteable, Recipient}; diff --git a/zingolib/src/wallet/message.rs b/zingolib/src/wallet/message.rs index ea4a73c7d..bbdde05af 100644 --- a/zingolib/src/wallet/message.rs +++ b/zingolib/src/wallet/message.rs @@ -1,4 +1,5 @@ //! TODO: Add Crate Discription Here! +use crate::config::ChainType; use byteorder::ReadBytesExt; use bytes::{Buf, Bytes, IntoBuf}; use group::GroupEncoding; @@ -18,7 +19,6 @@ use zcash_primitives::{ consensus::BlockHeight, memo::{Memo, MemoBytes}, }; -use crate::config::ChainType; pub struct Message { pub to: PaymentAddress, diff --git a/zingolib/src/wallet/send.rs b/zingolib/src/wallet/send.rs index 4d755dcf7..f68b590f5 100644 --- a/zingolib/src/wallet/send.rs +++ b/zingolib/src/wallet/send.rs @@ -185,12 +185,12 @@ pub(crate) fn change_memo_from_transaction_request(request: &TransactionRequest) mod tests { use std::str::FromStr; + use crate::config::ChainType; use zcash_client_backend::{address::Address, zip321::TransactionRequest}; use zcash_primitives::{ memo::{Memo, MemoBytes}, transaction::components::amount::NonNegativeAmount, }; - use crate::config::ChainType; use crate::data::receivers::{transaction_request_from_receivers, Receivers}; diff --git a/zingolib/src/wallet/traits.rs b/zingolib/src/wallet/traits.rs index df5f58dc5..398916e83 100644 --- a/zingolib/src/wallet/traits.rs +++ b/zingolib/src/wallet/traits.rs @@ -2,6 +2,7 @@ use crate::wallet::notes::interface::OutputConstructor; use std::io::{self, Read, Write}; +use crate::config::ChainType; use crate::data::witness_trees::WitnessTrees; use crate::wallet::notes::OutputInterface; use crate::wallet::notes::ShieldedNoteInterface; @@ -51,7 +52,6 @@ use zcash_primitives::{ }, }; use zingo_status::confirmation_status::ConfirmationStatus; -use crate::config::ChainType; /// This provides a uniform `.to_bytes` to types that might require it in a generic context. pub trait ToBytes { diff --git a/zingolib/src/wallet/transaction_context.rs b/zingolib/src/wallet/transaction_context.rs index 02177f3f9..a7d70ddd9 100644 --- a/zingolib/src/wallet/transaction_context.rs +++ b/zingolib/src/wallet/transaction_context.rs @@ -3,9 +3,9 @@ use std::sync::Arc; use tokio::sync::RwLock; +use crate::config::ZingoConfig; use zcash_client_backend::ShieldedProtocol; use zcash_primitives::{consensus::BlockHeight, transaction::TxId}; -use crate::config::ZingoConfig; use crate::wallet::{keys::unified::WalletCapability, tx_map_and_maybe_trees::TxMapAndMaybeTrees}; From 5a7cc20677e419aadcc3b9cdd1ee94d91396a7e3 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 18:46:05 -0600 Subject: [PATCH 15/26] update concrete.rs --- libtonode-tests/tests/concrete.rs | 281 ++++++++++++++++-------------- 1 file changed, 148 insertions(+), 133 deletions(-) diff --git a/libtonode-tests/tests/concrete.rs b/libtonode-tests/tests/concrete.rs index c00154e69..82488c989 100644 --- a/libtonode-tests/tests/concrete.rs +++ b/libtonode-tests/tests/concrete.rs @@ -11,17 +11,15 @@ use zcash_address::unified::Fvk; use zcash_client_backend::encoding::encode_payment_address; use zcash_primitives::transaction::components::amount::NonNegativeAmount; use zcash_primitives::{consensus::BlockHeight, transaction::fees::zip317::MINIMUM_FEE}; -use zingo_testutils::lightclient::from_inputs; -use zingo_testutils::{ - self, build_fvk_client, check_client_balances, get_base_address_macro, get_otd, - increase_height_and_wait_for_client, scenarios, validate_otds, -}; use zingolib::lightclient::propose::ProposeSendError; +use zingolib::testutils::lightclient::from_inputs; +use zingolib::testutils::{build_fvk_client, increase_height_and_wait_for_client, scenarios}; use zingolib::utils::conversion::address_from_str; use zingolib::wallet::data::summaries::TransactionSummaryInterface; +use zingolib::{check_client_balances, get_base_address_macro, get_otd, validate_otds}; -use zingo_testvectors::{block_rewards, seeds::HOSPITAL_MUSEUM_SEED, BASE_HEIGHT}; -use zingoconfig::{ChainType, RegtestNetwork, MAX_REORG}; +use zingolib::config::{ChainType, RegtestNetwork, MAX_REORG}; +use zingolib::testvectors::{block_rewards, seeds::HOSPITAL_MUSEUM_SEED, BASE_HEIGHT}; use zingolib::{ lightclient::{LightClient, PoolBalances}, utils, @@ -117,8 +115,8 @@ mod fast { use zcash_client_backend::{PoolType, ShieldedProtocol}; use zcash_primitives::transaction::components::amount::NonNegativeAmount; use zingo_status::confirmation_status::ConfirmationStatus; - use zingo_testutils::lightclient::from_inputs; - use zingoconfig::ZENNIES_FOR_ZINGO_REGTEST_ADDRESS; + use zingolib::config::ZENNIES_FOR_ZINGO_REGTEST_ADDRESS; + use zingolib::testutils::lightclient::from_inputs; use zingolib::wallet::notes::OutputInterface as _; use zingolib::{ @@ -367,7 +365,7 @@ mod fast { from_inputs::quick_send(&faucet, address_5000_nonememo_tuples) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); let balance_b = recipient.do_balance().await; @@ -588,9 +586,7 @@ mod fast { .first() .unwrap() .value(), - NonNegativeAmount::const_from_u64( - (zingo_testvectors::block_rewards::CANOPY * 4) - expected_fee - ) + NonNegativeAmount::const_from_u64((block_rewards::CANOPY * 4) - expected_fee) ) } } @@ -601,11 +597,11 @@ mod slow { consensus::NetworkConstants, memo::Memo, transaction::fees::zip317::MARGINAL_FEE, }; use zingo_status::confirmation_status::ConfirmationStatus; - use zingo_testutils::{ + use zingolib::testutils::{ assert_transaction_summary_equality, assert_transaction_summary_exists, lightclient::{from_inputs, get_fees_paid_by_client}, }; - use zingo_testvectors::TEST_TXID; + use zingolib::testvectors::TEST_TXID; use zingolib::{ lightclient::send::send_with_proposal::QuickSendError, wallet::{ @@ -638,7 +634,7 @@ mod slow { .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) .await .unwrap(); let _sent_transaction_id = from_inputs::quick_send( @@ -647,7 +643,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) .await .unwrap(); @@ -682,7 +678,7 @@ mod slow { .first() .to_string(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) .await .unwrap(); @@ -765,7 +761,7 @@ mod slow { .contains(&position)); // 4. Mine the sent transaction - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); @@ -808,7 +804,7 @@ mod slow { ); // 5. Mine 50 blocks, witness should still be there - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 50) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 50) .await .unwrap(); let position = recipient @@ -838,7 +834,7 @@ mod slow { .contains(&position)); // 5. Mine 100 blocks, witness should now disappear - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 50) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 50) .await .unwrap(); let position = recipient @@ -902,7 +898,7 @@ mod slow { let original_recipient = client_builder .build_client(HOSPITAL_MUSEUM_SEED.to_string(), 0, false, regtest_network) .await; - let zingo_config = zingoconfig::load_clientconfig( + let zingo_config = zingolib::config::load_clientconfig( client_builder.server_id, Some(client_builder.zingo_datadir), ChainType::Regtest(regtest_network), @@ -921,14 +917,14 @@ mod slow { (recipient_unified.as_str(), 3_000u64, None), ]; // 1. fill wallet with a coinbase transaction by syncing faucet with 1-block increase - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); // 2. send a transaction containing all types of outputs from_inputs::quick_send(&faucet, addr_amount_memos) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client( + zingolib::testutils::increase_height_and_wait_for_client( ®test_manager, &original_recipient, 1, @@ -950,7 +946,7 @@ mod slow { // Extract viewing keys let wallet_capability = original_recipient.wallet.wallet_capability().clone(); let [o_fvk, s_fvk, t_fvk] = - zingo_testutils::build_fvks_from_wallet_capability(&wallet_capability); + zingolib::testutils::build_fvks_from_wallet_capability(&wallet_capability); let fvks_sets = [ vec![&o_fvk], vec![&s_fvk], @@ -991,7 +987,11 @@ mod slow { assert!(matches!( from_inputs::quick_send( &watch_client, - vec![(zingo_testvectors::EXT_TADDR, 1000, None)] + vec![( + zingolib::testvectors::zingolib::config::XT_TADDR, + 1000, + None + )] ) .await, Err(QuickSendError::ProposeSend(ProposeSendError::Proposal( @@ -1015,7 +1015,7 @@ mod slow { .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); recipient.do_sync(true).await.unwrap(); @@ -1030,7 +1030,11 @@ mod slow { let sent_value = 20_000; let sent_transaction_error = from_inputs::quick_send( &recipient, - vec![(zingo_testvectors::EXT_TADDR, sent_value, None)], + vec![( + zingolib::testvectors::zingolib::config::XT_TADDR, + sent_value, + None, + )], ) .await .unwrap_err(); @@ -1060,11 +1064,11 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 1) .await .unwrap(); recipient.quick_shield().await.unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 1) .await .unwrap(); println!( @@ -1101,7 +1105,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); let list = faucet.do_list_transactions().await; @@ -1175,7 +1179,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, &recipient, 1) .await .unwrap(); let summary_external_sapling = TransactionSummaryBuilder::new() @@ -1276,7 +1280,7 @@ mod slow { Some(0) ); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, &faucet, 1) .await .unwrap(); @@ -1313,7 +1317,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, &recipient, 1) .await .unwrap(); @@ -1394,7 +1398,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, &recipient, 1) .await .unwrap(); @@ -1435,7 +1439,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, &recipient, 1) .await .unwrap(); @@ -1493,7 +1497,7 @@ mod slow { .unwrap(); let orch_change = block_rewards::CANOPY - (faucet_to_recipient_amount + u64::from(MINIMUM_FEE)); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); faucet.do_sync(true).await.unwrap(); @@ -1522,7 +1526,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); recipient.do_sync(true).await.unwrap(); @@ -1562,7 +1566,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); let balance = faucet.do_balance().await; @@ -1635,7 +1639,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); let recipient_taddr = get_base_address_macro!(recipient, "transparent"); @@ -1649,7 +1653,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); from_inputs::quick_send( @@ -1681,7 +1685,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); println!( @@ -1716,13 +1720,13 @@ mod slow { scenarios::faucet_recipient_default().await; // Give the faucet a block reward - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); let value = 100_000; // Send some sapling value to the recipient - let txid = zingo_testutils::send_value_between_clients_and_sync( + let txid = zingolib::testutils::send_value_between_clients_and_sync( ®test_manager, &faucet, &recipient, @@ -1743,7 +1747,7 @@ mod slow { .first() .to_string(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); // 5. Check the transaction list to make sure we got all transactions @@ -1781,7 +1785,7 @@ mod slow { .unwrap() .first() .to_string(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); @@ -1892,7 +1896,7 @@ mod slow { ); // 6. Mine the sent transaction - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); @@ -1948,7 +1952,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); check_client_balances!(recipient, o: for_orchard s: for_sapling t: 0 ); @@ -1963,7 +1967,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); let remaining_orchard = for_orchard - (6 * fee); @@ -1996,7 +2000,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 10) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 10) .await .unwrap(); from_inputs::quick_send( @@ -2005,7 +2009,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 10) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 10) .await .unwrap(); faucet.do_sync(false).await.unwrap(); @@ -2051,9 +2055,13 @@ mod slow { .unwrap() .first(), ); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) - .await - .unwrap(); + zingolib::testutils::increase_height_and_wait_for_client( + ®test_manager, + &faucet, + 1, + ) + .await + .unwrap(); } let nom_txid = &txids[0]; @@ -2088,7 +2096,7 @@ mod slow { .first(); // TODO: This chain height bump should be unnecessary. I think removing // this increase_height call reveals a bug! - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); let external_send_txid_no_memo_ref = &external_send_txid_no_memo; @@ -2110,7 +2118,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 1) .await .unwrap(); let pre_rescan_transactions = recipient.do_list_transactions().await; @@ -2142,7 +2150,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(regtest_manager, recipient, 1) .await .unwrap(); let pre_rescan_transactions = recipient.do_list_transactions().await; @@ -2170,7 +2178,7 @@ mod slow { // * sends back to the original sender's UA let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 5) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 5) .await .unwrap(); @@ -2194,7 +2202,7 @@ mod slow { .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) .await .unwrap(); // We know that the largest single note that 2 received from 1 was 30_000, for 2 to send @@ -2252,7 +2260,7 @@ mod slow { /* assert_eq!(non_change_note_values.iter().sum::(), 10000u64); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) .await .unwrap(); let client_2_post_transaction_notes = recipient.do_list_notes(false).await; @@ -2307,7 +2315,7 @@ mod slow { ); // Put some transactions unrelated to the recipient (faucet->faucet) on-chain, to get some clutter for _ in 0..5 { - zingo_testutils::send_value_between_clients_and_sync( + zingolib::testutils::send_value_between_clients_and_sync( ®test_manager, &faucet, &faucet, @@ -2320,7 +2328,7 @@ mod slow { let sent_to_self = 10; // Send recipient->recipient, to make tree equality check at the end simpler - zingo_testutils::send_value_between_clients_and_sync( + zingolib::testutils::send_value_between_clients_and_sync( ®test_manager, &recipient, &recipient, @@ -2478,7 +2486,7 @@ mod slow { assert_eq!(transactions_before.pretty(2), transactions_after.pretty(2)); // 6. Mine 10 blocks, the pending transaction should still be there. - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 10) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 10) .await .unwrap(); assert_eq!(recipient.wallet.last_synced_height().await, 21); @@ -2503,7 +2511,7 @@ mod slow { assert_eq!(transactions.len(), 3); // 7. Mine 100 blocks, so the mempool expires - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 100) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 100) .await .unwrap(); assert_eq!(recipient.wallet.last_synced_height().await, 121); @@ -2555,7 +2563,7 @@ mod slow { server_orchard_shardtree .insert_frontier_nodes( server_orchard_front.unwrap(), - zingo_testutils::incrementalmerkletree::Retention::Marked, + zingolib::testutils::incrementalmerkletree::Retention::Marked, ) .unwrap(); assert_eq!( @@ -2582,7 +2590,7 @@ mod slow { assert_eq!(bal.verified_orchard_balance.unwrap(), value); // 3. Mine 10 blocks - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 10) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 10) .await .unwrap(); let bal = recipient.do_balance().await; @@ -2614,7 +2622,7 @@ mod slow { assert_eq!(bal.unverified_orchard_balance.unwrap(), new_bal); // 5. Mine the pending block, making the funds verified and spendable. - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 10) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 10) .await .unwrap(); @@ -2673,7 +2681,7 @@ mod slow { ) .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); recipient1.do_sync(true).await.unwrap(); @@ -2739,7 +2747,7 @@ mod slow { .await .unwrap(); let sender_balance = faucet.do_balance().await; - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); @@ -2767,12 +2775,12 @@ mod slow { let pmc_sapling = get_base_address_macro!(pool_migration_client, "sapling"); let pmc_unified = get_base_address_macro!(pool_migration_client, "unified"); // Ensure that the client has confirmed spendable funds - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 3) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 3) .await .unwrap(); macro_rules! bump_and_check_pmc { (o: $o:tt s: $s:tt t: $t:tt) => { - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &pool_migration_client, 1).await.unwrap(); + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &pool_migration_client, 1).await.unwrap(); check_client_balances!(pool_migration_client, o:$o s:$s t:$t); }; } @@ -2813,12 +2821,16 @@ mod slow { let pmc_sapling = get_base_address_macro!(client, "sapling"); let pmc_unified = get_base_address_macro!(client, "unified"); // Ensure that the client has confirmed spendable funds - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &sapling_faucet, 1) - .await - .unwrap(); + zingolib::testutils::increase_height_and_wait_for_client( + ®test_manager, + &sapling_faucet, + 1, + ) + .await + .unwrap(); macro_rules! bump_and_check { (o: $o:tt s: $s:tt t: $t:tt) => { - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &client, 1).await.unwrap(); + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &client, 1).await.unwrap(); check_client_balances!(client, o:$o s:$s t:$t); }; } @@ -3121,7 +3133,7 @@ mod slow { async fn factor_do_shield_to_call_do_send() { let (regtest_manager, __cph, faucet, recipient) = scenarios::faucet_recipient_default().await; - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 2) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 2) .await .unwrap(); from_inputs::quick_send( @@ -3153,7 +3165,7 @@ mod slow { .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) .await .unwrap(); @@ -3182,7 +3194,7 @@ mod slow { .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 2) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 2) .await .unwrap(); let recipient_balance = recipient.do_balance().await; @@ -3218,9 +3230,10 @@ mod slow { 65_000 ); - let loaded_client = zingo_testutils::lightclient::new_client_from_save_buffer(&recipient) - .await - .unwrap(); + let loaded_client = + zingolib::testutils::lightclient::new_client_from_save_buffer(&recipient) + .await + .unwrap(); let loaded_balance = loaded_client.do_balance().await; assert_eq!(loaded_balance.unverified_orchard_balance, Some(0),); check_client_balances!(loaded_client, o: 100_000 s: 0 t: 0 ); @@ -3231,7 +3244,7 @@ mod slow { let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; let base_uaddress = get_base_address_macro!(recipient, "unified"); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 2) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 2) .await .unwrap(); println!( @@ -3262,7 +3275,7 @@ mod slow { let (regtest_manager, _cph, faucet, recipient, _txid) = scenarios::orchard_funded_recipient(100_000).await; - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); @@ -3283,7 +3296,7 @@ mod slow { .to_string(); // Validate transaction - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); @@ -3315,7 +3328,7 @@ mod slow { let (regtest_manager, _cph, faucet, recipient, _txid) = scenarios::orchard_funded_recipient(500_000).await; - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 15) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 15) .await .unwrap(); @@ -3335,7 +3348,7 @@ mod slow { .first() .to_string(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 5) .await .unwrap(); @@ -3464,7 +3477,7 @@ mod slow { .unwrap(); let chainwait: u32 = 6; let amount: u64 = u64::from(chainwait * i); - zingo_testutils::increase_server_height(®test_manager, chainwait).await; + zingolib::testutils::increase_server_height(®test_manager, chainwait).await; let _ = recipient.do_sync(false).await; from_inputs::quick_send( &recipient, @@ -3473,7 +3486,7 @@ mod slow { .await .unwrap(); } - zingo_testutils::increase_server_height(®test_manager, 1).await; + zingolib::testutils::increase_server_height(®test_manager, 1).await; let _synciiyur = recipient.do_sync(false).await; // let summ_sim = recipient.list_value_transfers().await; @@ -3483,7 +3496,7 @@ mod slow { dbg!("finished basic sync. restarting for interrupted data"); let timeout = 28; let race_condition = - zingo_testutils::interrupts::sync_with_timeout_millis(&recipient, timeout).await; + zingolib::testutils::interrupts::sync_with_timeout_millis(&recipient, timeout).await; match race_condition { Ok(_) => { println!("synced in less than {} millis ", timeout); @@ -3518,7 +3531,7 @@ mod slow { mod basic_transactions { use std::cmp; - use zingo_testutils::{get_base_address_macro, lightclient::from_inputs, scenarios}; + use zingolib::testutils::{get_base_address_macro, lightclient::from_inputs, scenarios}; #[tokio::test] async fn send_and_sync_with_multiple_notes_no_panic() { @@ -3528,7 +3541,7 @@ mod basic_transactions { let recipient_addr_ua = get_base_address_macro!(recipient, "unified"); let faucet_addr_ua = get_base_address_macro!(faucet, "unified"); - zingo_testutils::generate_n_blocks_return_new_height(®test_manager, 2) + zingolib::testutils::generate_n_blocks_return_new_height(®test_manager, 2) .await .unwrap(); @@ -3541,7 +3554,7 @@ mod basic_transactions { .unwrap(); } - zingo_testutils::generate_n_blocks_return_new_height(®test_manager, 1) + zingolib::testutils::generate_n_blocks_return_new_height(®test_manager, 1) .await .unwrap(); @@ -3552,7 +3565,7 @@ mod basic_transactions { .await .unwrap(); - zingo_testutils::generate_n_blocks_return_new_height(®test_manager, 1) + zingolib::testutils::generate_n_blocks_return_new_height(®test_manager, 1) .await .unwrap(); @@ -3604,7 +3617,7 @@ mod basic_transactions { .first() .to_string(); - zingo_testutils::generate_n_blocks_return_new_height(®test_manager, 1) + zingolib::testutils::generate_n_blocks_return_new_height(®test_manager, 1) .await .unwrap(); @@ -3613,23 +3626,23 @@ mod basic_transactions { println!( "Transaction Inputs:\n{:?}", - zingo_testutils::tx_inputs(&faucet, txid1.as_str()).await + zingolib::testutils::tx_inputs(&faucet, txid1.as_str()).await ); println!( "Transaction Outputs:\n{:?}", - zingo_testutils::tx_outputs(&recipient, txid1.as_str()).await + zingolib::testutils::tx_outputs(&recipient, txid1.as_str()).await ); println!( "Transaction Change:\n{:?}", - zingo_testutils::tx_outputs(&faucet, txid1.as_str()).await + zingolib::testutils::tx_outputs(&faucet, txid1.as_str()).await ); let tx_actions_txid1 = - zingo_testutils::tx_actions(&faucet, Some(&recipient), txid1.as_str()).await; + zingolib::testutils::tx_actions(&faucet, Some(&recipient), txid1.as_str()).await; println!("Transaction Actions:\n{:?}", tx_actions_txid1); let calculated_fee_txid1 = - zingo_testutils::total_tx_value(&faucet, txid1.as_str()).await - 40_000; + zingolib::testutils::total_tx_value(&faucet, txid1.as_str()).await - 40_000; println!("Fee Paid: {}", calculated_fee_txid1); let expected_fee_txid1 = 5000 @@ -3645,23 +3658,23 @@ mod basic_transactions { println!( "Transaction Inputs:\n{:?}", - zingo_testutils::tx_inputs(&faucet, txid2.as_str()).await + zingolib::testutils::tx_inputs(&faucet, txid2.as_str()).await ); println!( "Transaction Outputs:\n{:?}", - zingo_testutils::tx_outputs(&recipient, txid2.as_str()).await + zingolib::testutils::tx_outputs(&recipient, txid2.as_str()).await ); println!( "Transaction Change:\n{:?}", - zingo_testutils::tx_outputs(&faucet, txid2.as_str()).await + zingolib::testutils::tx_outputs(&faucet, txid2.as_str()).await ); let tx_actions_txid2 = - zingo_testutils::tx_actions(&faucet, Some(&recipient), txid2.as_str()).await; + zingolib::testutils::tx_actions(&faucet, Some(&recipient), txid2.as_str()).await; println!("Transaction Actions:\n{:?}", tx_actions_txid2); let calculated_fee_txid2 = - zingo_testutils::total_tx_value(&faucet, txid2.as_str()).await - 40_000; + zingolib::testutils::total_tx_value(&faucet, txid2.as_str()).await - 40_000; println!("Fee Paid: {}", calculated_fee_txid2); let expected_fee_txid2 = 5000 @@ -3677,23 +3690,23 @@ mod basic_transactions { println!( "Transaction Inputs:\n{:?}", - zingo_testutils::tx_inputs(&faucet, txid3.as_str()).await + zingolib::testutils::tx_inputs(&faucet, txid3.as_str()).await ); println!( "Transaction Outputs:\n{:?}", - zingo_testutils::tx_outputs(&recipient, txid3.as_str()).await + zingolib::testutils::tx_outputs(&recipient, txid3.as_str()).await ); println!( "Transaction Change:\n{:?}", - zingo_testutils::tx_outputs(&faucet, txid3.as_str()).await + zingolib::testutils::tx_outputs(&faucet, txid3.as_str()).await ); let tx_actions_txid3 = - zingo_testutils::tx_actions(&faucet, Some(&recipient), txid3.as_str()).await; + zingolib::testutils::tx_actions(&faucet, Some(&recipient), txid3.as_str()).await; println!("Transaction Actions:\n{:?}", tx_actions_txid3); let calculated_fee_txid3 = - zingo_testutils::total_tx_value(&faucet, txid3.as_str()).await - 40_000; + zingolib::testutils::total_tx_value(&faucet, txid3.as_str()).await - 40_000; println!("Fee Paid: {}", calculated_fee_txid3); let expected_fee_txid3 = 5000 @@ -3707,7 +3720,7 @@ mod basic_transactions { assert_eq!(calculated_fee_txid3, expected_fee_txid3 as u64); - let txid4 = zingo_testutils::lightclient::from_inputs::quick_send( + let txid4 = zingolib::testutils::lightclient::from_inputs::quick_send( &recipient, vec![( get_base_address_macro!(faucet, "transparent").as_str(), @@ -3720,7 +3733,7 @@ mod basic_transactions { .first() .to_string(); - zingo_testutils::generate_n_blocks_return_new_height(®test_manager, 1) + zingolib::testutils::generate_n_blocks_return_new_height(®test_manager, 1) .await .unwrap(); @@ -3729,23 +3742,23 @@ mod basic_transactions { println!( "Transaction Inputs:\n{:?}", - zingo_testutils::tx_inputs(&recipient, txid4.as_str()).await + zingolib::testutils::tx_inputs(&recipient, txid4.as_str()).await ); println!( "Transaction Outputs:\n{:?}", - zingo_testutils::tx_outputs(&faucet, txid4.as_str()).await + zingolib::testutils::tx_outputs(&faucet, txid4.as_str()).await ); println!( "Transaction Change:\n{:?}", - zingo_testutils::tx_outputs(&recipient, txid4.as_str()).await + zingolib::testutils::tx_outputs(&recipient, txid4.as_str()).await ); let tx_actions_txid4 = - zingo_testutils::tx_actions(&recipient, Some(&faucet), txid4.as_str()).await; + zingolib::testutils::tx_actions(&recipient, Some(&faucet), txid4.as_str()).await; println!("Transaction Actions:\n{:?}", tx_actions_txid4); let calculated_fee_txid4 = - zingo_testutils::total_tx_value(&recipient, txid4.as_str()).await - 55_000; + zingolib::testutils::total_tx_value(&recipient, txid4.as_str()).await - 55_000; println!("Fee Paid: {}", calculated_fee_txid4); let expected_fee_txid4 = 5000 @@ -3765,7 +3778,7 @@ mod basic_transactions { let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; - let txid1 = zingo_testutils::lightclient::from_inputs::quick_send( + let txid1 = zingolib::testutils::lightclient::from_inputs::quick_send( &faucet, vec![( get_base_address_macro!(recipient, "unified").as_str(), @@ -3778,7 +3791,7 @@ mod basic_transactions { .first() .to_string(); - zingo_testutils::generate_n_blocks_return_new_height(®test_manager, 1) + zingolib::testutils::generate_n_blocks_return_new_height(®test_manager, 1) .await .unwrap(); @@ -3787,22 +3800,23 @@ mod basic_transactions { println!( "Transaction Inputs:\n{:?}", - zingo_testutils::tx_inputs(&faucet, txid1.as_str()).await + zingolib::testutils::tx_inputs(&faucet, txid1.as_str()).await ); println!( "Transaction Outputs:\n{:?}", - zingo_testutils::tx_outputs(&recipient, txid1.as_str()).await + zingolib::testutils::tx_outputs(&recipient, txid1.as_str()).await ); println!( "Transaction Change:\n{:?}", - zingo_testutils::tx_outputs(&faucet, txid1.as_str()).await + zingolib::testutils::tx_outputs(&faucet, txid1.as_str()).await ); let tx_actions_txid1 = - zingo_testutils::tx_actions(&faucet, Some(&recipient), txid1.as_str()).await; + zingolib::testutils::tx_actions(&faucet, Some(&recipient), txid1.as_str()).await; println!("Transaction Actions:\n{:?}", tx_actions_txid1); - let calculated_fee_txid1 = zingo_testutils::total_tx_value(&faucet, txid1.as_str()).await; + let calculated_fee_txid1 = + zingolib::testutils::total_tx_value(&faucet, txid1.as_str()).await; println!("Fee Paid: {}", calculated_fee_txid1); let expected_fee_txid1 = 5000 @@ -3822,7 +3836,7 @@ mod basic_transactions { let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; - zingo_testutils::lightclient::from_inputs::quick_send( + zingolib::testutils::lightclient::from_inputs::quick_send( &faucet, vec![( get_base_address_macro!(recipient, "transparent").as_str(), @@ -3833,7 +3847,7 @@ mod basic_transactions { .await .unwrap(); - zingo_testutils::generate_n_blocks_return_new_height(®test_manager, 1) + zingolib::testutils::generate_n_blocks_return_new_height(®test_manager, 1) .await .unwrap(); @@ -3842,7 +3856,7 @@ mod basic_transactions { let txid1 = recipient.quick_shield().await.unwrap().first().to_string(); - zingo_testutils::generate_n_blocks_return_new_height(®test_manager, 1) + zingolib::testutils::generate_n_blocks_return_new_height(®test_manager, 1) .await .unwrap(); @@ -3851,18 +3865,19 @@ mod basic_transactions { println!( "Transaction Inputs:\n{:?}", - zingo_testutils::tx_inputs(&recipient, txid1.as_str()).await + zingolib::testutils::tx_inputs(&recipient, txid1.as_str()).await ); println!( "Transaction Outputs:\n{:?}", - zingo_testutils::tx_outputs(&recipient, txid1.as_str()).await + zingolib::testutils::tx_outputs(&recipient, txid1.as_str()).await ); - let tx_actions_txid1 = zingo_testutils::tx_actions(&recipient, None, txid1.as_str()).await; + let tx_actions_txid1 = + zingolib::testutils::tx_actions(&recipient, None, txid1.as_str()).await; println!("Transaction Actions:\n{:?}", tx_actions_txid1); let calculated_fee_txid1 = - zingo_testutils::total_tx_value(&recipient, txid1.as_str()).await; + zingolib::testutils::total_tx_value(&recipient, txid1.as_str()).await; println!("Fee Paid: {}", calculated_fee_txid1); let expected_fee_txid1 = 5000 @@ -3876,7 +3891,7 @@ mod basic_transactions { assert_eq!(calculated_fee_txid1, expected_fee_txid1 as u64); - zingo_testutils::lightclient::from_inputs::quick_send( + zingolib::testutils::lightclient::from_inputs::quick_send( &faucet, vec![( get_base_address_macro!(recipient, "transparent").as_str(), @@ -3887,7 +3902,7 @@ mod basic_transactions { .await .unwrap(); - zingo_testutils::generate_n_blocks_return_new_height(®test_manager, 1) + zingolib::testutils::generate_n_blocks_return_new_height(®test_manager, 1) .await .unwrap(); @@ -3898,7 +3913,7 @@ mod basic_transactions { #[ignore = "flake"] #[tokio::test] async fn proxy_server_worky() { - zingo_testutils::check_proxy_server_works().await + zingolib::testutils::check_proxy_server_works().await } // FIXME: does not assert dust was included in the proposal From e3463a564c68b0019d941107a28ea7386ae88de6 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 18:47:23 -0600 Subject: [PATCH 16/26] update concrete.rs again --- libtonode-tests/tests/concrete.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/libtonode-tests/tests/concrete.rs b/libtonode-tests/tests/concrete.rs index 82488c989..cdbdd0716 100644 --- a/libtonode-tests/tests/concrete.rs +++ b/libtonode-tests/tests/concrete.rs @@ -987,11 +987,7 @@ mod slow { assert!(matches!( from_inputs::quick_send( &watch_client, - vec![( - zingolib::testvectors::zingolib::config::XT_TADDR, - 1000, - None - )] + vec![(zingolib::testvectors::EXT_TADDR, 1000, None)] ) .await, Err(QuickSendError::ProposeSend(ProposeSendError::Proposal( @@ -1030,11 +1026,7 @@ mod slow { let sent_value = 20_000; let sent_transaction_error = from_inputs::quick_send( &recipient, - vec![( - zingolib::testvectors::zingolib::config::XT_TADDR, - sent_value, - None, - )], + vec![(zingolib::testvectors::EXT_TADDR, sent_value, None)], ) .await .unwrap_err(); @@ -3531,7 +3523,8 @@ mod slow { mod basic_transactions { use std::cmp; - use zingolib::testutils::{get_base_address_macro, lightclient::from_inputs, scenarios}; + use zingolib::get_base_address_macro; + use zingolib::testutils::{lightclient::from_inputs, scenarios}; #[tokio::test] async fn send_and_sync_with_multiple_notes_no_panic() { From 4dd07a77fb0b0dafa164c00234f32c802aad5b89 Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 18:49:30 -0600 Subject: [PATCH 17/26] manual change --- darkside-tests/src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/darkside-tests/src/utils.rs b/darkside-tests/src/utils.rs index 4495f834f..acf7bbdc7 100644 --- a/darkside-tests/src/utils.rs +++ b/darkside-tests/src/utils.rs @@ -18,7 +18,7 @@ use tonic::Status; use tower::{util::BoxCloneService, ServiceExt}; use zcash_primitives::consensus::BranchId; use zcash_primitives::{merkle_tree::read_commitment_tree, transaction::Transaction}; -use zingo_testutils::{ +use zingolib::testutils::{ self, incrementalmerkletree::frontier::CommitmentTree, paths::{get_bin_dir, get_cargo_manifest_dir}, From 54285adc3e0e63a1fd1630c7a0e09dbd32e40a8e Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 18:50:28 -0600 Subject: [PATCH 18/26] zingo_testutils --> zingolib::testutils --- darkside-tests/src/chain_generics.rs | 4 ++-- darkside-tests/src/utils.rs | 4 ++-- darkside-tests/tests/advanced_reorg_tests.rs | 2 +- .../tests/network_interruption_tests.rs | 2 +- darkside-tests/tests/tests.rs | 4 ++-- libtonode-tests/tests/chain_generics.rs | 6 ++--- libtonode-tests/tests/shield_transparent.rs | 6 ++--- libtonode-tests/tests/wallet.rs | 22 +++++++++---------- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/darkside-tests/src/chain_generics.rs b/darkside-tests/src/chain_generics.rs index e9b52c091..abd2190ab 100644 --- a/darkside-tests/src/chain_generics.rs +++ b/darkside-tests/src/chain_generics.rs @@ -6,7 +6,7 @@ use zcash_client_backend::PoolType::Transparent; use zcash_client_backend::ShieldedProtocol::Orchard; use zcash_client_backend::ShieldedProtocol::Sapling; -use zingo_testutils::chain_generics::fixtures::send_value_to_pool; +use zingolib::testutils::chain_generics::fixtures::send_value_to_pool; use crate::utils::scenarios::DarksideEnvironment; @@ -37,7 +37,7 @@ pub(crate) mod impl_conduct_chain_for_darkside_environment { //! - txids are regenerated randomly. zingo can optionally accept_server_txid //! these tests cannot portray the full range of network weather. - use zingo_testutils::chain_generics::conduct_chain::ConductChain; + use zingolib::testutils::chain_generics::conduct_chain::ConductChain; use zingolib::lightclient::LightClient; use zingolib::wallet::WalletBase; diff --git a/darkside-tests/src/utils.rs b/darkside-tests/src/utils.rs index acf7bbdc7..abd3d0387 100644 --- a/darkside-tests/src/utils.rs +++ b/darkside-tests/src/utils.rs @@ -499,7 +499,7 @@ pub mod scenarios { }; use zcash_client_backend::{PoolType, ShieldedProtocol}; use zcash_primitives::consensus::{BlockHeight, BranchId}; - use zingo_testutils::scenarios::setup::ClientBuilder; + use zingolib::testutils::scenarios::setup::ClientBuilder; use zingo_testvectors::seeds::HOSPITAL_MUSEUM_SEED; use zingoconfig::RegtestNetwork; use zingolib::lightclient::LightClient; @@ -679,7 +679,7 @@ pub mod scenarios { DarksideSender::IndexedClient(n) => self.get_lightclient(n), DarksideSender::ExternalClient(lc) => lc, }; - zingo_testutils::lightclient::from_inputs::quick_send( + zingolib::testutils::lightclient::from_inputs::quick_send( lightclient, vec![(receiver_address, value, None)], ) diff --git a/darkside-tests/tests/advanced_reorg_tests.rs b/darkside-tests/tests/advanced_reorg_tests.rs index 3b8ccf850..ebf1e1f28 100644 --- a/darkside-tests/tests/advanced_reorg_tests.rs +++ b/darkside-tests/tests/advanced_reorg_tests.rs @@ -12,7 +12,7 @@ use darkside_tests::{ use tokio::time::sleep; use zcash_primitives::consensus::BlockHeight; -use zingo_testutils::{ +use zingolib::testutils::{ lightclient::from_inputs, paths::get_cargo_manifest_dir, scenarios::setup::ClientBuilder, }; use zingoconfig::RegtestNetwork; diff --git a/darkside-tests/tests/network_interruption_tests.rs b/darkside-tests/tests/network_interruption_tests.rs index 2bfa70232..6060df212 100644 --- a/darkside-tests/tests/network_interruption_tests.rs +++ b/darkside-tests/tests/network_interruption_tests.rs @@ -17,7 +17,7 @@ use darkside_tests::{ }; use tokio::time::sleep; use zcash_client_backend::{PoolType, ShieldedProtocol}; -use zingo_testutils::{ +use zingolib::testutils::{ get_base_address_macro, scenarios::setup::ClientBuilder, start_proxy_and_connect_lightclient, }; use zingoconfig::RegtestNetwork; diff --git a/darkside-tests/tests/tests.rs b/darkside-tests/tests/tests.rs index 880cef9d3..1d57685ea 100644 --- a/darkside-tests/tests/tests.rs +++ b/darkside-tests/tests/tests.rs @@ -2,7 +2,7 @@ use darkside_tests::utils::{ prepare_darksidewalletd, update_tree_states_for_transaction, DarksideConnector, DarksideHandler, }; use tokio::time::sleep; -use zingo_testutils::{ +use zingolib::testutils::{ get_base_address_macro, lightclient::from_inputs, scenarios::setup::ClientBuilder, }; use zingo_testvectors::seeds::DARKSIDE_SEED; @@ -197,7 +197,7 @@ async fn sent_transaction_reorged_into_mempool() { serde_json::to_string_pretty(&light_client.do_balance().await).unwrap() ); dbg!("Sender post-reorg: {}", light_client.list_outputs().await); - let loaded_client = zingo_testutils::lightclient::new_client_from_save_buffer(&light_client) + let loaded_client = zingolib::testutils::lightclient::new_client_from_save_buffer(&light_client) .await .unwrap(); loaded_client.do_sync(false).await.unwrap(); diff --git a/libtonode-tests/tests/chain_generics.rs b/libtonode-tests/tests/chain_generics.rs index e80bc0f07..44e458770 100644 --- a/libtonode-tests/tests/chain_generics.rs +++ b/libtonode-tests/tests/chain_generics.rs @@ -4,7 +4,7 @@ mod chain_generics { use zcash_client_backend::ShieldedProtocol::Orchard; use zcash_client_backend::ShieldedProtocol::Sapling; - use zingo_testutils::chain_generics::fixtures; + use zingolib::testutils::chain_generics::fixtures; use environment::LibtonodeEnvironment; #[tokio::test] @@ -197,8 +197,8 @@ mod chain_generics { use zcash_client_backend::ShieldedProtocol::Sapling; - use zingo_testutils::chain_generics::conduct_chain::ConductChain; - use zingo_testutils::scenarios::setup::ScenarioBuilder; + use zingolib::testutils::chain_generics::conduct_chain::ConductChain; + use zingolib::testutils::scenarios::setup::ScenarioBuilder; use zingoconfig::RegtestNetwork; use zingolib::lightclient::LightClient; use zingolib::wallet::WalletBase; diff --git a/libtonode-tests/tests/shield_transparent.rs b/libtonode-tests/tests/shield_transparent.rs index d776266da..c8849c9fa 100644 --- a/libtonode-tests/tests/shield_transparent.rs +++ b/libtonode-tests/tests/shield_transparent.rs @@ -1,4 +1,4 @@ -use zingo_testutils::{ +use zingolib::testutils::{ get_base_address_macro, lightclient::from_inputs, scenarios::faucet_recipient_default, }; @@ -33,7 +33,7 @@ async fn shield_transparent() { serde_json::to_string_pretty(&faucet.do_balance().await).unwrap(), serde_json::to_string_pretty(&recipient.do_balance().await).unwrap(), ); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); @@ -54,7 +54,7 @@ async fn shield_transparent() { .complete_and_broadcast_stored_proposal() .await .unwrap(); - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); diff --git a/libtonode-tests/tests/wallet.rs b/libtonode-tests/tests/wallet.rs index 9dcfa0ca3..6a538a55b 100644 --- a/libtonode-tests/tests/wallet.rs +++ b/libtonode-tests/tests/wallet.rs @@ -8,11 +8,11 @@ mod load_wallet { use zcash_client_backend::ShieldedProtocol; use zcash_primitives::consensus::Parameters as _; use zcash_primitives::zip339::Mnemonic; - use zingo_testutils::check_client_balances; - use zingo_testutils::get_base_address_macro; - use zingo_testutils::lightclient::from_inputs; - use zingo_testutils::paths::get_cargo_manifest_dir; - use zingo_testutils::scenarios; + use zingolib::testutils::check_client_balances; + use zingolib::testutils::get_base_address_macro; + use zingolib::testutils::lightclient::from_inputs; + use zingolib::testutils::paths::get_cargo_manifest_dir; + use zingolib::testutils::scenarios; use zingo_testvectors::seeds::CHIMNEY_BETTER_SEED; use zingoconfig::ChainType; use zingoconfig::RegtestNetwork; @@ -112,9 +112,9 @@ mod load_wallet { async fn load_and_parse_different_wallet_versions() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (_sap_wallet, _sap_path, sap_dir) = - zingo_testutils::get_wallet_nym("sap_only").unwrap(); + zingolib::testutils::get_wallet_nym("sap_only").unwrap(); let (_loaded_wallet, _) = - zingo_testutils::load_wallet(sap_dir, ChainType::Regtest(regtest_network)).await; + zingolib::testutils::load_wallet(sap_dir, ChainType::Regtest(regtest_network)).await; } #[tokio::test] async fn load_wallet_from_v26_dat_file() { @@ -306,7 +306,7 @@ mod load_wallet { let _cph = regtest_manager.launch(false).unwrap(); println!("loading wallet"); let (wallet, conf) = - zingo_testutils::load_wallet(zingo_dest.into(), ChainType::Regtest(regtest_network)) + zingolib::testutils::load_wallet(zingo_dest.into(), ChainType::Regtest(regtest_network)) .await; println!("setting uri"); *conf.lightwalletd_uri.write().unwrap() = faucet.get_server_uri(); @@ -426,7 +426,7 @@ mod load_wallet { regtest_network, ) .await; - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); @@ -514,12 +514,12 @@ mod load_wallet { let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; // Ensure that the client has confirmed spendable funds - zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 5) + zingolib::testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 5) .await .unwrap(); // Without sync push server forward 2 blocks - zingo_testutils::increase_server_height(®test_manager, 2).await; + zingolib::testutils::increase_server_height(®test_manager, 2).await; let client_wallet_height = faucet.do_wallet_last_scanned_height().await; // Verify that wallet is still back at 6. From 5b43b5d6f5f480668cb575af335b9f7faaa025dc Mon Sep 17 00:00:00 2001 From: zancas Date: Tue, 6 Aug 2024 18:51:36 -0600 Subject: [PATCH 19/26] wip --- darkside-tests/src/utils.rs | 4 ++-- darkside-tests/tests/tests.rs | 4 ++-- libtonode-tests/tests/wallet.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/darkside-tests/src/utils.rs b/darkside-tests/src/utils.rs index abd3d0387..11db308ae 100644 --- a/darkside-tests/src/utils.rs +++ b/darkside-tests/src/utils.rs @@ -500,7 +500,7 @@ pub mod scenarios { use zcash_client_backend::{PoolType, ShieldedProtocol}; use zcash_primitives::consensus::{BlockHeight, BranchId}; use zingolib::testutils::scenarios::setup::ClientBuilder; - use zingo_testvectors::seeds::HOSPITAL_MUSEUM_SEED; + use zingolib::testvectors::seeds::HOSPITAL_MUSEUM_SEED; use zingoconfig::RegtestNetwork; use zingolib::lightclient::LightClient; @@ -564,7 +564,7 @@ pub mod scenarios { self.faucet = Some( self.client_builder .build_client( - zingo_testvectors::seeds::DARKSIDE_SEED.to_string(), + zingolib::testvectors::seeds::DARKSIDE_SEED.to_string(), 0, true, self.regtest_network, diff --git a/darkside-tests/tests/tests.rs b/darkside-tests/tests/tests.rs index 1d57685ea..3d7dbd094 100644 --- a/darkside-tests/tests/tests.rs +++ b/darkside-tests/tests/tests.rs @@ -5,7 +5,7 @@ use tokio::time::sleep; use zingolib::testutils::{ get_base_address_macro, lightclient::from_inputs, scenarios::setup::ClientBuilder, }; -use zingo_testvectors::seeds::DARKSIDE_SEED; +use zingolib::testvectors::seeds::DARKSIDE_SEED; use zingoconfig::RegtestNetwork; use zingolib::lightclient::PoolBalances; @@ -120,7 +120,7 @@ async fn sent_transaction_reorged_into_mempool() { .await; let recipient = client_manager .build_client( - zingo_testvectors::seeds::HOSPITAL_MUSEUM_SEED.to_string(), + zingolib::testvectors::seeds::HOSPITAL_MUSEUM_SEED.to_string(), 1, true, regtest_network, diff --git a/libtonode-tests/tests/wallet.rs b/libtonode-tests/tests/wallet.rs index 6a538a55b..6cc1187f5 100644 --- a/libtonode-tests/tests/wallet.rs +++ b/libtonode-tests/tests/wallet.rs @@ -13,7 +13,7 @@ mod load_wallet { use zingolib::testutils::lightclient::from_inputs; use zingolib::testutils::paths::get_cargo_manifest_dir; use zingolib::testutils::scenarios; - use zingo_testvectors::seeds::CHIMNEY_BETTER_SEED; + use zingolib::testvectors::seeds::CHIMNEY_BETTER_SEED; use zingoconfig::ChainType; use zingoconfig::RegtestNetwork; use zingoconfig::ZingoConfig; From 5f533894a74c7777571a96b6a116615e637278e9 Mon Sep 17 00:00:00 2001 From: zancas Date: Wed, 7 Aug 2024 08:35:38 -0600 Subject: [PATCH 20/26] more name change --- darkside-tests/src/utils.rs | 4 +-- darkside-tests/tests/advanced_reorg_tests.rs | 14 ++++---- .../tests/network_interruption_tests.rs | 9 +++-- darkside-tests/tests/tests.rs | 22 ++++++------ libtonode-tests/tests/chain_generics.rs | 2 +- libtonode-tests/tests/shield_transparent.rs | 5 ++- libtonode-tests/tests/wallet.rs | 35 ++++++++++--------- 7 files changed, 46 insertions(+), 45 deletions(-) diff --git a/darkside-tests/src/utils.rs b/darkside-tests/src/utils.rs index 11db308ae..519fac798 100644 --- a/darkside-tests/src/utils.rs +++ b/darkside-tests/src/utils.rs @@ -397,7 +397,7 @@ pub async fn init_darksidewalletd( set_port: Option, ) -> Result<(DarksideHandler, DarksideConnector), String> { let handler = DarksideHandler::new(set_port); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", handler.grpc_port ))); @@ -501,7 +501,7 @@ pub mod scenarios { use zcash_primitives::consensus::{BlockHeight, BranchId}; use zingolib::testutils::scenarios::setup::ClientBuilder; use zingolib::testvectors::seeds::HOSPITAL_MUSEUM_SEED; - use zingoconfig::RegtestNetwork; + use zingolib::config::RegtestNetwork; use zingolib::lightclient::LightClient; use super::{ diff --git a/darkside-tests/tests/advanced_reorg_tests.rs b/darkside-tests/tests/advanced_reorg_tests.rs index ebf1e1f28..e46bc5561 100644 --- a/darkside-tests/tests/advanced_reorg_tests.rs +++ b/darkside-tests/tests/advanced_reorg_tests.rs @@ -15,7 +15,7 @@ use zcash_primitives::consensus::BlockHeight; use zingolib::testutils::{ lightclient::from_inputs, paths::get_cargo_manifest_dir, scenarios::setup::ClientBuilder, }; -use zingoconfig::RegtestNetwork; +use zingolib::config::RegtestNetwork; use zingolib::lightclient::PoolBalances; use zingolib::wallet::data::summaries::ValueTransferKind; @@ -24,7 +24,7 @@ use zingolib::wallet::data::summaries::ValueTransferKind; async fn reorg_changes_incoming_tx_height() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); @@ -180,7 +180,7 @@ async fn prepare_after_tx_height_change_reorg(uri: http::Uri) -> Result<(), Stri async fn reorg_changes_incoming_tx_index() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); @@ -335,7 +335,7 @@ async fn prepare_after_tx_index_change_reorg(uri: http::Uri) -> Result<(), Strin async fn reorg_expires_incoming_tx() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); @@ -513,7 +513,7 @@ async fn prepare_expires_incoming_tx_after_reorg(uri: http::Uri) -> Result<(), S async fn reorg_changes_outgoing_tx_height() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); @@ -753,7 +753,7 @@ async fn prepare_changes_outgoing_tx_height_before_reorg(uri: http::Uri) -> Resu async fn reorg_expires_outgoing_tx_height() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); @@ -934,7 +934,7 @@ async fn reorg_expires_outgoing_tx_height() { async fn reorg_changes_outgoing_tx_index() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); diff --git a/darkside-tests/tests/network_interruption_tests.rs b/darkside-tests/tests/network_interruption_tests.rs index 6060df212..8349dfe93 100644 --- a/darkside-tests/tests/network_interruption_tests.rs +++ b/darkside-tests/tests/network_interruption_tests.rs @@ -17,10 +17,9 @@ use darkside_tests::{ }; use tokio::time::sleep; use zcash_client_backend::{PoolType, ShieldedProtocol}; -use zingolib::testutils::{ - get_base_address_macro, scenarios::setup::ClientBuilder, start_proxy_and_connect_lightclient, -}; -use zingoconfig::RegtestNetwork; +use zingolib::config::RegtestNetwork; +use zingolib::get_base_address_macro; +use zingolib::testutils::{scenarios::setup::ClientBuilder, start_proxy_and_connect_lightclient}; use zingolib::{ lightclient::PoolBalances, wallet::{ @@ -34,7 +33,7 @@ use zingolib::{ async fn interrupt_initial_tree_fetch() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); diff --git a/darkside-tests/tests/tests.rs b/darkside-tests/tests/tests.rs index 3d7dbd094..c97b16dc5 100644 --- a/darkside-tests/tests/tests.rs +++ b/darkside-tests/tests/tests.rs @@ -2,18 +2,17 @@ use darkside_tests::utils::{ prepare_darksidewalletd, update_tree_states_for_transaction, DarksideConnector, DarksideHandler, }; use tokio::time::sleep; -use zingolib::testutils::{ - get_base_address_macro, lightclient::from_inputs, scenarios::setup::ClientBuilder, -}; -use zingolib::testvectors::seeds::DARKSIDE_SEED; -use zingoconfig::RegtestNetwork; +use zingolib::config::RegtestNetwork; +use zingolib::get_base_address_macro; use zingolib::lightclient::PoolBalances; +use zingolib::testutils::{lightclient::from_inputs, scenarios::setup::ClientBuilder}; +use zingolib::testvectors::seeds::DARKSIDE_SEED; #[tokio::test] async fn simple_sync() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); @@ -52,7 +51,7 @@ async fn simple_sync() { async fn reorg_away_receipt() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); @@ -104,7 +103,7 @@ async fn reorg_away_receipt() { async fn sent_transaction_reorged_into_mempool() { let darkside_handler = DarksideHandler::new(None); - let server_id = zingoconfig::construct_lightwalletd_uri(Some(format!( + let server_id = zingolib::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{}", darkside_handler.grpc_port ))); @@ -197,9 +196,10 @@ async fn sent_transaction_reorged_into_mempool() { serde_json::to_string_pretty(&light_client.do_balance().await).unwrap() ); dbg!("Sender post-reorg: {}", light_client.list_outputs().await); - let loaded_client = zingolib::testutils::lightclient::new_client_from_save_buffer(&light_client) - .await - .unwrap(); + let loaded_client = + zingolib::testutils::lightclient::new_client_from_save_buffer(&light_client) + .await + .unwrap(); loaded_client.do_sync(false).await.unwrap(); dbg!("Sender post-load: {}", loaded_client.list_outputs().await); assert_eq!( diff --git a/libtonode-tests/tests/chain_generics.rs b/libtonode-tests/tests/chain_generics.rs index 44e458770..1beca8cfd 100644 --- a/libtonode-tests/tests/chain_generics.rs +++ b/libtonode-tests/tests/chain_generics.rs @@ -199,7 +199,7 @@ mod chain_generics { use zingolib::testutils::chain_generics::conduct_chain::ConductChain; use zingolib::testutils::scenarios::setup::ScenarioBuilder; - use zingoconfig::RegtestNetwork; + use zingolib::config::RegtestNetwork; use zingolib::lightclient::LightClient; use zingolib::wallet::WalletBase; pub(crate) struct LibtonodeEnvironment { diff --git a/libtonode-tests/tests/shield_transparent.rs b/libtonode-tests/tests/shield_transparent.rs index c8849c9fa..502bf71c1 100644 --- a/libtonode-tests/tests/shield_transparent.rs +++ b/libtonode-tests/tests/shield_transparent.rs @@ -1,6 +1,5 @@ -use zingolib::testutils::{ - get_base_address_macro, lightclient::from_inputs, scenarios::faucet_recipient_default, -}; +use zingolib::get_base_address_macro; +use zingolib::testutils::{lightclient::from_inputs, scenarios::faucet_recipient_default}; #[tokio::test] #[ignore] diff --git a/libtonode-tests/tests/wallet.rs b/libtonode-tests/tests/wallet.rs index 6cc1187f5..2f096ef34 100644 --- a/libtonode-tests/tests/wallet.rs +++ b/libtonode-tests/tests/wallet.rs @@ -8,19 +8,19 @@ mod load_wallet { use zcash_client_backend::ShieldedProtocol; use zcash_primitives::consensus::Parameters as _; use zcash_primitives::zip339::Mnemonic; - use zingolib::testutils::check_client_balances; - use zingolib::testutils::get_base_address_macro; - use zingolib::testutils::lightclient::from_inputs; - use zingolib::testutils::paths::get_cargo_manifest_dir; - use zingolib::testutils::scenarios; - use zingolib::testvectors::seeds::CHIMNEY_BETTER_SEED; - use zingoconfig::ChainType; - use zingoconfig::RegtestNetwork; - use zingoconfig::ZingoConfig; + use zingolib::check_client_balances; + use zingolib::config::ChainType; + use zingolib::config::RegtestNetwork; + use zingolib::config::ZingoConfig; + use zingolib::get_base_address_macro; use zingolib::lightclient::propose::ProposeSendError::Proposal; use zingolib::lightclient::send::send_with_proposal::QuickSendError; use zingolib::lightclient::LightClient; use zingolib::lightclient::PoolBalances; + use zingolib::testutils::lightclient::from_inputs; + use zingolib::testutils::paths::get_cargo_manifest_dir; + use zingolib::testutils::scenarios; + use zingolib::testvectors::seeds::CHIMNEY_BETTER_SEED; use zingolib::utils; use zingolib::wallet::keys::extended_transparent::ExtendedPrivKey; use zingolib::wallet::keys::unified::Capability; @@ -178,7 +178,7 @@ mod load_wallet { // with 3 addresses containing all receivers. let data = include_bytes!("zingo-wallet-v28.dat"); - let config = zingoconfig::ZingoConfig::build(ChainType::Testnet).create(); + let config = zingolib::config::ZingoConfig::build(ChainType::Testnet).create(); let mid_wallet = LightWallet::read_internal(&data[..], &config) .await .map_err(|e| format!("Cannot deserialize LightWallet version 28 file: {}", e)) @@ -305,9 +305,11 @@ mod load_wallet { .expect("wallet copy failed"); let _cph = regtest_manager.launch(false).unwrap(); println!("loading wallet"); - let (wallet, conf) = - zingolib::testutils::load_wallet(zingo_dest.into(), ChainType::Regtest(regtest_network)) - .await; + let (wallet, conf) = zingolib::testutils::load_wallet( + zingo_dest.into(), + ChainType::Regtest(regtest_network), + ) + .await; println!("setting uri"); *conf.lightwalletd_uri.write().unwrap() = faucet.get_server_uri(); println!("creating lightclient"); @@ -462,9 +464,10 @@ mod load_wallet { let mut wallet_location = regtest_manager.zingo_datadir; wallet_location.pop(); wallet_location.push("zingo_client_1"); - let zingo_config = ZingoConfig::build(zingoconfig::ChainType::Regtest(regtest_network)) - .set_wallet_dir(wallet_location.clone()) - .create(); + let zingo_config = + ZingoConfig::build(zingolib::config::ChainType::Regtest(regtest_network)) + .set_wallet_dir(wallet_location.clone()) + .create(); wallet_location.push("zingo-wallet.dat"); let read_buffer = File::open(wallet_location.clone()).unwrap(); From 19bc331ffee52f42c1ff5dace278f87f5f821680 Mon Sep 17 00:00:00 2001 From: zancas Date: Wed, 7 Aug 2024 12:02:00 -0600 Subject: [PATCH 21/26] add tempdir to list of optional features --- Cargo.lock | 1 + zingolib/Cargo.toml | 5 +++-- zingolib/src/testutils.rs | 5 +++-- zingolib/src/testutils/regtest.rs | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2858ee4a1..49b08f05d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4263,6 +4263,7 @@ dependencies = [ "sha2 0.9.9", "shardtree", "subtle", + "tempdir", "tempfile", "test-case", "thiserror", diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index ff329db93..034a19419 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" deprecations = ["lightclient-deprecated"] lightclient-deprecated = [] darkside_tests = [] -test-elevation = ["portpicker", "testvectors", "tempfile"] +test-elevation = ["portpicker", "testvectors", "tempfile", "tempdir"] testvectors = [] tempfile = ["dep:tempfile"] @@ -74,7 +74,8 @@ hdwallet = { workspace = true } chrono = { workspace = true } enum_dispatch = { workspace = true } portpicker = { workspace = true, optional = true } -tempfile = { workspace = true, optional = true } +tempdir = {workspace = true, optional = true } +tempfile = {workspace = true, optional = true } dirs.workspace = true log4rs.workspace = true diff --git a/zingolib/src/testutils.rs b/zingolib/src/testutils.rs index 12a22cdda..5afc7c8ad 100644 --- a/zingolib/src/testutils.rs +++ b/zingolib/src/testutils.rs @@ -685,7 +685,6 @@ pub mod scenarios { seeds, REG_O_ADDR_FROM_ABANDONART, REG_T_ADDR_FROM_ABANDONART, REG_Z_ADDR_FROM_ABANDONART, }; - use tempfile::TempDir; use zcash_client_backend::{PoolType, ShieldedProtocol}; use super::super::paths::get_regtest_dir; @@ -924,7 +923,9 @@ pub mod scenarios { let lightwalletd_rpcservice_port = TestEnvironmentGenerator::pick_unused_port_to_string(set_lightwalletd_port); let regtest_manager = RegtestManager::new( - TempDir::new_in("zingo_libtonode_test").unwrap().into_path(), + tempdir::TempDir::new("zingo_libtonode_test") + .unwrap() + .into_path(), ); let server_uri = crate::config::construct_lightwalletd_uri(Some(format!( "http://127.0.0.1:{lightwalletd_rpcservice_port}" diff --git a/zingolib/src/testutils/regtest.rs b/zingolib/src/testutils/regtest.rs index 53efdfafa..b5090e45e 100644 --- a/zingolib/src/testutils/regtest.rs +++ b/zingolib/src/testutils/regtest.rs @@ -206,7 +206,7 @@ pub fn launch_lightwalletd( fn write_zcash_conf(location: &PathBuf) { // This is the only data we need to supply *to* the zcashd, the other files are created by zcashd and lightwalletd use std::io::Write; - let conf_bytes: &'static [u8] = include_bytes!("./regtest/conf/zcash.conf"); + let conf_bytes: &'static [u8] = include_bytes!("regtest/conf/zcash.conf"); File::create(location) .unwrap() .write_all(conf_bytes) From f0a01a592670005a83093cc20780249bffb5c6c3 Mon Sep 17 00:00:00 2001 From: zancas Date: Thu, 8 Aug 2024 13:54:28 -0600 Subject: [PATCH 22/26] fix path for load_old_wallet_at_reorged_height --- libtonode-tests/tests/wallet.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libtonode-tests/tests/wallet.rs b/libtonode-tests/tests/wallet.rs index 2f096ef34..dc1f72cfe 100644 --- a/libtonode-tests/tests/wallet.rs +++ b/libtonode-tests/tests/wallet.rs @@ -266,11 +266,11 @@ mod load_wallet { let zcd_datadir = ®test_manager.zcashd_data_dir; let zingo_datadir = ®test_manager.zingo_datadir; // This test is the unique consumer of: - // zingo-testutils/old_wallet_reorg_test_wallet + // zingolib/src/testvectors/old_wallet_reorg_test_wallet let cached_data_dir = get_cargo_manifest_dir() .parent() .unwrap() - .join("zingo-testvectors") + .join("zingolib/src/testvectors") .join("old_wallet_reorg_test_wallet"); let zcd_source = cached_data_dir .join("zcashd") From 0ac19a090283d9db646aa0e8226d99b238e1ab17 Mon Sep 17 00:00:00 2001 From: zancas Date: Thu, 8 Aug 2024 13:56:21 -0600 Subject: [PATCH 23/26] apply clippy --- darkside-tests/src/chain_generics.rs | 2 +- darkside-tests/src/utils.rs | 4 ++-- darkside-tests/tests/advanced_reorg_tests.rs | 4 ++-- libtonode-tests/tests/chain_generics.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/darkside-tests/src/chain_generics.rs b/darkside-tests/src/chain_generics.rs index abd2190ab..f855607a0 100644 --- a/darkside-tests/src/chain_generics.rs +++ b/darkside-tests/src/chain_generics.rs @@ -37,8 +37,8 @@ pub(crate) mod impl_conduct_chain_for_darkside_environment { //! - txids are regenerated randomly. zingo can optionally accept_server_txid //! these tests cannot portray the full range of network weather. - use zingolib::testutils::chain_generics::conduct_chain::ConductChain; use zingolib::lightclient::LightClient; + use zingolib::testutils::chain_generics::conduct_chain::ConductChain; use zingolib::wallet::WalletBase; use crate::constants::ABANDON_TO_DARKSIDE_SAP_10_000_000_ZAT; diff --git a/darkside-tests/src/utils.rs b/darkside-tests/src/utils.rs index 519fac798..e3a02b0a9 100644 --- a/darkside-tests/src/utils.rs +++ b/darkside-tests/src/utils.rs @@ -499,10 +499,10 @@ pub mod scenarios { }; use zcash_client_backend::{PoolType, ShieldedProtocol}; use zcash_primitives::consensus::{BlockHeight, BranchId}; - use zingolib::testutils::scenarios::setup::ClientBuilder; - use zingolib::testvectors::seeds::HOSPITAL_MUSEUM_SEED; use zingolib::config::RegtestNetwork; use zingolib::lightclient::LightClient; + use zingolib::testutils::scenarios::setup::ClientBuilder; + use zingolib::testvectors::seeds::HOSPITAL_MUSEUM_SEED; use super::{ init_darksidewalletd, update_tree_states_for_transaction, write_raw_transaction, diff --git a/darkside-tests/tests/advanced_reorg_tests.rs b/darkside-tests/tests/advanced_reorg_tests.rs index e46bc5561..d02037a49 100644 --- a/darkside-tests/tests/advanced_reorg_tests.rs +++ b/darkside-tests/tests/advanced_reorg_tests.rs @@ -12,11 +12,11 @@ use darkside_tests::{ use tokio::time::sleep; use zcash_primitives::consensus::BlockHeight; +use zingolib::config::RegtestNetwork; +use zingolib::lightclient::PoolBalances; use zingolib::testutils::{ lightclient::from_inputs, paths::get_cargo_manifest_dir, scenarios::setup::ClientBuilder, }; -use zingolib::config::RegtestNetwork; -use zingolib::lightclient::PoolBalances; use zingolib::wallet::data::summaries::ValueTransferKind; #[ignore] diff --git a/libtonode-tests/tests/chain_generics.rs b/libtonode-tests/tests/chain_generics.rs index 1beca8cfd..4b83a8959 100644 --- a/libtonode-tests/tests/chain_generics.rs +++ b/libtonode-tests/tests/chain_generics.rs @@ -197,10 +197,10 @@ mod chain_generics { use zcash_client_backend::ShieldedProtocol::Sapling; - use zingolib::testutils::chain_generics::conduct_chain::ConductChain; - use zingolib::testutils::scenarios::setup::ScenarioBuilder; use zingolib::config::RegtestNetwork; use zingolib::lightclient::LightClient; + use zingolib::testutils::chain_generics::conduct_chain::ConductChain; + use zingolib::testutils::scenarios::setup::ScenarioBuilder; use zingolib::wallet::WalletBase; pub(crate) struct LibtonodeEnvironment { regtest_network: RegtestNetwork, From 6e8ec8e9e30461988f0f923e677188c5e3c279be Mon Sep 17 00:00:00 2001 From: zancas Date: Thu, 8 Aug 2024 14:04:11 -0600 Subject: [PATCH 24/26] fix format issues --- darkside-tests/src/utils.rs | 1 - zingolib/src/mocks.rs | 2 +- zingolib/src/testvectors.rs | 7 +++++-- zingolib/src/utils.rs | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/darkside-tests/src/utils.rs b/darkside-tests/src/utils.rs index e3a02b0a9..ea62a59f9 100644 --- a/darkside-tests/src/utils.rs +++ b/darkside-tests/src/utils.rs @@ -19,7 +19,6 @@ use tower::{util::BoxCloneService, ServiceExt}; use zcash_primitives::consensus::BranchId; use zcash_primitives::{merkle_tree::read_commitment_tree, transaction::Transaction}; use zingolib::testutils::{ - self, incrementalmerkletree::frontier::CommitmentTree, paths::{get_bin_dir, get_cargo_manifest_dir}, regtest::launch_lightwalletd, diff --git a/zingolib/src/mocks.rs b/zingolib/src/mocks.rs index 0ecb47ee3..44e24ff26 100644 --- a/zingolib/src/mocks.rs +++ b/zingolib/src/mocks.rs @@ -2,7 +2,7 @@ //! Tools to facilitate mocks for structs of external crates and general mocking utilities for testing -pub use proposal::{ProposalBuilder, StepBuilder}; +pub use proposal::ProposalBuilder; pub use sapling_crypto_note::SaplingCryptoNoteBuilder; fn zaddr_from_seed( diff --git a/zingolib/src/testvectors.rs b/zingolib/src/testvectors.rs index 360dcf5b5..3ed557cb2 100644 --- a/zingolib/src/testvectors.rs +++ b/zingolib/src/testvectors.rs @@ -1,7 +1,9 @@ -//! A publishable crate that provides access to the full dataset ZingoLabs uses to test -//! zingolib. It's available as a re-export from zingolib. +//! A publishable mod that provides access to the full dataset ZingoLabs uses to test +//! zingolib. It's available under the "testvectors" feature gate from zingolib. //! TODO: 1. specify feature gates for re-export access //! TODO: 2. after 1. is resolved add a doc-test + +/// The number of blocks most tests start with. pub const BASE_HEIGHT: u32 = 3; /// TODO: Add Mod Description Here! @@ -54,6 +56,7 @@ pub mod block_rewards { /// Burn-to regtest address generated by `zcash-cli getnewaddress` pub const EXT_TADDR: &str = "tmJTBtMwPU96XteSiP89xDz1WARNgRddEHq"; +/// A test txid pub const TEST_TXID: &str = "d5eaac5563f8bc1a0406588e05953977ad768d02f1cf8449e9d7d9cc8de3801c"; /// TODO: Add Doc Comment Here! diff --git a/zingolib/src/utils.rs b/zingolib/src/utils.rs index c89ca94ac..63ed8d96b 100644 --- a/zingolib/src/utils.rs +++ b/zingolib/src/utils.rs @@ -12,6 +12,7 @@ macro_rules! build_method { } }; } +#[cfg(test)] // temporary test gate as no production builders use this macros yet macro_rules! build_method_push { ($name:ident, $localtype:ty) => { #[doc = "Push a $ty to the builder."] @@ -31,6 +32,7 @@ macro_rules! build_push_list { } pub(crate) use build_method; +#[cfg(test)] pub(crate) use build_method_push; #[cfg(test)] pub(crate) use build_push_list; From 6e424764a9d0298e33426f5471ff3aaa6287879c Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Fri, 9 Aug 2024 00:43:35 +0000 Subject: [PATCH 25/26] fixed doctests --- zingolib/src/config.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zingolib/src/config.rs b/zingolib/src/config.rs index 6321c6607..c976f7945 100644 --- a/zingolib/src/config.rs +++ b/zingolib/src/config.rs @@ -163,7 +163,7 @@ impl ZingoConfigBuilder { /// Set the URI of the proxy server we download blockchain information from. /// # Examples /// ``` - /// use crate::config::ZingoConfigBuilder; + /// use zingolib::config::ZingoConfigBuilder; /// use http::Uri; /// assert_eq!(ZingoConfigBuilder::default().set_lightwalletd_uri(("https://zcash.mysideoftheweb.com:19067").parse::().unwrap()).lightwalletd_uri.clone().unwrap(), "https://zcash.mysideoftheweb.com:19067"); /// ``` @@ -178,8 +178,8 @@ impl ZingoConfigBuilder { /// Note "chain type" is not a formal standard. /// # Examples /// ``` - /// use crate::config::ZingoConfigBuilder; - /// use crate::config::ChainType::Testnet; + /// use zingolib::config::ZingoConfigBuilder; + /// use zingolib::config::ChainType::Testnet; /// assert_eq!(ZingoConfigBuilder::default().set_chain(Testnet).create().chain, Testnet); /// ``` pub fn set_chain(&mut self, chain: ChainType) -> &mut Self { @@ -190,7 +190,7 @@ impl ZingoConfigBuilder { /// Set the wallet directory where client transaction data will be stored in a wallet. /// # Examples /// ``` - /// use crate::config::ZingoConfigBuilder; + /// use zingolib::config::ZingoConfigBuilder; /// use tempdir::TempDir; /// let dir = TempDir::new("zingo_doc_test").unwrap().into_path(); /// let config = ZingoConfigBuilder::default().set_wallet_dir(dir.clone()).create(); From e446933659efb052156b8068a4da320029951089 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Fri, 9 Aug 2024 01:07:34 +0000 Subject: [PATCH 26/26] merged config test dep --- libtonode-tests/tests/sync.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libtonode-tests/tests/sync.rs b/libtonode-tests/tests/sync.rs index bda10c279..cc1c3b22c 100644 --- a/libtonode-tests/tests/sync.rs +++ b/libtonode-tests/tests/sync.rs @@ -1,15 +1,23 @@ use tempfile::TempDir; -use zingo_testvectors::seeds::HOSPITAL_MUSEUM_SEED; -use zingoconfig::{construct_lightwalletd_uri, load_clientconfig, DEFAULT_LIGHTWALLETD_SERVER}; -use zingolib::{lightclient::LightClient, wallet::WalletBase}; +use zingolib::{ + config::{construct_lightwalletd_uri, load_clientconfig, DEFAULT_LIGHTWALLETD_SERVER}, + lightclient::LightClient, + testvectors::seeds::HOSPITAL_MUSEUM_SEED, + wallet::WalletBase, +}; #[tokio::test] async fn sync_test() { let uri = construct_lightwalletd_uri(Some(DEFAULT_LIGHTWALLETD_SERVER.to_string())); let temp_dir = TempDir::new().unwrap(); let temp_path = temp_dir.path().to_path_buf(); - let config = - load_clientconfig(uri, Some(temp_path), zingoconfig::ChainType::Mainnet, true).unwrap(); + let config = load_clientconfig( + uri, + Some(temp_path), + zingolib::config::ChainType::Mainnet, + true, + ) + .unwrap(); let lightclient = LightClient::create_from_wallet_base_async( WalletBase::from_string(HOSPITAL_MUSEUM_SEED.to_string()), &config,