Read an undefined tagId as absent
Mirror / push (push) Has been cancelled
Test / lint (pull_request) Successful in 31s
Test / test (18) (pull_request) Successful in 30s
Test / test (20) (pull_request) Successful in 30s
Test / test (22) (pull_request) Successful in 30s
Test / test (26) (pull_request) Successful in 31s
Test / test (24) (pull_request) Successful in 36s
Mirror / push (push) Has been cancelled
Test / lint (pull_request) Successful in 31s
Test / test (18) (pull_request) Successful in 30s
Test / test (20) (pull_request) Successful in 30s
Test / test (22) (pull_request) Successful in 30s
Test / test (26) (pull_request) Successful in 31s
Test / test (24) (pull_request) Successful in 36s
This commit is contained in:
+2
-2
@@ -166,8 +166,8 @@ function entryOf(name: string, input: unknown): Result<{ tagId: number; tagValue
|
|||||||
|
|
||||||
if (keyed.err) return { err: keyed.err };
|
if (keyed.err) return { err: keyed.err };
|
||||||
|
|
||||||
if ('tagId' in input && input.tagId !== keyed.tagId) {
|
if ('tagId' in input && input.tagId !== undefined && input.tagId !== keyed.tagId) {
|
||||||
return { err: new Error(`TLV "${name}": tagId ${String(input.tagId)} is not the tag its key names, ${String(keyed.tagId)}; drop the tagId`) };
|
return { err: new Error(`TLV "${name}": its tagId is not ${String(keyed.tagId)}, the tag its key names; drop the tagId`) };
|
||||||
}
|
}
|
||||||
|
|
||||||
return { tagId: keyed.tagId, tagValue: input.tagValue };
|
return { tagId: keyed.tagId, tagValue: input.tagValue };
|
||||||
|
|||||||
+4
-2
@@ -443,9 +443,9 @@ describe('TLVs', () => {
|
|||||||
const refusals = [
|
const refusals = [
|
||||||
// @ts-expect-error nils is no tag name
|
// @ts-expect-error nils is no tag name
|
||||||
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { nils: { tagValue: 'blajfoo' } } }), reason: /decimal id/ },
|
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { nils: { tagValue: 'blajfoo' } } }), reason: /decimal id/ },
|
||||||
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { 5142: { tagId: 5143, tagValue: 'blajfoo' } } }), reason: /tagId 5143/ },
|
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { 5142: { tagId: 5143, tagValue: 'blajfoo' } } }), reason: /its tagId is not 5142/ },
|
||||||
// @ts-expect-error the key names the tag
|
// @ts-expect-error the key names the tag
|
||||||
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { message_state: { tagId: 5, tagValue: 2 } } }), reason: /tagId 5/ },
|
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { message_state: { tagId: 5, tagValue: 2 } } }), reason: /its tagId is not 1063/ },
|
||||||
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { 5142: { tagValue: 300 } } }), reason: /Buffer/ },
|
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { 5142: { tagValue: 300 } } }), reason: /Buffer/ },
|
||||||
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { 65536: { tagValue: 'blajfoo' } } }), reason: /out of range/ },
|
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { 65536: { tagValue: 'blajfoo' } } }), reason: /out of range/ },
|
||||||
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { '05142': { tagValue: 'blajfoo' } } }), reason: /decimal id/ },
|
{ built: objToPdu({ cmdName: 'deliver_sm', params, tlvs: { '05142': { tagValue: 'blajfoo' } } }), reason: /decimal id/ },
|
||||||
@@ -553,6 +553,8 @@ describe('TLVs', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
assert.deepEqual(decode(encode({ cmdName: 'deliver_sm', params, tlvs: parsed.tlvs })).tlvs, parsed.tlvs);
|
assert.deepEqual(decode(encode({ cmdName: 'deliver_sm', params, tlvs: parsed.tlvs })).tlvs, parsed.tlvs);
|
||||||
|
// @ts-expect-error the key names the tag, and an undefined tagId names none
|
||||||
|
assert.equal(objToPdu({ cmdName: 'deliver_sm', params, tlvs: { message_state: { tagId: undefined, tagValue: 2 } } }).err, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('types each known TLV by its tag, and an unknown one as octets', () => {
|
test('types each known TLV by its tag, and an unknown one as octets', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user