Skip to content

Commit

Permalink
test: streamline syncing stats tests
Browse files Browse the repository at this point in the history
  • Loading branch information
penovicp committed Jan 20, 2025
1 parent 885e747 commit 1719bf9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
19 changes: 7 additions & 12 deletions __tests__/rpcProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -440,13 +442,6 @@ describeIfRpc('RPCProvider', () => {
});
});
});

describeIfNotDevnet('global rpc only', () => {
test('getSyncingStats', async () => {
const syncingStats = await rpcProvider.getSyncingStats();
expect(syncingStats).toMatchSchemaRef('GetSyncingStatsResponse');
});
});
});

describeIfTestnet('RPCProvider', () => {
Expand Down
9 changes: 8 additions & 1 deletion __tests__/schemas/rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1719bf9

Please sign in to comment.