Skip to content

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

chore: files changed crates/openhuman-modules-linked/Cargo.toml,crates/openhuman-modules-linked/src/

Steven Enamakel6817582d6e8b
diff --git a/crates/openhuman-modules-linked/Cargo.toml b/crates/openhuman-modules-linked/Cargo.toml
index 25974a9634..dff56174b5 100644
--- a/crates/openhuman-modules-linked/Cargo.toml
+++ b/crates/openhuman-modules-linked/Cargo.toml
@@ -74,5 +74,9 @@ tinysearch = { path = "../../vendor/tinysearch/crates/tinysearch", features = ["
tinyvoice-module = { path = "../../vendor/tinyvoice/crates/tinyvoice-module", features = ["static-link"], optional = true }
tinywallet-module = { path = "../../vendor/tinywallet/crates/tinywallet-module", features = ["static-link"], optional = true }
+[dev-dependencies]
+serde_json = "1"
+tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
+
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)'] }
diff --git a/crates/openhuman-modules-linked/src/lib_tests.rs b/crates/openhuman-modules-linked/src/lib_tests.rs
index 347e3571f0..3bf55e2556 100644
--- a/crates/openhuman-modules-linked/src/lib_tests.rs
+++ b/crates/openhuman-modules-linked/src/lib_tests.rs
@@ -120,3 +120,97 @@ fn enabled_modules_claim_distinct_bus_names_and_object_paths() {
);
}
}
+
+/// A linked module is attested by the executable's digest. Every module this
+/// build links that the bare host admits must be attested, or its confidential
+/// members could never be delivered in a linked build.
+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
+async fn admitted_linked_modules_are_attested_as_host_code() {
+ use tinybus::module::ModuleHost;
+ use tinybus::transport::memory::MemoryBus;
+ use tinybus::Connection;
+
+ for (id, factory) in linked_modules() {
+ let bus = MemoryBus::new();
+ let broker = Broker::new();
+ let broker_task = broker.spawn(bus.clone());
+ let host = ModuleHost::new(broker);
+ let Ok(info) = host.attach_linked_with_config(factory().unwrap(), serde_json::json!({}))
+ else {
+ broker_task.abort();
+ continue;
+ };
+ let client = Connection::connect(bus.connect().await.unwrap())
+ .await
+ .unwrap();
+ let attestation = client
+ .attestation(info.manifest.bus_name.clone())
+ .await
+ .unwrap();
+ assert!(attestation.is_some(), "{id}: not attested as host code");
+ broker_task.abort();
+ }
+}
+
+/// tinywallet's attested members work linked: the module signs a transaction
+/// confidentially, which an unattested module would refuse. This is why
+/// tinywallet is linkable rather than `source`-only.
+#[cfg(feature = "tinywallet")]
+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
+async fn linked_tinywallet_accepts_confidential_delivery() {
+ use tinybus::module::ModuleHost;
+ use tinybus::transport::memory::MemoryBus;
+ use tinybus::Connection;
+
+ let bus = MemoryBus::new();
+ let broker = Broker::new();
+ let broker_task = broker.spawn(bus.clone());
+ let host = ModuleHost::new(broker);
+ let module = tinywallet_module::linked_module().unwrap();
+ let info = host
+ .attach_linked_with_config(module, serde_json::json!({}))
+ .expect("linked tinywallet is admitted");
+ let client = Connection::connect(bus.connect().await.unwrap())
+ .await
+ .unwrap();
+ let proxy = client
+ .proxy(
+ tinywallet_module::BUS_NAME,
+ tinywallet_module::OBJECT_PATH,
+ tinywallet_module::BUS_NAME,
+ )
+ .unwrap();
+ assert_eq!(info.manifest.bus_name.as_str(), tinywallet_module::BUS_NAME);
+ let request = serde_json::json!({
+ "secret": {
+ "mnemonic": "abandon abandon abandon abandon abandon abandon \
+ abandon abandon abandon abandon abandon about",
+ "derivation_path": "m/44'/60'/0'/0/0",
+ "chain": "evm",
+ },
+ "transaction": {
+ "kind": "evm",
+ "to": "0x3535353535353535353535353535353535353535",
+ "value_wei": "1000000000000000000",
+ "data_hex": "0x",
+ "nonce": 9,
+ "gas_limit": 21_000,
+ "gas_price_wei": "20000000000",
+ "chain_id": 1,
+ },
+ });
+ let mut delivered = false;
+ for _ in 0..50 {
+ if proxy
+ .call_confidential::<serde_json::Value>("SignTransaction", (request.clone(),))
+ .await
+ .is_ok()
+ {
+ delivered = true;
+ break;
+ }
+ tokio::time::sleep(std::time::Duration::from_millis(100)).await;
+ }
+ broker_task.abort();
+ assert!(delivered, "linked tinywallet must accept confidential delivery");
+}