Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
test get_validation_package_roundtrip()
Browse files Browse the repository at this point in the history
  • Loading branch information
lucksus committed Dec 6, 2018
1 parent 77c6d6f commit 6955178
Showing 1 changed file with 102 additions and 1 deletion.
103 changes: 102 additions & 1 deletion core/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ mod util;
#[cfg(test)]
pub mod tests {
use crate::{
instance::tests::test_instance_and_context_by_name, network::actions::get_entry::get_entry,
instance::tests::test_instance_and_context_by_name,
network::actions::{
get_entry::get_entry,
get_validation_package::get_validation_package,
},
workflows::author_entry::author_entry,
};
use futures::executor::block_on;
use holochain_core_types::{cas::content::AddressableContent, entry::test_entry};
Expand Down Expand Up @@ -60,4 +65,100 @@ pub mod tests {
let maybe_entry = result.unwrap();
assert!(maybe_entry.is_none());
}


#[test]
fn get_validation_package_roundtrip() {
let wat=
r#"
(module
(memory 1)
(export "memory" (memory 0))
(func
(export "__hdk_validate_app_entry")
(param $allocation i32)
(result i32)
(i32.const 0)
)
(func
(export "__hdk_validate_link")
(param $allocation i32)
(result i32)
(i32.const 0)
)
(func
(export "__hdk_get_validation_package_for_entry_type")
(param $allocation i32)
(result i32)
;; This writes "Entry" into memory
(i32.store (i32.const 0) (i32.const 34))
(i32.store (i32.const 1) (i32.const 69))
(i32.store (i32.const 2) (i32.const 110))
(i32.store (i32.const 3) (i32.const 116))
(i32.store (i32.const 4) (i32.const 114))
(i32.store (i32.const 5) (i32.const 121))
(i32.store (i32.const 6) (i32.const 34))
(i32.const 7)
)
(func
(export "__hdk_get_validation_package_for_link")
(param $allocation i32)
(result i32)
;; This writes "Entry" into memory
(i32.store (i32.const 0) (i32.const 34))
(i32.store (i32.const 1) (i32.const 69))
(i32.store (i32.const 2) (i32.const 110))
(i32.store (i32.const 3) (i32.const 116))
(i32.store (i32.const 4) (i32.const 114))
(i32.store (i32.const 5) (i32.const 121))
(i32.store (i32.const 6) (i32.const 34))
(i32.const 7)
)
(func
(export "__list_capabilities")
(param $allocation i32)
(result i32)
(i32.const 0)
)
)
"#;


let mut dna = create_test_dna_with_wat("test_zome", "test_cap", Some(wat));
dna.uuid = String::from("get_validation_package_roundtrip");
let (_, context1) = test_instance_and_context_by_name(dna.clone(), "alice1").unwrap();

println!("AGENT 1 address: {}", context1.agent_id.address());

let entry = test_entry();
block_on(author_entry(&entry, &context1))
.expect("Could not author entry");

let agent1_state = context1.state().unwrap().agent();
let header = agent1_state.chain()
.iter_type(&agent1_state.top_chain_header(), &entry.entry_type())
.find(|h| h.entry_address() == &entry.address())
.expect("There must be a header in the author's source chain after commit");


let (_, context2) = test_instance_and_context_by_name(dna.clone(), "bob1").unwrap();
let result = block_on(get_validation_package(header, &context2));

assert!(result.is_ok());
println!("{:?}", result.unwrap());
}
}

0 comments on commit 6955178

Please sign in to comment.