@omnibuf/node 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conformance.d.ts +3 -0
- package/dist/conformance.d.ts.map +1 -1
- package/dist/conformance.js +487 -43
- package/dist/conformance.js.map +1 -1
- package/dist/gen/conformance_omnibuf.pb.d.ts +171 -0
- package/dist/gen/conformance_omnibuf.pb.d.ts.map +1 -0
- package/dist/gen/conformance_omnibuf.pb.js +1915 -0
- package/dist/gen/conformance_omnibuf.pb.js.map +1 -0
- package/dist/gen/peer_omnibuf.pb.d.ts.map +1 -1
- package/dist/gen/peer_omnibuf.pb.js +41 -27
- package/dist/gen/peer_omnibuf.pb.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/conformance.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface ConformanceRequest {
|
|
|
16
16
|
json_payload: string;
|
|
17
17
|
self_describing: boolean;
|
|
18
18
|
test_opaque_splice: boolean;
|
|
19
|
+
test_opaque_splice_shrink: boolean;
|
|
19
20
|
}
|
|
20
21
|
export interface ConformanceResponse {
|
|
21
22
|
parse_error: string;
|
|
@@ -42,6 +43,8 @@ export declare const CONFORMANCE_FDS: FileDescriptorSetJSON;
|
|
|
42
43
|
export declare const LocationProtobufDesc: ProtobufDescMessage;
|
|
43
44
|
export declare const NeighborProtobufDesc: ProtobufDescMessage;
|
|
44
45
|
export declare const PeerUpdateProtobufDesc: ProtobufDescMessage;
|
|
46
|
+
export declare const AllTypesSubMsgProtobufDesc: ProtobufDescMessage;
|
|
47
|
+
export declare const TestAllTypesProtobufDesc: ProtobufDescMessage;
|
|
45
48
|
/**
|
|
46
49
|
* Execute a single `ConformanceRequest` and return a `ConformanceResponse`.
|
|
47
50
|
* Matches `cmd/conformance-go/main.go` across all 4 tiers (`TestTierBlind`, `TestTierPlugin`, `TestTierProtobufTypes`, `TestTierAnnotatedStruct`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EASlB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAkBvB,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB,EAAE,MAAM,CAAC;IAChC,eAAe,EAAE,UAAU,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,yBAAyB,EAAE,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,UAAU,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,wBAAwB,EAAE,aAAa,CAAC,kBAAkB,CAWnE,CAAC;AAEL,eAAO,MAAM,yBAAyB,EAAE,aAAa,CAAC,mBAAmB,CAQrE,CAAC;AAEL,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,GAAG,CAKlD,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,GAAG,CAuBhD,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,GAAG,CAQ5C,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,GAAG,CAI7C,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,GAAG,CAIhD,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,GAAG,CAI9C,CAAC;AAEH,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,GAAG,CAIjD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,qBA4H7B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,mBA8ClC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,mBAgClC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,mBAoFpC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,mBAgCxC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,mBAgItC,CAAC;AAyCF;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAChC,SAAS,GAAE,kBAAoC,GAC9C,mBAAmB,CAgYrB"}
|
package/dist/conformance.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DescriptorRegistry, ProtoScalarType, decodeBlind, decodeBlindJSON, defineMessage, fromBinary, toBinary, } from '@omnibuf/core';
|
|
2
|
-
import { OpaquePeerUpdate, PeerUpdateSchema,
|
|
1
|
+
import { DescriptorRegistry, Encoder, ProtoScalarType, decodeBlind, decodeBlindJSON, defineMessage, fromBinary, spliceFields, toBinary, } from '@omnibuf/core';
|
|
2
|
+
import { OpaquePeerUpdate, PeerUpdateSchema, createLocation, createNeighbor, createPeerUpdate, decodePeerUpdate, marshalPeerUpdateOmniBuf, } from './gen/peer_omnibuf.pb.js';
|
|
3
|
+
import { OpaqueTestAllTypes, createAllTypesSubMsg, createTestAllTypes, decodeTestAllTypes, marshalTestAllTypesOmniBuf, } from './gen/conformance_omnibuf.pb.js';
|
|
3
4
|
export const WireFormatUnspecified = 0;
|
|
4
5
|
export const WireFormatOmniBuf = 1;
|
|
5
6
|
export const WireFormatJSON = 2;
|
|
@@ -17,6 +18,7 @@ export const ConformanceRequestSchema = defineMessage('ConformanceRequest', {
|
|
|
17
18
|
json_payload: { fieldNum: 6, type: 'string' },
|
|
18
19
|
self_describing: { fieldNum: 7, type: 'bool' },
|
|
19
20
|
test_opaque_splice: { fieldNum: 8, type: 'bool' },
|
|
21
|
+
test_opaque_splice_shrink: { fieldNum: 9, type: 'bool' },
|
|
20
22
|
});
|
|
21
23
|
export const ConformanceResponseSchema = defineMessage('ConformanceResponse', {
|
|
22
24
|
parse_error: { fieldNum: 1, type: 'string' },
|
|
@@ -379,7 +381,204 @@ export const PeerUpdateProtobufDesc = {
|
|
|
379
381
|
},
|
|
380
382
|
],
|
|
381
383
|
};
|
|
384
|
+
export const AllTypesSubMsgProtobufDesc = {
|
|
385
|
+
typeName: 'omnibuf.conformance.AllTypesSubMsg',
|
|
386
|
+
fields: [
|
|
387
|
+
{
|
|
388
|
+
number: 1,
|
|
389
|
+
name: 'id',
|
|
390
|
+
localName: 'id',
|
|
391
|
+
fieldKind: 'scalar',
|
|
392
|
+
scalar: ProtoScalarType.UINT32,
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
number: 2,
|
|
396
|
+
name: 'label',
|
|
397
|
+
localName: 'label',
|
|
398
|
+
fieldKind: 'scalar',
|
|
399
|
+
scalar: ProtoScalarType.STRING,
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
number: 3,
|
|
403
|
+
name: 'flag',
|
|
404
|
+
localName: 'flag',
|
|
405
|
+
fieldKind: 'scalar',
|
|
406
|
+
scalar: ProtoScalarType.BOOL,
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
number: 4,
|
|
410
|
+
name: 'score',
|
|
411
|
+
localName: 'score',
|
|
412
|
+
fieldKind: 'scalar',
|
|
413
|
+
scalar: ProtoScalarType.SINT64,
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
};
|
|
417
|
+
export const TestAllTypesProtobufDesc = {
|
|
418
|
+
typeName: 'omnibuf.conformance.TestAllTypes',
|
|
419
|
+
fields: [
|
|
420
|
+
{
|
|
421
|
+
number: 1,
|
|
422
|
+
name: 'f1_uint32',
|
|
423
|
+
localName: 'f1Uint32',
|
|
424
|
+
fieldKind: 'scalar',
|
|
425
|
+
scalar: ProtoScalarType.UINT32,
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
number: 2,
|
|
429
|
+
name: 'f2_uint64',
|
|
430
|
+
localName: 'f2Uint64',
|
|
431
|
+
fieldKind: 'scalar',
|
|
432
|
+
scalar: ProtoScalarType.UINT64,
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
number: 3,
|
|
436
|
+
name: 'f3_sint32',
|
|
437
|
+
localName: 'f3Sint32',
|
|
438
|
+
fieldKind: 'scalar',
|
|
439
|
+
scalar: ProtoScalarType.SINT32,
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
number: 4,
|
|
443
|
+
name: 'f4_sint64',
|
|
444
|
+
localName: 'f4Sint64',
|
|
445
|
+
fieldKind: 'scalar',
|
|
446
|
+
scalar: ProtoScalarType.SINT64,
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
number: 5,
|
|
450
|
+
name: 'f5_bool',
|
|
451
|
+
localName: 'f5Bool',
|
|
452
|
+
fieldKind: 'scalar',
|
|
453
|
+
scalar: ProtoScalarType.BOOL,
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
number: 6,
|
|
457
|
+
name: 'f6_string',
|
|
458
|
+
localName: 'f6String',
|
|
459
|
+
fieldKind: 'scalar',
|
|
460
|
+
scalar: ProtoScalarType.STRING,
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
number: 7,
|
|
464
|
+
name: 'f7_bytes',
|
|
465
|
+
localName: 'f7Bytes',
|
|
466
|
+
fieldKind: 'scalar',
|
|
467
|
+
scalar: ProtoScalarType.BYTES,
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
number: 8,
|
|
471
|
+
name: 'f8_sub_msg',
|
|
472
|
+
localName: 'f8SubMsg',
|
|
473
|
+
fieldKind: 'message',
|
|
474
|
+
message: AllTypesSubMsgProtobufDesc,
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
number: 9,
|
|
478
|
+
name: 'f9_string_arr',
|
|
479
|
+
localName: 'f9StringArr',
|
|
480
|
+
fieldKind: 'list',
|
|
481
|
+
listKind: 'scalar',
|
|
482
|
+
scalar: ProtoScalarType.STRING,
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
number: 10,
|
|
486
|
+
name: 'f10_uint32_arr',
|
|
487
|
+
localName: 'f10Uint32Arr',
|
|
488
|
+
fieldKind: 'list',
|
|
489
|
+
listKind: 'scalar',
|
|
490
|
+
scalar: ProtoScalarType.UINT32,
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
number: 11,
|
|
494
|
+
name: 'f11_sub_msg_arr',
|
|
495
|
+
localName: 'f11SubMsgArr',
|
|
496
|
+
fieldKind: 'list',
|
|
497
|
+
listKind: 'message',
|
|
498
|
+
message: AllTypesSubMsgProtobufDesc,
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
number: 12,
|
|
502
|
+
name: 'f12_map_str_uint',
|
|
503
|
+
localName: 'f12MapStrUint',
|
|
504
|
+
fieldKind: 'map',
|
|
505
|
+
mapKey: ProtoScalarType.STRING,
|
|
506
|
+
mapKind: 'scalar',
|
|
507
|
+
scalar: ProtoScalarType.UINT64,
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
number: 13,
|
|
511
|
+
name: 'f13_float32',
|
|
512
|
+
localName: 'f13Float32',
|
|
513
|
+
fieldKind: 'scalar',
|
|
514
|
+
scalar: ProtoScalarType.FLOAT,
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
number: 14,
|
|
518
|
+
name: 'f14_float64',
|
|
519
|
+
localName: 'f14Float64',
|
|
520
|
+
fieldKind: 'scalar',
|
|
521
|
+
scalar: ProtoScalarType.DOUBLE,
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
number: 15,
|
|
525
|
+
name: 'f15_fixed32',
|
|
526
|
+
localName: 'f15Fixed32',
|
|
527
|
+
fieldKind: 'scalar',
|
|
528
|
+
scalar: ProtoScalarType.FIXED32,
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
number: 16,
|
|
532
|
+
name: 'f16_fixed64',
|
|
533
|
+
localName: 'f16Fixed64',
|
|
534
|
+
fieldKind: 'scalar',
|
|
535
|
+
scalar: ProtoScalarType.FIXED64,
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
number: 20,
|
|
539
|
+
name: 'f20_overflow_str',
|
|
540
|
+
localName: 'f20OverflowStr',
|
|
541
|
+
fieldKind: 'scalar',
|
|
542
|
+
scalar: ProtoScalarType.STRING,
|
|
543
|
+
},
|
|
544
|
+
],
|
|
545
|
+
};
|
|
382
546
|
const defaultRegistry = new DescriptorRegistry(CONFORMANCE_FDS);
|
|
547
|
+
function bytesEqual(a, b) {
|
|
548
|
+
if (a.byteLength !== b.byteLength)
|
|
549
|
+
return false;
|
|
550
|
+
for (let i = 0; i < a.byteLength; i++) {
|
|
551
|
+
if (a[i] !== b[i])
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
// Exercise the append-oriented runtime directly: generated opaque marshal
|
|
557
|
+
// methods allocate a fresh buffer and cannot test preservation of a nonempty prefix.
|
|
558
|
+
function checkSpliceAliasedPrefix(packet) {
|
|
559
|
+
const appendDirty = (enc, fnum) => {
|
|
560
|
+
enc.writeUint(fnum, 1n << 40n);
|
|
561
|
+
};
|
|
562
|
+
const spliced = spliceFields(packet, 1 << 1, 2, appendDirty);
|
|
563
|
+
for (const prefixLen of [0, 3, 32]) {
|
|
564
|
+
const prefix = new Uint8Array(prefixLen).fill(0xa5);
|
|
565
|
+
const storage = new Uint8Array(prefixLen + packet.byteLength + 512);
|
|
566
|
+
storage.set(prefix, 0);
|
|
567
|
+
storage.set(packet, prefixLen);
|
|
568
|
+
const want = new Uint8Array(prefixLen + spliced.byteLength);
|
|
569
|
+
want.set(prefix, 0);
|
|
570
|
+
want.set(spliced, prefixLen);
|
|
571
|
+
const enc = new Encoder(storage, prefixLen);
|
|
572
|
+
const rawSlice = storage.subarray(prefixLen, prefixLen + packet.byteLength);
|
|
573
|
+
const got = spliceFields(rawSlice, 1 << 1, 2, appendDirty, enc);
|
|
574
|
+
if (!bytesEqual(got, want)) {
|
|
575
|
+
throw new Error(`opaque splice with ${prefixLen}-byte aliased prefix changed prefix or output`);
|
|
576
|
+
}
|
|
577
|
+
if (!bytesEqual(rawSlice, packet)) {
|
|
578
|
+
throw new Error(`opaque splice with ${prefixLen}-byte aliased prefix modified source packet`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
383
582
|
/**
|
|
384
583
|
* Execute a single `ConformanceRequest` and return a `ConformanceResponse`.
|
|
385
584
|
* Matches `cmd/conformance-go/main.go` across all 4 tiers (`TestTierBlind`, `TestTierPlugin`, `TestTierProtobufTypes`, `TestTierAnnotatedStruct`).
|
|
@@ -404,65 +603,310 @@ export function handleConformanceRequest(req, _registry = defaultRegistry) {
|
|
|
404
603
|
return resp;
|
|
405
604
|
}
|
|
406
605
|
case TestTierPlugin: {
|
|
407
|
-
if (req.
|
|
408
|
-
resp.skipped = 'plugin tier generated for omnibuf.bench.PeerUpdate';
|
|
409
|
-
return resp;
|
|
410
|
-
}
|
|
411
|
-
let msg;
|
|
412
|
-
try {
|
|
413
|
-
msg = unmarshalPeerUpdateOmniBuf(payload);
|
|
414
|
-
}
|
|
415
|
-
catch (err) {
|
|
416
|
-
resp.parse_error = err instanceof Error ? err.message : String(err);
|
|
417
|
-
return resp;
|
|
418
|
-
}
|
|
419
|
-
// Also exercise lazy OpaquePeerUpdate getters to verify zero-panic conformance
|
|
420
|
-
const op = new OpaquePeerUpdate(payload);
|
|
421
|
-
void op.getAsn();
|
|
422
|
-
void op.getRouterId();
|
|
423
|
-
void op.getActive();
|
|
424
|
-
void op.getSequence();
|
|
425
|
-
if (req.test_opaque_splice) {
|
|
606
|
+
if (req.test_opaque_splice || req.test_opaque_splice_shrink) {
|
|
426
607
|
try {
|
|
427
|
-
|
|
428
|
-
op.setRouterId('edge-rtr-fra01-'.repeat(20));
|
|
429
|
-
op.setUptimeSec(0xffffffffffffffffn);
|
|
430
|
-
const curSeq = op.getSequence();
|
|
431
|
-
const nextSeq = BigInt.asUintN(64, (typeof curSeq === 'bigint' ? curSeq : BigInt(curSeq)) + 1n);
|
|
432
|
-
op.setSequence(nextSeq <= 9007199254740991n ? Number(nextSeq) : nextSeq);
|
|
433
|
-
resp.omnibuf_payload = op.marshal();
|
|
608
|
+
checkSpliceAliasedPrefix(payload);
|
|
434
609
|
}
|
|
435
610
|
catch (err) {
|
|
436
|
-
resp.
|
|
611
|
+
resp.runtime_error = err instanceof Error ? err.message : String(err);
|
|
612
|
+
return resp;
|
|
437
613
|
}
|
|
438
|
-
return resp;
|
|
439
|
-
}
|
|
440
|
-
try {
|
|
441
|
-
resp.omnibuf_payload = marshalPeerUpdateOmniBuf(msg, {
|
|
442
|
-
deterministic: true,
|
|
443
|
-
selfDescribing: Boolean(req.self_describing),
|
|
444
|
-
});
|
|
445
614
|
}
|
|
446
|
-
|
|
447
|
-
|
|
615
|
+
switch (req.message_type) {
|
|
616
|
+
case 'omnibuf.bench.PeerUpdate': {
|
|
617
|
+
const msg = createPeerUpdate({
|
|
618
|
+
asn: 999999,
|
|
619
|
+
routerId: 'stale-router',
|
|
620
|
+
active: true,
|
|
621
|
+
tags: ['stale-tag'],
|
|
622
|
+
prefixes: [999],
|
|
623
|
+
location: createLocation({ region: 'stale', city: 'stale-city', rack: 999 }),
|
|
624
|
+
neighbors: [createNeighbor({ peerAsn: 999, router: 'stale-neighbor' })],
|
|
625
|
+
sequence: 999999,
|
|
626
|
+
});
|
|
627
|
+
try {
|
|
628
|
+
decodePeerUpdate(payload, msg);
|
|
629
|
+
}
|
|
630
|
+
catch (err) {
|
|
631
|
+
resp.parse_error = err instanceof Error ? err.message : String(err);
|
|
632
|
+
return resp;
|
|
633
|
+
}
|
|
634
|
+
const op = new OpaquePeerUpdate(payload);
|
|
635
|
+
const opLoc = op.getLocation();
|
|
636
|
+
if (op.getAsn() !== msg.asn ||
|
|
637
|
+
op.getRouterId() !== msg.routerId ||
|
|
638
|
+
op.getActive() !== msg.active ||
|
|
639
|
+
BigInt(op.getUptimeSec()) !== BigInt(msg.uptimeSec) ||
|
|
640
|
+
op.getRssiDbm() !== msg.rssiDbm ||
|
|
641
|
+
!Object.is(op.getCpuLoad(), msg.cpuLoad) ||
|
|
642
|
+
op.getTags().length !== msg.tags.length ||
|
|
643
|
+
op.getPrefixes().length !== msg.prefixes.length ||
|
|
644
|
+
(opLoc?.city ?? '') !== (msg.location?.city ?? '') ||
|
|
645
|
+
op.getNeighbors().length !== msg.neighbors.length ||
|
|
646
|
+
BigInt(op.getSequence()) !== BigInt(msg.sequence)) {
|
|
647
|
+
resp.parse_error = 'opaque PeerUpdate getter mismatch with decoded struct';
|
|
648
|
+
return resp;
|
|
649
|
+
}
|
|
650
|
+
if (req.test_opaque_splice) {
|
|
651
|
+
try {
|
|
652
|
+
op.setAsn(1_000_000);
|
|
653
|
+
op.setRouterId('edge-rtr-fra01-'.repeat(20));
|
|
654
|
+
op.setActive(!op.getActive());
|
|
655
|
+
op.setUptimeSec(0xffffffffffffffffn);
|
|
656
|
+
op.setRssiDbm(-1_000_000);
|
|
657
|
+
op.setCpuLoad(99.875);
|
|
658
|
+
op.setTags(['tag-grow-a', 'tag-grow-b', 'long-tag-'.repeat(20)]);
|
|
659
|
+
op.setPrefixes([100000, 200000, 300000, 400000, 500000, 600000]);
|
|
660
|
+
op.setLocation({
|
|
661
|
+
$typeName: 'omnibuf.bench.Location',
|
|
662
|
+
region: 'eu-central-grown',
|
|
663
|
+
datacenter: 'fra-dc-'.repeat(25),
|
|
664
|
+
city: 'Berlin',
|
|
665
|
+
rack: 999999,
|
|
666
|
+
latitude: 52.52,
|
|
667
|
+
longitude: 13.405,
|
|
668
|
+
});
|
|
669
|
+
const curSeq = op.getSequence();
|
|
670
|
+
const nextSeq = BigInt.asUintN(64, (typeof curSeq === 'bigint' ? curSeq : BigInt(curSeq)) + 1n);
|
|
671
|
+
op.setSequence(nextSeq <= 9007199254740991n ? Number(nextSeq) : nextSeq);
|
|
672
|
+
resp.omnibuf_payload = op.marshal();
|
|
673
|
+
}
|
|
674
|
+
catch (err) {
|
|
675
|
+
resp.serialize_error = err instanceof Error ? err.message : String(err);
|
|
676
|
+
}
|
|
677
|
+
return resp;
|
|
678
|
+
}
|
|
679
|
+
if (req.test_opaque_splice_shrink) {
|
|
680
|
+
try {
|
|
681
|
+
op.setAsn(1);
|
|
682
|
+
op.setRouterId('r');
|
|
683
|
+
op.setActive(false);
|
|
684
|
+
op.setUptimeSec(5);
|
|
685
|
+
op.setRssiDbm(-1);
|
|
686
|
+
op.setCpuLoad(0.5);
|
|
687
|
+
op.setTags(['t']);
|
|
688
|
+
op.setPrefixes([1]);
|
|
689
|
+
op.setLocation({
|
|
690
|
+
$typeName: 'omnibuf.bench.Location',
|
|
691
|
+
region: 'r',
|
|
692
|
+
datacenter: 'd',
|
|
693
|
+
city: 'c',
|
|
694
|
+
rack: 1,
|
|
695
|
+
latitude: 1.0,
|
|
696
|
+
longitude: 2.0,
|
|
697
|
+
});
|
|
698
|
+
op.setSequence(2);
|
|
699
|
+
resp.omnibuf_payload = op.marshal();
|
|
700
|
+
}
|
|
701
|
+
catch (err) {
|
|
702
|
+
resp.serialize_error = err instanceof Error ? err.message : String(err);
|
|
703
|
+
}
|
|
704
|
+
return resp;
|
|
705
|
+
}
|
|
706
|
+
try {
|
|
707
|
+
resp.omnibuf_payload = marshalPeerUpdateOmniBuf(msg, {
|
|
708
|
+
deterministic: true,
|
|
709
|
+
selfDescribing: Boolean(req.self_describing),
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
catch (err) {
|
|
713
|
+
resp.serialize_error = err instanceof Error ? err.message : String(err);
|
|
714
|
+
}
|
|
715
|
+
return resp;
|
|
716
|
+
}
|
|
717
|
+
case 'omnibuf.conformance.TestAllTypes': {
|
|
718
|
+
const msg = createTestAllTypes({
|
|
719
|
+
f1Uint32: 999999,
|
|
720
|
+
f5Bool: true,
|
|
721
|
+
f6String: 'stale-str',
|
|
722
|
+
f7Bytes: new Uint8Array([0xff]),
|
|
723
|
+
f8SubMsg: createAllTypesSubMsg({
|
|
724
|
+
id: 999,
|
|
725
|
+
label: 'stale-sub',
|
|
726
|
+
flag: true,
|
|
727
|
+
score: -999,
|
|
728
|
+
}),
|
|
729
|
+
f9StringArr: ['stale'],
|
|
730
|
+
f10Uint32Arr: [999],
|
|
731
|
+
f11SubMsgArr: [createAllTypesSubMsg({ id: 999, label: 'stale-elem' })],
|
|
732
|
+
f12MapStrUint: { stale: 999 },
|
|
733
|
+
f20OverflowStr: 'stale-overflow',
|
|
734
|
+
});
|
|
735
|
+
try {
|
|
736
|
+
decodeTestAllTypes(payload, msg);
|
|
737
|
+
}
|
|
738
|
+
catch (err) {
|
|
739
|
+
resp.parse_error = err instanceof Error ? err.message : String(err);
|
|
740
|
+
return resp;
|
|
741
|
+
}
|
|
742
|
+
const op = new OpaqueTestAllTypes(payload);
|
|
743
|
+
void op.getF12MapStrUint();
|
|
744
|
+
const opSub = op.getF8SubMsg();
|
|
745
|
+
const wantSub = msg.f8SubMsg;
|
|
746
|
+
const opBytes = op.getF7Bytes();
|
|
747
|
+
let bytesMatch = opBytes.length === msg.f7Bytes.length;
|
|
748
|
+
if (bytesMatch) {
|
|
749
|
+
for (let i = 0; i < opBytes.length; i++) {
|
|
750
|
+
if (opBytes[i] !== msg.f7Bytes[i]) {
|
|
751
|
+
bytesMatch = false;
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
if (op.getF1Uint32() !== msg.f1Uint32 ||
|
|
757
|
+
BigInt(op.getF2Uint64()) !== BigInt(msg.f2Uint64) ||
|
|
758
|
+
op.getF3Sint32() !== msg.f3Sint32 ||
|
|
759
|
+
BigInt(op.getF4Sint64()) !== BigInt(msg.f4Sint64) ||
|
|
760
|
+
op.getF5Bool() !== msg.f5Bool ||
|
|
761
|
+
op.getF6String() !== msg.f6String ||
|
|
762
|
+
!bytesMatch ||
|
|
763
|
+
(opSub?.id ?? 0) !== (wantSub?.id ?? 0) ||
|
|
764
|
+
(opSub?.label ?? '') !== (wantSub?.label ?? '') ||
|
|
765
|
+
(opSub?.flag ?? false) !== (wantSub?.flag ?? false) ||
|
|
766
|
+
BigInt(opSub?.score ?? 0) !== BigInt(wantSub?.score ?? 0) ||
|
|
767
|
+
op.getF9StringArr().length !== msg.f9StringArr.length ||
|
|
768
|
+
op.getF10Uint32Arr().length !== msg.f10Uint32Arr.length ||
|
|
769
|
+
op.getF11SubMsgArr().length !== msg.f11SubMsgArr.length ||
|
|
770
|
+
!Object.is(op.getF13Float32(), msg.f13Float32) ||
|
|
771
|
+
!Object.is(op.getF14Float64(), msg.f14Float64) ||
|
|
772
|
+
op.getF15Fixed32() !== msg.f15Fixed32 ||
|
|
773
|
+
BigInt(op.getF16Fixed64()) !== BigInt(msg.f16Fixed64) ||
|
|
774
|
+
op.getF20OverflowStr() !== msg.f20OverflowStr) {
|
|
775
|
+
resp.parse_error = 'opaque TestAllTypes getter mismatch with decoded struct';
|
|
776
|
+
return resp;
|
|
777
|
+
}
|
|
778
|
+
if (req.test_opaque_splice) {
|
|
779
|
+
try {
|
|
780
|
+
op.setF1Uint32(1_000_000);
|
|
781
|
+
op.setF2Uint64(0xffffffffffffffffn);
|
|
782
|
+
op.setF3Sint32(-1_000_000);
|
|
783
|
+
op.setF4Sint64(-9223372036854775808n);
|
|
784
|
+
op.setF5Bool(!op.getF5Bool());
|
|
785
|
+
op.setF6String('grown-str-'.repeat(30));
|
|
786
|
+
const f7 = new Uint8Array(260);
|
|
787
|
+
for (let i = 0; i < 260; i += 2) {
|
|
788
|
+
f7[i] = 0xab;
|
|
789
|
+
f7[i + 1] = 0xcd;
|
|
790
|
+
}
|
|
791
|
+
op.setF7Bytes(f7);
|
|
792
|
+
op.setF8SubMsg({
|
|
793
|
+
$typeName: 'omnibuf.conformance.AllTypesSubMsg',
|
|
794
|
+
id: 888888,
|
|
795
|
+
label: 'sub-grown-'.repeat(20),
|
|
796
|
+
flag: true,
|
|
797
|
+
score: -999999999,
|
|
798
|
+
});
|
|
799
|
+
op.setF9StringArr(['arr-grow-1', 'arr-grow-2', 'arr-grow-3-'.repeat(15)]);
|
|
800
|
+
op.setF10Uint32Arr([100000, 200000, 300000, 400000, 500000]);
|
|
801
|
+
op.setF11SubMsgArr([
|
|
802
|
+
{
|
|
803
|
+
$typeName: 'omnibuf.conformance.AllTypesSubMsg',
|
|
804
|
+
id: 100001,
|
|
805
|
+
label: 'elem0-'.repeat(25),
|
|
806
|
+
flag: true,
|
|
807
|
+
score: -500000,
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
$typeName: 'omnibuf.conformance.AllTypesSubMsg',
|
|
811
|
+
id: 100002,
|
|
812
|
+
label: 'elem1-grown',
|
|
813
|
+
flag: false,
|
|
814
|
+
score: 500000,
|
|
815
|
+
},
|
|
816
|
+
]);
|
|
817
|
+
op.setF12MapStrUint({
|
|
818
|
+
k1: 1000000,
|
|
819
|
+
k2: 0xffffffffffffffffn,
|
|
820
|
+
k3_long_key: 424242,
|
|
821
|
+
});
|
|
822
|
+
op.setF13Float32(-1234.5);
|
|
823
|
+
op.setF14Float64(3.141592653589793);
|
|
824
|
+
op.setF15Fixed32(0xdeadbeef);
|
|
825
|
+
op.setF16Fixed64(0xcafebabedeadbeefn);
|
|
826
|
+
op.setF20OverflowStr('overflow20-'.repeat(20));
|
|
827
|
+
resp.omnibuf_payload = op.marshal();
|
|
828
|
+
}
|
|
829
|
+
catch (err) {
|
|
830
|
+
resp.serialize_error = err instanceof Error ? err.message : String(err);
|
|
831
|
+
}
|
|
832
|
+
return resp;
|
|
833
|
+
}
|
|
834
|
+
if (req.test_opaque_splice_shrink) {
|
|
835
|
+
try {
|
|
836
|
+
op.setF1Uint32(1);
|
|
837
|
+
op.setF2Uint64(2);
|
|
838
|
+
op.setF3Sint32(-1);
|
|
839
|
+
op.setF4Sint64(-2);
|
|
840
|
+
op.setF5Bool(false);
|
|
841
|
+
op.setF6String('s');
|
|
842
|
+
op.setF7Bytes(new Uint8Array([0x01]));
|
|
843
|
+
op.setF8SubMsg({
|
|
844
|
+
$typeName: 'omnibuf.conformance.AllTypesSubMsg',
|
|
845
|
+
id: 1,
|
|
846
|
+
label: 'x',
|
|
847
|
+
flag: false,
|
|
848
|
+
score: -1,
|
|
849
|
+
});
|
|
850
|
+
op.setF9StringArr(['a']);
|
|
851
|
+
op.setF10Uint32Arr([7]);
|
|
852
|
+
op.setF11SubMsgArr([
|
|
853
|
+
{
|
|
854
|
+
$typeName: 'omnibuf.conformance.AllTypesSubMsg',
|
|
855
|
+
id: 1,
|
|
856
|
+
label: 'e',
|
|
857
|
+
flag: true,
|
|
858
|
+
score: 1,
|
|
859
|
+
},
|
|
860
|
+
]);
|
|
861
|
+
op.setF12MapStrUint({ k: 1 });
|
|
862
|
+
op.setF13Float32(0.5);
|
|
863
|
+
op.setF14Float64(-0.25);
|
|
864
|
+
op.setF15Fixed32(7);
|
|
865
|
+
op.setF16Fixed64(9);
|
|
866
|
+
op.setF20OverflowStr('z');
|
|
867
|
+
resp.omnibuf_payload = op.marshal();
|
|
868
|
+
}
|
|
869
|
+
catch (err) {
|
|
870
|
+
resp.serialize_error = err instanceof Error ? err.message : String(err);
|
|
871
|
+
}
|
|
872
|
+
return resp;
|
|
873
|
+
}
|
|
874
|
+
try {
|
|
875
|
+
resp.omnibuf_payload = marshalTestAllTypesOmniBuf(msg, {
|
|
876
|
+
deterministic: true,
|
|
877
|
+
selfDescribing: Boolean(req.self_describing),
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
catch (err) {
|
|
881
|
+
resp.serialize_error = err instanceof Error ? err.message : String(err);
|
|
882
|
+
}
|
|
883
|
+
return resp;
|
|
884
|
+
}
|
|
885
|
+
default:
|
|
886
|
+
resp.skipped = 'plugin tier generated for PeerUpdate and TestAllTypes';
|
|
887
|
+
return resp;
|
|
448
888
|
}
|
|
449
|
-
return resp;
|
|
450
889
|
}
|
|
451
890
|
case TestTierProtobufTypes: {
|
|
452
|
-
|
|
453
|
-
|
|
891
|
+
const desc = req.message_type === 'omnibuf.bench.PeerUpdate'
|
|
892
|
+
? PeerUpdateProtobufDesc
|
|
893
|
+
: req.message_type === 'omnibuf.conformance.TestAllTypes'
|
|
894
|
+
? TestAllTypesProtobufDesc
|
|
895
|
+
: null;
|
|
896
|
+
if (!desc) {
|
|
897
|
+
resp.skipped = 'protobuf types tier exercises pb.PeerUpdate and pb.TestAllTypes';
|
|
454
898
|
return resp;
|
|
455
899
|
}
|
|
456
900
|
let msg;
|
|
457
901
|
try {
|
|
458
|
-
msg = fromBinary(
|
|
902
|
+
msg = fromBinary(desc, payload);
|
|
459
903
|
}
|
|
460
904
|
catch (err) {
|
|
461
905
|
resp.parse_error = err instanceof Error ? err.message : String(err);
|
|
462
906
|
return resp;
|
|
463
907
|
}
|
|
464
908
|
try {
|
|
465
|
-
resp.omnibuf_payload = toBinary(
|
|
909
|
+
resp.omnibuf_payload = toBinary(desc, msg, {
|
|
466
910
|
deterministic: true,
|
|
467
911
|
selfDescribing: Boolean(req.self_describing),
|
|
468
912
|
});
|