| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 40bc080 commit 0854fce
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -155,18 +155,41 @@ const hostObject = new (internalBinding('js_stream').JSStream)(); | |||
| 155 | 155 | } | |
| 156 | 156 | ||
| 157 | 157 | { | |
| 158 | + // Test that an old serialized value can still be deserialized. | ||
| 158 | 159 | const buf = Buffer.from('ff0d6f2203666f6f5e007b01', 'hex'); | |
| 159 | 160 | ||
| 160 | 161 | const des = new v8.DefaultDeserializer(buf); | |
| 161 | 162 | des.readHeader(); | |
| 163 | + assert.strictEqual(des.getWireFormatVersion(), 0x0d); | ||
| 164 | + | ||
| 165 | + const value = des.readValue(); | ||
| 166 | + assert.strictEqual(value, value.foo); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + { | ||
| 170 | + const message = `New serialization format. | ||
| 171 | + | ||
| 172 | + This test is expected to fail when V8 changes its serialization format. | ||
| 173 | + When that happens, the "desStr" variable must be updated to the new value | ||
| 174 | + and the change should be mentioned in the release notes, as it is semver-major. | ||
| 175 | + | ||
| 176 | + Consider opening an issue as a heads up at https://github.com/nodejs/node/issues/new | ||
| 177 | + `; | ||
| 178 | + | ||
| 179 | + const desStr = 'ff0f6f2203666f6f5e007b01'; | ||
| 180 | + | ||
| 181 | + const desBuf = Buffer.from(desStr, 'hex'); | ||
| 182 | + const des = new v8.DefaultDeserializer(desBuf); | ||
| 183 | + des.readHeader(); | ||
| 184 | + const value = des.readValue(); | ||
| 162 | 185 | ||
| 163 | 186 | const ser = new v8.DefaultSerializer(); | |
| 164 | 187 | ser.writeHeader(); | |
| 188 | + ser.writeValue(value); | ||
| 165 | 189 | ||
| 166 | - ser.writeValue(des.readValue()); | ||
| 167 | - | ||
| 168 | - assert.deepStrictEqual(buf, ser.releaseBuffer()); | ||
| 169 | - assert.strictEqual(des.getWireFormatVersion(), 0x0d); | ||
| 190 | + const serBuf = ser.releaseBuffer(); | ||
| 191 | + const serStr = serBuf.toString('hex'); | ||
| 192 | + assert.deepStrictEqual(serStr, desStr, message); | ||
| 170 | 193 | } | |
| 171 | 194 | ||
| 172 | 195 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments