From 2cbb7d2194e17534784cdbd545293ac9080d4a9d Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Fri, 13 Oct 2023 17:54:07 +0100 Subject: [PATCH 1/7] started creating default scenarios --- zingo-testutils/src/lib.rs | 119 +++++++++++++++------------- zingocli/tests/integration_tests.rs | 90 ++++++++++----------- 2 files changed, 108 insertions(+), 101 deletions(-) diff --git a/zingo-testutils/src/lib.rs b/zingo-testutils/src/lib.rs index 7a2ff58b7..6a82d98e9 100644 --- a/zingo-testutils/src/lib.rs +++ b/zingo-testutils/src/lib.rs @@ -531,22 +531,28 @@ pub mod scenarios { } } } - pub async fn custom_clients( + + pub async fn unfunded_client( regtest_network: zingoconfig::RegtestNetwork, - ) -> (RegtestManager, ChildProcessHandler, ClientBuilder) { - let sb = setup::ScenarioBuilder::build_configure_launch( - Some(REG_Z_ADDR_FROM_ABANDONART.to_string()), - None, - None, - ®test_network, - ) - .await; + ) -> (RegtestManager, ChildProcessHandler, LightClient) { + let mut scenario_builder = + setup::ScenarioBuilder::build_configure_launch(None, None, None, ®test_network) + .await; ( - sb.regtest_manager, - sb.child_process_handler.unwrap(), - sb.client_builder, + scenario_builder.regtest_manager, + scenario_builder.child_process_handler.unwrap(), + scenario_builder + .client_builder + .build_client(HOSPITAL_MUSEUM_SEED.to_string(), 0, false, regtest_network) + .await, ) } + + pub async fn unfunded_client_default() -> (RegtestManager, ChildProcessHandler, LightClient) { + let regtest_network = zingoconfig::RegtestNetwork::new(1, 1, 1, 1, 3, 5); + unfunded_client(regtest_network).await + } + /// Many scenarios need to start with spendable funds. This setup provides /// 3 blocks worth of coinbase to a preregistered spend capability. /// @@ -557,7 +563,7 @@ pub mod scenarios { /// and zcashd (in regtest mode). This setup is intended to produce the most basic /// of scenarios. As scenarios with even less requirements /// become interesting (e.g. without experimental features, or txindices) we'll create more setups. - pub async fn faucet( + pub async fn faucet_default( regtest_network: zingoconfig::RegtestNetwork, ) -> (RegtestManager, ChildProcessHandler, LightClient) { let mut sb = setup::ScenarioBuilder::build_configure_launch( @@ -576,7 +582,42 @@ pub mod scenarios { ) } - pub async fn two_wallet_one_synced_orchard_transaction( + pub async fn faucet_recipient_default( + regtest_network: zingoconfig::RegtestNetwork, + ) -> ( + RegtestManager, + ChildProcessHandler, + LightClient, + LightClient, + ) { + let mut sb = setup::ScenarioBuilder::build_configure_launch( + Some(REG_Z_ADDR_FROM_ABANDONART.to_string()), + None, + None, + ®test_network, + ) + .await; + let faucet = sb.client_builder.build_faucet(false, regtest_network).await; + faucet.do_sync(false).await.unwrap(); + + let recipient = sb + .client_builder + .build_client( + HOSPITAL_MUSEUM_SEED.to_string(), + BASE_HEIGHT as u64, + false, + regtest_network, + ) + .await; + ( + sb.regtest_manager, + sb.child_process_handler.unwrap(), + faucet, + recipient, + ) + } + + pub async fn faucet_funded_recipient_default( value: u64, regtest_network: zingoconfig::RegtestNetwork, ) -> ( @@ -588,7 +629,7 @@ pub mod scenarios { ) { dbg!("0 About to create faucet_recipient."); let (regtest_manager, child_process_handler, faucet, recipient) = - two_wallet_one_miner_fund(regtest_network).await; + faucet_recipient_default(regtest_network).await; dbg!("1 About to increase height and sync faucet."); increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await @@ -618,7 +659,7 @@ pub mod scenarios { ) } - pub async fn two_wallet_one_miner_fund( + pub async fn faucet_recipient_transparent( regtest_network: zingoconfig::RegtestNetwork, ) -> ( RegtestManager, @@ -627,7 +668,7 @@ pub mod scenarios { LightClient, ) { let mut sb = setup::ScenarioBuilder::build_configure_launch( - Some(REG_Z_ADDR_FROM_ABANDONART.to_string()), + Some(REG_T_ADDR_FROM_ABANDONART.to_string()), None, None, ®test_network, @@ -653,54 +694,20 @@ pub mod scenarios { ) } - pub async fn two_wallet_one_miner_fund_transparent( + pub async fn custom_clients_default( regtest_network: zingoconfig::RegtestNetwork, - ) -> ( - RegtestManager, - ChildProcessHandler, - LightClient, - LightClient, - ) { - let mut sb = setup::ScenarioBuilder::build_configure_launch( - Some(REG_T_ADDR_FROM_ABANDONART.to_string()), + ) -> (RegtestManager, ChildProcessHandler, ClientBuilder) { + let sb = setup::ScenarioBuilder::build_configure_launch( + Some(REG_Z_ADDR_FROM_ABANDONART.to_string()), None, None, ®test_network, ) .await; - let faucet = sb.client_builder.build_faucet(false, regtest_network).await; - faucet.do_sync(false).await.unwrap(); - - let recipient = sb - .client_builder - .build_client( - HOSPITAL_MUSEUM_SEED.to_string(), - BASE_HEIGHT as u64, - false, - regtest_network, - ) - .await; ( sb.regtest_manager, sb.child_process_handler.unwrap(), - faucet, - recipient, - ) - } - - pub async fn basic_no_spendable( - regtest_network: zingoconfig::RegtestNetwork, - ) -> (RegtestManager, ChildProcessHandler, LightClient) { - let mut scenario_builder = - setup::ScenarioBuilder::build_configure_launch(None, None, None, ®test_network) - .await; - ( - scenario_builder.regtest_manager, - scenario_builder.child_process_handler.unwrap(), - scenario_builder - .client_builder - .build_client(HOSPITAL_MUSEUM_SEED.to_string(), 0, false, regtest_network) - .await, + sb.client_builder, ) } diff --git a/zingocli/tests/integration_tests.rs b/zingocli/tests/integration_tests.rs index 84287aedb..8e6fd7117 100644 --- a/zingocli/tests/integration_tests.rs +++ b/zingocli/tests/integration_tests.rs @@ -1,4 +1,4 @@ -#![forbid(unsafe_code)] +![forbid(unsafe_code)] #![cfg(feature = "local_env")] pub mod darkside; @@ -46,7 +46,7 @@ use zingolib::{ async fn send_without_reorg_buffer_blocks_gives_correct_error() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (_regtest_manager, _cph, faucet, mut recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; recipient .wallet .transaction_context @@ -69,7 +69,7 @@ async fn send_without_reorg_buffer_blocks_gives_correct_error() { async fn dont_write_unconfirmed() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; faucet .do_send(vec![( &get_base_address!(recipient, "unified"), @@ -142,7 +142,7 @@ async fn dont_write_unconfirmed() { async fn sandblast_filter_preserves_trees() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (ref regtest_manager, _cph, ref faucet, ref recipient, _txid) = - scenarios::two_wallet_one_synced_orchard_transaction(100_000, regtest_network).await; + scenarios::faucet_funded_recipient_default(100_000, regtest_network).await; recipient .wallet .wallet_options @@ -245,7 +245,7 @@ async fn send_to_self_with_no_user_specified_memo_does_not_cause_error() { tracing_log::LogTracer::init().unwrap(); let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, _faucet, recipient, _txid) = - scenarios::two_wallet_one_synced_orchard_transaction(100_000, regtest_network).await; + scenarios::faucet_funded_recipient_default(100_000, regtest_network).await; recipient .do_send(vec![( &get_base_address!(recipient, "unified"), @@ -283,7 +283,7 @@ async fn send_to_self_with_no_user_specified_memo_does_not_cause_error() { async fn factor_do_shield_to_call_do_send() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, __cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 2) .await .unwrap(); @@ -301,7 +301,7 @@ async fn factor_do_shield_to_call_do_send() { async fn sapling_dust_fee_collection() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, __cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; let recipient_sapling = get_base_address!(recipient, "sapling"); let recipient_unified = get_base_address!(recipient, "unified"); check_client_balances!(recipient, o: 0 s: 0 t: 0); @@ -442,7 +442,7 @@ async fn test_scanning_in_watch_only_mode() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients(regtest_network).await; + scenarios::custom_clients_default(regtest_network).await; let faucet = client_builder.build_faucet(false, regtest_network).await; let original_recipient = client_builder .build_client(HOSPITAL_MUSEUM_SEED.to_string(), 0, false, regtest_network) @@ -542,7 +542,7 @@ async fn zcashd_sapling_commitment_tree() { // TODO: Add doc-comment explaining what constraints this test // enforces let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, _faucet) = scenarios::faucet(regtest_network).await; + let (regtest_manager, _cph, _faucet) = scenarios::faucet_default(regtest_network).await; let trees = regtest_manager .get_cli_handle() .args(["z_gettreestate", "1"]) @@ -563,7 +563,7 @@ async fn verify_old_wallet_uses_server_height_in_send() { // "mempool height" which is the server_height + 1 let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; // Ensure that the client has confirmed spendable funds zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 5) .await @@ -599,7 +599,7 @@ async fn actual_empty_zcashd_sapling_commitment_tree() { let finalstates = "000000"; // Setup let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, _client) = scenarios::basic_no_spendable(regtest_network).await; + let (regtest_manager, _cph, _client) = scenarios::unfunded_client_default(regtest_network).await; // Execution: let trees = regtest_manager .get_cli_handle() @@ -638,7 +638,7 @@ async fn actual_empty_zcashd_sapling_commitment_tree() { #[tokio::test] async fn mine_sapling_to_self() { let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet) = scenarios::faucet(regtest_network).await; + let (regtest_manager, _cph, faucet) = scenarios::faucet_default(regtest_network).await; check_client_balances!(faucet, o: 0u64 s: 1_875_000_000u64 t: 0u64); zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await @@ -650,7 +650,7 @@ async fn mine_sapling_to_self() { async fn unspent_notes_are_not_saved() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); @@ -721,7 +721,7 @@ async fn send_mined_sapling_to_orchard() { // consistent with all the notes in the relevant block changing state. // NOTE that the balance doesn't give insight into the distribution across notes. let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet) = scenarios::faucet(regtest_network).await; + let (regtest_manager, _cph, faucet) = scenarios::faucet_default(regtest_network).await; let amount_to_send = 5_000; faucet .do_send(vec![( @@ -758,7 +758,7 @@ async fn note_selection_order() { // * sends back to the original sender's UA let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 5) .await .unwrap(); @@ -870,7 +870,7 @@ async fn from_t_z_o_tz_to_zo_tzo_to_orchard() { // Test all possible promoting note source combinations let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients(regtest_network).await; + scenarios::custom_clients_default(regtest_network).await; let sapling_faucet = client_builder.build_faucet(false, regtest_network).await; let pool_migration_client = client_builder .build_client(HOSPITAL_MUSEUM_SEED.to_string(), 0, false, regtest_network) @@ -1017,7 +1017,7 @@ async fn send_orchard_back_and_forth() { // setup let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; let faucet_to_recipient_amount = 20_000u64; let recipient_to_faucet_amount = 5_000u64; // check start state @@ -1089,7 +1089,7 @@ async fn send_orchard_back_and_forth() { async fn diversified_addresses_receive_funds_in_best_pool() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; for code in ["o", "zo", "z"] { recipient.do_new_address(code).await.unwrap(); } @@ -1125,7 +1125,7 @@ async fn diversified_addresses_receive_funds_in_best_pool() { async fn rescan_still_have_outgoing_metadata() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; faucet .do_send(vec![( get_base_address!(recipient, "sapling").as_str(), @@ -1146,7 +1146,7 @@ async fn rescan_still_have_outgoing_metadata() { #[tokio::test] async fn rescan_still_have_outgoing_metadata_with_sends_to_self() { let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet) = scenarios::faucet(regtest_network).await; + let (regtest_manager, _cph, faucet) = scenarios::faucet_default(regtest_network).await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); @@ -1205,7 +1205,7 @@ async fn rescan_still_have_outgoing_metadata_with_sends_to_self() { async fn handling_of_nonregenerated_diversified_addresses_after_seed_restore() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients(regtest_network).await; + scenarios::custom_clients_default(regtest_network).await; let faucet = client_builder.build_faucet(false, regtest_network).await; faucet.do_sync(false).await.unwrap(); let seed_phrase_of_recipient1 = zcash_primitives::zip339::Mnemonic::from_entropy([1; 32]) @@ -1328,7 +1328,7 @@ async fn handling_of_nonregenerated_diversified_addresses_after_seed_restore() { async fn diversification_deterministic_and_coherent() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (_regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients(regtest_network).await; + scenarios::custom_clients_default(regtest_network).await; let seed_phrase = zcash_primitives::zip339::Mnemonic::from_entropy([1; 32]) .unwrap() .to_string(); @@ -1404,7 +1404,7 @@ async fn diversification_deterministic_and_coherent() { async fn ensure_taddrs_from_old_seeds_work() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (_regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients(regtest_network).await; + scenarios::custom_clients_default(regtest_network).await; // The first taddr generated on commit 9e71a14eb424631372fd08503b1bd83ea763c7fb let transparent_address = "tmFLszfkjgim4zoUMAXpuohnFBAKy99rr2i"; @@ -1422,7 +1422,7 @@ async fn ensure_taddrs_from_old_seeds_work() { async fn t_incoming_t_outgoing_disallowed() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; // 2. Get an incoming transaction to a t address let taddr = get_base_address!(recipient, "transparent"); @@ -1457,7 +1457,7 @@ async fn t_incoming_t_outgoing_disallowed() { async fn send_to_ua_saves_full_ua_in_wallet() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; //utils::increase_height_and_wait_for_client(®test_manager, &faucet, 5).await; let recipient_unified_address = get_base_address!(recipient, "unified"); let sent_value = 50_000; @@ -1502,7 +1502,7 @@ async fn send_to_ua_saves_full_ua_in_wallet() { async fn self_send_to_t_displays_as_one_transaction() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; let recipient_unified_address = get_base_address!(recipient, "unified"); let sent_value = 50_000; faucet @@ -1594,7 +1594,7 @@ async fn sapling_to_sapling_scan_together() { // 2. SpendK_R controls 0 + spend funds let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; // Give the faucet a block reward zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) @@ -1725,7 +1725,7 @@ async fn mempool_and_balance() { let value = 100_000; let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::two_wallet_one_synced_orchard_transaction(value, regtest_network).await; + scenarios::faucet_funded_recipient_default(value, regtest_network).await; let bal = recipient.do_balance().await; println!("{}", serde_json::to_string_pretty(&bal).unwrap()); @@ -1780,7 +1780,7 @@ async fn witness_clearing() { let value: u64 = 100_000; let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, txid) = - scenarios::two_wallet_one_synced_orchard_transaction(value, regtest_network).await; + scenarios::faucet_funded_recipient_default(value, regtest_network).await; dbg!(&txid); let mut txid_bytes = <[u8; 32]>::try_from(hex::decode(txid).unwrap()).unwrap(); // TxId byte order is displayed in the reverse order from how it's encoded, for some reason @@ -1962,7 +1962,7 @@ async fn mempool_clearing_and_full_batch_syncs_correct_trees() { let value = 100_000; let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, orig_transaction_id) = - scenarios::two_wallet_one_synced_orchard_transaction(value, regtest_network).await; + scenarios::faucet_funded_recipient_default(value, regtest_network).await; assert_eq!( do_maybe_recent_txid(&recipient).await["last_txid"], @@ -2310,7 +2310,7 @@ pub mod framework_validation { async fn sapling_incoming_sapling_outgoing() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; let value = 100_000; // 2. Send an incoming transaction to fill the wallet @@ -2504,7 +2504,7 @@ async fn aborted_resync() { let zvalue = 100_000; let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::two_wallet_one_synced_orchard_transaction(zvalue, regtest_network).await; + scenarios::faucet_funded_recipient_default(zvalue, regtest_network).await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 15) .await @@ -2615,7 +2615,7 @@ async fn zero_value_change() { let value = 100_000; let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::two_wallet_one_synced_orchard_transaction(value, regtest_network).await; + scenarios::faucet_funded_recipient_default(value, regtest_network).await; let sent_value = value - u64::from(MINIMUM_FEE); let sent_transaction_id = recipient @@ -2658,7 +2658,7 @@ async fn dust_sends_change_correctly() { let value = 100_000_000; let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::two_wallet_one_synced_orchard_transaction(value, regtest_network).await; + scenarios::faucet_funded_recipient_default(value, regtest_network).await; // Send of less that transaction fee let sent_value = 1000; @@ -2687,7 +2687,7 @@ async fn zero_value_receipts() { let value = 100_000_000; let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::two_wallet_one_synced_orchard_transaction(value, regtest_network).await; + scenarios::faucet_funded_recipient_default(value, regtest_network).await; let sent_value = 0; let _sent_transaction_id = faucet @@ -2725,7 +2725,7 @@ async fn zero_value_receipts() { async fn by_address_finsight() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; let base_uaddress = get_base_address!(recipient, "unified"); zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 2) .await @@ -2775,7 +2775,7 @@ async fn by_address_finsight() { #[tokio::test] async fn load_old_wallet_at_reorged_height() { let regtest_network = RegtestNetwork::all_upgrades_active(); - let (ref regtest_manager, cph, ref faucet) = scenarios::faucet(regtest_network).await; + let (ref regtest_manager, cph, ref faucet) = scenarios::faucet_default(regtest_network).await; println!("Shutting down initial zcd/lwd unneeded processes"); drop(cph); @@ -2920,7 +2920,7 @@ async fn load_old_wallet_at_reorged_height() { async fn shield_sapling() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; let sapling_dust = 100; let _sent_transaction_id = faucet @@ -3006,7 +3006,7 @@ async fn send_to_transparent_and_sapling_maintain_balance() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (ref regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::two_wallet_one_synced_orchard_transaction( + scenarios::faucet_funded_recipient_default( recipient_initial_funds, regtest_network, ) @@ -3282,7 +3282,7 @@ async fn sends_to_self_handle_balance_properly() { let transparent_funding = 100_000; let regtest_network = RegtestNetwork::all_upgrades_active(); let (ref regtest_manager, _cph, faucet, ref recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; faucet .do_send(vec![( &get_base_address!(recipient, "sapling"), @@ -3341,7 +3341,7 @@ async fn sends_to_self_handle_balance_properly() { #[tokio::test] async fn sync_all_epochs_from_sapling() { let regtest_network = RegtestNetwork::new(1, 1, 3, 5, 7, 9); - let (regtest_manager, _cph, lightclient) = scenarios::basic_no_spendable(regtest_network).await; + let (regtest_manager, _cph, lightclient) = scenarios::unfunded_client_default(regtest_network).await; increase_height_and_wait_for_client(®test_manager, &lightclient, 12) .await .unwrap(); @@ -3353,7 +3353,7 @@ async fn sync_all_epochs_from_sapling() { #[tokio::test] async fn sync_all_epochs() { let regtest_network = RegtestNetwork::new(1, 3, 5, 7, 9, 11); - let (regtest_manager, _cph, lightclient) = scenarios::basic_no_spendable(regtest_network).await; + let (regtest_manager, _cph, lightclient) = scenarios::unfunded_client_default(regtest_network).await; increase_height_and_wait_for_client(®test_manager, &lightclient, 12) .await .unwrap(); @@ -3365,7 +3365,7 @@ async fn sync_all_epochs() { async fn mine_to_transparent_and_shield() { let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, _recipient) = - scenarios::two_wallet_one_miner_fund_transparent(regtest_network).await; + scenarios::faucet_recipient_transparent(regtest_network).await; increase_height_and_wait_for_client(®test_manager, &faucet, 100) .await .unwrap(); @@ -3375,7 +3375,7 @@ async fn mine_to_transparent_and_shield() { #[tokio::test] async fn shield_heartwood_sapling_funds() { let regtest_network = RegtestNetwork::new(1, 1, 1, 1, 3, 5); - let (regtest_manager, _cph, faucet) = scenarios::faucet(regtest_network).await; + let (regtest_manager, _cph, faucet) = scenarios::faucet_default(regtest_network).await; increase_height_and_wait_for_client(®test_manager, &faucet, 3) .await .unwrap(); @@ -3391,7 +3391,7 @@ async fn shield_heartwood_sapling_funds() { async fn send_heartwood_sapling_funds() { let regtest_network = RegtestNetwork::new(1, 1, 1, 1, 3, 5); let (regtest_manager, _cph, faucet, recipient) = - scenarios::two_wallet_one_miner_fund(regtest_network).await; + scenarios::faucet_recipient_default(regtest_network).await; increase_height_and_wait_for_client(®test_manager, &faucet, 3) .await .unwrap(); From 0da20d50cb878920666378b12a307492d41bca15 Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Mon, 16 Oct 2023 15:14:17 +0100 Subject: [PATCH 2/7] added default scenarios --- zingo-testutils/src/lib.rs | 56 +++++++-- zingocli/tests/integration_tests.rs | 170 ++++++++++------------------ zingoconfig/src/lib.rs | 6 + 3 files changed, 112 insertions(+), 120 deletions(-) diff --git a/zingo-testutils/src/lib.rs b/zingo-testutils/src/lib.rs index 6a82d98e9..7c2637b78 100644 --- a/zingo-testutils/src/lib.rs +++ b/zingo-testutils/src/lib.rs @@ -227,10 +227,13 @@ pub mod scenarios { //! generated the address registered as the `minetoaddress` in the zcash.conf that's //! used by the 'regetst mode' zcashs backing these tests.). //! HELPERS: - //! If you just need a faucet, use the "faucet_only" helper. + //! If you just need a faucet, use the "faucet" helper. //! If you need a faucet, and a single recipient, use 'faucet_recipient` - //! For less common client configurations use the client_manager directly with + //! For less common client configurations use the client builder directly with //! custom_clients + //! All scenarios have a default (i.e. faucet_default) which take no 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::{ @@ -549,7 +552,7 @@ pub mod scenarios { } pub async fn unfunded_client_default() -> (RegtestManager, ChildProcessHandler, LightClient) { - let regtest_network = zingoconfig::RegtestNetwork::new(1, 1, 1, 1, 3, 5); + let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); unfunded_client(regtest_network).await } @@ -563,7 +566,7 @@ pub mod scenarios { /// and zcashd (in regtest mode). This setup is intended to produce the most basic /// of scenarios. As scenarios with even less requirements /// become interesting (e.g. without experimental features, or txindices) we'll create more setups. - pub async fn faucet_default( + pub async fn faucet( regtest_network: zingoconfig::RegtestNetwork, ) -> (RegtestManager, ChildProcessHandler, LightClient) { let mut sb = setup::ScenarioBuilder::build_configure_launch( @@ -582,7 +585,12 @@ pub mod scenarios { ) } - pub async fn faucet_recipient_default( + pub async fn faucet_default() -> (RegtestManager, ChildProcessHandler, LightClient) { + let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); + faucet(regtest_network).await + } + + pub async fn faucet_recipient( regtest_network: zingoconfig::RegtestNetwork, ) -> ( RegtestManager, @@ -617,7 +625,17 @@ pub mod scenarios { ) } - pub async fn faucet_funded_recipient_default( + pub async fn faucet_recipient_default() -> ( + RegtestManager, + ChildProcessHandler, + LightClient, + LightClient, + ) { + let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); + faucet_recipient(regtest_network).await + } + + pub async fn faucet_funded_recipient( value: u64, regtest_network: zingoconfig::RegtestNetwork, ) -> ( @@ -629,7 +647,7 @@ pub mod scenarios { ) { dbg!("0 About to create faucet_recipient."); let (regtest_manager, child_process_handler, faucet, recipient) = - faucet_recipient_default(regtest_network).await; + faucet_recipient(regtest_network).await; dbg!("1 About to increase height and sync faucet."); increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await @@ -659,6 +677,17 @@ pub mod scenarios { ) } + pub async fn faucet_funded_recipient_default() -> ( + RegtestManager, + ChildProcessHandler, + LightClient, + LightClient, + String, + ) { + let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); + faucet_funded_recipient(100000, regtest_network).await + } + pub async fn faucet_recipient_transparent( regtest_network: zingoconfig::RegtestNetwork, ) -> ( @@ -694,7 +723,7 @@ pub mod scenarios { ) } - pub async fn custom_clients_default( + pub async fn custom_clients( regtest_network: zingoconfig::RegtestNetwork, ) -> (RegtestManager, ChildProcessHandler, ClientBuilder) { let sb = setup::ScenarioBuilder::build_configure_launch( @@ -711,6 +740,17 @@ pub mod scenarios { ) } + pub async fn custom_clients_default() -> ( + RegtestManager, + ChildProcessHandler, + ClientBuilder, + zingoconfig::RegtestNetwork, + ) { + let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); + let (regtest_manager, cph, client_builder) = custom_clients(regtest_network).await; + (regtest_manager, cph, client_builder, regtest_network) + } + pub async fn unfunded_mobileclient() -> (RegtestManager, ChildProcessHandler) { let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); let scenario_builder = setup::ScenarioBuilder::build_configure_launch( diff --git a/zingocli/tests/integration_tests.rs b/zingocli/tests/integration_tests.rs index 8e6fd7117..66c61e059 100644 --- a/zingocli/tests/integration_tests.rs +++ b/zingocli/tests/integration_tests.rs @@ -1,4 +1,4 @@ -![forbid(unsafe_code)] +#![forbid(unsafe_code)] #![cfg(feature = "local_env")] pub mod darkside; @@ -44,9 +44,8 @@ use zingolib::{ #[tokio::test] async fn send_without_reorg_buffer_blocks_gives_correct_error() { - let regtest_network = RegtestNetwork::all_upgrades_active(); let (_regtest_manager, _cph, faucet, mut recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + scenarios::faucet_recipient_default().await; recipient .wallet .transaction_context @@ -67,9 +66,9 @@ async fn send_without_reorg_buffer_blocks_gives_correct_error() { #[tokio::test] async fn dont_write_unconfirmed() { - let regtest_network = RegtestNetwork::all_upgrades_active(); + let regtest_network = RegtestNetwork::scenario_default(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + scenarios::faucet_recipient(regtest_network).await; faucet .do_send(vec![( &get_base_address!(recipient, "unified"), @@ -140,9 +139,8 @@ async fn dont_write_unconfirmed() { #[tokio::test] async fn sandblast_filter_preserves_trees() { - let regtest_network = RegtestNetwork::all_upgrades_active(); let (ref regtest_manager, _cph, ref faucet, ref recipient, _txid) = - scenarios::faucet_funded_recipient_default(100_000, regtest_network).await; + scenarios::faucet_funded_recipient_default().await; recipient .wallet .wallet_options @@ -203,7 +201,7 @@ async fn sandblast_filter_preserves_trees() { #[tokio::test] async fn load_and_parse_different_wallet_versions() { - let regtest_network = RegtestNetwork::all_upgrades_active(); + let regtest_network = RegtestNetwork::scenario_default(); let (_sap_wallet, _sap_path, sap_dir) = zingo_testutils::get_wallet_nym("sap_only").unwrap(); let (_loaded_wallet, _) = zingo_testutils::load_wallet(sap_dir, ChainType::Regtest(regtest_network)).await; @@ -243,9 +241,8 @@ async fn list_transactions_include_foreign() { #[traced_test] async fn send_to_self_with_no_user_specified_memo_does_not_cause_error() { tracing_log::LogTracer::init().unwrap(); - let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, _faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default(100_000, regtest_network).await; + scenarios::faucet_funded_recipient_default().await; recipient .do_send(vec![( &get_base_address!(recipient, "unified"), @@ -281,9 +278,7 @@ async fn send_to_self_with_no_user_specified_memo_does_not_cause_error() { #[tokio::test] async fn factor_do_shield_to_call_do_send() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, __cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, __cph, faucet, recipient) = scenarios::faucet_recipient_default().await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 2) .await .unwrap(); @@ -299,9 +294,7 @@ async fn factor_do_shield_to_call_do_send() { #[tokio::test] async fn sapling_dust_fee_collection() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, __cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, __cph, faucet, recipient) = scenarios::faucet_recipient_default().await; let recipient_sapling = get_base_address!(recipient, "sapling"); let recipient_unified = get_base_address!(recipient, "unified"); check_client_balances!(recipient, o: 0 s: 0 t: 0); @@ -440,9 +433,8 @@ async fn test_scanning_in_watch_only_mode() { // - wallet will not detect funds on internal addresses // see: https://github.com/zingolabs/zingolib/issues/246 - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients_default(regtest_network).await; + let (regtest_manager, _cph, mut client_builder, regtest_network) = + scenarios::custom_clients_default().await; let faucet = client_builder.build_faucet(false, regtest_network).await; let original_recipient = client_builder .build_client(HOSPITAL_MUSEUM_SEED.to_string(), 0, false, regtest_network) @@ -541,8 +533,7 @@ async fn zcashd_sapling_commitment_tree() { // TODO: Make this test assert something, what is this a test of? // TODO: Add doc-comment explaining what constraints this test // enforces - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, _faucet) = scenarios::faucet_default(regtest_network).await; + let (regtest_manager, _cph, _faucet) = scenarios::faucet_default().await; let trees = regtest_manager .get_cli_handle() .args(["z_gettreestate", "1"]) @@ -561,9 +552,7 @@ async fn verify_old_wallet_uses_server_height_in_send() { // interrupting send, it made it immediately obvious that this was // the wrong height to use! The correct height is the // "mempool height" which is the server_height + 1 - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + 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) .await @@ -598,8 +587,7 @@ async fn actual_empty_zcashd_sapling_commitment_tree() { "ae2935f1dfd8a24aed7c70df7de3a668eb7a49b1319880dde2bbd9031ae5d82f"; let finalstates = "000000"; // Setup - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, _client) = scenarios::unfunded_client_default(regtest_network).await; + let (regtest_manager, _cph, _client) = scenarios::unfunded_client_default().await; // Execution: let trees = regtest_manager .get_cli_handle() @@ -637,8 +625,7 @@ async fn actual_empty_zcashd_sapling_commitment_tree() { #[tokio::test] async fn mine_sapling_to_self() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet) = scenarios::faucet_default(regtest_network).await; + let (regtest_manager, _cph, faucet) = scenarios::faucet_default().await; check_client_balances!(faucet, o: 0u64 s: 1_875_000_000u64 t: 0u64); zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await @@ -648,9 +635,9 @@ async fn mine_sapling_to_self() { #[tokio::test] async fn unspent_notes_are_not_saved() { - let regtest_network = RegtestNetwork::all_upgrades_active(); + let regtest_network = RegtestNetwork::scenario_default(); let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + scenarios::faucet_recipient(regtest_network).await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); @@ -720,8 +707,7 @@ async fn send_mined_sapling_to_orchard() { // debiting unverified_orchard_balance and crediting verified_orchard_balance. The debit amount is // consistent with all the notes in the relevant block changing state. // NOTE that the balance doesn't give insight into the distribution across notes. - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet) = scenarios::faucet_default(regtest_network).await; + let (regtest_manager, _cph, faucet) = scenarios::faucet_default().await; let amount_to_send = 5_000; faucet .do_send(vec![( @@ -756,9 +742,7 @@ async fn note_selection_order() { // In addition to testing the order in which notes are selected this test: // * sends to a sapling address // * sends back to the original sender's UA - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 5) .await .unwrap(); @@ -868,9 +852,8 @@ async fn note_selection_order() { #[tokio::test] async fn from_t_z_o_tz_to_zo_tzo_to_orchard() { // Test all possible promoting note source combinations - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients_default(regtest_network).await; + let (regtest_manager, _cph, mut client_builder, regtest_network) = + scenarios::custom_clients_default().await; let sapling_faucet = client_builder.build_faucet(false, regtest_network).await; let pool_migration_client = client_builder .build_client(HOSPITAL_MUSEUM_SEED.to_string(), 0, false, regtest_network) @@ -1015,9 +998,7 @@ async fn from_t_z_o_tz_to_zo_tzo_to_orchard() { #[tokio::test] async fn send_orchard_back_and_forth() { // setup - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; let faucet_to_recipient_amount = 20_000u64; let recipient_to_faucet_amount = 5_000u64; // check start state @@ -1087,9 +1068,7 @@ async fn send_orchard_back_and_forth() { #[tokio::test] async fn diversified_addresses_receive_funds_in_best_pool() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; for code in ["o", "zo", "z"] { recipient.do_new_address(code).await.unwrap(); } @@ -1123,9 +1102,7 @@ async fn diversified_addresses_receive_funds_in_best_pool() { #[tokio::test] async fn rescan_still_have_outgoing_metadata() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; faucet .do_send(vec![( get_base_address!(recipient, "sapling").as_str(), @@ -1145,8 +1122,7 @@ async fn rescan_still_have_outgoing_metadata() { #[tokio::test] async fn rescan_still_have_outgoing_metadata_with_sends_to_self() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet) = scenarios::faucet_default(regtest_network).await; + let (regtest_manager, _cph, faucet) = scenarios::faucet_default().await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) .await .unwrap(); @@ -1203,9 +1179,8 @@ async fn rescan_still_have_outgoing_metadata_with_sends_to_self() { /// is capable of recovering the diversified _receiver_. #[tokio::test] async fn handling_of_nonregenerated_diversified_addresses_after_seed_restore() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients_default(regtest_network).await; + let (regtest_manager, _cph, mut client_builder, regtest_network) = + scenarios::custom_clients_default().await; let faucet = client_builder.build_faucet(false, regtest_network).await; faucet.do_sync(false).await.unwrap(); let seed_phrase_of_recipient1 = zcash_primitives::zip339::Mnemonic::from_entropy([1; 32]) @@ -1326,9 +1301,8 @@ async fn handling_of_nonregenerated_diversified_addresses_after_seed_restore() { #[tokio::test] async fn diversification_deterministic_and_coherent() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (_regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients_default(regtest_network).await; + let (_regtest_manager, _cph, mut client_builder, regtest_network) = + scenarios::custom_clients_default().await; let seed_phrase = zcash_primitives::zip339::Mnemonic::from_entropy([1; 32]) .unwrap() .to_string(); @@ -1402,9 +1376,8 @@ async fn diversification_deterministic_and_coherent() { #[tokio::test] async fn ensure_taddrs_from_old_seeds_work() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (_regtest_manager, _cph, mut client_builder) = - scenarios::custom_clients_default(regtest_network).await; + let (_regtest_manager, _cph, mut client_builder, regtest_network) = + scenarios::custom_clients_default().await; // The first taddr generated on commit 9e71a14eb424631372fd08503b1bd83ea763c7fb let transparent_address = "tmFLszfkjgim4zoUMAXpuohnFBAKy99rr2i"; @@ -1420,9 +1393,7 @@ async fn ensure_taddrs_from_old_seeds_work() { #[tokio::test] async fn t_incoming_t_outgoing_disallowed() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; // 2. Get an incoming transaction to a t address let taddr = get_base_address!(recipient, "transparent"); @@ -1455,9 +1426,7 @@ async fn t_incoming_t_outgoing_disallowed() { #[tokio::test] async fn send_to_ua_saves_full_ua_in_wallet() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; //utils::increase_height_and_wait_for_client(®test_manager, &faucet, 5).await; let recipient_unified_address = get_base_address!(recipient, "unified"); let sent_value = 50_000; @@ -1500,9 +1469,7 @@ async fn send_to_ua_saves_full_ua_in_wallet() { #[tokio::test] async fn self_send_to_t_displays_as_one_transaction() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; let recipient_unified_address = get_base_address!(recipient, "unified"); let sent_value = 50_000; faucet @@ -1592,9 +1559,7 @@ async fn sapling_to_sapling_scan_together() { // Constraints: // 1. SpendK_S controls start - spend funds // 2. SpendK_R controls 0 + spend funds - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; // Give the faucet a block reward zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) @@ -1723,9 +1688,9 @@ async fn load_wallet_from_v26_dat_file() { #[tokio::test] async fn mempool_and_balance() { let value = 100_000; - let regtest_network = RegtestNetwork::all_upgrades_active(); + let regtest_network = RegtestNetwork::scenario_default(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default(value, regtest_network).await; + scenarios::faucet_funded_recipient(value, regtest_network).await; let bal = recipient.do_balance().await; println!("{}", serde_json::to_string_pretty(&bal).unwrap()); @@ -1777,10 +1742,8 @@ async fn mempool_and_balance() { #[tokio::test] async fn witness_clearing() { - let value: u64 = 100_000; - let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, txid) = - scenarios::faucet_funded_recipient_default(value, regtest_network).await; + scenarios::faucet_funded_recipient_default().await; dbg!(&txid); let mut txid_bytes = <[u8; 32]>::try_from(hex::decode(txid).unwrap()).unwrap(); // TxId byte order is displayed in the reverse order from how it's encoded, for some reason @@ -1960,9 +1923,9 @@ async fn mempool_clearing_and_full_batch_syncs_correct_trees() { } } let value = 100_000; - let regtest_network = RegtestNetwork::all_upgrades_active(); + let regtest_network = RegtestNetwork::scenario_default(); let (regtest_manager, _cph, faucet, recipient, orig_transaction_id) = - scenarios::faucet_funded_recipient_default(value, regtest_network).await; + scenarios::faucet_funded_recipient(value, regtest_network).await; assert_eq!( do_maybe_recent_txid(&recipient).await["last_txid"], @@ -2259,7 +2222,7 @@ pub mod framework_validation { #[tokio::test] async fn reboot_zcashd() { - let regtest_network = RegtestNetwork::all_upgrades_active(); + let regtest_network = RegtestNetwork::scenario_default(); let ScenarioBuilder { regtest_manager, child_process_handler, @@ -2308,9 +2271,7 @@ pub mod framework_validation { #[tokio::test] async fn sapling_incoming_sapling_outgoing() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; let value = 100_000; // 2. Send an incoming transaction to fill the wallet @@ -2501,10 +2462,8 @@ async fn sapling_incoming_sapling_outgoing() { #[tokio::test] async fn aborted_resync() { - let zvalue = 100_000; - let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default(zvalue, regtest_network).await; + scenarios::faucet_funded_recipient_default().await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 15) .await @@ -2613,9 +2572,9 @@ async fn aborted_resync() { async fn zero_value_change() { // 2. Send an incoming transaction to fill the wallet let value = 100_000; - let regtest_network = RegtestNetwork::all_upgrades_active(); + let regtest_network = RegtestNetwork::scenario_default(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default(value, regtest_network).await; + scenarios::faucet_funded_recipient(value, regtest_network).await; let sent_value = value - u64::from(MINIMUM_FEE); let sent_transaction_id = recipient @@ -2655,10 +2614,8 @@ async fn zero_value_change() { #[tokio::test] async fn dust_sends_change_correctly() { - let value = 100_000_000; - let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default(value, regtest_network).await; + scenarios::faucet_funded_recipient_default().await; // Send of less that transaction fee let sent_value = 1000; @@ -2684,10 +2641,8 @@ async fn dust_sends_change_correctly() { #[tokio::test] async fn zero_value_receipts() { - let value = 100_000_000; - let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default(value, regtest_network).await; + scenarios::faucet_funded_recipient_default().await; let sent_value = 0; let _sent_transaction_id = faucet @@ -2723,9 +2678,7 @@ async fn zero_value_receipts() { #[tokio::test] async fn by_address_finsight() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; let base_uaddress = get_base_address!(recipient, "unified"); zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 2) .await @@ -2774,8 +2727,8 @@ async fn by_address_finsight() { #[tokio::test] async fn load_old_wallet_at_reorged_height() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (ref regtest_manager, cph, ref faucet) = scenarios::faucet_default(regtest_network).await; + let regtest_network = RegtestNetwork::scenario_default(); + let (ref regtest_manager, cph, ref faucet) = scenarios::faucet(regtest_network).await; println!("Shutting down initial zcd/lwd unneeded processes"); drop(cph); @@ -2918,9 +2871,7 @@ async fn load_old_wallet_at_reorged_height() { #[tokio::test] async fn shield_sapling() { - let regtest_network = RegtestNetwork::all_upgrades_active(); - let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient_default().await; let sapling_dust = 100; let _sent_transaction_id = faucet @@ -3004,13 +2955,9 @@ async fn send_to_transparent_and_sapling_maintain_balance() { let second_send_to_sapling = 20_000; let third_send_to_transparent = 20_000; - let regtest_network = RegtestNetwork::all_upgrades_active(); + let regtest_network = RegtestNetwork::scenario_default(); let (ref regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default( - recipient_initial_funds, - regtest_network, - ) - .await; + scenarios::faucet_funded_recipient(recipient_initial_funds, regtest_network).await; let expected_transactions = json::parse( r#" @@ -3280,9 +3227,8 @@ async fn send_to_transparent_and_sapling_maintain_balance() { #[tokio::test] async fn sends_to_self_handle_balance_properly() { let transparent_funding = 100_000; - let regtest_network = RegtestNetwork::all_upgrades_active(); let (ref regtest_manager, _cph, faucet, ref recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + scenarios::faucet_recipient_default().await; faucet .do_send(vec![( &get_base_address!(recipient, "sapling"), @@ -3341,7 +3287,7 @@ async fn sends_to_self_handle_balance_properly() { #[tokio::test] async fn sync_all_epochs_from_sapling() { let regtest_network = RegtestNetwork::new(1, 1, 3, 5, 7, 9); - let (regtest_manager, _cph, lightclient) = scenarios::unfunded_client_default(regtest_network).await; + let (regtest_manager, _cph, lightclient) = scenarios::unfunded_client(regtest_network).await; increase_height_and_wait_for_client(®test_manager, &lightclient, 12) .await .unwrap(); @@ -3353,7 +3299,7 @@ async fn sync_all_epochs_from_sapling() { #[tokio::test] async fn sync_all_epochs() { let regtest_network = RegtestNetwork::new(1, 3, 5, 7, 9, 11); - let (regtest_manager, _cph, lightclient) = scenarios::unfunded_client_default(regtest_network).await; + let (regtest_manager, _cph, lightclient) = scenarios::unfunded_client(regtest_network).await; increase_height_and_wait_for_client(®test_manager, &lightclient, 12) .await .unwrap(); @@ -3375,7 +3321,7 @@ async fn mine_to_transparent_and_shield() { #[tokio::test] async fn shield_heartwood_sapling_funds() { let regtest_network = RegtestNetwork::new(1, 1, 1, 1, 3, 5); - let (regtest_manager, _cph, faucet) = scenarios::faucet_default(regtest_network).await; + let (regtest_manager, _cph, faucet) = scenarios::faucet(regtest_network).await; increase_height_and_wait_for_client(®test_manager, &faucet, 3) .await .unwrap(); @@ -3391,7 +3337,7 @@ async fn shield_heartwood_sapling_funds() { async fn send_heartwood_sapling_funds() { let regtest_network = RegtestNetwork::new(1, 1, 1, 1, 3, 5); let (regtest_manager, _cph, faucet, recipient) = - scenarios::faucet_recipient_default(regtest_network).await; + scenarios::faucet_recipient(regtest_network).await; increase_height_and_wait_for_client(®test_manager, &faucet, 3) .await .unwrap(); diff --git a/zingoconfig/src/lib.rs b/zingoconfig/src/lib.rs index f0a4180be..003e3616e 100644 --- a/zingoconfig/src/lib.rs +++ b/zingoconfig/src/lib.rs @@ -447,6 +447,12 @@ impl RegtestNetwork { activation_heights: ActivationHeights::new(1, 1, 1, 1, 1, orchard_activation_height), } } + pub fn scenario_default() -> Self { + Self { + activation_heights: ActivationHeights::new(1, 1, 1, 1, 1, 1), + // activation_heights: ActivationHeights::new(1, 1, 1, 1, 3, 5), + } + } // Network parameters pub fn activation_height(&self, nu: NetworkUpgrade) -> Option { From 1e2c9a8b0822f7972fc0b5699598cd442122fc5a Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Mon, 16 Oct 2023 17:11:29 +0100 Subject: [PATCH 3/7] finished scenarios and added test --- zingo-testutils/src/lib.rs | 92 ++++++++++++++++++++++------- zingocli/tests/integration_tests.rs | 51 ++++++++++------ 2 files changed, 104 insertions(+), 39 deletions(-) diff --git a/zingo-testutils/src/lib.rs b/zingo-testutils/src/lib.rs index 7c2637b78..f74554dba 100644 --- a/zingo-testutils/src/lib.rs +++ b/zingo-testutils/src/lib.rs @@ -636,48 +636,81 @@ pub mod scenarios { } pub async fn faucet_funded_recipient( - value: u64, + orchard_funds: Option, + sapling_funds: Option, + transparent_funds: Option, regtest_network: zingoconfig::RegtestNetwork, ) -> ( RegtestManager, ChildProcessHandler, LightClient, LightClient, - String, + Option, + Option, + Option, ) { - dbg!("0 About to create faucet_recipient."); let (regtest_manager, child_process_handler, faucet, recipient) = faucet_recipient(regtest_network).await; - dbg!("1 About to increase height and sync faucet."); - increase_height_and_wait_for_client(®test_manager, &faucet, 1) - .await - .unwrap(); - dbg!("2 faucet synced."); - let txid = faucet - .do_send(vec![( - &get_base_address!(recipient, "unified"), - value, - None, - )]) - .await - .unwrap(); - dbg!("3 faucet send complete"); + let orchard_txid = if let Some(funds) = orchard_funds { + Some( + faucet + .do_send(vec![( + &get_base_address!(recipient, "unified"), + funds, + None, + )]) + .await + .unwrap(), + ) + } else { + None + }; + let sapling_txid = if let Some(funds) = sapling_funds { + Some( + faucet + .do_send(vec![( + &get_base_address!(recipient, "sapling"), + funds, + None, + )]) + .await + .unwrap(), + ) + } else { + None + }; + let transparent_txid = if let Some(funds) = transparent_funds { + Some( + faucet + .do_send(vec![( + &get_base_address!(recipient, "transparent"), + funds, + None, + )]) + .await + .unwrap(), + ) + } else { + None + }; increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); - dbg!("4 recipient increased and synced."); - dbg!("5 about to sync faucet."); faucet.do_sync(false).await.unwrap(); ( regtest_manager, child_process_handler, faucet, recipient, - txid, + orchard_txid, + sapling_txid, + transparent_txid, ) } - pub async fn faucet_funded_recipient_default() -> ( + pub async fn faucet_funded_recipient_default( + orchard_funds: u64, + ) -> ( RegtestManager, ChildProcessHandler, LightClient, @@ -685,7 +718,22 @@ pub mod scenarios { String, ) { let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); - faucet_funded_recipient(100000, regtest_network).await + let ( + regtest_manager, + cph, + faucet, + recipient, + orchard_txid, + _sapling_txid, + _transparent_txid, + ) = faucet_funded_recipient(Some(orchard_funds), None, None, regtest_network).await; + ( + regtest_manager, + cph, + faucet, + recipient, + orchard_txid.unwrap(), + ) } pub async fn faucet_recipient_transparent( diff --git a/zingocli/tests/integration_tests.rs b/zingocli/tests/integration_tests.rs index 66c61e059..239f348e1 100644 --- a/zingocli/tests/integration_tests.rs +++ b/zingocli/tests/integration_tests.rs @@ -140,7 +140,7 @@ async fn dont_write_unconfirmed() { #[tokio::test] async fn sandblast_filter_preserves_trees() { let (ref regtest_manager, _cph, ref faucet, ref recipient, _txid) = - scenarios::faucet_funded_recipient_default().await; + scenarios::faucet_funded_recipient_default(100_000).await; recipient .wallet .wallet_options @@ -242,7 +242,7 @@ async fn list_transactions_include_foreign() { async fn send_to_self_with_no_user_specified_memo_does_not_cause_error() { tracing_log::LogTracer::init().unwrap(); let (regtest_manager, _cph, _faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default().await; + scenarios::faucet_funded_recipient_default(100_000).await; recipient .do_send(vec![( &get_base_address!(recipient, "unified"), @@ -1688,9 +1688,8 @@ async fn load_wallet_from_v26_dat_file() { #[tokio::test] async fn mempool_and_balance() { let value = 100_000; - let regtest_network = RegtestNetwork::scenario_default(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient(value, regtest_network).await; + scenarios::faucet_funded_recipient_default(value).await; let bal = recipient.do_balance().await; println!("{}", serde_json::to_string_pretty(&bal).unwrap()); @@ -1743,7 +1742,7 @@ async fn mempool_and_balance() { #[tokio::test] async fn witness_clearing() { let (regtest_manager, _cph, faucet, recipient, txid) = - scenarios::faucet_funded_recipient_default().await; + scenarios::faucet_funded_recipient_default(100_000).await; dbg!(&txid); let mut txid_bytes = <[u8; 32]>::try_from(hex::decode(txid).unwrap()).unwrap(); // TxId byte order is displayed in the reverse order from how it's encoded, for some reason @@ -1923,9 +1922,8 @@ async fn mempool_clearing_and_full_batch_syncs_correct_trees() { } } let value = 100_000; - let regtest_network = RegtestNetwork::scenario_default(); let (regtest_manager, _cph, faucet, recipient, orig_transaction_id) = - scenarios::faucet_funded_recipient(value, regtest_network).await; + scenarios::faucet_funded_recipient_default(value).await; assert_eq!( do_maybe_recent_txid(&recipient).await["last_txid"], @@ -2103,7 +2101,7 @@ async fn mempool_clearing_and_full_batch_syncs_correct_trees() { zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 10) .await .unwrap(); - assert_eq!(recipient.wallet.last_synced_height().await, 21); + assert_eq!(recipient.wallet.last_synced_height().await, 20); let notes = recipient.do_list_notes(true).await; @@ -2463,7 +2461,7 @@ async fn sapling_incoming_sapling_outgoing() { #[tokio::test] async fn aborted_resync() { let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default().await; + scenarios::faucet_funded_recipient_default(100_000).await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 15) .await @@ -2526,11 +2524,11 @@ async fn aborted_resync() { // 5. Now, we'll manually remove some of the blocks in the wallet, pretending that the sync was aborted in the middle. // We'll remove the top 20 blocks, so now the wallet only has the first 3 blocks recipient.wallet.blocks.write().await.drain(0..20); - assert_eq!(recipient.wallet.last_synced_height().await, 5); + assert_eq!(recipient.wallet.last_synced_height().await, 4); // 6. Do a sync again recipient.do_sync(true).await.unwrap(); - assert_eq!(recipient.wallet.last_synced_height().await, 25); + assert_eq!(recipient.wallet.last_synced_height().await, 24); // 7. Should be exactly the same let notes_after = recipient.do_list_notes(true).await; @@ -2572,9 +2570,8 @@ async fn aborted_resync() { async fn zero_value_change() { // 2. Send an incoming transaction to fill the wallet let value = 100_000; - let regtest_network = RegtestNetwork::scenario_default(); let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient(value, regtest_network).await; + scenarios::faucet_funded_recipient_default(value).await; let sent_value = value - u64::from(MINIMUM_FEE); let sent_transaction_id = recipient @@ -2615,7 +2612,7 @@ async fn zero_value_change() { #[tokio::test] async fn dust_sends_change_correctly() { let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default().await; + scenarios::faucet_funded_recipient_default(100_000).await; // Send of less that transaction fee let sent_value = 1000; @@ -2642,7 +2639,7 @@ async fn dust_sends_change_correctly() { #[tokio::test] async fn zero_value_receipts() { let (regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient_default().await; + scenarios::faucet_funded_recipient_default(100_000).await; let sent_value = 0; let _sent_transaction_id = faucet @@ -2955,9 +2952,8 @@ async fn send_to_transparent_and_sapling_maintain_balance() { let second_send_to_sapling = 20_000; let third_send_to_transparent = 20_000; - let regtest_network = RegtestNetwork::scenario_default(); let (ref regtest_manager, _cph, faucet, recipient, _txid) = - scenarios::faucet_funded_recipient(recipient_initial_funds, regtest_network).await; + scenarios::faucet_funded_recipient_default(recipient_initial_funds).await; let expected_transactions = json::parse( r#" @@ -3356,3 +3352,24 @@ async fn send_heartwood_sapling_funds() { .unwrap(); check_client_balances!(recipient, o: 3_499_990_000 s: 0 t: 0); } + +#[tokio::test] +async fn send_funds_to_all_pools_with_scenario() { + let regtest_network = RegtestNetwork::scenario_default(); + let ( + _regtest_manager, + _cph, + _faucet, + recipient, + _orchard_txid, + _sapling_txid, + _transparent_txid, + ) = scenarios::faucet_funded_recipient( + Some(100_000), + Some(100_000), + Some(100_000), + regtest_network, + ) + .await; + check_client_balances!(recipient, o: 100_000 s: 100_000 t: 100_000); +} From 330ae90af32acccee4b24cdfdca49403ba557c91 Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Mon, 16 Oct 2023 17:44:23 +0100 Subject: [PATCH 4/7] fixing broken tests --- zingo-testutils/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zingo-testutils/src/lib.rs b/zingo-testutils/src/lib.rs index f74554dba..80ddd8d17 100644 --- a/zingo-testutils/src/lib.rs +++ b/zingo-testutils/src/lib.rs @@ -693,7 +693,7 @@ pub mod scenarios { } else { None }; - increase_height_and_wait_for_client(®test_manager, &recipient, 1) + increase_height_and_wait_for_client(®test_manager, &recipient, 2) .await .unwrap(); faucet.do_sync(false).await.unwrap(); From 04b0a9e460b28d087eeee6e92c565f9ac9d7ee77 Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Mon, 16 Oct 2023 18:02:18 +0100 Subject: [PATCH 5/7] final fixes --- zingo-testutils/src/lib.rs | 5 ++++- zingocli/tests/integration_tests.rs | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/zingo-testutils/src/lib.rs b/zingo-testutils/src/lib.rs index 80ddd8d17..4669021a9 100644 --- a/zingo-testutils/src/lib.rs +++ b/zingo-testutils/src/lib.rs @@ -651,6 +651,9 @@ pub mod scenarios { ) { let (regtest_manager, child_process_handler, faucet, recipient) = faucet_recipient(regtest_network).await; + increase_height_and_wait_for_client(®test_manager, &faucet, 1) + .await + .unwrap(); let orchard_txid = if let Some(funds) = orchard_funds { Some( faucet @@ -693,7 +696,7 @@ pub mod scenarios { } else { None }; - increase_height_and_wait_for_client(®test_manager, &recipient, 2) + increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); faucet.do_sync(false).await.unwrap(); diff --git a/zingocli/tests/integration_tests.rs b/zingocli/tests/integration_tests.rs index 239f348e1..95c6f8d62 100644 --- a/zingocli/tests/integration_tests.rs +++ b/zingocli/tests/integration_tests.rs @@ -2101,7 +2101,7 @@ async fn mempool_clearing_and_full_batch_syncs_correct_trees() { zingo_testutils::increase_height_and_wait_for_client(®test_manager, &recipient, 10) .await .unwrap(); - assert_eq!(recipient.wallet.last_synced_height().await, 20); + assert_eq!(recipient.wallet.last_synced_height().await, 21); let notes = recipient.do_list_notes(true).await; @@ -2524,11 +2524,11 @@ async fn aborted_resync() { // 5. Now, we'll manually remove some of the blocks in the wallet, pretending that the sync was aborted in the middle. // We'll remove the top 20 blocks, so now the wallet only has the first 3 blocks recipient.wallet.blocks.write().await.drain(0..20); - assert_eq!(recipient.wallet.last_synced_height().await, 4); + assert_eq!(recipient.wallet.last_synced_height().await, 5); // 6. Do a sync again recipient.do_sync(true).await.unwrap(); - assert_eq!(recipient.wallet.last_synced_height().await, 24); + assert_eq!(recipient.wallet.last_synced_height().await, 25); // 7. Should be exactly the same let notes_after = recipient.do_list_notes(true).await; From 9f6e5e79c9a84b6034d8d701071ce29e9ba38d53 Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Mon, 16 Oct 2023 18:11:12 +0100 Subject: [PATCH 6/7] cleanup for merge --- zingo-testutils/src/lib.rs | 12 ++++++------ zingocli/tests/integration_tests.rs | 14 +++++++------- zingoconfig/src/lib.rs | 6 ------ 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/zingo-testutils/src/lib.rs b/zingo-testutils/src/lib.rs index 4669021a9..9b4c0908f 100644 --- a/zingo-testutils/src/lib.rs +++ b/zingo-testutils/src/lib.rs @@ -231,7 +231,7 @@ pub mod scenarios { //! If you need a faucet, and a single recipient, use 'faucet_recipient` //! For less common client configurations use the client builder directly with //! custom_clients - //! All scenarios have a default (i.e. faucet_default) which take no parameters and + //! 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; @@ -552,7 +552,7 @@ pub mod scenarios { } pub async fn unfunded_client_default() -> (RegtestManager, ChildProcessHandler, LightClient) { - let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); + let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); unfunded_client(regtest_network).await } @@ -586,7 +586,7 @@ pub mod scenarios { } pub async fn faucet_default() -> (RegtestManager, ChildProcessHandler, LightClient) { - let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); + let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); faucet(regtest_network).await } @@ -631,7 +631,7 @@ pub mod scenarios { LightClient, LightClient, ) { - let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); + let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); faucet_recipient(regtest_network).await } @@ -720,7 +720,7 @@ pub mod scenarios { LightClient, String, ) { - let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); + let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); let ( regtest_manager, cph, @@ -797,7 +797,7 @@ pub mod scenarios { ClientBuilder, zingoconfig::RegtestNetwork, ) { - let regtest_network = zingoconfig::RegtestNetwork::scenario_default(); + let regtest_network = zingoconfig::RegtestNetwork::all_upgrades_active(); let (regtest_manager, cph, client_builder) = custom_clients(regtest_network).await; (regtest_manager, cph, client_builder, regtest_network) } diff --git a/zingocli/tests/integration_tests.rs b/zingocli/tests/integration_tests.rs index 95c6f8d62..ff93b9ea2 100644 --- a/zingocli/tests/integration_tests.rs +++ b/zingocli/tests/integration_tests.rs @@ -66,7 +66,7 @@ async fn send_without_reorg_buffer_blocks_gives_correct_error() { #[tokio::test] async fn dont_write_unconfirmed() { - let regtest_network = RegtestNetwork::scenario_default(); + let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient(regtest_network).await; faucet @@ -201,7 +201,7 @@ async fn sandblast_filter_preserves_trees() { #[tokio::test] async fn load_and_parse_different_wallet_versions() { - let regtest_network = RegtestNetwork::scenario_default(); + let regtest_network = RegtestNetwork::all_upgrades_active(); let (_sap_wallet, _sap_path, sap_dir) = zingo_testutils::get_wallet_nym("sap_only").unwrap(); let (_loaded_wallet, _) = zingo_testutils::load_wallet(sap_dir, ChainType::Regtest(regtest_network)).await; @@ -635,7 +635,7 @@ async fn mine_sapling_to_self() { #[tokio::test] async fn unspent_notes_are_not_saved() { - let regtest_network = RegtestNetwork::scenario_default(); + let regtest_network = RegtestNetwork::all_upgrades_active(); let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient(regtest_network).await; zingo_testutils::increase_height_and_wait_for_client(®test_manager, &faucet, 1) @@ -2220,7 +2220,7 @@ pub mod framework_validation { #[tokio::test] async fn reboot_zcashd() { - let regtest_network = RegtestNetwork::scenario_default(); + let regtest_network = RegtestNetwork::all_upgrades_active(); let ScenarioBuilder { regtest_manager, child_process_handler, @@ -2724,7 +2724,7 @@ async fn by_address_finsight() { #[tokio::test] async fn load_old_wallet_at_reorged_height() { - let regtest_network = RegtestNetwork::scenario_default(); + let regtest_network = RegtestNetwork::all_upgrades_active(); let (ref regtest_manager, cph, ref faucet) = scenarios::faucet(regtest_network).await; println!("Shutting down initial zcd/lwd unneeded processes"); drop(cph); @@ -3354,8 +3354,8 @@ async fn send_heartwood_sapling_funds() { } #[tokio::test] -async fn send_funds_to_all_pools_with_scenario() { - let regtest_network = RegtestNetwork::scenario_default(); +async fn send_funds_to_all_pools() { + let regtest_network = RegtestNetwork::all_upgrades_active(); let ( _regtest_manager, _cph, diff --git a/zingoconfig/src/lib.rs b/zingoconfig/src/lib.rs index 003e3616e..f0a4180be 100644 --- a/zingoconfig/src/lib.rs +++ b/zingoconfig/src/lib.rs @@ -447,12 +447,6 @@ impl RegtestNetwork { activation_heights: ActivationHeights::new(1, 1, 1, 1, 1, orchard_activation_height), } } - pub fn scenario_default() -> Self { - Self { - activation_heights: ActivationHeights::new(1, 1, 1, 1, 1, 1), - // activation_heights: ActivationHeights::new(1, 1, 1, 1, 3, 5), - } - } // Network parameters pub fn activation_height(&self, nu: NetworkUpgrade) -> Option { From fb52ffd48f1212767827751bb13af261a3428c6d Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Mon, 16 Oct 2023 18:22:31 +0100 Subject: [PATCH 7/7] fix merges errors --- zingocli/tests/integration_tests.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/zingocli/tests/integration_tests.rs b/zingocli/tests/integration_tests.rs index 9bfee3eb0..828ae6c10 100644 --- a/zingocli/tests/integration_tests.rs +++ b/zingocli/tests/integration_tests.rs @@ -68,11 +68,7 @@ async fn send_without_reorg_buffer_blocks_gives_correct_error() { async fn multiple_outgoing_metadatas_work_right_on_restore() { let inital_value = 100_000; let (ref regtest_manager, _cph, faucet, ref recipient, _txid) = - scenarios::two_wallet_one_synced_orchard_transaction( - inital_value, - RegtestNetwork::all_upgrades_active(), - ) - .await; + scenarios::faucet_funded_recipient_default(inital_value).await; recipient .do_send(vec![ (&get_base_address!(faucet, "unified"), 10_000, None);