Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relaymanager: do not start new relay if one already exists #2093

Merged
merged 5 commits into from
Feb 16, 2023

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Feb 14, 2023

fixes: #2091

func TestReachabilityChangeEvent(t *testing.T) {
h := bhost.NewBlankHost(swarmt.GenSwarm(t))
rmgr := NewRelayManager(h)
rmgr.reachabilityChanged(network.ReachabilityPublic)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a slight preference for not calling unexported functions in tests (where possible). In this case, you could get the event bus (via h.EventBus()), and then emit reachability events.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's neat!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fixed now

p2p/host/relaysvc/relay.go Outdated Show resolved Hide resolved
require.Eventually(
t,
func() bool { rmgr.mutex.Lock(); defer rmgr.mutex.Unlock(); return rmgr.relay != nil },
200*time.Millisecond,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to increase this to a second, CI is super slow (sometimes), which then leads to flaky tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@marten-seemann marten-seemann merged commit 22954b3 into libp2p:master Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

relay circuitv2: relaymanager starts new relays without closing older ones
2 participants