mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-29 15:05:29 +00:00
fix: lint and failing test
This commit is contained in:
parent
cbbc5dc09f
commit
82ec44fcfa
@ -34,6 +34,7 @@ func TestConnectionStatusChanges(t *testing.T) {
|
|||||||
WithHostAddress([]*net.TCPAddr{hostAddr2}),
|
WithHostAddress([]*net.TCPAddr{hostAddr2}),
|
||||||
WithWakuRelay(),
|
WithWakuRelay(),
|
||||||
)
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
err = node2.Start()
|
err = node2.Start()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -49,8 +50,11 @@ func TestConnectionStatusChanges(t *testing.T) {
|
|||||||
err = node3.Start()
|
err = node3.Start()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
node1.DialPeer(ctx, node2.ListenAddresses()[0].String())
|
err = node1.DialPeer(ctx, node2.ListenAddresses()[0].String())
|
||||||
node1.DialPeer(ctx, node3.ListenAddresses()[0].String())
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = node1.DialPeer(ctx, node3.ListenAddresses()[0].String())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
@ -77,6 +81,8 @@ func TestConnectionStatusChanges(t *testing.T) {
|
|||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
|
node3.Stop()
|
||||||
|
|
||||||
connStatus := <-connStatusChan
|
connStatus := <-connStatusChan
|
||||||
_, ok := connStatus.Peers[node3.Host().ID()]
|
_, ok := connStatus.Peers[node3.Host().ID()]
|
||||||
require.True(t, connStatus.IsOnline)
|
require.True(t, connStatus.IsOnline)
|
||||||
@ -85,13 +91,15 @@ func TestConnectionStatusChanges(t *testing.T) {
|
|||||||
require.Len(t, node1.Host().Network().Peers(), 1) // No peers connected
|
require.Len(t, node1.Host().Network().Peers(), 1) // No peers connected
|
||||||
}()
|
}()
|
||||||
|
|
||||||
node3.Stop()
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
|
err = node1.ClosePeerById(node2.Host().ID())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
connStatus := <-connStatusChan
|
connStatus := <-connStatusChan
|
||||||
_, ok := connStatus.Peers[node3.Host().ID()]
|
_, ok := connStatus.Peers[node3.Host().ID()]
|
||||||
require.False(t, connStatus.IsOnline) // Peers are not connected. Should be offline
|
require.False(t, connStatus.IsOnline) // Peers are not connected. Should be offline
|
||||||
@ -100,14 +108,15 @@ func TestConnectionStatusChanges(t *testing.T) {
|
|||||||
require.Len(t, node1.Host().Network().Peers(), 0) // No peers connected
|
require.Len(t, node1.Host().Network().Peers(), 0) // No peers connected
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = node1.ClosePeerById(node2.Host().ID())
|
|
||||||
require.NoError(t, err)
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
|
err = node1.DialPeerByID(ctx, node2.Host().ID())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
connStatus := <-connStatusChan
|
connStatus := <-connStatusChan
|
||||||
_, ok := connStatus.Peers[node2.Host().ID()]
|
_, ok := connStatus.Peers[node2.Host().ID()]
|
||||||
require.True(t, connStatus.IsOnline) // Peers2 is connected. Should be online
|
require.True(t, connStatus.IsOnline) // Peers2 is connected. Should be online
|
||||||
@ -116,7 +125,5 @@ func TestConnectionStatusChanges(t *testing.T) {
|
|||||||
require.Len(t, node1.Host().Network().Peers(), 1)
|
require.Len(t, node1.Host().Network().Peers(), 1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = node1.DialPeerByID(ctx, node2.Host().ID())
|
|
||||||
require.NoError(t, err)
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user