Skip to content

pallet - node-authorization : Adding Tests for Node_ID_Too_Long#593

Open
ritankarsaha wants to merge 2 commits intodhiway:develop_20250418from
ritankarsaha:nodeidtoolong
Open

pallet - node-authorization : Adding Tests for Node_ID_Too_Long#593
ritankarsaha wants to merge 2 commits intodhiway:develop_20250418from
ritankarsaha:nodeidtoolong

Conversation

@ritankarsaha
Copy link
Copy Markdown
Contributor

@ritankarsaha ritankarsaha commented Mar 9, 2025

This PR fixes the issue #592

Description

This test is designed to verify that the system correctly enforces the MaxNodeIdLength constraint in NodeAuthorization. Here's a breakdown of how it works:

  • Fetches the Maximum Allowed NodeId Length:

  • Retrieves the MaxNodeIdLength from 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 Assertions to Validate Enforcement:

  • Test add_well_known_node:

  • Calls NodeAuthorization::add_well_known_node with 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

Screenshot 2025-03-09 at 5 13 19 PM

@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?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants