From 1719bf979995cbddfedf9dd8b6567235c19c5eb8 Mon Sep 17 00:00:00 2001 From: Petar Penovic Date: Mon, 20 Jan 2025 12:27:58 +0100 Subject: [PATCH] test: streamline syncing stats tests --- __tests__/rpcProvider.test.ts | 19 +++++++------------ __tests__/schemas/rpc.json | 9 ++++++++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/__tests__/rpcProvider.test.ts b/__tests__/rpcProvider.test.ts index 76dbd1b4f..4101aae43 100644 --- a/__tests__/rpcProvider.test.ts +++ b/__tests__/rpcProvider.test.ts @@ -32,6 +32,7 @@ import { waitNextBlock, } from './config/fixtures'; import { initializeMatcher } from './config/schema'; +import { isBoolean } from '../src/utils/typed'; describeIfRpc('RPCProvider', () => { const rpcProvider = getTestProvider(false); @@ -307,16 +308,17 @@ describeIfRpc('RPCProvider', () => { expect(Array.isArray(transactions)).toBe(true); }); + test('getSyncingStats', async () => { + const syncingStats = await rpcProvider.getSyncingStats(); + expect(syncingStats).toMatchSchemaRef('GetSyncingStatsResponse'); + if (isBoolean(syncingStats)) expect(syncingStats).toBe(false); + }); + xtest('traceBlockTransactions', async () => { await rpcProvider.getBlockTransactionsTraces(latestBlock.block_hash); }); describeIfDevnet('devnet only', () => { - test('getSyncingStats', async () => { - const syncingStats = await rpcProvider.getSyncingStats(); - expect(syncingStats).toBe(false); - }); - test('getEvents ', async () => { const randomWallet = stark.randomAddress(); const classHash = '0x011ab8626b891bcb29f7cc36907af7670d6fb8a0528c7944330729d8f01e9ea3'; @@ -440,13 +442,6 @@ describeIfRpc('RPCProvider', () => { }); }); }); - - describeIfNotDevnet('global rpc only', () => { - test('getSyncingStats', async () => { - const syncingStats = await rpcProvider.getSyncingStats(); - expect(syncingStats).toMatchSchemaRef('GetSyncingStatsResponse'); - }); - }); }); describeIfTestnet('RPCProvider', () => { diff --git a/__tests__/schemas/rpc.json b/__tests__/schemas/rpc.json index b449713c4..a5eb03ed0 100644 --- a/__tests__/schemas/rpc.json +++ b/__tests__/schemas/rpc.json @@ -2,7 +2,14 @@ "$id": "rpcSchemas", "definitions": { "GetSyncingStatsResponse": { - "$ref": "starknet_api_openrpc#/components/schemas/SYNC_STATUS" + "oneOf": [ + { + "type": "boolean" + }, + { + "$ref": "starknet_api_openrpc#/components/schemas/SYNC_STATUS" + } + ] }, "StarknetEmittedEvent": { "$ref": "starknet_api_openrpc#/components/schemas/EMITTED_EVENT"