Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: set identity head on init
Fintan Halpenny committed 3 years ago
commit af99d6f47aa4d6bbc0bf1e48c588397e5f1594db
parent a629f91b1e4fc249ce2a41e82eb2a2f9a716fd79
2 files changed +25 -1
modified 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<Verified>) {
        let (_, bytes) = doc.encode().unwrap();
modified radicle/src/rad.rs
@@ -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))
}