Skip to content

Commit

Permalink
added mempool_manager test
Browse files Browse the repository at this point in the history
  • Loading branch information
idky137 committed Jun 17, 2024
1 parent 84ef335 commit 6c35b78
Showing 1 changed file with 52 additions and 5 deletions.
57 changes: 52 additions & 5 deletions integration-tests/tests/integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#![forbid(unsafe_code)]

use std::sync::{atomic::AtomicBool, Arc};
use zingoproxy_testutils::{drop_test_manager, TestManager};

use zingo_netutils::GrpcConnector;
use zingolib::lightclient::LightClient;
use zingoproxy_testutils::{drop_test_manager, TestManager};

mod wallet_basic {
use super::*;
Expand Down Expand Up @@ -402,9 +402,56 @@ mod wallet_basic {
.await;
}

// TODO: Add test for get_mempool_stream: lightclient::start_mempool_monitor.
// #[tokio::test]
// async fn monitor_mempool() {}
#[tokio::test]
async fn monitor_unverified_mempool() {
let online = Arc::new(AtomicBool::new(true));
let (test_manager, regtest_handler, _proxy_handler) =
TestManager::launch(online.clone()).await;
let zingo_client = test_manager.build_lightclient().await;

test_manager.regtest_manager.generate_n_blocks(1).unwrap();
zingo_client.do_sync(false).await.unwrap();
zingo_client
.do_send(vec![(
&zingolib::get_base_address!(zingo_client, "sapling"),
250_000,
None,
)])
.await
.unwrap();

let zingo_client_saved = zingo_client.export_save_buffer_async().await.unwrap();
let zingo_client_loaded = std::sync::Arc::new(
LightClient::read_wallet_from_buffer_async(
zingo_client.config(),
&zingo_client_saved[..],
)
.await
.unwrap(),
);
LightClient::start_mempool_monitor(zingo_client_loaded.clone());
// This seems to be long enough for the mempool monitor to kick in.
// One second is insufficient. Even if this fails, this can only ever be
// a false negative, giving us a balance of 100_000. Still, could be improved.
tokio::time::sleep(std::time::Duration::from_secs(5)).await;

let balance = zingo_client.do_balance().await;
println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.unverified_sapling_balance.unwrap(), 250_000);

test_manager.regtest_manager.generate_n_blocks(1).unwrap();
zingo_client.do_sync(false).await.unwrap();
let balance = zingo_client.do_balance().await;
println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.verified_sapling_balance.unwrap(), 250_000);

drop_test_manager(
Some(test_manager.temp_conf_dir.path().to_path_buf()),
regtest_handler,
online,
)
.await;
}
}

mod nym {
Expand Down

0 comments on commit 6c35b78

Please sign in to comment.