package tests import ( "lux/rpc" "testing" ) type DummyController struct { t *testing.T } func (ctrl *DummyController) GetRpcName() string { return "dummy" } func (ctrl *DummyController) Register(sv *rpc.LuxRpcServer) {} func (ctrl *DummyController) Handle(request rpc.LuxRpcRequest, rpcType rpc.LuxRpcType) (rpc.LuxRpcResponse, rpc.LuxRpcError, bool) { ctrl.t.Log(request, rpcType) return rpc.LuxRpcResponse{}, rpc.LuxRpcError{}, true } func TestRpcServerClient(t *testing.T) { sv := rpc.NewLuxRpcServer() sv.RegisterController(&DummyController{t: t}) err := sv.AddEndpoint("unix", "/tmp/lux-rpc-test.sock", rpc.LuxRpcTypeRoot) if err != nil { t.Fatal(err) } cl, err := rpc.LuxDialRpc("unix", "/tmp/lux-rpc-test.sock") if err != nil { t.Fatal(err) } rpcRes, rpcErr, err := cl.Execute(rpc.LuxRpcRequest{ Controller: "dummy", }) if err != nil { t.Fatal(err) } t.Log(rpcRes) t.Log(rpcErr) }