Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: test do not fetch from owned refs
Fintan Halpenny committed 3 years ago
commit 821a6b6c08440dc7fdce85a03889c9843283c26d
parent 7fddc70a57834b9479f429d5962a9020d219dfa0
2 files changed +40 -1
modified radicle-node/src/test/environment.rs
@@ -9,6 +9,8 @@ use std::{

use crossbeam_channel as chan;

+
use radicle::cob;
+
use radicle::cob::issue;
use radicle::crypto::ssh::{keystore::MemorySigner, Keystore};
use radicle::crypto::test::signer::MockSigner;
use radicle::crypto::{KeyPair, Seed, Signer};
@@ -19,7 +21,7 @@ use radicle::node::Handle as _;
use radicle::profile::Home;
use radicle::profile::Profile;
use radicle::rad;
-
use radicle::storage::ReadStorage;
+
use radicle::storage::ReadStorage as _;
use radicle::test::fixtures;
use radicle::Storage;

@@ -234,6 +236,16 @@ impl<G: Signer + cyphernet::Ecdh> NodeHandle<G> {
        }
        Ok(())
    }
+

+
    /// Create an [`issue::Issue`] in the `NodeHandle`'s storage.
+
    pub fn issue(&self, rid: Id, title: &str, desc: &str) -> cob::ObjectId {
+
        let repo = self.storage.repository(rid).unwrap();
+
        let mut issues = issue::Issues::open(&repo).unwrap();
+
        *issues
+
            .create(title, desc, &[], &[], &self.signer)
+
            .unwrap()
+
            .id()
+
    }
}

impl Node<MockSigner> {
modified radicle-node/src/tests/e2e.rs
@@ -196,6 +196,33 @@ fn test_replication() {
}

#[test]
+
fn test_dont_fetch_owned_refs() {
+
    logger::init(log::Level::Debug);
+

+
    let tmp = tempfile::tempdir().unwrap();
+
    let mut alice = Node::init(tmp.path());
+
    let bob = Node::init(tmp.path());
+
    let acme = alice.project("acme", "");
+

+
    let mut alice = alice.spawn(service::Config::default());
+
    let mut bob = bob.spawn(service::Config::default());
+

+
    alice.connect(&bob);
+
    converge([&alice, &bob]);
+

+
    assert!(bob.handle.track_repo(acme, Scope::Trusted).unwrap());
+

+
    let result = bob.handle.fetch(acme, alice.id).unwrap();
+
    assert!(result.is_success());
+

+
    log::debug!(target: "test", "Fetch complete with {}", bob.id);
+

+
    alice.issue(acme, "Don't fetch self", "Use ^");
+
    let result = alice.handle.fetch(acme, bob.id).unwrap();
+
    assert!(result.is_success())
+
}
+

+
#[test]
#[ignore = "failing"]
fn test_fetch_trusted_remotes() {
    logger::init(log::Level::Debug);