test: add test for signature notifications

This commit is contained in:
steveluscher 2022-04-09 19:03:29 -07:00 committed by Steven Luscher
parent 21a64db140
commit 1882434c69
1 changed files with 15 additions and 0 deletions

View File

@ -32,6 +32,7 @@ import {
EpochInfo, EpochInfo,
InflationGovernor, InflationGovernor,
Logs, Logs,
SignatureResult,
SlotInfo, SlotInfo,
} from '../src/connection'; } from '../src/connection';
import {sleep} from '../src/util/sleep'; import {sleep} from '../src/util/sleep';
@ -3685,6 +3686,20 @@ describe('Connection', function () {
} }
}); });
it('signature notification', async () => {
const owner = Keypair.generate();
const signature = await connection.requestAirdrop(
owner.publicKey,
LAMPORTS_PER_SOL,
);
const signatureResult = await new Promise<SignatureResult>(resolve => {
// NOTE: Signature subscriptions auto-remove themselves, so there's no
// need to track the subscription id and remove it when the test ends.
connection.onSignature(signature, resolve, 'processed');
});
expect(signatureResult.err).to.be.null;
});
it('logs notification', async () => { it('logs notification', async () => {
let subscriptionId: number | undefined; let subscriptionId: number | undefined;
const owner = Keypair.generate(); const owner = Keypair.generate();