From af99d6f47aa4d6bbc0bf1e48c588397e5f1594db Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 23 Mar 2023 14:04:08 +0000 Subject: [PATCH] radicle: set identity head on init Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle/src/identity/doc.rs | 25 ++++++++++++++++++++++++- radicle/src/rad.rs | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/radicle/src/identity/doc.rs b/radicle/src/identity/doc.rs index f6aa04aa..771baf18 100644 --- a/radicle/src/identity/doc.rs +++ b/radicle/src/identity/doc.rs @@ -395,7 +395,7 @@ mod test { use crate::rad; use crate::storage::git::transport; use crate::storage::git::Storage; - use crate::storage::WriteStorage as _; + use crate::storage::{ReadStorage as _, WriteStorage as _}; use crate::test::arbitrary; use crate::test::fixtures; @@ -448,6 +448,29 @@ mod test { assert!(err.is_not_found()); } + #[test] + fn test_canonical_doc() { + let tempdir = tempfile::tempdir().unwrap(); + let storage = Storage::open(tempdir.path().join("storage")).unwrap(); + transport::local::register(storage.clone()); + + let (working, _) = fixtures::repository(tempdir.path().join("working")); + + let delegate = MockSigner::from_seed([0xff; 32]); + let (rid, doc, _) = rad::init( + &working, + "heartwood", + "Radicle Heartwood Protocol & Stack", + git::refname!("master"), + &delegate, + &storage, + ) + .unwrap(); + let repo = storage.repository(rid).unwrap(); + + assert_eq!(doc, Doc::canonical(&repo).unwrap().doc); + } + #[quickcheck] fn prop_encode_decode(doc: Doc) { let (_, bytes) = doc.encode().unwrap(); diff --git a/radicle/src/rad.rs b/radicle/src/rad.rs index d9f161ff..35ca264b 100644 --- a/radicle/src/rad.rs +++ b/radicle/src/rad.rs @@ -83,6 +83,7 @@ pub fn init( )?; let signed = project.sign_refs(signer)?; let _head = project.set_head()?; + let _head = project.set_identity_head()?; Ok((project.id, doc, signed)) }