package peer import ( "net/netip" "testing" "vppn/peer/control" ) type sentPing struct { Dst netip.AddrPort Ping control.Ping } type fakeControlConn struct { Sent []sentPing } func (f *fakeControlConn) SendPing(dst netip.AddrPort, ping control.Ping, _ []byte) error { f.Sent = append(f.Sent, sentPing{Dst: dst, Ping: ping}) return nil } func (f *fakeControlConn) AssertNone(t *testing.T) { t.Helper() if len(f.Sent) != 0 { t.Fatalf("expected no pings sent, got %d: %v", len(f.Sent), f.Sent) } } func (f *fakeControlConn) AssertSent(t *testing.T, i int, dst netip.AddrPort, ping control.Ping) { t.Helper() if i >= len(f.Sent) { t.Fatalf("no ping at index %d (have %d)", i, len(f.Sent)) } got := f.Sent[i] if got.Dst != dst { t.Errorf("ping[%d].Dst = %v, want %v", i, got.Dst, dst) } if got.Ping != ping { t.Errorf("ping[%d].Ping = %+v, want %+v", i, got.Ping, ping) } }