From eba8dc83a393779e157142d2045d15393cf6ceb6 Mon Sep 17 00:00:00 2001 From: Offroaders123 <65947371+Offroaders123@users.noreply.github.com> Date: Mon, 27 Nov 2023 21:22:15 -0800 Subject: [PATCH] Small Lobby Streamline I need to better account for compression differences with my tests, as right now it depends on which zlib compression implementation you write your NBT files with, will depend on whether the tests will pass or not. This should be excluded I think, I thought it would be perfect to ensure that the compressed versions are the exact same as well, but I don't think that's worthwhile if you can check the raw bytes themselves anyways. Say, to make this file recompiled with the matching zlib layouts, and with the newly updated empty ListTag types ( #40 ), simply opening it with Dovetail and re-saving it didn't work, because it looks like Chrome's zlib backing is different than Node's, even though they both use V8, and they are both on the same macOS ARM machine. So I can rule those things out. I already knew this was the case between Linux and macOS, but I thought this wasn't different between Chrome and Node on the same machine for some reason. I guess I assumed that they would *happen* to be using the same compression implementations, even if they may be two separate installations of that. That would make sense, I didn't expect them to use the same install of it. Just the same or nearly same versions. Another weird thing I encountered. Since I discovered the zlib differences between Node and the browser, I thought I'd use my local global install of NBTify in the CLI to resave the file, using Node as well. That actually encountered an error, and it was only happening with the `--pipe` flag to write it back to the original file. I'm not sure what it was about, that was frustrating though. Going to look into debugging that one. #25 --- src/read.ts | 5 ----- src/write.ts | 5 ----- test/index.test.ts | 13 +++---------- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/read.ts b/src/read.ts index 9afe63d..0861542 100644 --- a/src/read.ts +++ b/src/read.ts @@ -315,11 +315,6 @@ export class NBTReader { const entry = this.#readTag(type); value.push(entry); } - - if (length < 1){ - console.log("read:",type,value); - } - return value; } diff --git a/src/write.ts b/src/write.ts index 1c9ba58..9428605 100644 --- a/src/write.ts +++ b/src/write.ts @@ -250,11 +250,6 @@ export class NBTWriter { value = value.filter(isTag); const type: TAG = (value[0] !== undefined) ? getTagType(value[0]) : TAG.END; const { length } = value; - - if (length < 1){ - console.log("write:",type,value); - } - this.#writeTagType(type); this.#writeInt(length); for (const entry of value){ diff --git a/test/index.test.ts b/test/index.test.ts index 0ac07e2..738281c 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -59,18 +59,13 @@ describe("Read, Stringify, Parse and Write",() => { const compression = (result instanceof NBT.NBTData) ? result.compression : null; - const header = (compression !== null && compression !== "deflate-raw" && !name.endsWith(".schem")) ? 10 : 0; + const header = (compression !== null && compression !== "deflate-raw") ? 10 : 0; - let control: Buffer | Uint8Array = (snbt) + const control = (snbt) ? Buffer.from(stringified) : buffer.subarray(header); - let experiment = recompile.subarray(header); - - // if (name.endsWith(".schem")){ - // control = await NBT.decompress(control,"gzip"); - // experiment = await NBT.decompress(experiment,"gzip"); - // } + const experiment = recompile.subarray(header); /** * Compare the original NBT file buffer to that of the recompiled buffer, @@ -78,8 +73,6 @@ describe("Read, Stringify, Parse and Write",() => { * it's formats implemented correctly! */ const compare = Buffer.compare(control,experiment); - // if (name.endsWith("schem")) console.log(control.join(" "),"\n"); - // if (name.endsWith("schem")) console.log(experiment.join(" ")); strictEqual(compare,0,`'${name}' does not symmetrically recompile`); }); }