Repair lexicographic ordering among Bytes instances, which in turn repairs canonicalizing binary output, which in turn fixes the tests now there's just been a very long test name symbol added.

This commit is contained in:
Tony Garnock-Jones 2022-01-13 23:30:28 +01:00
parent 850678a80a
commit 2721ce81c4
2 changed files with 7 additions and 0 deletions

View File

@ -160,6 +160,11 @@ export class Bytes implements Preservable<never> {
return nibbles.join('');
}
valueOf(): string {
// Defined mostly in order to get lexicographic comparison to "work reliably"
return this.toHex();
}
[PreserveOn](encoder: Encoder<never>) {
encoder.state.emitbyte(Tag.ByteString);
encoder.state.varint(this.length);

View File

@ -26,6 +26,8 @@ describe('reading common test suite', () => {
includeAnnotations: true,
canonical: true,
}));
// console.log('original', new Bytes(samples_bin).toHex());
// console.log('reencoded', new Bytes(bs).toHex());
expect(bs).toEqual(new Uint8Array(samples_bin));
});