-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
123 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
//! - mempool | ||
pub mod conduct_chain; | ||
pub mod libtonode; | ||
pub mod live_chain; | ||
|
||
pub mod fixtures; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
//! libtonode tests use zcashd regtest mode to mock a chain | ||
use zcash_client_backend::PoolType; | ||
|
||
use zcash_client_backend::ShieldedProtocol::Sapling; | ||
|
||
use crate::config::RegtestNetwork; | ||
use crate::lightclient::LightClient; | ||
use crate::testutils::chain_generics::conduct_chain::ConductChain; | ||
use crate::testutils::scenarios::setup::ScenarioBuilder; | ||
|
||
/// includes utilities for connecting to zcashd regtest | ||
pub struct LibtonodeEnvironment { | ||
/// internal RegtestNetwork | ||
pub regtest_network: RegtestNetwork, | ||
/// internal ScenarioBuilder | ||
pub scenario_builder: ScenarioBuilder, | ||
} | ||
|
||
/// known issues include --slow | ||
/// these tests cannot portray the full range of network weather. | ||
impl ConductChain for LibtonodeEnvironment { | ||
async fn setup() -> Self { | ||
let regtest_network = RegtestNetwork::all_upgrades_active(); | ||
let scenario_builder = ScenarioBuilder::build_configure_launch( | ||
Some(PoolType::Shielded(Sapling)), | ||
None, | ||
None, | ||
®test_network, | ||
) | ||
.await; | ||
LibtonodeEnvironment { | ||
regtest_network, | ||
scenario_builder, | ||
} | ||
} | ||
|
||
async fn create_faucet(&mut self) -> LightClient { | ||
self.scenario_builder | ||
.client_builder | ||
.build_faucet(false, self.regtest_network) | ||
.await | ||
} | ||
|
||
fn zingo_config(&mut self) -> crate::config::ZingoConfig { | ||
self.scenario_builder | ||
.client_builder | ||
.make_unique_data_dir_and_load_config(self.regtest_network) | ||
} | ||
|
||
async fn bump_chain(&mut self) { | ||
let start_height = self | ||
.scenario_builder | ||
.regtest_manager | ||
.get_current_height() | ||
.unwrap(); | ||
self.scenario_builder | ||
.regtest_manager | ||
.generate_n_blocks(1) | ||
.expect("Called for side effect, failed!"); | ||
assert_eq!( | ||
self.scenario_builder | ||
.regtest_manager | ||
.get_current_height() | ||
.unwrap(), | ||
start_height + 1 | ||
); | ||
} | ||
|
||
fn get_chain_height(&mut self) -> u32 { | ||
self.scenario_builder | ||
.regtest_manager | ||
.get_current_height() | ||
.unwrap() | ||
} | ||
} |