fix: add fullnodeExit()

This commit is contained in:
Michael Vines 2019-04-24 15:22:50 -07:00
parent 2292b5910e
commit 456f34e95b
3 changed files with 36 additions and 0 deletions

View File

@ -98,6 +98,7 @@ declare module '@solana/web3.js' {
callback: ProgramAccountChangeCallback, callback: ProgramAccountChangeCallback,
): number; ): number;
removeProgramAccountChangeListener(id: number): Promise<void>; removeProgramAccountChangeListener(id: number): Promise<void>;
fullnodeExit(): Promise<boolean>;
} }
// === src/system-program.js === // === src/system-program.js ===

View File

@ -521,6 +521,19 @@ export class Connection {
return await this.sendRawTransaction(wireTransaction); return await this.sendRawTransaction(wireTransaction);
} }
/**
* @private
*/
async fullnodeExit(): Promise<boolean> {
const unsafeRes = await this._rpcRequest('fullnodeExit', []);
const res = jsonRpcResult('boolean')(unsafeRes);
if (res.error) {
throw new Error(res.error.message);
}
assert(typeof res.result !== 'undefined');
return res.result;
}
/** /**
* Send a transaction that has already been signed and serialized into the * Send a transaction that has already been signed and serialized into the
* wire format * wire format

View File

@ -44,6 +44,28 @@ test('get account info - error', () => {
); );
}); });
test('fullnodeExit', async () => {
if (!mockRpcEnabled) {
console.log('fullnodeExit skipped on live node');
return;
}
const connection = new Connection(url);
mockRpc.push([
url,
{
method: 'fullnodeExit',
},
{
error: null,
result: false,
},
]);
const result = await connection.fullnodeExit();
expect(result).toBe(false);
});
test('get balance', async () => { test('get balance', async () => {
const account = new Account(); const account = new Account();
const connection = new Connection(url); const connection = new Connection(url);