MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestNewPersistentCaller

Function TestNewPersistentCaller

rpc/mux/wrapper_test.go:167–313  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

165}
166
167func TestNewPersistentCaller(t *testing.T) {
168 log.SetLevel(log.FatalLevel)
169 utils.RemoveAll(PubKeyStorePath + "*")
170 defer utils.RemoveAll(PubKeyStorePath + "*")
171 utils.RemoveAll(publicKeyStore + "*")
172 defer utils.RemoveAll(publicKeyStore + "*")
173
174 var d string
175 var err error
176 if d, err = ioutil.TempDir("", "rpcutil_test_"); err != nil {
177 return
178 }
179
180 // init conf
181 _, testFile, _, _ := runtime.Caller(0)
182 dupConfFile := filepath.Join(d, "config.yaml")
183 confFile := filepath.Join(filepath.Dir(testFile), "../../test/node_standalone/config.yaml")
184 if err = utils.DupConf(confFile, dupConfFile); err != nil {
185 return
186 }
187 privateKeyPath := filepath.Join(filepath.Dir(testFile), "../../test/node_standalone/private.key")
188
189 conf.GConf, _ = conf.LoadConfig(dupConfFile)
190 log.Debugf("GConf: %#v", conf.GConf)
191 // reset the once
192 route.Once.Reset()
193 _ = GetSessionPoolInstance().Close()
194 route.InitKMS(publicKeyStore)
195
196 addr := conf.GConf.ListenAddr // see ../test/node_standalone/config.yaml
197 masterKey := []byte("")
198 dht, err := route.NewDHTService(PubKeyStorePath, new(consistent.KMSStorage), true)
199
200 server, err := NewServerWithService(ServiceMap{route.DHTRPCName: dht})
201 if err != nil {
202 t.Fatal(err)
203 }
204
205 ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
206 defer cancel()
207 err = utils.WaitForPorts(ctx, "127.0.0.1", []int{
208 12230,
209 }, time.Millisecond*200)
210
211 if err != nil {
212 log.Fatalf("wait for port ready timeout: %v", err)
213 }
214
215 err = server.InitRPCServer(addr, privateKeyPath, masterKey)
216 if err != nil {
217 t.Fatal(err)
218 }
219 go server.Serve()
220
221 client := NewPersistentCaller(conf.GConf.BP.NodeID)
222 node1 := proto.NewNode()
223 _ = node1.InitNodeCryptoInfo(100 * time.Millisecond)
224 node1.Addr = "1.1.1.1:1"

Callers

nothing calls this directly

Calls 15

InitNodeCryptoInfoMethod · 0.95
NewMethod · 0.95
CallMethod · 0.95
ResetClientMethod · 0.95
CloseMethod · 0.95
SetLevelFunction · 0.92
RemoveAllFunction · 0.92
DupConfFunction · 0.92
LoadConfigFunction · 0.92
DebugfFunction · 0.92
InitKMSFunction · 0.92
NewDHTServiceFunction · 0.92

Tested by

no test coverage detected