Struct holochain::test_utils::conductor_setup::ConductorTestData
source · pub struct ConductorTestData { /* private fields */ }
Expand description
Everything you need to run a test that uses the conductor
Implementations§
source§impl ConductorTestData
impl ConductorTestData
sourcepub async fn new(
envs: TempDir,
dna_files: Vec<DnaFile>,
agents: Vec<AgentPubKey>,
network_config: KitsuneP2pConfig
) -> (Self, HashMap<DnaHash, Vec<CellId>>)
pub async fn new(
envs: TempDir,
dna_files: Vec<DnaFile>,
agents: Vec<AgentPubKey>,
network_config: KitsuneP2pConfig
) -> (Self, HashMap<DnaHash, Vec<CellId>>)
Examples found in repository?
src/test_utils/conductor_setup.rs (lines 215-220)
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
async fn two_agents_inner(
zomes: Vec<TestWasm>,
with_bob: bool,
network: Option<KitsuneP2pConfig>,
) -> Self {
let dna_file = DnaFile::new(
DnaDef {
name: "conductor_test".to_string(),
modifiers: DnaModifiers {
network_seed: "ba1d046d-ce29-4778-914b-47e6010d2faf".to_string(),
properties: SerializedBytes::try_from(()).unwrap(),
origin_time: Timestamp::HOLOCHAIN_EPOCH,
quantum_time: holochain_p2p::dht::spacetime::STANDARD_QUANTUM_TIME,
},
integrity_zomes: zomes
.clone()
.into_iter()
.map(TestZomes::from)
.map(|z| z.integrity.into_inner())
.collect(),
coordinator_zomes: zomes
.clone()
.into_iter()
.map(TestZomes::from)
.map(|z| z.coordinator.into_inner())
.collect(),
},
zomes.into_iter().flat_map(Vec::<DnaWasm>::from),
)
.await;
let mut agents = vec![fake_agent_pubkey_1()];
if with_bob {
agents.push(fake_agent_pubkey_2());
}
let (this, _) = Self::new(
test_db_dir(),
vec![dna_file],
agents,
network.unwrap_or_default(),
)
.await;
this
}
sourcepub async fn two_agents(zomes: Vec<TestWasm>, with_bob: bool) -> Self
pub async fn two_agents(zomes: Vec<TestWasm>, with_bob: bool) -> Self
Create a new conductor and test data
sourcepub async fn with_network_config(
zomes: Vec<TestWasm>,
with_bob: bool,
network: KitsuneP2pConfig
) -> Self
pub async fn with_network_config(
zomes: Vec<TestWasm>,
with_bob: bool,
network: KitsuneP2pConfig
) -> Self
New test data that creates a conductor using a custom network config
sourcepub async fn shutdown_conductor(&mut self)
pub async fn shutdown_conductor(&mut self)
Shutdown the conductor
sourcepub async fn bring_bob_online(&mut self)
pub async fn bring_bob_online(&mut self)
Bring bob online if he isn’t already
sourcepub fn handle(&self) -> ConductorHandle
pub fn handle(&self) -> ConductorHandle
Examples found in repository?
src/test_utils/conductor_setup.rs (line 241)
234 235 236 237 238 239 240 241 242 243 244 245 246 247
pub async fn bring_bob_online(&mut self) {
let dna_file = self.alice_call_data().ribosome.dna_file().clone();
if self.bob_call_data().is_none() {
let bob_agent_id = fake_agent_pubkey_2();
let bob_cell_id = CellId::new(dna_file.dna_hash().clone(), bob_agent_id.clone());
let bob_installed_cell = InstalledCell::new(bob_cell_id.clone(), "bob_handle".into());
let cell_data = vec![(bob_installed_cell, None)];
install_app("bob_app", cell_data, vec![dna_file.clone()], self.handle()).await;
self.cell_apis.insert(
bob_cell_id.clone(),
CellHostFnCaller::new(&bob_cell_id, &self.handle(), &dna_file, None).await,
);
}
}
sourcepub fn alice_call_data(&self) -> &CellHostFnCaller
pub fn alice_call_data(&self) -> &CellHostFnCaller
Examples found in repository?
src/test_utils/conductor_setup.rs (line 235)
234 235 236 237 238 239 240 241 242 243 244 245 246 247
pub async fn bring_bob_online(&mut self) {
let dna_file = self.alice_call_data().ribosome.dna_file().clone();
if self.bob_call_data().is_none() {
let bob_agent_id = fake_agent_pubkey_2();
let bob_cell_id = CellId::new(dna_file.dna_hash().clone(), bob_agent_id.clone());
let bob_installed_cell = InstalledCell::new(bob_cell_id.clone(), "bob_handle".into());
let cell_data = vec![(bob_installed_cell, None)];
install_app("bob_app", cell_data, vec![dna_file.clone()], self.handle()).await;
self.cell_apis.insert(
bob_cell_id.clone(),
CellHostFnCaller::new(&bob_cell_id, &self.handle(), &dna_file, None).await,
);
}
}
sourcepub fn bob_call_data(&self) -> Option<&CellHostFnCaller>
pub fn bob_call_data(&self) -> Option<&CellHostFnCaller>
Examples found in repository?
src/test_utils/conductor_setup.rs (line 236)
234 235 236 237 238 239 240 241 242 243 244 245 246 247
pub async fn bring_bob_online(&mut self) {
let dna_file = self.alice_call_data().ribosome.dna_file().clone();
if self.bob_call_data().is_none() {
let bob_agent_id = fake_agent_pubkey_2();
let bob_cell_id = CellId::new(dna_file.dna_hash().clone(), bob_agent_id.clone());
let bob_installed_cell = InstalledCell::new(bob_cell_id.clone(), "bob_handle".into());
let cell_data = vec![(bob_installed_cell, None)];
install_app("bob_app", cell_data, vec![dna_file.clone()], self.handle()).await;
self.cell_apis.insert(
bob_cell_id.clone(),
CellHostFnCaller::new(&bob_cell_id, &self.handle(), &dna_file, None).await,
);
}
}
pub fn alice_call_data_mut(&mut self) -> &mut CellHostFnCaller
pub fn get_cell(&mut self, cell_id: &CellId) -> Option<&mut CellHostFnCaller>
Auto Trait Implementations§
impl !RefUnwindSafe for ConductorTestData
impl Send for ConductorTestData
impl Sync for ConductorTestData
impl Unpin for ConductorTestData
impl !UnwindSafe for ConductorTestData
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
TODO: once 1.33.0 is the minimum supported compiler version, remove
Any::type_id_compat and use StdAny::type_id instead.
https://github.com/rust-lang/rust/issues/27745
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.§impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref