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

Function TestJoinServerRace

pkg/interop/client_test.go:688–864  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

686}
687
688func TestJoinServerRace(t *testing.T) { //nolint:paralleltest
689 for _, tc := range []struct { //nolint:paralleltest
690 Name string
691 NewServers func(*assertions.Assertion) []*httptest.Server
692 NetID types.NetID
693 Request *ttnpb.JoinRequest
694 ResponseAssertion func(*assertions.Assertion, *ttnpb.JoinResponse) bool
695 ErrorAssertion func(*assertions.Assertion, error) bool
696 }{
697 {
698 Name: "Slowest server successful",
699 NewServers: func(a *assertions.Assertion) []*httptest.Server {
700 return []*httptest.Server{
701 newTLSServer(9183, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
702 time.Sleep(test.Delay << 4)
703 test.Must[any](nil, json.NewEncoder(w).Encode(map[string]any{
704 "ProtocolVersion": "1.0",
705 "TransactionID": 0,
706 "MessageType": "JoinAns",
707 "ReceiverToken": "01",
708 "SenderID": "70B3D57ED0000000",
709 "ReceiverID": "42FFFF",
710 "PHYPayload": "204D675073BB4153B23653EFA82C1F3A49E19C2A8696C9A34BF492674779E4BEFA",
711 "Result": map[string]any{
712 "ResultCode": "Success",
713 },
714 "Lifetime": 0,
715 "NwkSKey": map[string]any{
716 "KEKLabel": "ns:42ffff",
717 "AESKey": "EB56FE6681999F25D548CFEDD4A6528B331BB5ADE1CAF17F",
718 },
719 "AppSKey": map[string]any{
720 "KEKLabel": "as:010042",
721 "AESKey": "2A195CC93CA54AD82CFB36C83D91450F3D2D523556F13E69",
722 },
723 "SessionKeyID": "016BFA7BAD4756346A674981E75CDBDC",
724 }))
725 })),
726 newTLSServer(9184, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
727 test.Must[any](nil, json.NewEncoder(w).Encode(map[string]any{
728 "ProtocolVersion": "1.0",
729 "TransactionID": 0.0,
730 "MessageType": "JoinAns",
731 "SenderID": "EC656E0000000001",
732 "ReceiverID": "42FFFF",
733 "Result": map[string]any{
734 "ResultCode": "MICFailed",
735 },
736 }))
737 })),
738 }
739 },
740 NetID: types.NetID{0x42, 0xff, 0xff},
741 Request: &ttnpb.JoinRequest{
742 SelectedMacVersion: ttnpb.MACVersion_MAC_V1_0_3,
743 DevAddr: types.DevAddr{0x01, 0x02, 0x03, 0x04}.Bytes(),
744 RxDelay: ttnpb.RxDelay_RX_DELAY_5,
745 DownlinkSettings: &ttnpb.DLSettings{},

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
HandleJoinRequestMethod · 0.95
ContextFunction · 0.92
NewContextFunction · 0.92
GetLoggerFunction · 0.92
StackFunction · 0.92
newTLSServerFunction · 0.85
NewEncoderMethod · 0.80
NewClientFunction · 0.70
EncodeMethod · 0.65
BytesMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected