Function holochain::test_utils::setup_app_inner
source · pub async fn setup_app_inner(
db_dir: &Path,
apps_data: Vec<(&str, InstalledCellsWithProofs)>,
dnas: Vec<DnaFile>,
network: Option<KitsuneP2pConfig>
) -> (RealAppInterfaceApi, ConductorHandle)
Expand description
Setup an app with full configurability
Examples found in repository?
src/test_utils.rs (line 385)
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
pub async fn setup_app_with_names(
apps_data: Vec<(&str, InstalledCellsWithProofs)>,
dnas: Vec<DnaFile>,
) -> (TempDir, RealAppInterfaceApi, ConductorHandle) {
let dir = test_db_dir();
let (iface, handle) = setup_app_inner(dir.path(), apps_data, dnas, None).await;
(dir, iface, handle)
}
/// Setup an app with a custom network config for testing
/// apps_data is a vec of app nicknames with vecs of their cell data.
pub async fn setup_app_with_network(
apps_data: Vec<(&str, InstalledCellsWithProofs)>,
dnas: Vec<DnaFile>,
network: KitsuneP2pConfig,
) -> (TempDir, RealAppInterfaceApi, ConductorHandle) {
let dir = test_db_dir();
let (iface, handle) = setup_app_inner(dir.path(), apps_data, dnas, Some(network)).await;
(dir, iface, handle)
}
More examples
src/test_utils/conductor_setup.rs (lines 133-138)
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
pub async fn new(
envs: TempDir,
dna_files: Vec<DnaFile>,
agents: Vec<AgentPubKey>,
network_config: KitsuneP2pConfig,
) -> (Self, HashMap<DnaHash, Vec<CellId>>) {
let num_agents = agents.len();
let num_dnas = dna_files.len();
let mut cells = Vec::with_capacity(num_dnas * num_agents);
let mut cell_id_by_dna_file = Vec::with_capacity(num_dnas);
for (i, dna_file) in dna_files.iter().enumerate() {
let mut cell_ids = Vec::with_capacity(num_agents);
for (j, agent_id) in agents.iter().enumerate() {
let cell_id = CellId::new(dna_file.dna_hash().to_owned(), agent_id.clone());
cells.push((
InstalledCell::new(cell_id.clone(), format!("agent-{}-{}", i, j)),
None,
));
cell_ids.push(cell_id);
}
cell_id_by_dna_file.push((dna_file, cell_ids));
}
let (_app_api, handle) = setup_app_inner(
envs.path(),
vec![("test_app", cells)],
dna_files.clone(),
Some(network_config),
)
.await;
let mut cell_apis = BTreeMap::new();
for (dna_file, cell_ids) in cell_id_by_dna_file.iter() {
for cell_id in cell_ids {
cell_apis.insert(
cell_id.clone(),
CellHostFnCaller::new(cell_id, &handle, dna_file, None).await,
);
}
}
let this = Self {
_db_dir: envs,
// app_api,
handle,
cell_apis,
};
let installed = cell_id_by_dna_file
.into_iter()
.map(|(dna_file, cell_ids)| (dna_file.dna_hash().clone(), cell_ids))
.collect();
(this, installed)
}