Files
zeekay 241625e7d9 rename: ziti → zt across all paths
- Repo names: ziti-* → zt-*
- Go modules: github.com/hanzozt/ziti → github.com/hanzozt/zt
- Docker images: hanzozt/ziti-* → hanzozt/zt-*
- C/Java/JS symbols: ziti_* → zt_*
- File and directory names updated
2026-02-18 18:34:19 -08:00

27 lines
891 B
Go

package testutil
import (
"time"
"github.com/hanzozt/channel/v4"
"github.com/hanzozt/zt/v2/common/handler_common"
"github.com/hanzozt/zt/v2/common/pb/ctrl_pb"
"github.com/stretchr/testify/require"
)
func AcceptControl(id string, uf channel.UnderlayFactory, assertions *require.Assertions) (channel.Channel, *MessageCollector) {
msgc := NewMessageCollector(id)
bindHandler := func(binding channel.Binding) error {
binding.AddReceiveHandler(channel.AnyContentType, msgc)
binding.AddReceiveHandlerF(int32(ctrl_pb.ContentType_VerifyRouterType), func(msg *channel.Message, ch channel.Channel) {
handler_common.SendSuccess(msg, ch, "link success")
})
return nil
}
timeoutUF := NewTimeoutUnderlayFactory(uf, 2*time.Second)
ch, err := channel.NewChannel(id, timeoutUF, channel.BindHandlerF(bindHandler), channel.DefaultOptions())
assertions.NoError(err)
return ch, msgc
}