Add to_json() and serialize_json() to block_sideband - #5089
Open
gabparrot wants to merge 2 commits into
Open
Conversation
Implements the JSON inspection method requested in nanocurrency#4390, mirroring the existing nano::vote::to_json() pattern. Also adds a unit test covering all 7 sideband fields. Refs nanocurrency#4390
gabparrot
marked this pull request as draft
June 27, 2026 19:54
Replace tautological assertions (expected values derived from the same conversions the SUT calls) with literal expected JSON values so the test independently verifies serialize_json output. Add a second test covering the send/epoch/change branches of state_subtype that were previously unexercised. Refs nanocurrency#4390
gabparrot
marked this pull request as ready for review
June 27, 2026 20:07
Test Results for Commit 5acf321Pull Request 5089: Results Test Case Results
Last updated: 2026-06-27 22:40:56 UTC |
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.
Summary
Implements the
to_json()inspection method requested in #4390 fornano::block_sideband. Useful for debugging and consistent with the existingnano::vote::to_json()pattern.Changes
nano/lib/block_sideband.hpp— declareto_json()andserialize_json()alongside the existing loggingoperator().nano/lib/block_sideband.cpp— implement both, writing all 7 sideband fields: account, balance, height, timestamp, topo_height, source_epoch, details (viastate_subtype).nano/core_test/block.cpp— addTEST (block_sideband, to_json)covering all fields, mirroring the existingblock_store, sideband_serializationtest style.Notes
nano::vote::to_json()(vote.cpp:164) andnano::vote::serialize_json()(vote.cpp:147).source_epochis serialized as the underlying integer value (matching how it's persisted) rather than the enum name; a future change to enum names would be a no-op for persisted data.core_testverification.Fixes #4390