MCPcopy Create free account
hub / github.com/CPChain/chain / TestServerRegisterName

Function TestServerRegisterName

api/rpc/server_test.go:78–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76}
77
78func TestServerRegisterName(t *testing.T) {
79 server := NewServer()
80 service := new(Service)
81
82 if err := server.RegisterName("calc", service); err != nil {
83 t.Fatalf("%v", err)
84 }
85
86 if len(server.services) != 2 {
87 t.Fatalf("Expected 2 service entries, got %d", len(server.services))
88 }
89
90 svc, ok := server.services["calc"]
91 if !ok {
92 t.Fatalf("Expected service calc to be registered")
93 }
94
95 if len(svc.callbacks) != 5 {
96 t.Errorf("Expected 5 callbacks for service 'calc', got %d", len(svc.callbacks))
97 }
98
99 if len(svc.subscriptions) != 1 {
100 t.Errorf("Expected 1 subscription for service 'calc', got %d", len(svc.subscriptions))
101 }
102}
103
104func testServerMethodExecution(t *testing.T, method string) {
105 server := NewServer()

Callers

nothing calls this directly

Calls 2

RegisterNameMethod · 0.95
NewServerFunction · 0.85

Tested by

no test coverage detected