Skip to content

Commit

Permalink
updated prints
Browse files Browse the repository at this point in the history
  • Loading branch information
idky137 committed Sep 5, 2024
1 parent be8a191 commit 5114bce
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 61 deletions.
33 changes: 15 additions & 18 deletions integration-tests/tests/integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ mod wallet_basic {
let zingo_client = test_manager.build_lightclient().await;

let lightd_info = zingo_client.do_info().await;
println!(
"@zingoindexertest: Lightd_info response:\n{:#?}.",
lightd_info
);
println!("[TEST LOG] Lightd_info response:\n{:#?}.", lightd_info);

drop_test_manager(
Some(test_manager.temp_conf_dir.path().to_path_buf()),
Expand Down Expand Up @@ -53,7 +50,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.orchard_balance.unwrap(), 1_875_000_000);

drop_test_manager(
Expand Down Expand Up @@ -85,7 +82,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.sapling_balance.unwrap(), 250_000);

drop_test_manager(
Expand Down Expand Up @@ -117,7 +114,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.transparent_balance.unwrap(), 250_000);

drop_test_manager(
Expand Down Expand Up @@ -165,7 +162,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.orchard_balance.unwrap(), 2_499_500_000);
assert_eq!(balance.sapling_balance.unwrap(), 250_000);
assert_eq!(balance.transparent_balance.unwrap(), 250_000);
Expand Down Expand Up @@ -199,7 +196,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.sapling_balance.unwrap(), 250_000);

zingo_client
Expand All @@ -210,7 +207,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.sapling_balance.unwrap(), 0);
assert_eq!(balance.orchard_balance.unwrap(), 2_500_000_000);

Expand Down Expand Up @@ -243,7 +240,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.transparent_balance.unwrap(), 250_000);

zingo_client
Expand All @@ -254,7 +251,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.transparent_balance.unwrap(), 0);
assert_eq!(balance.orchard_balance.unwrap(), 2_500_000_000);

Expand Down Expand Up @@ -295,7 +292,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.sapling_balance.unwrap(), 250_000);
assert_eq!(balance.transparent_balance.unwrap(), 250_000);

Expand All @@ -307,7 +304,7 @@ mod wallet_basic {
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.sapling_balance.unwrap(), 0);
assert_eq!(balance.transparent_balance.unwrap(), 0);
assert_eq!(balance.orchard_balance.unwrap(), 2_500_000_000);
Expand Down Expand Up @@ -359,11 +356,11 @@ mod wallet_basic {
.unwrap();
test_manager.regtest_manager.generate_n_blocks(30).unwrap();

println!("@zingoindexertest: syncing full batch.");
println!("[TEST LOG] syncing full batch.");
zingo_client.do_sync(false).await.unwrap();

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.orchard_balance.unwrap(), 76_874_500_000);
assert_eq!(balance.sapling_balance.unwrap(), 250_000);
assert_eq!(balance.transparent_balance.unwrap(), 250_000);
Expand Down Expand Up @@ -405,13 +402,13 @@ mod wallet_basic {
start_zingo_mempool_monitor(&zingo_client).await;

let balance = zingo_client.do_balance().await;
println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.unverified_sapling_balance.unwrap(), 500_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!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance);
println!("[TEST LOG] zingo_client balance: \n{:#?}.", balance);
assert_eq!(balance.verified_sapling_balance.unwrap(), 500_000);

drop_test_manager(
Expand Down
2 changes: 0 additions & 2 deletions zaino-nym/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Nym client functionality.
//!
//! TODO: - Add NymClientError error type and rewrite functions to return <Result<(), NymClientError>>.

use nym_sdk::mixnet::{
MixnetClient, MixnetClientBuilder, MixnetMessageSender, Recipient, ReconstructedMessage,
Expand Down
45 changes: 21 additions & 24 deletions zaino-serve/src/rpc/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_latest_block.");
println!("[TEST] Received call of get_latest_block.");
Box::pin(async {
let blockchain_info = JsonRpcConnector::new(
self.zebrad_uri.clone(),
Expand Down Expand Up @@ -144,7 +144,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_block.");
println!("[TEST] Received call of get_block.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_block not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand All @@ -169,7 +169,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_block_nullifiers.");
println!("[TEST] Received call of get_block_nullifiers.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_block_nullifiers not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand Down Expand Up @@ -201,7 +201,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_block_range.");
println!("[TEST] Received call of get_block_range.");
let zebrad_uri = self.zebrad_uri.clone();
Box::pin(async move {
let blockrange = request.into_inner();
Expand All @@ -216,16 +216,13 @@ impl CompactTxStreamer for GrpcClient {
if start > end {
(start, end) = (end, start);
}
println!(
"@zingoindexertest: Fetching blocks in range: {}-{}.",
start, end
);
println!("[TEST] Fetching blocks in range: {}-{}.", start, end);
let (channel_tx, channel_rx) = tokio::sync::mpsc::channel(32);
tokio::spawn(async move {
// NOTE: This timeout is so slow due to the blockcache not being implemented. This should be reduced to 30s once functionality is in place.
let timeout = timeout(std::time::Duration::from_secs(120), async {
for height in (start..=end).rev() {
println!("@zingoindexertest: Fetching block at height: {}.", height);
println!("[TEST] Fetching block at height: {}.", height);
let compact_block = get_block_from_node(&zebrad_uri, &height).await;
match compact_block {
Ok(block) => {
Expand Down Expand Up @@ -290,7 +287,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_block_range_nullifiers.");
println!("[TEST] Received call of get_block_range_nullifiers.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_block_range_nullifiers not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand All @@ -312,7 +309,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_transaction.");
println!("[TEST] Received call of get_transaction.");
Box::pin(async {
let hash = request.into_inner().hash;
if hash.len() == 32 {
Expand Down Expand Up @@ -367,7 +364,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of send_transaction.");
println!("[TEST] Received call of send_transaction.");
Box::pin(async {
let hex_tx = hex::encode(request.into_inner().data);
let tx_output = JsonRpcConnector::new(
Expand Down Expand Up @@ -410,7 +407,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_taddress_txids.");
println!("[TEST] Received call of get_taddress_txids.");
Box::pin(async move {
let block_filter = request.into_inner();
let address = block_filter.address;
Expand Down Expand Up @@ -514,7 +511,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_taddress_balance.");
println!("[TEST] Received call of get_taddress_balance.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_taddress_balance not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand All @@ -538,7 +535,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_taddress_balance_stream.");
println!("[TEST] Received call of get_taddress_balance_stream.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_taddress_balance_stream not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand Down Expand Up @@ -578,7 +575,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_mempool_tx.");
println!("[TEST] Received call of get_mempool_tx.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_mempool_tx not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand Down Expand Up @@ -611,7 +608,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_mempool_stream.");
println!("[TEST] Received call of get_mempool_stream.");
Box::pin(async {
let zebrad_client = JsonRpcConnector::new(
self.zebrad_uri.clone(),
Expand Down Expand Up @@ -736,7 +733,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_tree_state.");
println!("[TEST] Received call of get_tree_state.");
Box::pin(async {
let block_id = request.into_inner();
let hash_or_height = if block_id.height != 0 {
Expand Down Expand Up @@ -790,7 +787,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_latest_tree_state.");
println!("[TEST] Received call of get_latest_tree_state.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_latest_tree_state not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand Down Expand Up @@ -823,7 +820,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_subtree_roots.");
println!("[TEST] Received call of get_subtree_roots.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_subtree_roots not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand All @@ -849,7 +846,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_address_utxos.");
println!("[TEST] Received call of get_address_utxos.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_address_utxos not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand Down Expand Up @@ -879,7 +876,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_address_utxos_stream.");
println!("[TEST] Received call of get_address_utxos_stream.");
Box::pin(async {
Err(tonic::Status::unimplemented("get_address_utxos_stream not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand All @@ -901,7 +898,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of get_lightd_info.");
println!("[TEST] Received call of get_lightd_info.");
// TODO: Add user and password as fields of GrpcClient and use here.
// TODO: Return Nym_Address in get_lightd_info response, for use by wallets.
Box::pin(async {
Expand Down Expand Up @@ -977,7 +974,7 @@ impl CompactTxStreamer for GrpcClient {
'life0: 'async_trait,
Self: 'async_trait,
{
println!("@zingoindexerd: Received call of ping.");
println!("[TEST] Received call of ping.");
Box::pin(async {
Err(tonic::Status::unimplemented("ping not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer)."))
})
Expand Down
23 changes: 7 additions & 16 deletions zaino-testutils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,14 @@ pub async fn drop_test_manager(
if let Some(ref path) = temp_conf_path {
if let Err(e) = std::fs::remove_dir_all(path) {
eprintln!(
"@zingoindexerd: Failed to delete temporary regtest configuration directory: {:?}.",
"Failed to delete temporary regtest configuration directory: {:?}.",
e
);
}
}
if let Some(ref path) = Some(temp_wallet_path) {
if let Err(e) = std::fs::remove_dir_all(path) {
eprintln!(
"@zingoindexerd: Failed to delete temporary directory: {:?}.",
e
);
eprintln!("Failed to delete temporary directory: {:?}.", e);
}
}
}
Expand Down Expand Up @@ -179,17 +176,14 @@ fn set_custom_drops(
if let Some(ref path) = temp_conf_path_panic {
if let Err(e) = std::fs::remove_dir_all(path) {
eprintln!(
"@zingoindexerd: Failed to delete temporary regtest config directory: {:?}.",
"Failed to delete temporary regtest config directory: {:?}.",
e
);
}
}
if let Some(ref path) = temp_wallet_path_panic {
if let Err(e) = std::fs::remove_dir_all(path) {
eprintln!(
"@zingoindexerd: Failed to delete temporary wallet directory: {:?}.",
e
);
eprintln!("Failed to delete temporary wallet directory: {:?}.", e);
}
}
// Assures tests fail on secondary thread panics.
Expand All @@ -199,22 +193,19 @@ fn set_custom_drops(

CTRL_C_ONCE.call_once(|| {
ctrlc::set_handler(move || {
println!("@zingoindexerd: Received Ctrl+C, exiting.");
println!("Received Ctrl+C, exiting.");
online_ctrlc.store(false, std::sync::atomic::Ordering::SeqCst);
if let Some(ref path) = temp_conf_path_ctrlc {
if let Err(e) = std::fs::remove_dir_all(path) {
eprintln!(
"@zingoindexerd: Failed to delete temporary regtest config directory: {:?}.",
"Failed to delete temporary regtest config directory: {:?}.",
e
);
}
}
if let Some(ref path) = temp_wallet_path_ctrlc {
if let Err(e) = std::fs::remove_dir_all(path) {
eprintln!(
"@zingoindexerd: Failed to delete temporary wallet directory: {:?}.",
e
);
eprintln!("Failed to delete temporary wallet directory: {:?}.", e);
}
}
// Assures tests fail on ctrlc exit.
Expand Down
Loading

0 comments on commit 5114bce

Please sign in to comment.