fix: add fullnodeExit()
This commit is contained in:
parent
2292b5910e
commit
456f34e95b
|
@ -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 ===
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue