mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-25 09:33:24 +01:00
0c039274a4
This update adds new relay integration for NetBird clients. The new relay is based on web sockets and listens on a single port. - Adds new relay implementation with websocket with single port relaying mechanism - refactor peer connection logic, allowing upgrade and downgrade from/to P2P connection - peer connections are faster since it connects first to relay and then upgrades to P2P - maintains compatibility with old clients by not using the new relay - updates infrastructure scripts with new relay service
41 lines
774 B
Go
41 lines
774 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"go.opentelemetry.io/otel"
|
|
|
|
"github.com/netbirdio/netbird/relay/metrics"
|
|
)
|
|
|
|
func TestStore_DeletePeer(t *testing.T) {
|
|
s := NewStore()
|
|
|
|
m, _ := metrics.NewMetrics(context.Background(), otel.Meter(""))
|
|
|
|
p := NewPeer(m, []byte("peer_one"), nil, nil)
|
|
s.AddPeer(p)
|
|
s.DeletePeer(p)
|
|
if _, ok := s.Peer(p.String()); ok {
|
|
t.Errorf("peer was not deleted")
|
|
}
|
|
}
|
|
|
|
func TestStore_DeleteDeprecatedPeer(t *testing.T) {
|
|
s := NewStore()
|
|
|
|
m, _ := metrics.NewMetrics(context.Background(), otel.Meter(""))
|
|
|
|
p1 := NewPeer(m, []byte("peer_id"), nil, nil)
|
|
p2 := NewPeer(m, []byte("peer_id"), nil, nil)
|
|
|
|
s.AddPeer(p1)
|
|
s.AddPeer(p2)
|
|
s.DeletePeer(p1)
|
|
|
|
if _, ok := s.Peer(p2.String()); !ok {
|
|
t.Errorf("second peer was deleted")
|
|
}
|
|
}
|