Skip to content

Commit

Permalink
chore: remove TestWatchConnectionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-sirotin committed Jul 14, 2024
1 parent 8e0e351 commit 3b584d8
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions internal/transport/waku_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ package transport

import (
"context"
"reflect"
"testing"
"time"

"github.com/brianvoe/gofakeit/v6"
"github.com/stretchr/testify/suite"
"github.com/waku-org/go-waku/waku/v2/node"
wakuenr "github.com/waku-org/go-waku/waku/v2/protocol/enr"
"go.uber.org/zap"

Expand Down Expand Up @@ -87,42 +84,3 @@ func (s *WakuSuite) TestParseEnrProtocols() {
p = parseEnrProtocols(wakuenr.WakuEnrBitfield(0b00001111))
s.Require().Equal("lightpush,filter,store,relay", p)
}

func (s *WakuSuite) TestWatchConnectionStatus() {
err := s.node.Initialize()
s.Require().NoError(err)

sub := s.node.SubscribeToConnectionStatus()

finished := make(chan struct{})

go func() {
s.node.watchConnectionStatus()
close(finished)
}()

sent := node.ConnStatus{}
err = gofakeit.Struct(&sent)
s.Require().NoError(err)

s.node.wakuConnectionStatus <- sent

select {
case received := <-sub:
s.Require().Equal(sent.IsOnline, received.IsOnline)
s.Require().Equal(sent.HasHistory, received.HasHistory)
s.Require().Equal(len(sent.Peers), received.PeersCount)
s.Require().True(reflect.DeepEqual(received, s.node.ConnectionStatus()))
case <-time.After(500 * time.Millisecond):
s.Require().Fail("timeout waiting for connection status")
}

close(s.node.wakuConnectionStatus)

select {
case <-finished:
break
case <-time.After(500 * time.Millisecond):
s.Require().Fail("timeout waiting for connection status watch finish")
}
}

0 comments on commit 3b584d8

Please sign in to comment.