Skip to content

Commit

Permalink
Add roles settings test and changelog (#132)
Browse files Browse the repository at this point in the history
* add test around installing app with roles settings

* added changelog

* add missing imports and dev-dependency

* add missing import
  • Loading branch information
matthme authored Dec 2, 2024
1 parent 1ecd21d commit 6bdc65d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
76 changes: 75 additions & 1 deletion tests/admin.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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";

Expand Down Expand Up @@ -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));
}

0 comments on commit 6bdc65d

Please sign in to comment.