node: ensure that we can fetch with a non-existent tracked node

Ensure that non-existent tracking relationships do not affect
fetching.

This is tested by first performing a clone, by `bob` from `alice`,
after `bob` tracks a remote that does not exist. `alice` creates an
issue which is then fetched by `bob` -- to ensure the fetching
scenario is also tested.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2023-04-14 13:15:23 +01:00 committed by Alexis Sellier
parent ac12a4deee
commit 5a48cdf507
No known key found for this signature in database
1 changed files with 29 additions and 0 deletions

View File

@ -416,6 +416,35 @@ fn test_fetch_trusted_remotes() {
assert!(bob_remotes.contains(&alice.id));
}
#[test]
fn test_missing_remote() {
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());
let carol = MockSigner::default();
alice.connect(&bob);
converge([&alice, &bob]);
assert!(bob.handle.track_repo(acme, Scope::Trusted).unwrap());
assert!(bob.handle.track_node(*carol.public_key(), None).unwrap());
let result = bob.handle.fetch(acme, alice.id).unwrap();
assert!(result.is_success());
log::debug!(target: "test", "Fetch complete with {}", bob.id);
rad::fork_remote(acme, &alice.id, &carol, &bob.storage).unwrap();
alice.issue(acme, "Missing Remote", "Fixing the missing remote issue");
let result = bob.handle.fetch(acme, alice.id).unwrap();
assert!(result.is_success());
log::debug!(target: "test", "Fetch complete with {}", bob.id);
}
#[test]
fn test_fetch_preserve_owned_refs() {
logger::init(log::Level::Debug);