Skip to content

Commit

Permalink
Adding unit test for ConnType to String function
Browse files Browse the repository at this point in the history
  • Loading branch information
john-westcott-iv committed Nov 16, 2021
1 parent f55174c commit 34949c3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/netceptor/netceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,3 +782,25 @@ func TestAllowedPeers(t *testing.T) {
n1.BackendWait()
n2.BackendWait()
}

func TestConnTypeString(t *testing.T) {
lw := &logWriter{
t: t,
}
log.SetOutput(lw)
logger.SetShowTrace(true)
defer func() {
log.SetOutput(os.Stdout)
logger.SetShowTrace(false)
}()

n1 := New(context.Background(), "node1")
if ConnTypeStrings[ConnTypeDatagram] != n1.GetConnectionTypeAsString(0) {
t.Fatal("Datagram should be the first entry in ConnTypeStrings")
}
if "Unknown" != n1.GetConnectionTypeAsString(254) {
t.Fatal("Either we now have 254 ConnTypes or GetConnectionTypeAsString did not properly return Unknown")
}
// Shutdown the network
n1.Shutdown()
}

0 comments on commit 34949c3

Please sign in to comment.