test(hello-solana): assert the greeting log instead of only tx success#105
Merged
Conversation
hello-solana only logs a message and changes no state, so a test that just checks the transaction landed verifies nothing about the program. Assert each flavor emits 'Hello, Solana!': - anchor: kite's send helper discards transaction metadata, so send through LiteSVM directly (adds a solana-transaction dev-dep) and read the logs. - native: capture the send result and assert the log (was is_ok only). - quasar: assert on result.logs after assert_success. pinocchio already asserted the log. anchor verified with cargo check --tests; native/quasar mirror existing log-asserting tests in the repo.
Wrap the metadata.logs method chain to satisfy cargo fmt --check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
hello-solanalogs a message and changes no state, so a test that only checks the transaction landed verifies nothing about the program's actual behavior — the skill calls these out as not-real tests. Each flavor now asserts the program emittedHello, Solana!.Changes
send_transaction_from_instructionsreturnsResult<(), _>and discards the metadata (and logs). Send through LiteSVM directly instead (adds asolana-transactiondev-dep) and assert the greeting appears inmetadata.logs.assert!(...is_ok()); now captures the result and asserts the log.result.logscontains the greeting afterassert_success().Verification
The anchor rewrite was type-checked with
cargo check --tests(against a placeholder.sosoinclude_bytes!resolves — the sbf toolchain isn't available locally, so full execution is left to CI). The native and quasar changes mirror log-asserting patterns already used elsewhere in the repo (pinocchiohello-solana;repository-layout/quasar).This covers the clearly-weak
hello-solanafamily. If you want, I can sweep for other assert-only tests in a follow-up.🤖 Generated with Claude Code
Generated by Claude Code