MCPcopy Index your code
hub / github.com/PasarGuard/node / TestGRPC_SyncUsersChunked

Function TestGRPC_SyncUsersChunked

controller/rpc/rpc_test.go:269–330  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

267}
268
269func TestGRPC_SyncUsersChunked(t *testing.T) {
270 ctx, cancel := context.WithTimeout(sharedTestCtx.ctxWithSession, 10*time.Second)
271 defer cancel()
272
273 stream, err := sharedTestCtx.client.SyncUsersChunked(ctx)
274 if err != nil {
275 t.Fatalf("Failed to open chunked sync stream: %v", err)
276 }
277
278 firstChunk := &common.UsersChunk{
279 Index: 0,
280 Users: []*common.User{
281 {
282 Email: "chunk_user1@example.com",
283 Inbounds: []string{
284 "VMESS TCP NOTLS",
285 "VLESS TCP REALITY",
286 },
287 Proxies: &common.Proxy{
288 Vmess: &common.Vmess{
289 Id: uuid.New().String(),
290 },
291 Vless: &common.Vless{
292 Id: uuid.New().String(),
293 },
294 },
295 },
296 },
297 }
298
299 secondChunk := &common.UsersChunk{
300 Index: 1,
301 Users: []*common.User{
302 {
303 Email: "chunk_user2@example.com",
304 Inbounds: []string{
305 "Shadowsocks TCP",
306 "Shadowsocks UDP",
307 },
308 Proxies: &common.Proxy{
309 Shadowsocks: &common.Shadowsocks{
310 Password: "try a random string",
311 Method: "aes-256-gcm",
312 },
313 },
314 },
315 },
316 Last: true,
317 }
318
319 if err = stream.Send(firstChunk); err != nil {
320 t.Fatalf("Failed to send first chunk: %v", err)
321 }
322
323 if err = stream.Send(secondChunk); err != nil {
324 t.Fatalf("Failed to send final chunk: %v", err)
325 }
326

Callers

nothing calls this directly

Calls 2

SyncUsersChunkedMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected