-
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.
feat(user_registry): Get/set user metadata (#7)
Adds update_metadata_item and get_metadata_item_value coordinator functions for managing a user curated key-value store - implemented by encoding key-value pairs into link tags on the user's agent pub key. * chore: refactor e2e test * feat: get/set user metadata + e2e test * feat(user_registry): get another user's metadata + test refactor
- Loading branch information
Showing
28 changed files
with
1,153 additions
and
869 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,3 +1,3 @@ | ||
{ | ||
"cSpell.words": ["Dalek", "Holochain", "Solana", "zome", "zomes"] | ||
"cSpell.words": ["Dalek", "Holochain", "pubkey", "Solana", "zome", "zomes"] | ||
} |
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
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,2 @@ | ||
mod signer; | ||
mod username_registry; |
2 changes: 1 addition & 1 deletion
2
crates/game_identity_tests/tests/signer.rs → ...s/game_identity_tests/src/tests/signer.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
3 changes: 3 additions & 0 deletions
3
crates/game_identity_tests/src/tests/username_registry/mod.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,3 @@ | ||
mod user_metadata; | ||
mod username_attestation; | ||
mod wallet_attestation; |
63 changes: 63 additions & 0 deletions
63
crates/game_identity_tests/src/tests/username_registry/user_metadata.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,63 @@ | ||
use std::collections::HashMap; | ||
|
||
use game_identity_types::{GetMetadataItemValuePayload, UpdateMetadataItemPayload}; | ||
use holochain::conductor::api::error::ConductorApiError; | ||
|
||
use crate::TestSetup; | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn users_can_only_update_their_own_metadata() { | ||
let setup = TestSetup::authority_and_alice_bob().await; | ||
setup.conductors.exchange_peer_info().await; | ||
|
||
// Alice starts with no metadata | ||
let initial_metadata: HashMap<String, String> = setup | ||
.alice_call("username_registry", "get_metadata", setup.alice_pubkey()) | ||
.await | ||
.unwrap(); | ||
assert_eq!(initial_metadata, HashMap::default()); | ||
|
||
// Bob cannot set Alice's metadata | ||
let res1: Result<(), ConductorApiError> = setup | ||
.bob_call( | ||
"username_registry", | ||
"update_metadata_item", | ||
UpdateMetadataItemPayload { | ||
agent_pubkey: setup.alice_pubkey(), | ||
name: "foo".into(), | ||
value: "bar".into(), | ||
}, | ||
) | ||
.await; | ||
assert!(res1.is_err()); | ||
|
||
// Alice sets an item | ||
let _: () = setup | ||
.alice_call( | ||
"username_registry", | ||
"update_metadata_item", | ||
UpdateMetadataItemPayload { | ||
agent_pubkey: setup.alice_pubkey(), | ||
name: "foo".into(), | ||
value: "bar2".into(), | ||
}, | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
setup.consistency().await; | ||
|
||
// Bob sees new item | ||
let value1: String = setup | ||
.bob_call( | ||
"username_registry", | ||
"get_metadata_item_value", | ||
GetMetadataItemValuePayload { | ||
agent_pubkey: setup.alice_pubkey(), | ||
name: "foo".into(), | ||
}, | ||
) | ||
.await | ||
.unwrap(); | ||
assert_eq!(value1, String::from("bar2")); | ||
} |
Oops, something went wrong.