diff --git a/radicle-cli/examples/rad-id-unknown-field.md b/radicle-cli/examples/rad-id-unknown-field.md new file mode 100644 index 00000000..68657ded --- /dev/null +++ b/radicle-cli/examples/rad-id-unknown-field.md @@ -0,0 +1,47 @@ +The payloads in the identity document are extensible and arbitrary fields can be +added. Here we will add an emoji alias for the heartwood project: + +``` +$ rad id update --title "Add emoji alias" --description "Adding alias field" --payload xyz.radicle.project alias '"❤️🪵"' +✓ Identity revision 05100d3f0a73b9373681677158615a53ba51940e created +╭────────────────────────────────────────────────────────────────────────╮ +│ Title Add emoji alias │ +│ Revision 05100d3f0a73b9373681677158615a53ba51940e │ +│ Blob a0f421c928dcfc6eca129fc2ea1f50877de7dc20 │ +│ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi │ +│ State accepted │ +│ Quorum yes │ +│ │ +│ Adding alias field │ +├────────────────────────────────────────────────────────────────────────┤ +│ ✓ did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi alice (you) │ +╰────────────────────────────────────────────────────────────────────────╯ + +@@ -1,13 +1,14 @@ + { + "payload": { + "xyz.radicle.project": { ++ "alias": "❤️🪵", + "defaultBranch": "master", + "description": "Radicle Heartwood Protocol & Stack", + "name": "heartwood" + } + }, + "delegates": [ + "did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi" + ], + "threshold": 1 + } +``` + +We can see that the project payload still loads by using `rad ls` which will +attempt to deserialize the payload: + +``` +$ rad ls +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ Name RID Visibility Head Description │ +├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤ +│ heartwood rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji public f2de534 Radicle Heartwood Protocol & Stack │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +``` diff --git a/radicle-cli/tests/commands.rs b/radicle-cli/tests/commands.rs index 2121af6c..e09d5553 100644 --- a/radicle-cli/tests/commands.rs +++ b/radicle-cli/tests/commands.rs @@ -627,6 +627,35 @@ fn rad_id_conflict() { .unwrap(); } +#[test] +fn rad_id_unknown_field() { + let mut environment = Environment::new(); + let alice = environment.node(config::node("alice")); + let working = tempfile::tempdir().unwrap(); + let working = working.path(); + + // Setup a test repository. + fixtures::repository(working.join("alice")); + + test( + "examples/rad-init.md", + working.join("alice"), + Some(&alice.home), + [], + ) + .unwrap(); + + let alice = alice.spawn(); + + test( + "examples/rad-id-unknown-field.md", + working.join("alice"), + Some(&alice.home), + [], + ) + .unwrap(); +} + #[test] fn rad_node_connect() { let mut environment = Environment::new();