Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
e2e: improve flake in missing_delegate_default_branch
Merged fintohaps opened 1 year ago

The missing_delegate_default_branch test was flakey and would fail checking if Bob had the rid in storage.

This can be improved by waiting to ensure that Bob has a RefsFetched event before performing the check.

1 file changed +12 -1 0d402647 f9c35231
modified radicle-node/src/tests/e2e.rs
@@ -1229,6 +1229,8 @@ fn missing_delegate_default_branch() {
    let mut bob = bob.spawn();
    let mut seed = seed.spawn();

+
    let bob_events = bob.handle.events();
+

    alice.handle.seed(rid, Scope::All).unwrap();
    bob.handle.seed(rid, Scope::All).unwrap();
    seed.handle.seed(rid, Scope::All).unwrap();
@@ -1237,6 +1239,15 @@ fn missing_delegate_default_branch() {
    bob.connect(&seed);

    bob.handle.fetch(rid, seed.id, DEFAULT_TIMEOUT).unwrap();
+
    bob_events
+
        .wait(
+
            |e| {
+
                matches!(e, service::Event::RefsFetched { updated, .. } if !updated.is_empty())
+
                    .then_some(())
+
            },
+
            DEFAULT_TIMEOUT,
+
        )
+
        .unwrap();
    assert!(bob.storage.contains(&rid).unwrap());

    // Helper to assert that Bob's default branch is not in storage
@@ -1291,7 +1302,7 @@ fn missing_delegate_default_branch() {
            &radicle::cob::issue::TYPENAME,
            &issue,
        );
-
        assert!(repo.backend.find_reference(issue_ref.as_str()).is_ok());
+
        assert!(repo.backend.find_reference(issue_ref.as_str()).is_ok(),);
    };

    // The seed fetches from Bob and checks that: