Skip to content

Commit

Permalink
Merge branch 'master' into chore/update-godisc
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos authored Mar 25, 2024
2 parents 67efcb9 + 327391a commit 79f155a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions waku/v2/discv5/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func (d *DiscoveryV5) listen(ctx context.Context) error {

}

d.params.udpPort = uint(d.udpAddr.Port)
d.localnode.SetFallbackUDP(d.udpAddr.Port)

listener, err := discover.ListenV5(ctx, conn, d.localnode, d.config)
Expand Down
4 changes: 4 additions & 0 deletions waku/v2/protocol/enr/localnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func WithIP(ipAddr *net.TCPAddr) ENROption {

func WithUDPPort(udpPort uint) ENROption {
return func(localnode *enode.LocalNode) (err error) {
if udpPort == 0 {
return nil
}

if udpPort > math.MaxUint16 {
return errors.New("invalid udp port number")
}
Expand Down
7 changes: 6 additions & 1 deletion waku/v2/protocol/metadata/waku_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/rand"
"errors"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -50,6 +51,10 @@ func isProtocolNotSupported(err error) bool {
return errors.Is(err, notSupportedErr)
}

func isStreamReset(err error) bool {
return strings.Contains(err.Error(), "stream reset")
}

func TestWakuMetadataRequest(t *testing.T) {
testShard16 := uint16(16)

Expand Down Expand Up @@ -84,7 +89,7 @@ func TestWakuMetadataRequest(t *testing.T) {

// Query a peer not subscribed to any shard
_, err = m16_1.Request(context.Background(), m_noRS.h.ID())
require.True(t, isProtocolNotSupported(err))
require.True(t, isProtocolNotSupported(err) || isStreamReset(err))
}

func TestNoNetwork(t *testing.T) {
Expand Down

0 comments on commit 79f155a

Please sign in to comment.