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

Function TestExtensions

pkg/interop/extensions_test.go:26–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestExtensions(t *testing.T) { //nolint:paralleltest
27 a := assertions.New(t)
28
29 actual := TTIHomeNSAns{
30 HomeNSAns: HomeNSAns{
31 JsNsMessageHeader: JsNsMessageHeader{
32 MessageHeader: MessageHeader{
33 ProtocolVersion: ProtocolV1_1,
34 TransactionID: 42,
35 MessageType: MessageTypeHomeNSAns,
36 },
37 SenderID: EUI64{0x42, 0x42, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
38 ReceiverID: NetID{0x42, 0x0, 0x0},
39 ReceiverNSID: &EUI64{0x42, 0x42, 0x42, 0x0, 0x0, 0x0, 0x0, 0x0},
40 },
41 Result: Result{
42 ResultCode: ResultSuccess,
43 },
44 HNSID: &EUI64{0x42, 0x42, 0x42, 0x42, 0x0, 0x0, 0x0, 0x0},
45 HNetID: NetID{0x42, 0x42, 0x0},
46 },
47 TTIVSExtension: TTIVSExtension{
48 HTenantID: "foo-tenant",
49 HNSAddress: "thethings.example.com",
50 },
51 }
52
53 buf := bytes.NewBuffer(nil)
54 enc := json.NewEncoder(buf)
55 enc.SetIndent("", "\t")
56 err := enc.Encode(actual)
57 if !a.So(err, should.BeNil) {
58 t.FailNow()
59 }
60 data := buf.Bytes()
61 a.So(string(data), should.Equal, `{
62 "ProtocolVersion": "1.1",
63 "TransactionID": 42,
64 "MessageType": "HomeNSAns",
65 "SenderID": "4242000000000000",
66 "ReceiverID": "420000",
67 "ReceiverNSID": "4242420000000000",
68 "Result": {
69 "ResultCode": "Success"
70 },
71 "HNSID": "4242424200000000",
72 "HNetID": "424200",
73 "VSExtension": {
74 "VendorID": "EC656E",
75 "Object": {
76 "TTSV3": {
77 "HTenantID": "foo-tenant",
78 "HNSAddress": "thethings.example.com"
79 }
80 }
81 }
82}
83`)

Callers

nothing calls this directly

Calls 5

NewEncoderMethod · 0.80
NewMethod · 0.65
EncodeMethod · 0.65
BytesMethod · 0.65
UnmarshalMethod · 0.65

Tested by

no test coverage detected