feat(devnet-sdk): add chain descriptor validation #16523
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.
Description
Replaces TODO comments in
chain.go
with comprehensive descriptor validation to prevent runtime panics when creating chains from malformed descriptors. Adds validation functions for chain descriptors, node configurations, and L2 chain structures with clear error messages.Tests
TestChainFromDescriptorValidation
with 9 test cases covering nil descriptors, empty chain IDs, missing nodes, invalid services/endpoints, and port validationTestL2ChainFromDescriptorValidation
with 3 test cases for L2-specific validation scenariosAdditional context
The original code had TODO comments indicating potential panic situations in
newChainFromDescriptor()
andnewL2ChainFromDescriptor()
functions. Without proper validation, the code could panic when accessing nested descriptor fields that might be nil or missing. This fix ensures graceful error handling with descriptive error messages while maintaining full backward compatibility.Metadata