Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(channel_runtime): allow tests to supply a fixture proxy

Steven Enamakele749bdb9fe44
diff --git a/crates/openhuman-core/src/modules/channel_runtime.rs b/crates/openhuman-core/src/modules/channel_runtime.rs
index 05f41b90b2..7be4cb5d95 100644
--- a/crates/openhuman-core/src/modules/channel_runtime.rs
+++ b/crates/openhuman-core/src/modules/channel_runtime.rs
@@ -116,12 +116,9 @@ impl ChannelRuntimeLease {
callback: impl tinybus::service::Interface,
runtime: &'static super::host::ModuleRuntime,
) -> Result<Self, ModuleCallError> {
- let connection = runtime.connection().clone();
let callback_path = ObjectPath::new(&reservation.host_object_path)
.map_err(|_| ModuleCallError::ModuleFault)?;
- let proxy = runtime
- .proxy(tinychannels_bus::BUS_NAME, OBJECT_PATH)
- .map_err(|_| ModuleCallError::IncompatibleContract)?;
+ let (connection, proxy) = runtime_transport(&client, runtime)?;
let cleanup = Cleanup {
proxy,
connection: connection.clone(),
@@ -201,6 +198,23 @@ async fn join_cleanup(
result.map_err(|_| ModuleCallError::TransportFailed)?
}
+fn runtime_transport(
+ client: &ModuleClient,
+ runtime: &'static super::host::ModuleRuntime,
+) -> Result<(Connection, Proxy), ModuleCallError> {
+ #[cfg(test)]
+ if let Some(proxy) = client.fixture_proxy() {
+ return Ok((proxy.connection().clone(), proxy));
+ }
+ let _ = client;
+ Ok((
+ runtime.connection().clone(),
+ runtime
+ .proxy(tinychannels_bus::BUS_NAME, OBJECT_PATH)
+ .map_err(|_| ModuleCallError::IncompatibleContract)?,
+ ))
+}
+
fn validate_reservation(reservation: &ChannelRuntimeReservation) -> Result<(), ModuleCallError> {
if reservation.handle.len() != 32
|| !reservation
diff --git a/crates/openhuman-core/src/modules/client.rs b/crates/openhuman-core/src/modules/client.rs
index a111c96a5c..4e33edb467 100644
--- a/crates/openhuman-core/src/modules/client.rs
+++ b/crates/openhuman-core/src/modules/client.rs
@@ -65,6 +65,11 @@ impl ModuleClient {
}
}
+ #[cfg(test)]
+ pub(crate) fn fixture_proxy(&self) -> Option<tinybus::Proxy> {
+ self.fixture.clone()
+ }
+
/// Override the TinyBus deadline for every call made through this client.
///
/// Use this for module operations whose contract has a longer bounded