Skip to content

test: cover Bool returned as SC_SPEC_TYPE_VAL (#2438) - #2686

Open
Galmanus wants to merge 1 commit into
stellar:mainfrom
Galmanus:fix/2438-bool-val-regression-test
Open

test: cover Bool returned as SC_SPEC_TYPE_VAL (#2438)#2686
Galmanus wants to merge 1 commit into
stellar:mainfrom
Galmanus:fix/2438-bool-val-regression-test

Conversation

@Galmanus

Copy link
Copy Markdown

What

Adds a regression test locking the behavior reported in #2438: a contract function returning Val (SC_SPEC_TYPE_VAL) whose runtime value is ScVal::Bool(false) (or true) must render via xdr_to_json instead of panicking with "doesn't have a matching Val".

Why this is test-only

The defect itself is already fixed on main by the generic-Val arm added in #2469 ((val, ScType::Val) => to_json(val)), which handles every ScVal variant. Existing regression coverage for that arm exercises Bytes, Map and Vec — but not Bool. This adds that missing case so a future refactor of the match can't silently reintroduce the panic.

Note: the false value in the original report is incidental — both Bool(true) and Bool(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-tools and cargo clippy -p soroban-spec-tools --all-targets are green.

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.
Copilot AI balanced review requested due to automatic review settings August 15, 2026 00:55
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Aug 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and ScVal::Bool(true) with ScType::Val.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

2 participants