From 42bb381d37dc81f3149777fbd2a8b0a3b4e0fbb1 Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Mon, 8 Jul 2024 20:51:15 +0100 Subject: [PATCH 1/2] added test which shows mempool tx change from pending to confirmed --- libtonode-tests/tests/concrete.rs | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/libtonode-tests/tests/concrete.rs b/libtonode-tests/tests/concrete.rs index c2d0e661a..ea5179a5d 100644 --- a/libtonode-tests/tests/concrete.rs +++ b/libtonode-tests/tests/concrete.rs @@ -131,6 +131,43 @@ mod fast { use zingolib::wallet::WalletBase; use super::*; + + #[tokio::test] + async fn tx_status_pending_to_confirmed() { + let (regtest_manager, _cph, faucet, recipient, _txid) = + scenarios::orchard_funded_recipient(100_000).await; + + let recipient = std::sync::Arc::new(recipient); + + let txid = from_inputs::quick_send( + &recipient, + vec![(&get_base_address_macro!(faucet, "sapling"), 20_000, None)], + ) + .await + .unwrap(); + + recipient + .wallet + .transaction_context + .transaction_metadata_set + .write() + .await + .transaction_records_by_id + .remove(txid.first()); + + LightClient::start_mempool_monitor(recipient.clone()); + tokio::time::sleep(Duration::from_secs(5)).await; + println!("pre bump and sync"); + println!("{}", &recipient.transaction_summaries().await); + + increase_height_and_wait_for_client(®test_manager, &recipient, 1) + .await + .unwrap(); + + println!("post bump and sync"); + println!("{}", &recipient.transaction_summaries().await); + } + #[tokio::test] async fn utxos_are_not_prematurely_confirmed() { let (regtest_manager, _cph, faucet, recipient) = @@ -2407,6 +2444,8 @@ mod slow { // More explicit than ignoring the unused variable, we only care about this in order to drop it */ } + + // FIXME: it seems this test makes assertions on mempool but mempool monitoring is off? #[tokio::test] async fn mempool_clearing_and_full_batch_syncs_correct_trees() { async fn do_maybe_recent_txid(lc: &LightClient) -> JsonValue { @@ -2693,6 +2732,7 @@ mod slow { .unwrap() ) } + // FIXME: it seems this test makes assertions on mempool but mempool monitoring is off? #[tokio::test] async fn mempool_and_balance() { let value = 100_000; From dfb7fbae7c7826d910c38bc30e2006372318ed74 Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Tue, 9 Jul 2024 11:13:15 +0100 Subject: [PATCH 2/2] changed test to a simple test showing mempool monitor works and status correctly changes from pending to confirmed when bump and synced --- libtonode-tests/tests/concrete.rs | 45 +++++++++++++++++++------------ 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/libtonode-tests/tests/concrete.rs b/libtonode-tests/tests/concrete.rs index ea5179a5d..d43e8ba2f 100644 --- a/libtonode-tests/tests/concrete.rs +++ b/libtonode-tests/tests/concrete.rs @@ -127,45 +127,56 @@ mod fast { use zcash_address::unified::Encoding; 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 zingolib::wallet::WalletBase; use super::*; #[tokio::test] - async fn tx_status_pending_to_confirmed() { + async fn received_tx_status_pending_to_confirmed_with_mempool_monitor() { let (regtest_manager, _cph, faucet, recipient, _txid) = scenarios::orchard_funded_recipient(100_000).await; let recipient = std::sync::Arc::new(recipient); - let txid = from_inputs::quick_send( - &recipient, - vec![(&get_base_address_macro!(faucet, "sapling"), 20_000, None)], + from_inputs::quick_send( + &faucet, + vec![( + &get_base_address_macro!(&recipient, "sapling"), + 20_000, + None, + )], ) .await .unwrap(); - recipient - .wallet - .transaction_context - .transaction_metadata_set - .write() - .await - .transaction_records_by_id - .remove(txid.first()); - LightClient::start_mempool_monitor(recipient.clone()); tokio::time::sleep(Duration::from_secs(5)).await; - println!("pre bump and sync"); - println!("{}", &recipient.transaction_summaries().await); + + let transactions = &recipient.transaction_summaries().await.0; + assert_eq!( + transactions + .iter() + .find(|tx| tx.value() == 20_000) + .unwrap() + .status(), + ConfirmationStatus::Pending(BlockHeight::from_u32(5)) // FIXME: mempool blockheight is at chain hieght instead of chain height + 1 + ); increase_height_and_wait_for_client(®test_manager, &recipient, 1) .await .unwrap(); - println!("post bump and sync"); - println!("{}", &recipient.transaction_summaries().await); + let transactions = &recipient.transaction_summaries().await.0; + assert_eq!( + transactions + .iter() + .find(|tx| tx.value() == 20_000) + .unwrap() + .status(), + ConfirmationStatus::Confirmed(BlockHeight::from_u32(6)) + ); } #[tokio::test]