-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: tidy up * feat: jq aggregation; also: - rationalise test containers - tidy integrity validation function * chore: update e2e
- Loading branch information
Showing
53 changed files
with
2,482 additions
and
699 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"cSpell.language": "en,en-GB", | ||
"cSpell.words": [ | ||
"Dalek", | ||
"Faceit", | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod oracle; | ||
mod user_metadata; | ||
mod username_attestation; | ||
mod wallet_attestation; |
161 changes: 161 additions & 0 deletions
161
crates/holoom_dna_tests/src/tests/username_registry/oracle.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 |
---|---|---|
@@ -0,0 +1,161 @@ | ||
use hdk::prelude::*; | ||
|
||
use holochain::conductor::api::error::ConductorApiResult; | ||
use holoom_types::{ | ||
JqExecution, OracleDocument, OracleDocumentListSnapshot, | ||
RefreshJqExecutionForNamedRelationPayload, RelateOracleDocumentPayload, SnapshotInput, | ||
}; | ||
use username_registry_utils::deserialize_record_entry; | ||
|
||
use crate::TestSetup; | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn can_fetch_documents_by_relation() { | ||
let setup = TestSetup::authority_only().await; | ||
|
||
let foo1_record: Record = setup | ||
.authority_call( | ||
"username_registry", | ||
"create_oracle_document", | ||
OracleDocument { | ||
name: "foo/1".into(), | ||
json_data: "{\"type\":\"foo\",\"value\":1}".into(), | ||
}, | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let foo2_record: Record = setup | ||
.authority_call( | ||
"username_registry", | ||
"create_oracle_document", | ||
OracleDocument { | ||
name: "foo/2".into(), | ||
json_data: "{\"type\":\"foo\",\"value\":2}".into(), | ||
}, | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let res: ConductorApiResult<()> = setup | ||
.authority_call( | ||
"username_registry", | ||
"relate_oracle_document", | ||
RelateOracleDocumentPayload { | ||
name: "foo/1".into(), | ||
relation: "foo".into(), | ||
}, | ||
) | ||
.await; | ||
assert!(res.is_ok()); | ||
|
||
let res: ConductorApiResult<()> = setup | ||
.authority_call( | ||
"username_registry", | ||
"relate_oracle_document", | ||
RelateOracleDocumentPayload { | ||
name: "foo/2".into(), | ||
relation: "foo".into(), | ||
}, | ||
) | ||
.await; | ||
assert!(res.is_ok()); | ||
|
||
let identifiers: Vec<String> = setup | ||
.authority_call( | ||
"username_registry", | ||
"get_related_oracle_document", | ||
String::from("foo"), | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let expected_identifiers = vec![String::from("foo/1"), String::from("foo/2")]; | ||
assert_eq!(identifiers, expected_identifiers); | ||
|
||
let snapshot_record: Record = setup | ||
.authority_call( | ||
"username_registry", | ||
"refresh_oracle_document_snapshot_for_relation", | ||
String::from("foo"), | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let snapshot: OracleDocumentListSnapshot = deserialize_record_entry(snapshot_record).unwrap(); | ||
|
||
assert_eq!( | ||
snapshot.identifiers_input, | ||
SnapshotInput::RelationSnapshot(expected_identifiers) | ||
); | ||
assert_eq!( | ||
snapshot.resolved_documents, | ||
vec![ | ||
foo1_record.action_address().clone(), | ||
foo2_record.action_address().clone() | ||
] | ||
); | ||
|
||
let jq_execution_record: Record = setup | ||
.authority_call( | ||
"username_registry", | ||
"refresh_jq_execution_for_named_relation", | ||
RefreshJqExecutionForNamedRelationPayload { | ||
relation_name: "foo".into(), | ||
program: "[.[].value]".into(), | ||
}, | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let jq_execution: JqExecution = deserialize_record_entry(jq_execution_record).unwrap(); | ||
assert_eq!(jq_execution.output, String::from("[1,2]")); | ||
|
||
let revised_foo2_record: Record = setup | ||
.authority_call( | ||
"username_registry", | ||
"create_oracle_document", | ||
OracleDocument { | ||
name: "foo/2".into(), | ||
json_data: "{\"type\":\"foo\",\"value\":\"two\"}".into(), | ||
}, | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let revised_snapshot_record: Record = setup | ||
.authority_call( | ||
"username_registry", | ||
"refresh_oracle_document_snapshot_for_relation", | ||
String::from("foo"), | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let revised_snapshot: OracleDocumentListSnapshot = | ||
deserialize_record_entry(revised_snapshot_record).unwrap(); | ||
|
||
assert_eq!( | ||
revised_snapshot.resolved_documents, | ||
vec![ | ||
foo1_record.action_address().clone(), | ||
revised_foo2_record.action_address().clone() | ||
] | ||
); | ||
|
||
let revised_jq_execution_record: Record = setup | ||
.authority_call( | ||
"username_registry", | ||
"refresh_jq_execution_for_named_relation", | ||
RefreshJqExecutionForNamedRelationPayload { | ||
relation_name: "foo".into(), | ||
program: "[.[].value]".into(), | ||
}, | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let revised_jq_execution: JqExecution = | ||
deserialize_record_entry(revised_jq_execution_record).unwrap(); | ||
assert_eq!(revised_jq_execution.output, String::from("[1,\"two\"]")); | ||
} |
Oops, something went wrong.