diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b0ec88..23e3c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added ### Changed +- Update to Holochain 0.5.0-dev.7 +- Updates to new zome call signing logic +- Uses the new `roles_settings` field in the `InstallAppPayload`. ### Fixed ### Removed diff --git a/Cargo.lock b/Cargo.lock index fcb867f..31b6bf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2614,6 +2614,7 @@ dependencies = [ "parking_lot 0.12.3", "rand 0.8.5", "serde", + "serde_yaml", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index 04dca2a..7685008 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,7 @@ tokio = { version = "1.36", features = ["rt"] } [dev-dependencies] fixt = "0.5.0-dev.0" holochain = { version = "0.5.0-dev.7", features = ["test_utils"] } +serde_yaml = "0.9" [features] default = ["lair_signing"] diff --git a/tests/admin.rs b/tests/admin.rs index c5aa640..56cea23 100644 --- a/tests/admin.rs +++ b/tests/admin.rs @@ -1,3 +1,4 @@ +use holochain::prelude::{DnaModifiersOpt, RoleSettings, Timestamp, YamlProperties}; use holochain::test_utils::itertools::Itertools; use holochain::{prelude::AppBundleSource, sweettest::SweetConductor}; use holochain_client::{ @@ -10,7 +11,7 @@ use holochain_zome_types::prelude::ExternIO; use kitsune_p2p_types::fixt::AgentInfoSignedFixturator; use std::collections::BTreeSet; use std::net::Ipv4Addr; -use std::path::PathBuf; +use std::{collections::HashMap, path::PathBuf}; const ROLE_NAME: &str = "foo"; @@ -330,3 +331,76 @@ async fn list_cell_ids() { // because the DPKI cell is included too. assert!(cell_ids.contains(&cell_id)); } + +#[tokio::test(flavor = "multi_thread")] +async fn install_app_with_roles_settings() { + let conductor = SweetConductor::from_standard_config().await; + let admin_port = conductor.get_arbitrary_admin_websocket_port().unwrap(); + let admin_ws = AdminWebsocket::connect(format!("127.0.0.1:{}", admin_port)) + .await + .unwrap(); + let app_id: InstalledAppId = "test-app".into(); + let agent_key = admin_ws.generate_agent_pub_key().await.unwrap(); + + let custom_network_seed = String::from("modified seed"); + let custom_properties = YamlProperties::new(serde_yaml::Value::String(String::from( + "some properties provided at install time", + ))); + let custom_origin_time = Timestamp::now(); + let custom_quantum_time = std::time::Duration::from_secs(5 * 60); + + let custom_modifiers = DnaModifiersOpt::default() + .with_network_seed(custom_network_seed.clone()) + .with_origin_time(custom_origin_time) + .with_quantum_time(custom_quantum_time) + .with_properties(custom_properties.clone()); + + let role_settings = ( + String::from("foo"), + RoleSettings::Provisioned { + membrane_proof: Default::default(), + modifiers: Some(custom_modifiers), + }, + ); + + admin_ws + .install_app(InstallAppPayload { + agent_key: Some(agent_key.clone()), + installed_app_id: Some(app_id.clone()), + roles_settings: Some(HashMap::from([role_settings])), + network_seed: None, + source: AppBundleSource::Path(PathBuf::from("./fixture/test.happ")), + ignore_genesis_failure: false, + allow_throwaway_random_agent_key: false, + }) + .await + .unwrap(); + admin_ws.enable_app(app_id.clone()).await.unwrap(); + + let app_info = admin_ws + .list_apps(None) + .await + .unwrap() + .first() + .unwrap() + .clone(); + + let manifest = app_info.manifest; + + let app_role = manifest + .app_roles() + .into_iter() + .find(|r| r.name == "foo") + .unwrap(); + + assert_eq!( + app_role.dna.modifiers.network_seed, + Some(custom_network_seed) + ); + assert_eq!(app_role.dna.modifiers.origin_time, Some(custom_origin_time)); + assert_eq!( + app_role.dna.modifiers.quantum_time, + Some(custom_quantum_time) + ); + assert_eq!(app_role.dna.modifiers.properties, Some(custom_properties)); +}