Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consistent typegen outputs #3040

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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