Skip to content

Commit

Permalink
add test for daCompressedBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf committed Jan 22, 2025
1 parent 0b29a60 commit 438fa98
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packages/account/src/providers/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { expectToThrowFuelError, safeExec } from '@fuel-ts/errors/test-utils';
import { BN, bn } from '@fuel-ts/math';
import type { Receipt } from '@fuel-ts/transactions';
import { InputType, OutputType, ReceiptType } from '@fuel-ts/transactions';
import { DateTime, arrayify, sleep } from '@fuel-ts/utils';
import { DateTime, arrayify, hexlify, sleep } from '@fuel-ts/utils';
import { ASSET_A, ASSET_B } from '@fuel-ts/utils/test-utils';
import { versions } from '@fuel-ts/versions';

Expand Down Expand Up @@ -2576,4 +2576,29 @@ describe('Provider', () => {
code: ErrorCode.SCRIPT_REVERTED,
});
});

it('can get compressed block bytes', async () => {
const bytes = hexlify(randomBytes(32));

using launched = await setupTestProviderAndWallets();
const { provider } = launched;

// Should return null when block is not found
let compressed = await provider.daCompressedBlock('1');

expect(compressed).toBeNull();

vi.spyOn(provider, 'daCompressedBlock').mockImplementationOnce(async () =>
Promise.resolve({
bytes,
})
);

const block = await provider.getBlock('latest');
compressed = await provider.daCompressedBlock(String(block?.height));

expect(compressed).toStrictEqual({ bytes });

vi.restoreAllMocks();
});
});

0 comments on commit 438fa98

Please sign in to comment.