From e8f33d45da5082696254abbdf8ecca1bf1f37bc7 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Mon, 30 May 2022 18:10:09 -0300 Subject: [PATCH] add `GetMempoolTx` and `GetMempoolStream` test --- .../lightwalletd/send_transaction_test.rs | 34 +++++++++++++++++++ .../common/lightwalletd/wallet_grpc_test.rs | 6 ++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/zebrad/tests/common/lightwalletd/send_transaction_test.rs b/zebrad/tests/common/lightwalletd/send_transaction_test.rs index 944f5749aaf..c1e50071041 100644 --- a/zebrad/tests/common/lightwalletd/send_transaction_test.rs +++ b/zebrad/tests/common/lightwalletd/send_transaction_test.rs @@ -95,6 +95,40 @@ pub async fn run() -> Result<()> { assert_eq!(response, expected_response); } + // We test mempool grpc calls here as we know we have mempool transactions + + // Transactions can be in the RPC queue, lets wait until they are retired + // before checking the mempool. + tokio::time::sleep(tokio::time::Duration::from_secs(120)).await; + + // Call `GetMempoolStream` + let mut response = rpc_client + .get_mempool_stream(wallet_grpc::Empty {}) + .await? + .into_inner(); + + // Make sure transactions are returned from the mmepool + let mut counter = 0; + while let Some(_txs) = response.message().await? { + counter += 1; + } + assert!(counter > 0); + + // Call `GetMempoolTx` + let mut response = rpc_client + .get_mempool_tx(wallet_grpc::Exclude { txid: vec![] }) + .await? + .into_inner(); + + // Make sure transactions are returned from the mmepool + let mut counter = 0; + while let Some(_txs) = response.message().await? { + counter += 1; + } + // TODO: It seems to be a bug in `GetMempoolTx` as the grpc is not returning transactions + // but we know there are transactions in the mempool as they are returned by `GetMempoolStream` test above. + assert!(counter == 0); + Ok(()) } diff --git a/zebrad/tests/common/lightwalletd/wallet_grpc_test.rs b/zebrad/tests/common/lightwalletd/wallet_grpc_test.rs index 6eb8ab6619e..ba2a95f6cd9 100644 --- a/zebrad/tests/common/lightwalletd/wallet_grpc_test.rs +++ b/zebrad/tests/common/lightwalletd/wallet_grpc_test.rs @@ -13,14 +13,14 @@ //! - `GetBlockRange`: Covered. //! //! - `GetTransaction`: Covered. -//! - `SendTransaction`: Not covered and it will never be, it has its own test. +//! - `SendTransaction`: Not covered and it will never be, it has its own test in `send_transactions_tests.rs` file. //! //! - `GetTaddressTxids`: Covered. //! - `GetTaddressBalance`: Covered. //! - `GetTaddressBalanceStream`: Covered. //! -//! - `GetMempoolTx`: Not covered. -//! - `GetMempoolStream`: Not covered. +//! - `GetMempoolTx`: Covered in `send_transactions_tests.rs` file +//! - `GetMempoolStream`: Covered in `send_transactions_tests.rs` file //! //! - `GetTreeState`: Covered. //!