radicle: set identity head on init

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2023-03-23 14:04:08 +00:00
parent a629f91b1e
commit af99d6f47a
No known key found for this signature in database
GPG Key ID: 2552FB6F64066CB7
2 changed files with 25 additions and 1 deletions

View File

@ -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<Verified>) {
let (_, bytes) = doc.encode().unwrap();

View File

@ -83,6 +83,7 @@ pub fn init<G: Signer>(
)?;
let signed = project.sign_refs(signer)?;
let _head = project.set_head()?;
let _head = project.set_identity_head()?;
Ok((project.id, doc, signed))
}