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