1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-31 14:36:50 -05:00
v2fly/testing/scenarios/common_instanceMgr.go
Xiaokang Wang (Shelikhoo) d9181ad84a
Add Testing for meek, grpc, httpUpgrade Transport (#3160)
* Add instance management based testing

* Add testing for meek transport

* Add testing for grpc, httpupgrade transport
2024-09-16 11:19:42 +01:00

28 lines
843 B
Go

package scenarios
import (
core "github.com/v2fly/v2ray-core/v5"
"github.com/v2fly/v2ray-core/v5/app/instman"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/common/serial"
"github.com/v2fly/v2ray-core/v5/features/extension"
)
func NewInstanceManagerInstanceConfig() *core.Config {
config := &core.Config{}
config.App = append(config.App, serial.ToTypedMessage(&instman.Config{}))
return config
}
func NewInstanceManagerCoreInstance() (*core.Instance, extension.InstanceManagement) {
coreConfig := NewInstanceManagerInstanceConfig()
instance, err := core.New(coreConfig)
if err != nil {
panic(err)
}
common.Must(instance.Start())
instanceMgr := instance.GetFeature(extension.InstanceManagementType())
InstanceMgrIfce := instanceMgr.(extension.InstanceManagement)
return instance, InstanceMgrIfce
}