MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / startMockJS

Function startMockJS

pkg/applicationserver/util_test.go:161–177  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

159}
160
161func startMockJS(ctx context.Context) (*mockJS, string) {
162 js := &mockJS{
163 keys: make(map[string]*ttnpb.KeyEnvelope),
164 }
165 srv := rpcserver.New(ctx)
166 ttnpb.RegisterAsJsServer(srv.Server, js)
167 lis, err := net.Listen("tcp", ":0")
168 if err != nil {
169 panic(err)
170 }
171 go func() {
172 if err := srv.Serve(lis); err != nil {
173 panic(err)
174 }
175 }()
176 return js, lis.Addr().String()
177}
178
179func (js *mockJS) add(ctx context.Context, devEUI types.EUI64, sessionKeyID []byte, key *ttnpb.KeyEnvelope) {
180 js.keys[fmt.Sprintf("%v:%v", devEUI, sessionKeyID)] = key

Callers 2

TestApplicationServerFunction · 0.85
TestSkipPayloadCryptoFunction · 0.85

Calls 6

NewFunction · 0.92
RegisterAsJsServerFunction · 0.92
ServeMethod · 0.80
ListenMethod · 0.65
StringMethod · 0.65
AddrMethod · 0.65

Tested by

no test coverage detected