Skip to content

Commit

Permalink
Merge pull request #1322 from zancas/mv_zingo_testutils_into_zingolib
Browse files Browse the repository at this point in the history
Mv zingo testutils into zingolib
  • Loading branch information
fluidvanadium authored Aug 9, 2024
2 parents 8146f16 + 27dacc4 commit a4ab4a6
Show file tree
Hide file tree
Showing 140 changed files with 426 additions and 477 deletions.
61 changes: 5 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
# 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",
"zingolib",
"zingoconfig",
"zingo-testvectors",
"zingo-netutils",
"zingo-memo",
"zingo-sync",
Expand Down
5 changes: 1 addition & 4 deletions darkside-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ edition = "2021"
chain_generic_tests = []

[dependencies]
zingolib = { path = "../zingolib", features = ["darkside_tests"] }
zingo-testutils = { path = "../zingo-testutils" }
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 }
Expand Down
4 changes: 2 additions & 2 deletions darkside-tests/src/chain_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 zingo_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;
Expand Down
15 changes: 7 additions & 8 deletions darkside-tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +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::{
self,
use zingolib::testutils::{
incrementalmerkletree::frontier::CommitmentTree,
paths::{get_bin_dir, get_cargo_manifest_dir},
regtest::launch_lightwalletd,
Expand Down Expand Up @@ -397,7 +396,7 @@ pub async fn init_darksidewalletd(
set_port: Option<portpicker::Port>,
) -> 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
)));
Expand Down Expand Up @@ -499,10 +498,10 @@ pub mod scenarios {
};
use zcash_client_backend::{PoolType, ShieldedProtocol};
use zcash_primitives::consensus::{BlockHeight, BranchId};
use zingo_testutils::scenarios::setup::ClientBuilder;
use zingo_testvectors::seeds::HOSPITAL_MUSEUM_SEED;
use zingoconfig::RegtestNetwork;
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,
Expand Down Expand Up @@ -564,7 +563,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,
Expand Down Expand Up @@ -679,7 +678,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)],
)
Expand Down
18 changes: 9 additions & 9 deletions darkside-tests/tests/advanced_reorg_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ use darkside_tests::{

use tokio::time::sleep;
use zcash_primitives::consensus::BlockHeight;
use zingo_testutils::{
use zingolib::config::RegtestNetwork;
use zingolib::lightclient::PoolBalances;
use zingolib::testutils::{
lightclient::from_inputs, paths::get_cargo_manifest_dir, scenarios::setup::ClientBuilder,
};
use zingoconfig::RegtestNetwork;
use zingolib::lightclient::PoolBalances;
use zingolib::wallet::data::summaries::ValueTransferKind;

#[ignore]
#[tokio::test]
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
)));
Expand Down Expand Up @@ -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
)));
Expand Down Expand Up @@ -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
)));
Expand Down Expand Up @@ -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
)));
Expand Down Expand Up @@ -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
)));
Expand Down Expand Up @@ -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
)));
Expand Down
9 changes: 4 additions & 5 deletions darkside-tests/tests/network_interruption_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ use darkside_tests::{
};
use tokio::time::sleep;
use zcash_client_backend::{PoolType, ShieldedProtocol};
use zingo_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::{
Expand All @@ -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
)));
Expand Down
24 changes: 12 additions & 12 deletions darkside-tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ use darkside_tests::utils::{
prepare_darksidewalletd, update_tree_states_for_transaction, DarksideConnector, DarksideHandler,
};
use tokio::time::sleep;
use zingo_testutils::{
get_base_address_macro, lightclient::from_inputs, scenarios::setup::ClientBuilder,
};
use zingo_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
)));
Expand Down Expand Up @@ -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
)));
Expand Down Expand Up @@ -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
)));
Expand All @@ -120,7 +119,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,
Expand Down Expand Up @@ -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 = zingo_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!(
Expand Down
3 changes: 0 additions & 3 deletions libtonode-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ chain_generic_tests = []
[dependencies]
zingolib = { path = "../zingolib", features = ["deprecations", "test-elevation", "sync"] }
zingo-status = { path = "../zingo-status" }
zingo-testutils = { path = "../zingo-testutils" }
zingo-testvectors = { path = "../zingo-testvectors" }
zingoconfig = { path = "../zingoconfig" }
zingo-netutils = { path = "../zingo-netutils" }
zingo-sync = { path = "../zingo-sync" }

Expand Down
Loading

0 comments on commit a4ab4a6

Please sign in to comment.