Skip to content
12 changes: 6 additions & 6 deletions darkside-tests/src/chain_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ pub(crate) mod conduct_chain {
}

/// the mock chain is fed to the Client via lightwalletd. where is that server to be found?
fn lightserver_uri(&self) -> Option<http::Uri> {
Some(self.client_builder.server_id.clone())
fn indexer_uri(&self) -> Option<http::Uri> {
Some(self.client_builder.indexer_uri.clone().expect("some uri"))
}

async fn create_faucet(&mut self) -> LightClient {
Expand All @@ -76,13 +76,13 @@ pub(crate) mod conduct_chain {
.make_unique_data_dir_and_load_config(self.configured_activation_heights);
let mut lightclient = LightClient::create_from_wallet(
LightWallet::new(
config.network_type(),
config.chain_type,
WalletBase::Mnemonic {
mnemonic: Mnemonic::from_phrase(DARKSIDE_SEED.to_string()).unwrap(),
no_of_accounts: NonZeroU32::try_from(1).expect("hard-coded integer"),
},
1.into(),
config.wallet_settings(),
config.wallet_settings.clone(),
)
.unwrap(),
config,
Expand All @@ -105,7 +105,7 @@ pub(crate) mod conduct_chain {

async fn increase_chain_height(&mut self) {
let height_before =
zingolib::grpc_connector::get_latest_block(self.lightserver_uri().unwrap())
zingolib::grpc_connector::get_latest_block(self.indexer_uri().unwrap())
.await
.unwrap()
.height;
Expand All @@ -124,7 +124,7 @@ pub(crate) mod conduct_chain {

// trees
let trees = zingolib::grpc_connector::get_trees(
self.client_builder.server_id.clone(),
self.client_builder.indexer_uri.clone().expect("some uri"),
height_before,
)
.await
Expand Down
2 changes: 1 addition & 1 deletion darkside-tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ pub mod scenarios {
) -> DarksideEnvironment {
let (lightwalletd, darkside_connector) = init_darksidewalletd(set_port).await.unwrap();
let client_builder = ClientBuilder::new(
darkside_connector.0.clone(),
Some(darkside_connector.0.clone()),
zingolib::testutils::tempfile::tempdir().unwrap(),
);
let configured_activation_heights = ActivationHeights::default();
Expand Down
12 changes: 6 additions & 6 deletions darkside-tests/tests/advanced_reorg_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async fn reorg_changes_incoming_tx_height() {
.unwrap();

let wallet_dir = TempDir::new().unwrap();
let mut light_client = ClientBuilder::new(server_id.clone(), wallet_dir).build_client(
let mut light_client = ClientBuilder::new(Some(server_id.clone()), wallet_dir).build_client(
ADVANCED_REORG_TESTS_USER_WALLET.to_string(),
202,
true,
Expand Down Expand Up @@ -194,7 +194,7 @@ async fn reorg_changes_incoming_tx_index() {
.unwrap();

let wallet_dir = TempDir::new().unwrap();
let mut light_client = ClientBuilder::new(server_id.clone(), wallet_dir).build_client(
let mut light_client = ClientBuilder::new(Some(server_id.clone()), wallet_dir).build_client(
ADVANCED_REORG_TESTS_USER_WALLET.to_string(),
202,
true,
Expand Down Expand Up @@ -352,7 +352,7 @@ async fn reorg_expires_incoming_tx() {
.unwrap();

let wallet_dir = TempDir::new().unwrap();
let mut light_client = ClientBuilder::new(server_id.clone(), wallet_dir).build_client(
let mut light_client = ClientBuilder::new(Some(server_id.clone()), wallet_dir).build_client(
ADVANCED_REORG_TESTS_USER_WALLET.to_string(),
202,
true,
Expand Down Expand Up @@ -532,7 +532,7 @@ async fn reorg_changes_outgoing_tx_height() {
.unwrap();

let wallet_dir = TempDir::new().unwrap();
let mut light_client = ClientBuilder::new(server_id.clone(), wallet_dir).build_client(
let mut light_client = ClientBuilder::new(Some(server_id.clone()), wallet_dir).build_client(
ADVANCED_REORG_TESTS_USER_WALLET.to_string(),
202,
true,
Expand Down Expand Up @@ -787,7 +787,7 @@ async fn reorg_expires_outgoing_tx_height() {
.unwrap();

let wallet_dir = TempDir::new().unwrap();
let mut light_client = ClientBuilder::new(server_id.clone(), wallet_dir).build_client(
let mut light_client = ClientBuilder::new(Some(server_id.clone()), wallet_dir).build_client(
ADVANCED_REORG_TESTS_USER_WALLET.to_string(),
202,
true,
Expand Down Expand Up @@ -987,7 +987,7 @@ async fn reorg_changes_outgoing_tx_index() {
.unwrap();

let wallet_dir = TempDir::new().unwrap();
let mut light_client = ClientBuilder::new(server_id.clone(), wallet_dir).build_client(
let mut light_client = ClientBuilder::new(Some(server_id.clone()), wallet_dir).build_client(
ADVANCED_REORG_TESTS_USER_WALLET.to_string(),
202,
true,
Expand Down
6 changes: 3 additions & 3 deletions darkside-tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn simple_sync() {
.unwrap();
let activation_heights = ActivationHeights::default();
let wallet_dir = TempDir::new().unwrap();
let mut light_client = ClientBuilder::new(server_id, wallet_dir).build_client(
let mut light_client = ClientBuilder::new(Some(server_id), wallet_dir).build_client(
DARKSIDE_SEED.to_string(),
1,
true,
Expand Down Expand Up @@ -69,7 +69,7 @@ async fn reorg_receipt_sync_generic() {

let activation_heights = ActivationHeights::default();
let wallet_dir = TempDir::new().unwrap();
let mut light_client = ClientBuilder::new(server_id.clone(), wallet_dir).build_client(
let mut light_client = ClientBuilder::new(Some(server_id.clone()), wallet_dir).build_client(
DARKSIDE_SEED.to_string(),
1,
true,
Expand Down Expand Up @@ -128,7 +128,7 @@ async fn sent_transaction_reorged_into_mempool() {
.unwrap();

let wallet_dir = TempDir::new().unwrap();
let mut client_manager = ClientBuilder::new(server_id.clone(), wallet_dir);
let mut client_manager = ClientBuilder::new(Some(server_id.clone()), wallet_dir);
let activation_heights = ActivationHeights::default();
let mut light_client =
client_manager.build_client(DARKSIDE_SEED.to_string(), 0, true, activation_heights);
Expand Down
2 changes: 1 addition & 1 deletion libtonode-tests/src/chain_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl ConductChain for LibtonodeEnvironment {
);
}

fn lightserver_uri(&self) -> Option<http::Uri> {
fn indexer_uri(&self) -> Option<http::Uri> {
Some(port_to_localhost_uri(
self.local_net.indexer().listen_port(),
))
Expand Down
42 changes: 19 additions & 23 deletions libtonode-tests/tests/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ mod fast {
// messages
let alice_to_bob = TransactionRequest::new(vec![
Payment::new(
ZcashAddress::from_str(&bob.encode(&faucet.config().network_type())).unwrap(),
ZcashAddress::from_str(&bob.encode(&faucet.config().chain_type)).unwrap(),
Zatoshis::from_u64(1_000).unwrap(),
Some(Memo::encode(
&Memo::from_str(&("Alice->Bob #1\nReply to\n".to_string() + &alice)).unwrap(),
Expand All @@ -808,7 +808,7 @@ mod fast {
.unwrap();
let alice_to_bob_2 = TransactionRequest::new(vec![
Payment::new(
ZcashAddress::from_str(&bob.encode(&faucet.config().network_type())).unwrap(),
ZcashAddress::from_str(&bob.encode(&faucet.config().chain_type)).unwrap(),
Zatoshis::from_u64(1_000).unwrap(),
Some(Memo::encode(
&Memo::from_str(&("Alice->Bob #2\nReply to\n".to_string() + &alice)).unwrap(),
Expand All @@ -822,7 +822,7 @@ mod fast {
.unwrap();
let alice_to_charlie = TransactionRequest::new(vec![
Payment::new(
ZcashAddress::from_str(&charlie.encode(&faucet.config().network_type())).unwrap(),
ZcashAddress::from_str(&charlie.encode(&faucet.config().chain_type)).unwrap(),
Zatoshis::from_u64(1_000).unwrap(),
Some(Memo::encode(
&Memo::from_str(&("Alice->Charlie #2\nReply to\n".to_string() + &alice))
Expand All @@ -842,7 +842,7 @@ mod fast {
Some(Memo::encode(
&Memo::from_str(
&("Charlie->Alice #2\nReply to\n".to_string()
+ &charlie.encode(&faucet.config().network_type())),
+ &charlie.encode(&faucet.config().chain_type)),
)
.unwrap(),
)),
Expand All @@ -860,7 +860,7 @@ mod fast {
Some(Memo::encode(
&Memo::from_str(
&("Bob->Alice #2\nReply to\n".to_string()
+ &bob.encode(&faucet.config().network_type())),
+ &bob.encode(&faucet.config().chain_type)),
)
.unwrap(),
)),
Expand All @@ -886,11 +886,11 @@ mod fast {

// Collect observations
let value_transfers_bob = &recipient
.messages_containing(Some(&bob.encode(&recipient.config().network_type())))
.messages_containing(Some(&bob.encode(&recipient.config().chain_type)))
.await
.unwrap();
let value_transfers_charlie = &recipient
.messages_containing(Some(&charlie.encode(&recipient.config().network_type())))
.messages_containing(Some(&charlie.encode(&recipient.config().chain_type)))
.await
.unwrap();
let all_vts = &recipient.value_transfers(true).await.unwrap();
Expand Down Expand Up @@ -1454,7 +1454,7 @@ mod slow {
use zingo_common_components::protocol::ActivationHeights;
use zingo_status::confirmation_status::ConfirmationStatus;
use zingo_test_vectors::TEST_TXID;
use zingolib::config::{ChainType, ZingoConfig};
use zingolib::config::{ChainType, ZingoConfigBuilder};
use zingolib::lightclient::error::{LightClientError, SendError};
use zingolib::testutils::lightclient::{from_inputs, get_fees_paid_by_client};
use zingolib::testutils::{
Expand Down Expand Up @@ -1780,9 +1780,9 @@ mod slow {
false,
local_net.validator().get_activation_heights().await,
);
let zingo_config = ZingoConfig::builder()
.set_indexer_uri(client_builder.server_id)
.set_network_type(ChainType::Regtest(
let zingo_config = ZingoConfigBuilder::default()
.set_indexer_uri(client_builder.indexer_uri.clone())
.set_chain(ChainType::Regtest(
local_net.validator().get_activation_heights().await,
))
.set_wallet_dir(client_builder.zingo_datadir.path().to_path_buf())
Expand All @@ -1795,7 +1795,7 @@ mod slow {
min_confirmations: NonZeroU32::try_from(1).unwrap(),
})
.set_no_of_accounts(NonZeroU32::try_from(1).unwrap())
.build();
.create();

let (recipient_taddr, recipient_sapling, recipient_unified) = (
get_base_address_macro!(original_recipient, "transparent"),
Expand Down Expand Up @@ -4574,7 +4574,7 @@ mod testnet_test {
use pepper_sync::sync_status;
use zingo_test_vectors::seeds::HOSPITAL_MUSEUM_SEED;
use zingolib::{
config::{ChainType, DEFAULT_TESTNET_LIGHTWALLETD_SERVER, ZingoConfig},
config::{ChainType, DEFAULT_TESTNET_INDEXER_URI, ZingoConfigBuilder, some_infallible_uri},
lightclient::LightClient,
testutils::tempfile::TempDir,
wallet::{LightWallet, WalletBase},
Expand All @@ -4592,23 +4592,19 @@ mod testnet_test {

while test_count < NUM_TESTS {
let wallet_dir = TempDir::new().unwrap();
let config = ZingoConfig::builder()
.set_network_type(ChainType::Testnet)
.set_indexer_uri(
(DEFAULT_TESTNET_LIGHTWALLETD_SERVER)
.parse::<http::Uri>()
.unwrap(),
)
let config = ZingoConfigBuilder::default()
.set_chain(ChainType::Testnet)
.set_indexer_uri(some_infallible_uri(DEFAULT_TESTNET_INDEXER_URI))
.set_wallet_dir(wallet_dir.path().to_path_buf())
.build();
.create();
let wallet = LightWallet::new(
ChainType::Testnet,
WalletBase::Mnemonic {
mnemonic: Mnemonic::from_phrase(HOSPITAL_MUSEUM_SEED).unwrap(),
no_of_accounts: config.no_of_accounts(),
no_of_accounts: config.no_of_accounts,
},
2_000_000.into(),
config.wallet_settings(),
config.wallet_settings.clone(),
)
.unwrap();

Expand Down
28 changes: 14 additions & 14 deletions libtonode-tests/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use zcash_local_net::validator::Validator;
use zcash_protocol::consensus::BlockHeight;
use zingo_common_components::protocol::ActivationHeights;
use zingo_test_vectors::seeds::HOSPITAL_MUSEUM_SEED;
use zingolib::config::{ChainType, ZingoConfig};
use zingolib::config::{ChainType, ZingoConfigBuilder, some_infallible_uri};
use zingolib::testutils::lightclient::from_inputs::quick_send;
use zingolib::testutils::paths::get_cargo_manifest_dir;
use zingolib::testutils::tempfile::TempDir;
use zingolib::{
config::{DEFAULT_LIGHTWALLETD_SERVER, construct_lightwalletd_uri},
config::DEFAULT_INDEXER_URI,
get_base_address_macro,
lightclient::LightClient,
testutils::lightclient::from_inputs::{self},
Expand All @@ -28,12 +28,12 @@ async fn sync_mainnet_test() {
.expect("Ring to work as a default");
tracing_subscriber::fmt().init();

let uri = construct_lightwalletd_uri(Some(DEFAULT_LIGHTWALLETD_SERVER.to_string()));
let uri = some_infallible_uri(DEFAULT_INDEXER_URI);
let temp_dir = TempDir::new().unwrap();
let temp_path = temp_dir.path().to_path_buf();
let config = ZingoConfig::builder()
let config = ZingoConfigBuilder::default()
.set_indexer_uri(uri.clone())
.set_network_type(ChainType::Mainnet)
.set_chain(ChainType::Mainnet)
.set_wallet_dir(temp_path)
.set_wallet_name("".to_string())
.set_wallet_settings(WalletSettings {
Expand All @@ -44,16 +44,16 @@ async fn sync_mainnet_test() {
min_confirmations: NonZeroU32::try_from(1).unwrap(),
})
.set_no_of_accounts(NonZeroU32::try_from(1).unwrap())
.build();
.create();
let mut lightclient = LightClient::create_from_wallet(
LightWallet::new(
config.network_type(),
config.chain_type,
WalletBase::Mnemonic {
mnemonic: Mnemonic::from_phrase(HOSPITAL_MUSEUM_SEED.to_string()).unwrap(),
no_of_accounts: NonZeroU32::try_from(1).expect("hard-coded integer"),
},
1_500_000.into(),
config.wallet_settings(),
config.wallet_settings.clone(),
)
.unwrap(),
config,
Expand Down Expand Up @@ -97,12 +97,12 @@ async fn sync_status() {
.expect("Ring to work as a default");
tracing_subscriber::fmt().init();

let uri = construct_lightwalletd_uri(Some(DEFAULT_LIGHTWALLETD_SERVER.to_string()));
let uri = some_infallible_uri(DEFAULT_INDEXER_URI);
let temp_dir = TempDir::new().unwrap();
let temp_path = temp_dir.path().to_path_buf();
let config = ZingoConfig::builder()
let config = ZingoConfigBuilder::default()
.set_indexer_uri(uri.clone())
.set_network_type(ChainType::Mainnet)
.set_chain(ChainType::Mainnet)
.set_wallet_dir(temp_path)
.set_wallet_name("".to_string())
.set_wallet_settings(WalletSettings {
Expand All @@ -113,16 +113,16 @@ async fn sync_status() {
min_confirmations: NonZeroU32::try_from(1).unwrap(),
})
.set_no_of_accounts(NonZeroU32::try_from(1).unwrap())
.build();
.create();
let mut lightclient = LightClient::create_from_wallet(
LightWallet::new(
config.network_type(),
config.chain_type,
WalletBase::Mnemonic {
mnemonic: Mnemonic::from_phrase(HOSPITAL_MUSEUM_SEED.to_string()).unwrap(),
no_of_accounts: NonZeroU32::try_from(1).expect("hard-coded integer"),
},
2_496_152.into(),
config.wallet_settings(),
config.wallet_settings.clone(),
)
.unwrap(),
config,
Expand Down
Loading
Loading