Skip to content

Commit

Permalink
fix: consistent typegen outputs (#3040)
Browse files Browse the repository at this point in the history
* chore: added test to display failure

* fix: fixed the modified timestamp

* chore: changset
  • Loading branch information
petertonysmith94 authored Aug 27, 2024
1 parent 362ea33 commit 01e2f0e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fast-ties-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/utils": patch
---

fix: consistent typegen outputs
8 changes: 8 additions & 0 deletions packages/utils/src/utils/bytecode.test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/utils/bytecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down

0 comments on commit 01e2f0e

Please sign in to comment.