node: e2e test simulating a peer migrating their key

Previously, if a peer created a project which was replicated and then
moved to another setup, ultimately deleting that project, then they
would not be able to fetch it again since their remote namespace would
be excluded from the fetch.

This test confirms that a peer can remove their project and clone it
again from a peer that has replicated the project. This is simulated
by directly removing the project directory in the test and fetching
the project from the other peer.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2023-03-29 15:54:12 +01:00
parent 6e08f0be59
commit f78e010c55
No known key found for this signature in database
GPG Key ID: 2552FB6F64066CB7
1 changed files with 50 additions and 0 deletions

View File

@ -195,6 +195,56 @@ fn test_replication() {
assert_matches!(alice.storage.repository(acme).unwrap().verify(), Ok(()));
}
#[test]
fn test_migrated_clone() {
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]);
let tracked = bob.handle.track_repo(acme, Scope::All).unwrap();
assert!(tracked);
let result = bob.handle.fetch(acme, alice.id).unwrap();
assert!(result.is_success());
log::debug!(target: "test", "Fetch complete with {}", alice.id);
// Simulate alice deleting the project and cloning it again
{
let path = alice.storage.path().join(acme.canonical());
std::fs::remove_dir_all(path).unwrap();
}
assert!(!alice.storage.contains(&acme).unwrap());
let result = alice.handle.fetch(acme, bob.id).unwrap();
assert!(result.is_success());
let alice_repo = alice.storage.repository(acme).unwrap();
let bob_repo = bob.storage.repository(acme).unwrap();
let alice_refs = alice_repo
.references()
.unwrap()
.collect::<Result<Vec<_>, _>>()
.unwrap();
let bob_refs = bob_repo
.references()
.unwrap()
.collect::<Result<Vec<_>, _>>()
.unwrap();
assert_eq!(alice_refs, bob_refs);
assert_matches!(alice.storage.repository(acme).unwrap().verify(), Ok(()));
}
#[test]
fn test_dont_fetch_owned_refs() {
logger::init(log::Level::Debug);