You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During unit test development at #1035 was discovered unexpected behavior for events transitioning from libp2p layer to Waku layer. Within TestHandlePeerTopicEvent 5 nodes subscribed to the same pubsub topic. It is expected (w *WakuRelay) topicEventPoll(topic string, handler *pubsub.TopicEventHandler) gets executed and based on received libp2p events, new events for peer manager will get emitted and handled:
pubsub.PeerJoin - > relay.PEER_JOINED
It was not the case. topicEventPoll() either wasn't executed or not received any libp2p events.
Details - failed test:
func TestHandlePeerTopicEvent(t *testing.T) {
log := utils.Logger()
pubSubTopic := "/waku/2/go/pm/test"
ctx := context.Background()
hosts := make([]host.Host, 5)
relays := make([]*relay.WakuRelay, 5)
for i := 0; i < 5; i++ {
relays[i], hosts[i], _ = makeWakuRelay(t, log)
err := relays[i].Start(ctx)
require.NoError(t, err)
}
// Create peer manager instance with the first hosts
pm, _ := makePeerManagerWithEventBus(t, relays[0], &hosts[0])
pm.ctx = ctx
pm.RegisterWakuProtocol(relay.WakuRelayID_v200, relay.WakuRelayENRField)
// Connect host[0] with all other hosts to reach 4 connections
for i := 1; i < 5; i++ {
pm.host.Peerstore().AddAddrs(hosts[i].ID(), hosts[i].Addrs(), peerstore.PermanentAddrTTL)
err := pm.host.Connect(ctx, hosts[i].Peerstore().PeerInfo(hosts[i].ID()))
require.NoError(t, err)
err = pm.host.Peerstore().(wps.WakuPeerstore).SetDirection(hosts[i].ID(), network.DirOutbound)
require.NoError(t, err)
}
// Wait for connections to settle
time.Sleep(2 * time.Second)
if len(pm.host.Peerstore().(*wps.WakuPeerstoreImpl).PeersByPubSubTopic(pubSubTopic)) == 0 {
log.Info("No peers for the topic yet")
}
// Start event loop to listen to events
ctxEventLoop := context.Background()
go pm.peerEventLoop(ctxEventLoop)
for i := 1; i < 5; i++ {
// Subscribe to Pubsub topic on first host only
_, err := relays[i].Subscribe(ctx, protocol.NewContentFilter(pubSubTopic))
require.NoError(t, err)
}
// Wait for connections to settle
time.Sleep(30 * time.Second)
// Check four hosts have joined the topic
require.Equal(t, 4, len(pm.host.Peerstore().(*wps.WakuPeerstoreImpl).PeersByPubSubTopic(pubSubTopic)))
// Check all hosts have been connected
for _, peer := range pm.host.Peerstore().(*wps.WakuPeerstoreImpl).PeersByPubSubTopic(pubSubTopic) {
require.Equal(t, network.Connected, pm.host.Network().Connectedness(peer))
}
}
Acceptance criteria
Clear explanation why peer manager related events were not emitted after the subscribe, or unsubscribe respectively. Suggest new test code. Estimate if this issue could cause problems during full node operations.
The text was updated successfully, but these errors were encountered:
Background
During unit test development at #1035 was discovered unexpected behavior for events transitioning from libp2p layer to Waku layer. Within TestHandlePeerTopicEvent 5 nodes subscribed to the same pubsub topic. It is expected (w *WakuRelay) topicEventPoll(topic string, handler *pubsub.TopicEventHandler) gets executed and based on received libp2p events, new events for peer manager will get emitted and handled:
pubsub.PeerJoin - > relay.PEER_JOINED
It was not the case. topicEventPoll() either wasn't executed or not received any libp2p events.
Details - failed test:
Acceptance criteria
Clear explanation why peer manager related events were not emitted after the subscribe, or unsubscribe respectively. Suggest new test code. Estimate if this issue could cause problems during full node operations.
The text was updated successfully, but these errors were encountered: