diff --git a/src/lib/bankrun-context.ts b/src/lib/bankrun-context.ts index 28feea3..097baaa 100644 --- a/src/lib/bankrun-context.ts +++ b/src/lib/bankrun-context.ts @@ -297,6 +297,26 @@ export class BankrunConnection { return signature; } + async confirmTransaction( + signature: TransactionSignature, + _commitment?: Commitment + ): Promise> { + const status = await this.getSignatureStatus(signature); + + if (status.value === null) { + throw new Error('Transaction not found'); + } + + // In bankrun, if the transaction exists, it's always "finalized" + return { + context: status.context, + value: { + ...status.value, + confirmationStatus: 'finalized', + }, + }; + } + private async updateSlotAndClock() { const currentSlot = await this.getSlot(); const nextSlot = currentSlot + BigInt(1); diff --git a/tests/bankrun_test/tests/bankrun.test.ts b/tests/bankrun_test/tests/bankrun.test.ts index ca04c24..3200fc0 100644 --- a/tests/bankrun_test/tests/bankrun.test.ts +++ b/tests/bankrun_test/tests/bankrun.test.ts @@ -22,19 +22,23 @@ describe("bankrun_test", async () => { [] ); const provider = new BankrunProvider(context); - const wallet = provider.wallet as anchor.Wallet; const bankrunContextWrapper = new BankrunContextWrapper(context); const connection = bankrunContextWrapper.connection.toConnection(); const program = new anchor.Program(IDL, { ...provider, connection: connection, }); + const wallet = provider.wallet; const client = context.banksClient; it("Is initialized!", async () => { + const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash(); const ix = await program.methods.initialize().instruction(); const tx = new Transaction().add(ix); - const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash(); + tx.recentBlockhash = blockhash; + tx.feePayer = wallet.payer.publicKey; + tx.sign(wallet.payer); + const sig = await sendAndConfirmTransaction(connection, tx, [wallet.payer]); const status = await client.getTransactionStatus(sig);