solana/web3.js/test/mockrpc/get-recent-blockhash.js

37 lines
730 B
JavaScript
Raw Normal View History

// @flow
2018-11-04 11:41:21 -08:00
import {Account} from '../../src';
import type {Commitment} from '../../src/connection';
import {url} from '../url';
import {mockRpc} from '../__mocks__/node-fetch';
export function mockGetRecentBlockhash(commitment: ?Commitment) {
2019-03-04 08:06:33 -08:00
const recentBlockhash = new Account();
const params = [];
if (commitment) {
params.push({commitment});
}
mockRpc.push([
url,
{
2019-03-04 08:06:33 -08:00
method: 'getRecentBlockhash',
params,
},
{
error: null,
2020-01-08 12:59:58 -08:00
result: {
context: {
slot: 11,
2019-05-23 09:44:55 -07:00
},
value: {
blockhash: recentBlockhash.publicKey.toBase58(),
feeCalculator: {
2020-01-08 12:59:58 -08:00
lamportsPerSignature: 42,
},
},
2020-01-08 12:59:58 -08:00
},
2018-11-04 11:41:21 -08:00
},
]);
}