From 01e2f0e72fce7eda34351c012a49f663b199f99e Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 27 Aug 2024 22:00:55 +0100 Subject: [PATCH] fix: consistent typegen outputs (#3040) * chore: added test to display failure * fix: fixed the modified timestamp * chore: changset --- .changeset/fast-ties-crash.md | 5 +++++ packages/utils/src/utils/bytecode.test.ts | 8 ++++++++ packages/utils/src/utils/bytecode.ts | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .changeset/fast-ties-crash.md diff --git a/.changeset/fast-ties-crash.md b/.changeset/fast-ties-crash.md new file mode 100644 index 00000000000..e91a560dad6 --- /dev/null +++ b/.changeset/fast-ties-crash.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/utils": patch +--- + +fix: consistent typegen outputs diff --git a/packages/utils/src/utils/bytecode.test.ts b/packages/utils/src/utils/bytecode.test.ts index cbd25098034..69d6a932f0b 100644 --- a/packages/utils/src/utils/bytecode.test.ts +++ b/packages/utils/src/utils/bytecode.test.ts @@ -1,5 +1,6 @@ import { arrayify } from './arrayify'; import { compressBytecode, decompressBytecode } from './bytecode'; +import { sleep } from './sleep'; /** * We are using a base64 encoded bytecode here to avoid having to @@ -20,6 +21,13 @@ describe('bytecode utils', () => { expect(compressedBytecode.length).toBeLessThan(bytecodeBinary.length); }); + test('should compress to the same value', async () => { + const compressedBytecode = compressBytecode(bytecodeBinary); + await sleep(1000); + const compressedBytecode2 = compressBytecode(bytecodeBinary); + expect(compressedBytecode).toEqual(compressedBytecode2); + }); + test('should decompress bytecode', () => { const compressedBytecode = compressBytecode(bytecodeBinary); const decompressedBytecode = decompressBytecode(compressedBytecode); diff --git a/packages/utils/src/utils/bytecode.ts b/packages/utils/src/utils/bytecode.ts index 74534c0188c..ced17ff5daf 100644 --- a/packages/utils/src/utils/bytecode.ts +++ b/packages/utils/src/utils/bytecode.ts @@ -9,7 +9,7 @@ export const compressBytecode = (bytecodeAsBinary?: BytesLike) => { } const bytecodeCompressBytes = arrayify(bytecodeAsBinary); - const bytecodeCompressGzipped = gzipSync(bytecodeCompressBytes); + const bytecodeCompressGzipped = gzipSync(bytecodeCompressBytes, { mtime: 0 }); const bytecodeCompressBinary = String.fromCharCode.apply( null, new Uint8Array(bytecodeCompressGzipped) as unknown as number[]