mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-01 20:00:22 -05:00
Revert "Ensure all bytes consumed on decode (#2019)"
This reverts commit cd45787a91.
This commit is contained in:
+2
-5
@@ -35,12 +35,9 @@ setEncodeValue(encodeValue);
|
||||
|
||||
export function decodeValue(chunk: Chunk, vr: ValueReader): Value {
|
||||
const data = chunk.data;
|
||||
const br = new BinaryNomsReader(data);
|
||||
const dec = new ValueDecoder(br, vr, staticTypeCache);
|
||||
const dec = new ValueDecoder(new BinaryNomsReader(data), vr, staticTypeCache);
|
||||
const v = dec.readValue();
|
||||
if (br.pos() !== data.byteLength) {
|
||||
throw new Error('Invalid chunk data: not all bytes consumed');
|
||||
}
|
||||
|
||||
if (v instanceof ValueBase) {
|
||||
setHash(v, chunk.hash);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import {assert} from 'chai';
|
||||
|
||||
import Blob from './blob.js';
|
||||
import * as Bytes from './bytes.js';
|
||||
import Chunk from './chunk.js';
|
||||
import Hash from './hash.js';
|
||||
import List, {newListLeafSequence} from './list.js';
|
||||
import Map from './map.js';
|
||||
@@ -388,17 +387,6 @@ suite('Encoding', () => {
|
||||
newStruct('S', {x: 42, b: true}));
|
||||
});
|
||||
|
||||
test('struct too much data', async () => {
|
||||
const s = newStruct('S', {x: 42, b: true});
|
||||
const c = encodeValue(s, null);
|
||||
const data = c.data;
|
||||
const buff = Bytes.alloc(data.byteLength + 1);
|
||||
Bytes.copy(data, buff);
|
||||
buff[data.byteLength] = 5; // Add a bogus extra byte
|
||||
const c2 = new Chunk(buff);
|
||||
assert.throws(() => decodeValue(c2, null));
|
||||
});
|
||||
|
||||
test('struct with list', () => {
|
||||
// struct S {l: List<String>}({l: ['a', 'b']})
|
||||
assertEncoding([
|
||||
|
||||
Reference in New Issue
Block a user