fix: waku udp port conflict (#4610)

This commit is contained in:
frank 2024-01-24 09:09:43 +08:00 committed by GitHub
parent 2a91fba1fa
commit 9050ed7aaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 0 additions and 23 deletions

View File

@ -751,7 +751,6 @@ func TestLoginWithKey(t *testing.T) {
require.NotNil(t, activeAccount.ColorHash) require.NotNil(t, activeAccount.ColorHash)
} }
/*
func TestLoginAccount(t *testing.T) { func TestLoginAccount(t *testing.T) {
utils.Init() utils.Init()
password := "some-password" password := "some-password"
@ -794,7 +793,6 @@ func TestLoginAccount(t *testing.T) {
t.FailNow() t.FailNow()
} }
} }
*/
func TestVerifyDatabasePassword(t *testing.T) { func TestVerifyDatabasePassword(t *testing.T) {
utils.Init() utils.Init()

View File

@ -173,18 +173,6 @@ func (w *Waku) SetStatusTelemetryClient(client ITelemetryClient) {
w.statusTelemetryClient = client w.statusTelemetryClient = client
} }
func getUsableUDPPort() (int, error) {
conn, err := net.ListenUDP("udp", &net.UDPAddr{
IP: net.IPv4zero,
Port: 0,
})
if err != nil {
return 0, err
}
defer conn.Close()
return conn.LocalAddr().(*net.UDPAddr).Port, nil
}
// New creates a WakuV2 client ready to communicate through the LibP2P network. // New creates a WakuV2 client ready to communicate through the LibP2P network.
func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *sql.DB, ts *timesource.NTPTimeSource, onHistoricMessagesRequestFailed func([]byte, peer.ID, error), onPeerStats func(types.ConnStatus)) (*Waku, error) { func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *sql.DB, ts *timesource.NTPTimeSource, onHistoricMessagesRequestFailed func([]byte, peer.ID, error), onPeerStats func(types.ConnStatus)) (*Waku, error) {
var err error var err error
@ -201,13 +189,6 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s
cfg = setDefaults(cfg) cfg = setDefaults(cfg)
if cfg.UDPPort == 0 {
cfg.UDPPort, err = getUsableUDPPort()
if err != nil {
return nil, err
}
}
logger.Info("starting wakuv2 with config", zap.Any("config", cfg)) logger.Info("starting wakuv2 with config", zap.Any("config", cfg))
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())

View File

@ -40,7 +40,6 @@ func TestDiscoveryV5(t *testing.T) {
config.EnableDiscV5 = true config.EnableDiscV5 = true
config.DiscV5BootstrapNodes = []string{testENRBootstrap} config.DiscV5BootstrapNodes = []string{testENRBootstrap}
config.DiscoveryLimit = 20 config.DiscoveryLimit = 20
config.UDPPort = 9001
w, err := New("", "", config, nil, nil, nil, nil, nil) w, err := New("", "", config, nil, nil, nil, nil, nil)
require.NoError(t, err) require.NoError(t, err)
@ -288,7 +287,6 @@ func TestWakuV2Filter(t *testing.T) {
config.EnableDiscV5 = true config.EnableDiscV5 = true
config.DiscV5BootstrapNodes = []string{enrTreeAddress} config.DiscV5BootstrapNodes = []string{enrTreeAddress}
config.DiscoveryLimit = 20 config.DiscoveryLimit = 20
config.UDPPort = 9001
config.WakuNodes = []string{enrTreeAddress} config.WakuNodes = []string{enrTreeAddress}
fleet := "status.test" // Need a name fleet so that LightClient is not set to false fleet := "status.test" // Need a name fleet so that LightClient is not set to false
w, err := New("", fleet, config, nil, nil, nil, nil, nil) w, err := New("", fleet, config, nil, nil, nil, nil, nil)