Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf committed Jan 20, 2025
1 parent f0649fd commit 890a247
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions packages/account/src/providers/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,58 @@ describe('Provider', () => {
expect(block?.transactions?.[0]).toStrictEqual(expectedData);
});

it('ensures "daCompressedBlock" is supported by the node', async () => {
const nodeVersion = '0.40.0';

vi.spyOn(Provider.prototype, 'fetchChainAndNodeInfo').mockResolvedValue({
chain: {} as ChainInfo,
nodeInfo: { nodeVersion } as NodeInfo,
});

vi.spyOn(Provider.prototype, 'getNode').mockResolvedValue({
nodeVersion,
} as NodeInfo);

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

await expectToThrowFuelError(
() => provider.daCompressedBlock('100'),
new FuelError(
ErrorCode.NOT_SUPPORTED,
`The query "daCompressedBlock" is not supported by node version: ${nodeVersion}`
)
);

vi.restoreAllMocks();
});

it('ensures "getAssetDetails" is supported by the node', async () => {
const nodeVersion = '0.40.0';

vi.spyOn(Provider.prototype, 'fetchChainAndNodeInfo').mockResolvedValue({
chain: {} as ChainInfo,
nodeInfo: { nodeVersion } as NodeInfo,
});

vi.spyOn(Provider.prototype, 'getNode').mockResolvedValue({
nodeVersion,
} as NodeInfo);

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

await expectToThrowFuelError(
() => provider.getAssetDetails(getRandomB256()),
new FuelError(
ErrorCode.NOT_SUPPORTED,
`The query "getAssetDetails" is not supported by node version: ${nodeVersion}`
)
);

vi.restoreAllMocks();
});

describe('paginated methods', () => {
test('can properly use getCoins', async () => {
const totalCoins = RESOURCES_PAGE_SIZE_LIMIT + 1;
Expand Down

0 comments on commit 890a247

Please sign in to comment.