From 1882434c6927782f33f9a495ce5a48114bcd187d Mon Sep 17 00:00:00 2001 From: steveluscher Date: Sat, 9 Apr 2022 19:03:29 -0700 Subject: [PATCH] test: add test for signature notifications --- web3.js/test/connection.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/web3.js/test/connection.test.ts b/web3.js/test/connection.test.ts index 609d2a0c2..742cc02d1 100644 --- a/web3.js/test/connection.test.ts +++ b/web3.js/test/connection.test.ts @@ -32,6 +32,7 @@ import { EpochInfo, InflationGovernor, Logs, + SignatureResult, SlotInfo, } from '../src/connection'; 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(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 () => { let subscriptionId: number | undefined; const owner = Keypair.generate();