Skip to content
4 changes: 2 additions & 2 deletions darkside-tests/src/chain_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ 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())
Some(self.client_builder.indexer_uri.clone().expect("some uri"))
}

async fn create_faucet(&mut self) -> LightClient {
Expand Down Expand Up @@ -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/tests/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ mod slow {
local_net.validator().get_activation_heights().await,
);
let zingo_config = ZingoConfig::builder()
.set_indexer_uri(client_builder.server_id)
.set_indexer_uri(client_builder.indexer_uri.unwrap())
.set_network_type(ChainType::Regtest(
local_net.validator().get_activation_heights().await,
))
Expand Down
26 changes: 12 additions & 14 deletions zingolib_testutils/src/scenarios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,18 @@ async fn zebrad_shielded_funds<V, I>(
/// Struct for building lightclients for integration testing
pub struct ClientBuilder {
/// Indexer URI
pub server_id: http::Uri,
pub indexer_uri: Option<http::Uri>,
/// Directory for wallet files
pub zingo_datadir: TempDir,
client_number: u8,
}

impl ClientBuilder {
/// TODO: Add Doc Comment Here!
pub fn new(server_id: http::Uri, zingo_datadir: TempDir) -> Self {
pub fn new(indexer_uri: Option<http::Uri>, zingo_datadir: TempDir) -> Self {
let client_number = 0;
ClientBuilder {
server_id,
indexer_uri,
zingo_datadir,
client_number,
}
Expand All @@ -163,18 +163,17 @@ impl ClientBuilder {
self.zingo_datadir.path().to_string_lossy(),
self.client_number
);
self.create_clientconfig(PathBuf::from(conf_path), configured_activation_heights)
self.create_lightclient_config(PathBuf::from(conf_path), configured_activation_heights)
}

/// TODO: Add Doc Comment Here!
pub fn create_clientconfig(
pub fn create_lightclient_config(
&self,
conf_path: PathBuf,
configured_activation_heights: ActivationHeights,
) -> ZingoConfig {
std::fs::create_dir(&conf_path).unwrap();
ZingoConfig::builder()
.set_indexer_uri(self.server_id.clone())
.set_indexer_uri(self.indexer_uri.clone().unwrap())
.set_network_type(ChainType::Regtest(configured_activation_heights))
.set_wallet_dir(conf_path)
.set_wallet_name("".to_string())
Expand All @@ -185,7 +184,6 @@ impl ClientBuilder {
},
min_confirmations: NonZeroU32::try_from(1).unwrap(),
})
.set_no_of_accounts(NonZeroU32::try_from(1).unwrap())
.build()
}

Expand All @@ -198,7 +196,7 @@ impl ClientBuilder {
//! A "faucet" is a lightclient that receives mining rewards
self.build_client(
seeds::ABANDON_ART_SEED.to_string(),
1,
0,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear on why this changed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to make tests fail, so I am changing it back.

overwrite,
configured_activation_heights,
)
Expand Down Expand Up @@ -459,7 +457,7 @@ pub async fn custom_clients(
}

let client_builder = ClientBuilder::new(
port_to_localhost_uri(local_net.indexer().listen_port()),
Some(port_to_localhost_uri(local_net.indexer().listen_port())),
tempfile::tempdir().unwrap(),
);

Expand Down Expand Up @@ -490,7 +488,7 @@ pub async fn unfunded_mobileclient() -> LocalNet<DefaultValidator, DefaultIndexe
pub async fn funded_orchard_mobileclient(value: u64) -> LocalNet<DefaultValidator, DefaultIndexer> {
let local_net = unfunded_mobileclient().await;
let mut client_builder = ClientBuilder::new(
port_to_localhost_uri(local_net.indexer().port()),
Some(port_to_localhost_uri(local_net.indexer().port())),
tempfile::tempdir().unwrap(),
);
let mut faucet =
Expand Down Expand Up @@ -519,7 +517,7 @@ pub async fn funded_orchard_with_3_txs_mobileclient(
) -> LocalNet<DefaultValidator, DefaultIndexer> {
let local_net = unfunded_mobileclient().await;
let mut client_builder = ClientBuilder::new(
port_to_localhost_uri(local_net.indexer().port()),
Some(port_to_localhost_uri(local_net.indexer().port())),
tempfile::tempdir().unwrap(),
);
let mut faucet =
Expand Down Expand Up @@ -577,7 +575,7 @@ pub async fn funded_transparent_mobileclient(
) -> LocalNet<DefaultValidator, DefaultIndexer> {
let local_net = unfunded_mobileclient().await;
let mut client_builder = ClientBuilder::new(
port_to_localhost_uri(local_net.indexer().port()),
Some(port_to_localhost_uri(local_net.indexer().port())),
tempfile::tempdir().unwrap(),
);
let mut faucet =
Expand Down Expand Up @@ -618,7 +616,7 @@ pub async fn funded_orchard_sapling_transparent_shielded_mobileclient(
) -> LocalNet<DefaultValidator, DefaultIndexer> {
let local_net = unfunded_mobileclient().await;
let mut client_builder = ClientBuilder::new(
port_to_localhost_uri(local_net.indexer().port()),
Some(port_to_localhost_uri(local_net.indexer().port())),
tempfile::tempdir().unwrap(),
);
let mut faucet =
Expand Down
Loading