Skip to content

Commit bd62ad7

Browse files
authored
Assert for all the log messages received from a tx (#80)
1 parent 1176ca2 commit bd62ad7

File tree

1 file changed

+9
-2
lines changed
  • basics/hello-solana/native/tests

1 file changed

+9
-2
lines changed

basics/hello-solana/native/tests/test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from '@solana/web3.js';
66
import { start } from 'solana-bankrun';
77
import { describe, test } from 'node:test';
8+
import { assert } from "chai";
89

910
describe('hello-solana', async () => {
1011
// load program in solana-bankrun
@@ -28,6 +29,12 @@ describe('hello-solana', async () => {
2829

2930
// Now we process the transaction
3031
let transaction = await client.processTransaction(tx);
31-
console.log(transaction?.meta?.logMessages);
32-
});
32+
33+
assert(transaction.logMessages[0].startsWith("Program " + PROGRAM_ID));
34+
assert(transaction.logMessages[1] === "Program log: Hello, Solana!");
35+
assert(transaction.logMessages[2] === "Program log: Our program's Program ID: " + PROGRAM_ID);
36+
assert(transaction.logMessages[3].startsWith("Program " + PROGRAM_ID + " consumed"));
37+
assert(transaction.logMessages[4] === "Program " + PROGRAM_ID + " success");
38+
assert(transaction.logMessages.length == 5);
39+
});
3340
});

0 commit comments

Comments
 (0)