Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 39 additions & 47 deletions integration-tests/tests/fetch_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ use zebra_rpc::client::ValidateAddressResponse;
use zebra_rpc::methods::{AddressStrings, GetAddressTxIdsRequest, GetBlock, GetBlockHash};
use zip32::AccountId;

// TODO one unused var in tuple across 47 uses.
#[allow(deprecated)]
async fn create_test_manager_and_fetch_service(
validator: &ValidatorKind,
chain_cache: Option<std::path::PathBuf>,
enable_zaino: bool,
_zaino_no_sync: bool,
enable_clients: bool,
) -> (TestManager, FetchService, FetchServiceSubscriber) {
let test_manager = TestManager::launch(
Expand Down Expand Up @@ -70,7 +68,7 @@ async fn create_test_manager_and_fetch_service(

async fn launch_fetch_service(validator: &ValidatorKind, chain_cache: Option<std::path::PathBuf>) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, chain_cache, false, true, false).await;
create_test_manager_and_fetch_service(validator, chain_cache, false, false).await;
assert_eq!(fetch_service_subscriber.status(), StatusType::Ready);
dbg!(fetch_service_subscriber.data.clone());
dbg!(fetch_service_subscriber.get_info().await.unwrap());
Expand All @@ -85,7 +83,7 @@ async fn launch_fetch_service(validator: &ValidatorKind, chain_cache: Option<std

async fn fetch_service_get_address_balance(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -149,7 +147,7 @@ async fn fetch_service_get_address_balance(validator: &ValidatorKind) {

async fn fetch_service_get_block_raw(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, false, true, false).await;
create_test_manager_and_fetch_service(validator, None, false, false).await;

dbg!(fetch_service_subscriber
.z_get_block("1".to_string(), Some(0))
Expand All @@ -161,7 +159,7 @@ async fn fetch_service_get_block_raw(validator: &ValidatorKind) {

async fn fetch_service_get_block_object(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, false, true, false).await;
create_test_manager_and_fetch_service(validator, None, false, false).await;

dbg!(fetch_service_subscriber
.z_get_block("1".to_string(), Some(1))
Expand All @@ -173,7 +171,7 @@ async fn fetch_service_get_block_object(validator: &ValidatorKind) {

async fn fetch_service_get_raw_mempool(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;
let mut clients = test_manager
.clients
.take()
Expand Down Expand Up @@ -244,7 +242,7 @@ async fn fetch_service_get_raw_mempool(validator: &ValidatorKind) {
// `getmempoolinfo` computed from local Broadcast state for all validators
pub async fn test_get_mempool_info(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -327,7 +325,7 @@ pub async fn test_get_mempool_info(validator: &ValidatorKind) {

async fn fetch_service_z_get_treestate(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -366,7 +364,7 @@ async fn fetch_service_z_get_treestate(validator: &ValidatorKind) {

async fn fetch_service_z_get_subtrees_by_index(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -405,7 +403,7 @@ async fn fetch_service_z_get_subtrees_by_index(validator: &ValidatorKind) {

async fn fetch_service_get_raw_transaction(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -444,7 +442,7 @@ async fn fetch_service_get_raw_transaction(validator: &ValidatorKind) {

async fn fetch_service_get_address_tx_ids(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -499,7 +497,7 @@ async fn fetch_service_get_address_tx_ids(validator: &ValidatorKind) {

async fn fetch_service_get_address_utxos(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -544,7 +542,7 @@ async fn fetch_service_get_address_utxos(validator: &ValidatorKind) {

async fn fetch_service_get_latest_block(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;
test_manager.local_net.generate_blocks(1).await.unwrap();
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;

Expand Down Expand Up @@ -583,7 +581,7 @@ async fn fetch_service_get_latest_block(validator: &ValidatorKind) {

async fn assert_fetch_service_difficulty_matches_rpc(validator: &ValidatorKind) {
let (test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let fetch_service_get_difficulty = fetch_service_subscriber.get_difficulty().await.unwrap();

Expand All @@ -607,7 +605,7 @@ async fn assert_fetch_service_difficulty_matches_rpc(validator: &ValidatorKind)

async fn assert_fetch_service_mininginfo_matches_rpc(validator: &ValidatorKind) {
let (test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let fetch_service_mining_info = fetch_service_subscriber.get_mining_info().await.unwrap();

Expand All @@ -631,7 +629,7 @@ async fn assert_fetch_service_mininginfo_matches_rpc(validator: &ValidatorKind)

async fn assert_fetch_service_peerinfo_matches_rpc(validator: &ValidatorKind) {
let (test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let fetch_service_get_peer_info = fetch_service_subscriber.get_peer_info().await.unwrap();

Expand All @@ -658,7 +656,7 @@ async fn assert_fetch_service_peerinfo_matches_rpc(validator: &ValidatorKind) {

async fn fetch_service_get_block_subsidy(validator: &ValidatorKind) {
let (test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

const BLOCK_LIMIT: u32 = 10;

Expand Down Expand Up @@ -689,7 +687,7 @@ async fn fetch_service_get_block_subsidy(validator: &ValidatorKind) {

async fn fetch_service_get_block(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let block_id = BlockId {
height: 1,
Expand Down Expand Up @@ -717,7 +715,7 @@ async fn fetch_service_get_block(validator: &ValidatorKind) {

async fn fetch_service_get_block_header(validator: &ValidatorKind) {
let (test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

const BLOCK_LIMIT: u32 = 10;

Expand Down Expand Up @@ -779,7 +777,7 @@ async fn fetch_service_get_block_header(validator: &ValidatorKind) {

async fn fetch_service_get_best_blockhash(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

test_manager.local_net.generate_blocks(5).await.unwrap();
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
Expand Down Expand Up @@ -808,7 +806,7 @@ async fn fetch_service_get_best_blockhash(validator: &ValidatorKind) {

async fn fetch_service_get_block_count(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

test_manager.local_net.generate_blocks(5).await.unwrap();
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
Expand All @@ -828,7 +826,7 @@ async fn fetch_service_get_block_count(validator: &ValidatorKind) {

async fn fetch_service_validate_address(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

// scriptpubkey: "76a914000000000000000000000000000000000000000088ac"
let expected_validation = ValidateAddressResponse::new(
Expand Down Expand Up @@ -865,7 +863,7 @@ async fn fetch_service_validate_address(validator: &ValidatorKind) {

async fn fetch_service_get_block_nullifiers(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let block_id = BlockId {
height: 1,
Expand All @@ -884,7 +882,7 @@ async fn fetch_service_get_block_nullifiers(validator: &ValidatorKind) {

async fn fetch_service_get_block_range(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;
test_manager.local_net.generate_blocks(10).await.unwrap();
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;

Expand Down Expand Up @@ -917,7 +915,7 @@ async fn fetch_service_get_block_range(validator: &ValidatorKind) {

async fn fetch_service_get_block_range_nullifiers(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;
test_manager.local_net.generate_blocks(10).await.unwrap();
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;

Expand Down Expand Up @@ -950,7 +948,7 @@ async fn fetch_service_get_block_range_nullifiers(validator: &ValidatorKind) {

async fn fetch_service_get_transaction_mined(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -996,7 +994,7 @@ async fn fetch_service_get_transaction_mined(validator: &ValidatorKind) {

async fn fetch_service_get_transaction_mempool(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -1042,7 +1040,7 @@ async fn fetch_service_get_transaction_mempool(validator: &ValidatorKind) {

async fn fetch_service_get_taddress_txids(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -1112,7 +1110,7 @@ async fn fetch_service_get_taddress_txids(validator: &ValidatorKind) {

async fn fetch_service_get_taddress_balance(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -1167,7 +1165,7 @@ async fn fetch_service_get_taddress_balance(validator: &ValidatorKind) {

async fn fetch_service_get_mempool_tx(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -1260,7 +1258,7 @@ async fn fetch_service_get_mempool_tx(validator: &ValidatorKind) {

async fn fetch_service_get_mempool_stream(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -1326,7 +1324,7 @@ async fn fetch_service_get_mempool_stream(validator: &ValidatorKind) {

async fn fetch_service_get_tree_state(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let block_id = BlockId {
height: 1,
Expand All @@ -1345,7 +1343,7 @@ async fn fetch_service_get_tree_state(validator: &ValidatorKind) {

async fn fetch_service_get_latest_tree_state(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

dbg!(fetch_service_subscriber
.get_latest_tree_state()
Expand All @@ -1357,7 +1355,7 @@ async fn fetch_service_get_latest_tree_state(validator: &ValidatorKind) {

async fn fetch_service_get_subtree_roots(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let subtree_roots_arg = GetSubtreeRootsArg {
start_index: 0,
Expand All @@ -1383,7 +1381,7 @@ async fn fetch_service_get_subtree_roots(validator: &ValidatorKind) {

async fn fetch_service_get_taddress_utxos(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -1430,7 +1428,7 @@ async fn fetch_service_get_taddress_utxos(validator: &ValidatorKind) {

async fn fetch_service_get_taddress_utxos_stream(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let mut clients = test_manager
.clients
Expand Down Expand Up @@ -1482,7 +1480,7 @@ async fn fetch_service_get_taddress_utxos_stream(validator: &ValidatorKind) {

async fn fetch_service_get_lightd_info(validator: &ValidatorKind) {
let (mut test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

dbg!(fetch_service_subscriber.get_lightd_info().await.unwrap());

Expand All @@ -1491,7 +1489,7 @@ async fn fetch_service_get_lightd_info(validator: &ValidatorKind) {

async fn assert_fetch_service_getnetworksols_matches_rpc(validator: &ValidatorKind) {
let (test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(validator, None, true, true, true).await;
create_test_manager_and_fetch_service(validator, None, true, true).await;

let fetch_service_get_networksolps = fetch_service_subscriber
.get_network_sol_ps(None, None)
Expand Down Expand Up @@ -1632,14 +1630,8 @@ mod zcashd {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
pub(crate) async fn block_deltas() {
let (test_manager, _fetch_service, fetch_service_subscriber) =
create_test_manager_and_fetch_service(
&ValidatorKind::Zcashd,
None,
true,
true,
true,
)
.await;
create_test_manager_and_fetch_service(&ValidatorKind::Zcashd, None, true, true)
.await;

let current_block = fetch_service_subscriber.get_latest_block().await.unwrap();

Expand Down