From bd62ad7a4b0a311518d1894168c1acb474b4bb04 Mon Sep 17 00:00:00 2001 From: asolana <110843012+ksolana@users.noreply.github.com> Date: Fri, 17 May 2024 19:54:29 -0700 Subject: [PATCH] Assert for all the log messages received from a tx (#80) --- basics/hello-solana/native/tests/test.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/basics/hello-solana/native/tests/test.ts b/basics/hello-solana/native/tests/test.ts index 06fd9d6f8..0e61b19ef 100644 --- a/basics/hello-solana/native/tests/test.ts +++ b/basics/hello-solana/native/tests/test.ts @@ -5,6 +5,7 @@ import { } from '@solana/web3.js'; import { start } from 'solana-bankrun'; import { describe, test } from 'node:test'; +import { assert } from "chai"; describe('hello-solana', async () => { // load program in solana-bankrun @@ -28,6 +29,12 @@ describe('hello-solana', async () => { // Now we process the transaction let transaction = await client.processTransaction(tx); - console.log(transaction?.meta?.logMessages); - }); + + assert(transaction.logMessages[0].startsWith("Program " + PROGRAM_ID)); + assert(transaction.logMessages[1] === "Program log: Hello, Solana!"); + assert(transaction.logMessages[2] === "Program log: Our program's Program ID: " + PROGRAM_ID); + assert(transaction.logMessages[3].startsWith("Program " + PROGRAM_ID + " consumed")); + assert(transaction.logMessages[4] === "Program " + PROGRAM_ID + " success"); + assert(transaction.logMessages.length == 5); +}); });