27 lines
438 B
Go
27 lines
438 B
Go
package peer
|
|
|
|
import (
|
|
"net/netip"
|
|
"testing"
|
|
)
|
|
|
|
func addrPort4(a, b, c, d byte, port uint16) netip.AddrPort {
|
|
return netip.AddrPortFrom(netip.AddrFrom4([4]byte{a, b, c, d}), port)
|
|
}
|
|
|
|
func assertType[T any](t *testing.T, obj any) T {
|
|
t.Helper()
|
|
x, ok := obj.(T)
|
|
if !ok {
|
|
t.Fatalf("invalid type: %#v", obj)
|
|
}
|
|
return x
|
|
}
|
|
|
|
func assertEqual[T comparable](t *testing.T, a, b T) {
|
|
t.Helper()
|
|
if a != b {
|
|
t.Fatal(a, " != ", b)
|
|
}
|
|
}
|