-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
152 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
193 changes: 133 additions & 60 deletions
193
dnas/clutter/coordinator_zomes/mews/tests/mews_tests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,158 @@ | ||
#![warn(warnings)] | ||
|
||
use futures::future; | ||
|
||
use hdk::prelude::*; | ||
use holochain::sweettest::{ | ||
SweetAgents, SweetAppBatch, SweetCell, SweetConductor, SweetConductorBatch, SweetDnaFile, | ||
}; | ||
// use hdk::prelude::holo_hash::*; | ||
use holochain::conductor::config::ConductorConfig; | ||
use holochain::sweettest::{SweetConductorBatch, SweetDnaFile}; | ||
use holochain::test_utils::consistency_10s; | ||
|
||
use mews_integrity::*; | ||
|
||
const DNA_FILEPATH: &str = "../../workdir/clutter.dna"; | ||
|
||
// TESTS: | ||
const ZOME_NAME: &str = "clutter"; | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
pub async fn mew_can_be_200_chars() { | ||
let (conductor, _alice, cell1): (SweetConductor, AgentPubKey, SweetCell) = | ||
setup_1_conductor().await; | ||
|
||
let long_mew = std::iter::repeat('a').take(200).collect::<String>(); | ||
let create_mew_input = CreateMewInput { | ||
text: Some(long_mew), | ||
mew_type: MewType::Original, | ||
links: None, | ||
}; | ||
|
||
let mew_hash: ActionHash = conductor | ||
.call(&cell1.zome("mews"), "create_mew", create_mew_input) | ||
async fn trustd_feed_is_based_on_follow_topics() { | ||
// Use prebuilt DNA file | ||
let dna_path = std::env::current_dir().unwrap().join(DNA_FILEPATH); | ||
let dna = SweetDnaFile::from_bundle(&dna_path).await.unwrap(); | ||
|
||
// Set up conductors | ||
let mut conductors = SweetConductorBatch::from_config(3, ConductorConfig::default()).await; | ||
let apps = conductors.setup_app("clutter", &[dna]).await.unwrap(); | ||
conductors.exchange_peer_info().await; | ||
|
||
let ((ann,), (bob,), (cat,)) = apps.into_tuples(); | ||
|
||
let ann_zome = ann.zome(ZOME_NAME); | ||
let bob_zome = bob.zome(ZOME_NAME); | ||
let cat_zome = cat.zome(ZOME_NAME); | ||
|
||
// let ann_conductor = conductors[0].clone(); | ||
// let bob_conductor = conductors[1].clone(); | ||
// let cat_conductor = conductors[2].clone(); | ||
|
||
let _entry_hash: EntryHash = conductors[0] | ||
.call( | ||
&ann_zome, | ||
"follow", | ||
FollowInput { | ||
agent: bob.agent_pubkey().clone(), | ||
follow_topics: vec![FollowTopicInput { | ||
topic: String::from("kittens"), | ||
weight: String::from("1.0"), | ||
}], | ||
}, | ||
) | ||
.await; | ||
|
||
let bytes = mew_hash.get_raw_39(); | ||
let leading_bytes = bytes.get(..3).unwrap(); | ||
assert_eq!(leading_bytes, &[132, 41, 36]); | ||
consistency_10s([&ann, &bob, &cat]).await; | ||
|
||
// let applet = AppletInstance { | ||
// custom_name: String::from("custom name"), | ||
// description: String::from("description"), | ||
// logo_src: None, | ||
// devhub_happ_release_hash: fixt!(EntryHash), | ||
// devhub_gui_release_hash: fixt!(EntryHash), | ||
|
||
// network_seed: None, | ||
// properties: BTreeMap::new(), // Segmented by RoleId | ||
// dna_hashes: BTreeMap::new(), // Segmented by RoleId | ||
// }; | ||
|
||
// let _entry_hash: EntryHash = conductors[0] | ||
// .call(&ann_zome, "register_applet_instance", applet) | ||
// .await; | ||
|
||
// let all_applets: Vec<Record> = conductors[1] | ||
// .call(&bob_zome, "get_applets_instances", ()) | ||
// .await; | ||
|
||
// assert_eq!(all_applets.len(), 1); | ||
} | ||
|
||
// SETUP: | ||
// #![warn(warnings)] | ||
|
||
async fn setup_1_conductor() -> (SweetConductor, AgentPubKey, SweetCell) { | ||
let dna = SweetDnaFile::from_bundle(std::path::Path::new(DNA_FILEPATH)) | ||
.await | ||
.unwrap(); | ||
// use futures::future; | ||
|
||
let mut conductor = SweetConductor::from_standard_config().await; | ||
// use hdk::prelude::*; | ||
// use holochain::sweettest::{ | ||
// SweetAgents, SweetAppBatch, SweetCell, SweetConductor, SweetConductorBatch, SweetDnaFile, | ||
// }; | ||
|
||
let holo_core_agent = SweetAgents::one(conductor.keystore()).await; | ||
let app1 = conductor | ||
.setup_app_for_agent("app", holo_core_agent.clone(), &[dna.clone()]) | ||
.await | ||
.unwrap(); | ||
// use mews_integrity::*; | ||
|
||
let cell1 = app1.into_cells()[0].clone(); | ||
// const DNA_FILEPATH: &str = "../../workdir/clutter.dna"; | ||
|
||
let agent_hash = holo_core_agent.into_inner(); | ||
let agent = AgentPubKey::from_raw_39(agent_hash).unwrap(); | ||
// // TESTS: | ||
|
||
(conductor, agent, cell1) | ||
} | ||
// #[tokio::test(flavor = "multi_thread")] | ||
// pub async fn trustd_feed_is_based_on_follow_() { | ||
// let (conductor, _ann, cell1): (SweetConductor, AgentPubKey, SweetCell) = | ||
// setup_1_conductor().await; | ||
|
||
pub async fn setup_conductors(n: usize) -> (SweetConductorBatch, Vec<AgentPubKey>, SweetAppBatch) { | ||
let dna = SweetDnaFile::from_bundle(std::path::Path::new(DNA_FILEPATH)) | ||
.await | ||
.unwrap(); | ||
// let long_mew = std::iter::repeat('a').take(200).collect::<String>(); | ||
// let create_mew_input = CreateMewInput { | ||
// text: Some(long_mew), | ||
// mew_type: MewType::Original, | ||
// links: None, | ||
// }; | ||
|
||
let mut conductors = SweetConductorBatch::from_standard_config(n).await; | ||
// let mew_hash: ActionHash = conductor | ||
// .call(&cell1.zome("mews"), "create_mew", create_mew_input) | ||
// .await; | ||
|
||
let all_agents1: Vec<holochain::core::AgentPubKey> = | ||
future::join_all(conductors.iter().map(|c| SweetAgents::one(c.keystore()))).await; | ||
// let bytes = mew_hash.get_raw_39(); | ||
// let leading_bytes = bytes.get(..3).unwrap(); | ||
// assert_eq!(leading_bytes, &[132, 41, 36]); | ||
// } | ||
|
||
let all_agents2: Vec<AgentPubKey> = all_agents1 | ||
.iter() | ||
.map(|holo_core_agent| { | ||
let agent_hash = holo_core_agent.clone().into_inner(); | ||
AgentPubKey::from_raw_39(agent_hash).unwrap() | ||
}) | ||
.collect(); | ||
// // SETUP: | ||
|
||
let apps = conductors | ||
.setup_app_for_zipped_agents("app", &all_agents1, &[dna]) | ||
.await | ||
.unwrap(); | ||
// async fn setup_1_conductor() -> (SweetConductor, AgentPubKey, SweetCell) { | ||
// let dna = SweetDnaFile::from_bundle(std::path::Path::new(DNA_FILEPATH)) | ||
// .await | ||
// .unwrap(); | ||
|
||
conductors.exchange_peer_info().await; | ||
(conductors, all_agents2, apps) | ||
} | ||
// let mut conductor = SweetConductor::from_standard_config().await; | ||
|
||
// let holo_core_agent = SweetAgents::one(conductor.keystore()).await; | ||
// let app1 = conductor | ||
// .setup_app_for_agent("app", holo_core_agent.clone(), &[dna.clone()]) | ||
// .await | ||
// .unwrap(); | ||
|
||
// let cell1 = app1.into_cells()[0].clone(); | ||
|
||
// let agent_hash = holo_core_agent.into_inner(); | ||
// let agent = AgentPubKey::from_raw_39(agent_hash).unwrap(); | ||
|
||
// (conductor, agent, cell1) | ||
// } | ||
|
||
// pub async fn setup_conductors(n: usize) -> (SweetConductorBatch, Vec<AgentPubKey>, SweetAppBatch) { | ||
// let dna = SweetDnaFile::from_bundle(std::path::Path::new(DNA_FILEPATH)) | ||
// .await | ||
// .unwrap(); | ||
|
||
// let mut conductors = SweetConductorBatch::from_standard_config(n).await; | ||
|
||
// let all_agents1: Vec<holochain::core::AgentPubKey> = | ||
// future::join_all(conductors.iter().map(|c| SweetAgents::one(c.keystore()))).await; | ||
|
||
// let all_agents2: Vec<AgentPubKey> = all_agents1 | ||
// .iter() | ||
// .map(|holo_core_agent| { | ||
// let agent_hash = holo_core_agent.clone().into_inner(); | ||
// AgentPubKey::from_raw_39(agent_hash).unwrap() | ||
// }) | ||
// .collect(); | ||
|
||
// let apps = conductors | ||
// .setup_app_for_zipped_agents("app", &all_agents1, &[dna]) | ||
// .await | ||
// .unwrap(); | ||
|
||
// conductors.exchange_peer_info().await; | ||
// (conductors, all_agents2, apps) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.