Skip to content

Commit 663b35a

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 6b08588 commit 663b35a

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ const reportedDiagnosticEvent = {
2727
const chunks = await toArray(serializer([diagnosticEvent]));
2828
const defaultSerializer = new DefaultSerializer();
2929
defaultSerializer.writeHeader();
30-
const headerLength = defaultSerializer.releaseBuffer().length;
31-
const headerOnly = Buffer.from([0xff, 0x0f]);
32-
const oversizedLengthHeader = Buffer.from([0xff, 0x0f, 0x7f, 0xff, 0xff, 0xff]);
33-
const unsignedOversizedLengthHeader = Buffer.from([0xff, 0x0f, 0x80, 0x00, 0x00, 0x00]);
34-
const truncatedLengthHeader = Buffer.from([0xff, 0x0f, 0x00, 0x01, 0x00, 0x00]);
30+
const headerOnly = Buffer.from(defaultSerializer.releaseBuffer());
31+
const headerLength = headerOnly.length;
32+
const oversizedLengthHeader = Buffer.concat([headerOnly, Buffer.from([0x7f, 0xff, 0xff, 0xff])]);
33+
const unsignedOversizedLengthHeader = Buffer.concat([headerOnly, Buffer.from([0x80, 0x00, 0x00, 0x00])]);
34+
const truncatedLengthHeader = Buffer.concat([headerOnly, Buffer.from([0x00, 0x01, 0x00, 0x00])]);
3535
// Expected stdout for oversizedLengthHeader: first byte is emitted via
3636
// String.fromCharCode (byte-by-byte fallback in #drainRawBuffer), remaining
3737
// bytes go through the nonSerialized UTF-8 decode path in #processRawBuffer.
@@ -103,10 +103,10 @@ describe('v8 deserializer', common.mustCall(() => {
103103

104104
it('should not hang when buffer starts with v8Header followed by oversized length', async () => {
105105
// Regression test for https://github.com/nodejs/node/issues/62693
106-
// FF 0F is the v8 serializer header; the next 4 bytes are read as a
107-
// big-endian message size. 0x7FFFFFFF far exceeds any actual buffer
108-
// size, causing #processRawBuffer to make no progress and
109-
// #drainRawBuffer to loop forever without the no-progress guard.
106+
// The v8 serializer header is followed by 4 bytes read as a big-endian
107+
// message size. 0x7FFFFFFF far exceeds any actual buffer size, causing
108+
// #processRawBuffer to make no progress and #drainRawBuffer to loop
109+
// forever without the no-progress guard.
110110
const reported = await collectReported([oversizedLengthHeader]);
111111
assert.partialDeepStrictEqual(
112112
reported,
@@ -132,14 +132,14 @@ describe('v8 deserializer', common.mustCall(() => {
132132
});
133133

134134
it('should flush v8Header-only bytes as stdout when stream ends', async () => {
135-
// Just the two-byte v8 header with no size field at all.
135+
// Just the v8 header bytes with no size field at all.
136136
const reported = await collectReported([headerOnly]);
137137
assert(reported.every((event) => event.type === 'test:stdout'));
138138
assert.strictEqual(collectStdout(reported), headerOnly.toString('latin1'));
139139
});
140140

141141
it('should resync and parse valid messages after false v8 header', async () => {
142-
// A false v8 header (FF 0F + oversized length) followed by a
142+
// A false v8 header (header bytes + oversized length) followed by a
143143
// legitimate serialized message. The parser must skip the corrupt
144144
// bytes and still deserialize the real message.
145145
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)