Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
server: add TestServer_HandlePeerData
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Aug 19, 2018
1 parent b67f643 commit 3532022
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,33 @@ func TestServer_processBindingRequest(t *testing.T) {
})
}

func TestServer_HandlePeerData(t *testing.T) {
s, stop := newServer(t)
defer stop()
addr := turn.Addr{IP: net.IPv4(127, 0, 0, 1), Port: 34567}
peerAddr := turn.Addr{IP: net.IPv4(127, 0, 0, 1), Port: 34567}
now := time.Now()
clientTuple := turn.FiveTuple{
Client: addr,
Proto: turn.ProtoUDP,
}
timeout := now.Add(time.Minute)
_, allocErr := s.allocs.New(clientTuple, timeout, s)
if allocErr != nil {
t.Fatal(allocErr)
}
t.Log("created allocation")
if createErr := s.allocs.CreatePermission(clientTuple, peerAddr, timeout); createErr != nil {
t.Fatal(createErr)
}
t.Log("created permission")
if bindErr := s.allocs.ChannelBind(clientTuple, 0x4001, peerAddr, timeout); bindErr != nil {
t.Fatal(bindErr)
}
t.Log("created binding")
s.HandlePeerData([]byte("hello"), clientTuple, peerAddr)
}

func TestServer_processChannelData(t *testing.T) {
s, stop := newServer(t)
defer stop()
Expand Down

0 comments on commit 3532022

Please sign in to comment.