pallet - node-authorization : Adding Tests for Node_ID_Too_Long#593
Open
ritankarsaha wants to merge 2 commits intodhiway:develop_20250418from
Open
pallet - node-authorization : Adding Tests for Node_ID_Too_Long#593ritankarsaha wants to merge 2 commits intodhiway:develop_20250418from
ritankarsaha wants to merge 2 commits intodhiway:develop_20250418from
Conversation
vatsa287
approved these changes
Mar 9, 2025
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.
This PR fixes the issue #592
Description
This test is designed to verify that the system correctly enforces the
MaxNodeIdLengthconstraint inNodeAuthorization. Here's a breakdown of how it works:Fetches the Maximum Allowed NodeId Length:
Retrieves the
MaxNodeIdLengthfrom the runtime configuration(<Test as Config>::MaxNodeIdLength::get()).Creates an Oversized NodeId:
Generates a string that exceeds the allowed length by one character
("a".repeat((max_len + 1) as usize)).Uses
test_node(&long_string)to create a node with this oversized identifier.Executes
Two Assertionsto Validate Enforcement:Test
add_well_known_node:Calls
NodeAuthorization::add_well_known_nodewith the oversized node.Expects it to fail with
Error::<Test>::NodeIdTooLong.Test
add_connection:Calls
NodeAuthorization::add_connection, attempting to establish a connection using the oversized node.Expects it to fail with the same error.
Testing
The tests are passed in my local environment as well
Below is the attached screenshot for the same
@amarts @vatsa287 would you please take a look at the issue #592 and the PR to check if they are in compliance with the present requirements?