Skip to content

Commit

Permalink
Fix failing allocation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
levaitamas committed Nov 23, 2023
1 parent 09b48ae commit 6115eb5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions internal/allocation/allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import (
"github.com/stretchr/testify/assert"
)

var testFiveTuple = FiveTuple{
SrcAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 2000},
DstAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 4000},
}

func TestAllocation(t *testing.T) {
tt := []struct {
name string
Expand Down Expand Up @@ -46,7 +51,7 @@ func TestAllocation(t *testing.T) {
}

func subTestGetPermission(t *testing.T) {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)

addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:3478")
if err != nil {
Expand Down Expand Up @@ -88,7 +93,7 @@ func subTestGetPermission(t *testing.T) {
}

func subTestAddPermission(t *testing.T) {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)

addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:3478")
if err != nil {
Expand All @@ -107,7 +112,7 @@ func subTestAddPermission(t *testing.T) {
}

func subTestRemovePermission(t *testing.T) {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)

addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:3478")
if err != nil {
Expand All @@ -130,7 +135,7 @@ func subTestRemovePermission(t *testing.T) {
}

func subTestAddChannelBind(t *testing.T) {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)

addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:3478")
if err != nil {
Expand All @@ -154,7 +159,7 @@ func subTestAddChannelBind(t *testing.T) {
}

func subTestGetChannelByNumber(t *testing.T) {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)

addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:3478")
if err != nil {
Expand All @@ -173,7 +178,7 @@ func subTestGetChannelByNumber(t *testing.T) {
}

func subTestGetChannelByAddr(t *testing.T) {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)

addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:3478")
if err != nil {
Expand All @@ -193,7 +198,7 @@ func subTestGetChannelByAddr(t *testing.T) {
}

func subTestRemoveChannelBind(t *testing.T) {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)

addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:3478")
if err != nil {
Expand All @@ -214,7 +219,7 @@ func subTestRemoveChannelBind(t *testing.T) {
}

func subTestAllocationRefresh(t *testing.T) {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)

var wg sync.WaitGroup
wg.Add(1)
Expand All @@ -236,7 +241,7 @@ func subTestAllocationClose(t *testing.T) {
panic(err)
}

a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)
a.RelaySocket = l
// Add mock lifetimeTimer
a.lifetimeTimer = time.AfterFunc(proto.DefaultLifetime, func() {})
Expand Down Expand Up @@ -357,7 +362,7 @@ func subTestPacketHandler(t *testing.T) {
}

func subTestResponseCache(t *testing.T) {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)
transactionID := [stun.TransactionIDSize]byte{1, 2, 3}
responseAttrs := []stun.Setter{
&proto.Lifetime{
Expand Down
2 changes: 1 addition & 1 deletion internal/allocation/channel_bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestChannelBindReset(t *testing.T) {
}

func newChannelBind(lifetime time.Duration) *ChannelBind {
a := NewAllocation(nil, nil, nil)
a := NewAllocation(nil, &testFiveTuple, nil)

addr, _ := net.ResolveUDPAddr("udp", "0.0.0.0:0")
c := &ChannelBind{
Expand Down

0 comments on commit 6115eb5

Please sign in to comment.