Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
httpd: Insert test node into node db in `test::profile` fn
Merged did:key:z6MkkfM3...sVz5 opened 2 years ago

To allow the AliasStore to retrieve an alias from the node db, we need to insert it manually into the database in the profile function, else we won’t find any Aliases there.

2 files changed +77 -11 b1435629 325289d2
modified radicle-httpd/src/api/v1/projects.rs
@@ -1774,6 +1774,7 @@ mod routes {
            json!([
              {
                "id": "z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi",
+
                "alias": CONTRIBUTOR_ALIAS,
                "heads": {
                  "master": HEAD
                },
@@ -2018,7 +2019,8 @@ mod routes {
              {
                "id": ISSUE_ID,
                "author": {
-
                  "id": DID
+
                  "id": DID,
+
                  "alias": CONTRIBUTOR_ALIAS
                },
                "title": "Issue #1",
                "state": {
@@ -2029,13 +2031,15 @@ mod routes {
                  {
                    "id": ISSUE_ID,
                    "author": {
-
                      "id": DID
+
                      "id": DID,
+
                      "alias": CONTRIBUTOR_ALIAS
                    },
                    "body": "Change 'hello world' to 'hello everyone'",
                    "edits": [
                      {
                        "author": {
                          "id": DID,
+
                          "alias": CONTRIBUTOR_ALIAS
                        },
                        "body": "Change 'hello world' to 'hello everyone'",
                        "timestamp": TIMESTAMP,
@@ -2105,6 +2109,7 @@ mod routes {
              "id": CREATED_ISSUE_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "Issue #2",
              "state": {
@@ -2115,12 +2120,14 @@ mod routes {
                "id": CREATED_ISSUE_ID,
                "author": {
                  "id": CONTRIBUTOR_DID,
+
                  "alias": CONTRIBUTOR_ALIAS
                },
                "body": "Change 'hello world' to 'hello everyone'",
                "edits": [
                  {
                    "author": {
                      "id": CONTRIBUTOR_DID,
+
                      "alias": CONTRIBUTOR_ALIAS
                    },
                    "body": "Change 'hello world' to 'hello everyone'",
                    "timestamp": TIMESTAMP,
@@ -2252,6 +2259,7 @@ mod routes {
              "id": ISSUE_DISCUSSION_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "Issue #1",
              "state": {
@@ -2263,12 +2271,14 @@ mod routes {
                  "id": ISSUE_DISCUSSION_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "body": "EDIT: Change 'hello world' to 'hello anyone'",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "Change 'hello world' to 'hello everyone'",
                      "timestamp": TIMESTAMP,
@@ -2277,6 +2287,7 @@ mod routes {
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "EDIT: Change 'hello world' to 'hello anyone'",
                      "timestamp": TIMESTAMP,
@@ -2355,6 +2366,7 @@ mod routes {
              "id": ISSUE_DISCUSSION_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "Issue #1",
              "state": {
@@ -2366,12 +2378,14 @@ mod routes {
                  "id": ISSUE_DISCUSSION_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "body": "Change 'hello world' to 'hello everyone'",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "Change 'hello world' to 'hello everyone'",
                      "timestamp": TIMESTAMP,
@@ -2388,12 +2402,14 @@ mod routes {
                  "id": ISSUE_COMMENT_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "body": "This is a reply to the first comment",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "This is a reply to the first comment",
                      "timestamp": TIMESTAMP,
@@ -2436,7 +2452,8 @@ mod routes {
              {
                "id": CONTRIBUTOR_PATCH_ID,
                "author": {
-
                  "id": CONTRIBUTOR_DID
+
                  "id": CONTRIBUTOR_DID,
+
                  "alias": CONTRIBUTOR_ALIAS
                },
                "title": "A new `hello world`",
                "state": { "status": "open" },
@@ -2450,12 +2467,14 @@ mod routes {
                    "reactions": [],
                    "author": {
                      "id": CONTRIBUTOR_DID,
+
                      "alias": CONTRIBUTOR_ALIAS
                    },
                    "description": "change `hello world` in README to something else",
                    "edits": [
                      {
                        "author": {
                          "id": CONTRIBUTOR_DID,
+
                          "alias": CONTRIBUTOR_ALIAS
                        },
                        "body": "change `hello world` in README to something else",
                        "timestamp": TIMESTAMP,
@@ -2489,7 +2508,8 @@ mod routes {
              {
                "id": CONTRIBUTOR_PATCH_ID,
                "author": {
-
                  "id": CONTRIBUTOR_DID
+
                  "id": CONTRIBUTOR_DID,
+
                  "alias": CONTRIBUTOR_ALIAS
                },
                "title": "A new `hello world`",
                "state": { "status": "open" },
@@ -2503,12 +2523,14 @@ mod routes {
                    "reactions": [],
                    "author": {
                      "id": CONTRIBUTOR_DID,
+
                      "alias": CONTRIBUTOR_ALIAS
                    },
                    "description": "change `hello world` in README to something else",
                    "edits": [
                      {
                        "author": {
                          "id": CONTRIBUTOR_DID,
+
                          "alias": CONTRIBUTOR_ALIAS
                        },
                        "body": "change `hello world` in README to something else",
                        "timestamp": TIMESTAMP,
@@ -2581,7 +2603,8 @@ mod routes {
              {
                "id": CREATED_PATCH_ID,
                "author": {
-
                  "id": CONTRIBUTOR_DID
+
                  "id": CONTRIBUTOR_DID,
+
                  "alias": CONTRIBUTOR_ALIAS
                },
                "title": "Update README",
                "state": { "status": "open" },
@@ -2595,12 +2618,14 @@ mod routes {
                    "reactions": [],
                    "author": {
                      "id": CONTRIBUTOR_DID,
+
                      "alias": CONTRIBUTOR_ALIAS
                    },
                    "description": "Do some changes to README",
                    "edits": [
                      {
                        "author": {
                          "id": CONTRIBUTOR_DID,
+
                          "alias": CONTRIBUTOR_ALIAS
                        },
                        "body": "Do some changes to README",
                        "timestamp": TIMESTAMP,
@@ -2655,6 +2680,7 @@ mod routes {
              "id": CONTRIBUTOR_PATCH_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "A new `hello world`",
              "state": { "status": "open" },
@@ -2667,12 +2693,14 @@ mod routes {
                  "id": CONTRIBUTOR_PATCH_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "description": "change `hello world` in README to something else",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "change `hello world` in README to something else",
                      "timestamp": TIMESTAMP,
@@ -2727,6 +2755,7 @@ mod routes {
              "id": CONTRIBUTOR_PATCH_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "A new `hello world`",
              "state": { "status": "open" },
@@ -2742,12 +2771,14 @@ mod routes {
                  "id": CONTRIBUTOR_PATCH_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "description": "change `hello world` in README to something else",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "change `hello world` in README to something else",
                      "timestamp": TIMESTAMP,
@@ -2804,6 +2835,7 @@ mod routes {
              "id": CONTRIBUTOR_PATCH_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "A new `hello world`",
              "state": { "status": "open" },
@@ -2816,12 +2848,14 @@ mod routes {
                  "id": CONTRIBUTOR_PATCH_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "description": "change `hello world` in README to something else",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "change `hello world` in README to something else",
                      "timestamp": TIMESTAMP,
@@ -2842,16 +2876,18 @@ mod routes {
                  "id": "cccf3b0675220f25b054b6625d84611cb6506d9a",
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "description": "This is a new revision",
                  "edits": [
                    {
-
                        "author": {
-
                            "id": CONTRIBUTOR_DID,
-
                        },
-
                        "body": "This is a new revision",
-
                        "timestamp": TIMESTAMP,
-
                        "embeds": [],
+
                      "author": {
+
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
+
                      },
+
                      "body": "This is a new revision",
+
                      "timestamp": TIMESTAMP,
+
                      "embeds": [],
                    },
                  ],
                  "reactions": [],
@@ -2904,6 +2940,7 @@ mod routes {
              "id": CONTRIBUTOR_PATCH_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "This is a updated title",
              "state": { "status": "open" },
@@ -2917,12 +2954,14 @@ mod routes {
                  "reactions": [],
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "description": "change `hello world` in README to something else",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "change `hello world` in README to something else",
                      "timestamp": TIMESTAMP,
@@ -3023,6 +3062,7 @@ mod routes {
              "id": CONTRIBUTOR_PATCH_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "A new `hello world`",
              "state": { "status": "open" },
@@ -3035,12 +3075,14 @@ mod routes {
                  "id": CONTRIBUTOR_PATCH_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "description": "Let's change the description a bit",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "change `hello world` in README to something else",
                      "timestamp": TIMESTAMP,
@@ -3049,6 +3091,7 @@ mod routes {
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "Let's change the description a bit",
                      "timestamp": TIMESTAMP,
@@ -3190,6 +3233,7 @@ mod routes {
              "id": CONTRIBUTOR_PATCH_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "A new `hello world`",
              "state": { "status": "open" },
@@ -3202,12 +3246,14 @@ mod routes {
                  "id": CONTRIBUTOR_PATCH_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "description": "change `hello world` in README to something else",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "change `hello world` in README to something else",
                      "timestamp": TIMESTAMP,
@@ -3225,12 +3271,14 @@ mod routes {
                      "id": comment_id,
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "EDIT: This is a root level comment",
                      "edits": [
                        {
                          "author": {
                            "id": CONTRIBUTOR_DID,
+
                            "alias": CONTRIBUTOR_ALIAS
                          },
                          "body": "This is a root level comment",
                          "timestamp": TIMESTAMP,
@@ -3244,6 +3292,7 @@ mod routes {
                        {
                          "author": {
                            "id": CONTRIBUTOR_DID,
+
                            "alias": CONTRIBUTOR_ALIAS
                          },
                          "body": "EDIT: This is a root level comment",
                          "timestamp": TIMESTAMP,
@@ -3276,12 +3325,14 @@ mod routes {
                      "id": comment_id_2,
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "This is a root level comment",
                      "edits": [
                        {
                          "author": {
                            "id": CONTRIBUTOR_DID,
+
                            "alias": CONTRIBUTOR_ALIAS
                          },
                          "body": "This is a root level comment",
                          "timestamp": TIMESTAMP,
@@ -3423,6 +3474,7 @@ mod routes {
              "id": CONTRIBUTOR_PATCH_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "A new `hello world`",
              "state": { "status": "open" },
@@ -3435,12 +3487,14 @@ mod routes {
                  "id": CONTRIBUTOR_PATCH_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "description": "change `hello world` in README to something else",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "change `hello world` in README to something else",
                      "timestamp": TIMESTAMP,
@@ -3460,6 +3514,7 @@ mod routes {
                      "id": "140a44a4eac2cdb74b2f5f95a9dce97847eb9636",
                      "author": {
                          "id": CONTRIBUTOR_DID,
+
                          "alias": CONTRIBUTOR_ALIAS
                      },
                      "verdict": "accept",
                      "summary": "A small review",
@@ -3468,12 +3523,14 @@ mod routes {
                          "id": "0dcfca53416761cf975cc4cd6d452790cee06b49",
                          "author": {
                            "id": "did:key:z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8",
+
                            "alias": CONTRIBUTOR_ALIAS
                          },
                          "body": "EDIT: This is a comment on a review",
                          "edits": [
                            {
                              "author": {
                                "id": "did:key:z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8",
+
                                "alias": CONTRIBUTOR_ALIAS
                              },
                              "body": "This is a comment on a review",
                              "timestamp": 1671125284,
@@ -3487,6 +3544,7 @@ mod routes {
                            {
                              "author": {
                                "id": "did:key:z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8",
+
                                "alias": CONTRIBUTOR_ALIAS
                              },
                              "body": "EDIT: This is a comment on a review",
                              "timestamp": 1671125284,
@@ -3570,6 +3628,7 @@ mod routes {
              "id": CONTRIBUTOR_PATCH_ID,
              "author": {
                "id": CONTRIBUTOR_DID,
+
                "alias": CONTRIBUTOR_ALIAS
              },
              "title": "A new `hello world`",
              "state": {
@@ -3582,6 +3641,7 @@ mod routes {
              "merges": [{
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "commit": PARENT,
                  "timestamp": TIMESTAMP,
@@ -3593,12 +3653,14 @@ mod routes {
                  "id": CONTRIBUTOR_PATCH_ID,
                  "author": {
                    "id": CONTRIBUTOR_DID,
+
                    "alias": CONTRIBUTOR_ALIAS
                  },
                  "description": "change `hello world` in README to something else",
                  "edits": [
                    {
                      "author": {
                        "id": CONTRIBUTOR_DID,
+
                        "alias": CONTRIBUTOR_ALIAS
                      },
                      "body": "change `hello world` in README to something else",
                      "timestamp": TIMESTAMP,
modified radicle-httpd/src/test.rs
@@ -37,6 +37,7 @@ pub const SESSION_ID: &str = "u9MGAkkfkMOv0uDDB2WeUHBT7HbsO2Dy";
pub const TIMESTAMP: u64 = 1671125284;
pub const CONTRIBUTOR_RID: &str = "rad:z4XaCmN3jLSeiMvW15YTDpNbDHFhG";
pub const CONTRIBUTOR_DID: &str = "did:key:z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8";
+
pub const CONTRIBUTOR_ALIAS: &str = "seed";
pub const CONTRIBUTOR_PATCH_ID: &str = "3e3f0dc34b3eeb64cfbc7218fbd52b97246e0564";

/// Create a new profile.
@@ -54,6 +55,9 @@ pub fn profile(home: &Path, seed: [u8; 32]) -> radicle::Profile {
    )
    .unwrap();

+
    let mut db = home.policies_mut().unwrap();
+
    db.follow(&keypair.pk.into(), Some(&alias)).unwrap();
+

    radicle::storage::git::transport::local::register(storage.clone());
    keystore.store(keypair.clone(), "radicle", None).unwrap();