Skip to content

Commit db1d6f4

Browse files
committed
chore: add JSDoc for updateRequestParams function to document JSON-RPC parameter overrides (#3886)
Signed-off-by: Michał Walczak <[email protected]>
1 parent 2ef979a commit db1d6f4

File tree

1 file changed

+29
-0
lines changed
  • packages/server/tests/acceptance/data/conformity/utils

1 file changed

+29
-0
lines changed

packages/server/tests/acceptance/data/conformity/utils/overwrites.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,35 @@ import { JsonRpcRequest, Transaction } from './interfaces';
1717
import { legacyTransaction, transaction1559, transaction1559_2930, transaction2930 } from './transactions';
1818
import { getTransactionCount } from './utils';
1919

20+
/**
21+
* Updates request parameters for JSON-RPC requests based on predefined mappings.
22+
* This function allows overriding specific parameters in JSON-RPC requests for testing purposes
23+
* by using file-based mappings that correspond to specific test scenarios.
24+
*
25+
* @template T - The type of the resolved parameter value
26+
* @param {string} fileName - The name of the test file (e.g., 'get-block-by-hash.io')
27+
* @param {JsonRpcRequest} request - The JSON-RPC request object containing method and params
28+
* @returns {Promise<JsonRpcRequest>} A promise that resolves to the updated JSON-RPC request
29+
*
30+
* @example
31+
* ```typescript
32+
* const request = {
33+
* jsonrpc: '2.0',
34+
* id: 1,
35+
* method: 'eth_getTransactionByHash',
36+
* params: ['0x...']
37+
* };
38+
*
39+
* const updatedRequest = await updateRequestParams('get-legacy-tx.io', request);
40+
* // The request.params[0] will be updated with the corresponding transaction hash
41+
* ```
42+
*
43+
* @remarks
44+
* The `buildTransactionOverrides` function provides a comprehensive mapping of test scenarios
45+
* to their corresponding parameter overrides, including static values (transaction hashes,
46+
* block hashes, account addresses) and dynamic functions that prepare and sign transactions
47+
* with current nonces for `eth_sendRawTransaction` test cases.
48+
*/
2049
export async function updateRequestParams<T = unknown>(
2150
fileName: string,
2251
request: JsonRpcRequest,

0 commit comments

Comments
 (0)