Skip to content

Commit d7d29f8

Browse files
joyeecheungnodejs-github-bot
authored andcommitted
test: update for new V8 serialization format
V8 bumped its wire-format version from 0x0f to 0x10. Update the expected hex in test-v8-serdes, and derive the v8 header bytes dynamically in test-runner-v8-deserializer so it tracks future bumps automatically. Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 99bf9c4 commit d7d29f8

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

test/parallel/test-runner-v8-deserializer.mjs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ const diagnosticEvent = {
2121
const chunks = await toArray(serializer([diagnosticEvent]));
2222
const defaultSerializer = new DefaultSerializer();
2323
defaultSerializer.writeHeader();
24-
const headerLength = defaultSerializer.releaseBuffer().length;
25-
const headerOnly = Buffer.from([0xff, 0x0f]);
26-
const oversizedLengthHeader = Buffer.from([0xff, 0x0f, 0x7f, 0xff, 0xff, 0xff]);
27-
const truncatedLengthHeader = Buffer.from([0xff, 0x0f, 0x00, 0x01, 0x00, 0x00]);
24+
const headerOnly = Buffer.from(defaultSerializer.releaseBuffer());
25+
const headerLength = headerOnly.length;
26+
const oversizedLengthHeader = Buffer.concat([headerOnly, Buffer.from([0x7f, 0xff, 0xff, 0xff])]);
27+
const truncatedLengthHeader = Buffer.concat([headerOnly, Buffer.from([0x00, 0x01, 0x00, 0x00])]);
2828
// Expected stdout for oversizedLengthHeader: first byte is emitted via
2929
// String.fromCharCode (byte-by-byte fallback in #drainRawBuffer), remaining
3030
// bytes go through the nonSerialized UTF-8 decode path in #processRawBuffer.
@@ -94,10 +94,10 @@ describe('v8 deserializer', common.mustCall(() => {
9494

9595
it('should not hang when buffer starts with v8Header followed by oversized length', async () => {
9696
// Regression test for https://github.com/nodejs/node/issues/62693
97-
// FF 0F is the v8 serializer header; the next 4 bytes are read as a
98-
// big-endian message size. 0x7FFFFFFF far exceeds any actual buffer
99-
// size, causing #processRawBuffer to make no progress and
100-
// #drainRawBuffer to loop forever without the no-progress guard.
97+
// The v8 serializer header is followed by 4 bytes read as a big-endian
98+
// message size. 0x7FFFFFFF far exceeds any actual buffer size, causing
99+
// #processRawBuffer to make no progress and #drainRawBuffer to loop
100+
// forever without the no-progress guard.
101101
const reported = await collectReported([oversizedLengthHeader]);
102102
assert.partialDeepStrictEqual(
103103
reported,
@@ -117,14 +117,14 @@ describe('v8 deserializer', common.mustCall(() => {
117117
});
118118

119119
it('should flush v8Header-only bytes as stdout when stream ends', async () => {
120-
// Just the two-byte v8 header with no size field at all.
120+
// Just the v8 header bytes with no size field at all.
121121
const reported = await collectReported([headerOnly]);
122122
assert(reported.every((event) => event.type === 'test:stdout'));
123123
assert.strictEqual(collectStdout(reported), headerOnly.toString('latin1'));
124124
});
125125

126126
it('should resync and parse valid messages after false v8 header', async () => {
127-
// A false v8 header (FF 0F + oversized length) followed by a
127+
// A false v8 header (header bytes + oversized length) followed by a
128128
// legitimate serialized message. The parser must skip the corrupt
129129
// bytes and still deserialize the real message.
130130
const reported = await collectReported([

test/parallel/test-v8-serdes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ const hostObject = new (internalBinding('js_stream').JSStream)();
184184
Consider opening an issue as a heads up at https://github.com/nodejs/node/issues/new
185185
`;
186186

187-
const desStr = 'ff0f6f2203666f6f5e007b01';
187+
const desStr = 'ff106f2203666f6f5e007b01';
188188

189189
const desBuf = Buffer.from(desStr, 'hex');
190190
const des = new v8.DefaultDeserializer(desBuf);

0 commit comments

Comments
 (0)