test: cover Bool returned as SC_SPEC_TYPE_VAL (#2438) - #2686
Open
Galmanus wants to merge 1 commit into
Open
Conversation
Adds a regression test for stellar#2438: a contract fn returning `Val` whose runtime value is ScVal::Bool must render via xdr_to_json instead of panicking. The defect itself was already resolved on main by the generic-Val arm added in stellar#2469; existing Val-type coverage handled Bytes, Map and Vec but not Bool. Both booleans exercise the same arm.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a regression test to ensure xdr_to_json correctly renders ScVal::Bool when the declared spec type is ScType::Val, preventing a panic reported in stellar-cli issue #2438.
Changes:
- Added a unit test covering
ScVal::Bool(false)andScVal::Bool(true)withScType::Val.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
What
Adds a regression test locking the behavior reported in #2438: a contract function returning
Val(SC_SPEC_TYPE_VAL) whose runtime value isScVal::Bool(false)(ortrue) must render viaxdr_to_jsoninstead of panicking with "doesn't have a matching Val".Why this is test-only
The defect itself is already fixed on
mainby the generic-Valarm added in #2469 ((val, ScType::Val) => to_json(val)), which handles everyScValvariant. Existing regression coverage for that arm exercisesBytes,MapandVec— but notBool. This adds that missing case so a future refactor of the match can't silently reintroduce the panic.Note: the
falsevalue in the original report is incidental — bothBool(true)andBool(false)hit the same arm; the match discriminates on the variant, not the payload. #2438 can be closed as resolved by #2469 once this coverage lands.Tests
cargo test -p soroban-spec-toolsandcargo clippy -p soroban-spec-tools --all-targetsare green.