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[]