p2p/server: fix stun test

This commit is contained in:
fearlessfe 2025-02-01 20:10:38 +08:00
parent ea8e272e1a
commit e02e3abea9
2 changed files with 5 additions and 5 deletions

View file

@ -69,10 +69,10 @@ func TestAutoDiscRace(t *testing.T) {
func TestParseStun(t *testing.T) {
testcases := []struct {
natStr string
want *stun
want STUN
}{
{"stun", &stun{serverList: strings.Split(stunDefaultServers, "\n")}},
{"stun:1.2.3.4:1234", &stun{serverList: []string{"1.2.3.4:1234"}}},
{"stun", STUN{stun: stun{serverList: strings.Split(stunDefaultServers, "\n")}}},
{"stun:1.2.3.4:1234", STUN{stun: stun{serverList: []string{"1.2.3.4:1234"}}}},
}
for _, tc := range testcases {
@ -80,7 +80,7 @@ func TestParseStun(t *testing.T) {
if err != nil {
t.Errorf("should no err, but get %v", err)
}
stun := nat.(*stun)
stun := nat.(STUN)
assert.Equal(t, stun.serverList, tc.want.serverList)
}
}

View file

@ -54,7 +54,7 @@ func newSTUN(serverAddr string) (Interface, error) {
}
s.serverList = []string{serverAddr}
}
return s, nil
return STUN{stun: *s}, nil
}
func (s stun) String() string {