mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-01 22:56:41 +00:00
Refactor peer state change subscription mechanism
Because the code generated new channel for every single event, was easy to miss notification. Use single channel.
This commit is contained in:
@@ -86,8 +86,8 @@ func TestGetPeerStateChangeNotifierLogic(t *testing.T) {
|
||||
status := NewRecorder("https://mgm")
|
||||
_ = status.AddPeer(key, "abc.netbird", ip)
|
||||
|
||||
ch := status.GetPeerStateChangeNotifier(key)
|
||||
assert.NotNil(t, ch, "channel shouldn't be nil")
|
||||
sub := status.SubscribeToPeerStateChanges(key)
|
||||
assert.NotNil(t, sub, "channel shouldn't be nil")
|
||||
|
||||
peerState := State{
|
||||
PubKey: key,
|
||||
@@ -100,7 +100,7 @@ func TestGetPeerStateChangeNotifierLogic(t *testing.T) {
|
||||
assert.NoError(t, err, "shouldn't return error")
|
||||
|
||||
select {
|
||||
case <-ch:
|
||||
case <-sub.eventsChan:
|
||||
default:
|
||||
t.Errorf("channel wasn't closed after update")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user