mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
Move MockPacketConn to fakenet package
This commit is contained in:
+5
-14
@@ -16,6 +16,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/ice/v2/internal/fakenet"
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/stun"
|
||||
"github.com/pion/transport/v2/test"
|
||||
@@ -24,16 +25,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type mockPacketConn struct{}
|
||||
|
||||
func (m *mockPacketConn) ReadFrom([]byte) (n int, addr net.Addr, err error) { return 0, nil, nil }
|
||||
func (m *mockPacketConn) WriteTo([]byte, net.Addr) (n int, err error) { return 0, nil }
|
||||
func (m *mockPacketConn) Close() error { return nil }
|
||||
func (m *mockPacketConn) LocalAddr() net.Addr { return nil }
|
||||
func (m *mockPacketConn) SetDeadline(time.Time) error { return nil }
|
||||
func (m *mockPacketConn) SetReadDeadline(time.Time) error { return nil }
|
||||
func (m *mockPacketConn) SetWriteDeadline(time.Time) error { return nil }
|
||||
|
||||
func TestOnSelectedCandidatePairChange(t *testing.T) {
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
@@ -133,7 +124,7 @@ func TestHandlePeerReflexive(t *testing.T) {
|
||||
Component: 1,
|
||||
}
|
||||
local, err := NewCandidateHost(&hostConfig)
|
||||
local.conn = &mockPacketConn{}
|
||||
local.conn = &fakenet.MockPacketConn{}
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create a new candidate: %v", err)
|
||||
}
|
||||
@@ -224,7 +215,7 @@ func TestHandlePeerReflexive(t *testing.T) {
|
||||
Component: 1,
|
||||
}
|
||||
local, err := NewCandidateHost(&hostConfig)
|
||||
local.conn = &mockPacketConn{}
|
||||
local.conn = &fakenet.MockPacketConn{}
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create a new candidate: %v", err)
|
||||
}
|
||||
@@ -445,7 +436,7 @@ func TestInboundValidity(t *testing.T) {
|
||||
Component: 1,
|
||||
}
|
||||
local, err := NewCandidateHost(&hostConfig)
|
||||
local.conn = &mockPacketConn{}
|
||||
local.conn = &fakenet.MockPacketConn{}
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create a new candidate: %v", err)
|
||||
}
|
||||
@@ -547,7 +538,7 @@ func TestInboundValidity(t *testing.T) {
|
||||
Component: 1,
|
||||
}
|
||||
local, err := NewCandidateHost(&hostConfig)
|
||||
local.conn = &mockPacketConn{}
|
||||
local.conn = &fakenet.MockPacketConn{}
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create a new candidate: %v", err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build !js
|
||||
// +build !js
|
||||
|
||||
package fakenet
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
// MockPacketConn for tests
|
||||
type MockPacketConn struct{}
|
||||
|
||||
func (m *MockPacketConn) ReadFrom([]byte) (n int, addr net.Addr, err error) { return 0, nil, nil } //nolint:revive
|
||||
func (m *MockPacketConn) WriteTo([]byte, net.Addr) (n int, err error) { return 0, nil } //nolint:revive
|
||||
func (m *MockPacketConn) Close() error { return nil } //nolint:revive
|
||||
func (m *MockPacketConn) LocalAddr() net.Addr { return nil } //nolint:revive
|
||||
func (m *MockPacketConn) SetDeadline(time.Time) error { return nil } //nolint:revive
|
||||
func (m *MockPacketConn) SetReadDeadline(time.Time) error { return nil } //nolint:revive
|
||||
func (m *MockPacketConn) SetWriteDeadline(time.Time) error { return nil } //nolint:revive
|
||||
Reference in New Issue
Block a user