web3.js: add support for batch getParsedConfirmedTransactions (#16001)
* feat: add support for batch requests * feat: get confirmed transactions batch * feat: test get parsed confirmed transactions * fix: run prettier * fix: test uses one signature * fix: fix docs and return type on ParsedConfirmedTransactions * fix: null values in test
This commit is contained in:
@ -5,7 +5,7 @@ import * as mockttp from 'mockttp';
|
||||
|
||||
import {mockRpcMessage} from './rpc-websockets';
|
||||
import {Account, Connection, PublicKey, Transaction} from '../../src';
|
||||
import type {Commitment} from '../../src/connection';
|
||||
import type {Commitment, RpcParams} from '../../src/connection';
|
||||
|
||||
export const mockServer: mockttp.Mockttp | undefined =
|
||||
process.env.TEST_LIVE === undefined ? mockttp.getLocal() : undefined;
|
||||
@ -24,6 +24,40 @@ export const mockErrorResponse = {
|
||||
message: mockErrorMessage,
|
||||
};
|
||||
|
||||
export const mockRpcBatchResponse = async ({
|
||||
batch,
|
||||
result,
|
||||
error,
|
||||
}: {
|
||||
batch: RpcParams[];
|
||||
result: any[];
|
||||
error?: string;
|
||||
}) => {
|
||||
if (!mockServer) return;
|
||||
|
||||
const request = batch.map((batch: RpcParams) => {
|
||||
return {
|
||||
jsonrpc: '2.0',
|
||||
method: batch.methodName,
|
||||
params: batch.args,
|
||||
};
|
||||
});
|
||||
|
||||
const response = result.map((result: any) => {
|
||||
return {
|
||||
jsonrpc: '2.0',
|
||||
id: '',
|
||||
result,
|
||||
error,
|
||||
};
|
||||
});
|
||||
|
||||
await mockServer
|
||||
.post('/')
|
||||
.withJsonBodyIncluding(request)
|
||||
.thenReply(200, JSON.stringify(response));
|
||||
};
|
||||
|
||||
export const mockRpcResponse = async ({
|
||||
method,
|
||||
params,
|
||||
|
Reference in New Issue
Block a user