func (m MockCluster) Leave() error {
	if m.LeaveFunc == nil {
		panic("Leave called, but not set")
	}
	return m.LeaveFunc()
}
Leave calls LeaveFunc if set and panics otherwise.
package test
import (
	"context"
	"reflect"
	"go.thethings.network/lorawan-stack/v3/pkg/cluster"
	"go.thethings.network/lorawan-stack/v3/pkg/rpcclient"
	"go.thethings.network/lorawan-stack/v3/pkg/rpcserver"
	"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
	"google.golang.org/grpc"
)
type MockPeer struct {
	NameFunc    func() string
	ConnFunc    func() (*grpc.ClientConn, error)
	HasRoleFunc func(ttnpb.ClusterRole) bool
	RolesFunc   func() []ttnpb.ClusterRole
	TagsFunc    func() map[string]string
}
func (m MockPeer) Name() string {
	if m.NameFunc == nil {
		panic("Name called, but not set")
	}
	return m.NameFunc()
}
func (m MockPeer) Conn() (*grpc.ClientConn, error) {
	if m.ConnFunc == nil {
		panic("Conn called, but not set")
	}
	return m.ConnFunc()
}
func (m MockPeer) HasRole(r ttnpb.ClusterRole) bool {
	if m.HasRoleFunc == nil {
		panic("HasRole called, but not set")
	}
	return m.HasRoleFunc(r)
}
func (m MockPeer) Roles() []ttnpb.ClusterRole {
	if m.RolesFunc == nil {
		panic("Roles called, but not set")
	}
	return m.RolesFunc()
}
func (m MockPeer) Tags() map[string]string {
	if m.TagsFunc == nil {
		panic("Tags called, but not set")
	}
	return m.TagsFunc()
}
func NewGRPCServerPeer(ctx context.Context, srv interface{}, registrators ...interface{}) (*MockPeer, error) {
	grpcSrv := rpcserver.New(ctx).Server
	for _, r := range registrators {
		reflect.ValueOf(r).Call([]reflect.Value{
			reflect.ValueOf(grpcSrv),
			reflect.ValueOf(srv),
		})
	}
	conn, err := rpcserver.StartLoopback(ctx, grpcSrv, rpcclient.DefaultDialOptions(ctx)...)
	if err != nil {
		return nil, err
	}
	return &MockPeer{
		ConnFunc: func() (*grpc.ClientConn, error) { return conn, nil },
	}, nil
}
type MockCluster struct {
	JoinFunc               func() error
	LeaveFunc              func() error
	GetPeersFunc           func(ctx context.Context, role ttnpb.ClusterRole) ([]cluster.Peer, error)
	GetPeerFunc            func(ctx context.Context, role ttnpb.ClusterRole, ids cluster.EntityIdentifiers) (cluster.Peer, error)
	ClaimIDsFunc           func(ctx context.Context, ids cluster.EntityIdentifiers) error
	UnclaimIDsFunc         func(ctx context.Context, ids cluster.EntityIdentifiers) error
	TLSFunc                func() bool
	AuthFunc               func() grpc.CallOption
	WithVerifiedSourceFunc func(ctx context.Context) context.Context
}
func (m MockCluster) Join() error {
	if m.JoinFunc == nil {
		panic("Join called, but not set")
	}
	return m.JoinFunc()
}