Struct holochain::test_utils::conductor_setup::CellHostFnCaller
source · pub struct CellHostFnCaller {
pub cell_id: CellId,
pub authored_db: DbWrite<DbKindAuthored>,
pub dht_db: DbWrite<DbKindDht>,
pub dht_db_cache: DhtDbQueryCache,
pub cache: DbWrite<DbKindCache>,
pub ribosome: RealRibosome,
pub network: HolochainP2pDna,
pub keystore: MetaLairClient,
pub signal_tx: SignalBroadcaster,
pub triggers: QueueTriggers,
pub cell_conductor_api: CellConductorApi,
}
Expand description
A “factory” for HostFnCaller, which will produce them when given a ZomeName
Fields§
§cell_id: CellId
§dht_db: DbWrite<DbKindDht>
§dht_db_cache: DhtDbQueryCache
§cache: DbWrite<DbKindCache>
§ribosome: RealRibosome
§network: HolochainP2pDna
§keystore: MetaLairClient
§signal_tx: SignalBroadcaster
§triggers: QueueTriggers
§cell_conductor_api: CellConductorApi
Implementations§
source§impl CellHostFnCaller
impl CellHostFnCaller
sourcepub async fn new(
cell_id: &CellId,
handle: &ConductorHandle,
dna_file: &DnaFile,
chc: Option<ChcImpl>
) -> Self
pub async fn new(
cell_id: &CellId,
handle: &ConductorHandle,
dna_file: &DnaFile,
chc: Option<ChcImpl>
) -> Self
Examples found in repository?
src/test_utils/conductor_setup.rs (line 147)
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
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)
}
/// Create a new conductor and test data
pub async fn two_agents(zomes: Vec<TestWasm>, with_bob: bool) -> Self {
Self::two_agents_inner(zomes, with_bob, None).await
}
/// New test data that creates a conductor using a custom network config
pub async fn with_network_config(
zomes: Vec<TestWasm>,
with_bob: bool,
network: KitsuneP2pConfig,
) -> Self {
Self::two_agents_inner(zomes, with_bob, Some(network)).await
}
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
}
/// Shutdown the conductor
pub async fn shutdown_conductor(&mut self) {
let shutdown = self.handle.take_shutdown_handle().unwrap();
self.handle.shutdown();
shutdown.await.unwrap().unwrap();
}
/// Bring bob online if he isn't already
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 get_api<I: Into<ZomeName>>(&self, zome_name: I) -> HostFnCaller
pub fn get_api<I: Into<ZomeName>>(&self, zome_name: I) -> HostFnCaller
Create a HostFnCaller for a specific zome and call
Auto Trait Implementations§
impl !RefUnwindSafe for CellHostFnCaller
impl Send for CellHostFnCaller
impl Sync for CellHostFnCaller
impl Unpin for CellHostFnCaller
impl !UnwindSafe for CellHostFnCaller
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