feat: add getLargestAccounts rpc api

This commit is contained in:
Justin Starry
2020-05-23 01:23:29 +08:00
committed by Michael Vines
parent 9c677c7d3d
commit 1b8fe71230
4 changed files with 128 additions and 0 deletions

View File

@ -1141,6 +1141,33 @@ test('get supply', async () => {
expect(supply.nonCirculatingAccounts.length).toBeGreaterThan(0);
});
test('get largest accounts', async () => {
const connection = new Connection(url);
mockRpc.push([
url,
{
method: 'getLargestAccounts',
params: [],
},
{
error: null,
result: {
context: {
slot: 1,
},
value: new Array(20).fill(0).map(() => ({
address: new Account().publicKey.toBase58(),
lamports: 1000,
})),
},
},
]);
const largestAccounts = (await connection.getLargestAccounts()).value;
expect(largestAccounts.length).toEqual(20);
});
test('getVersion', async () => {
const connection = new Connection(url);