Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for invalid UTF8 #508

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pallets/node-authorization/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ pub mod pallet {
}

#[pallet::error]
#[derive(PartialEq)]
vatsa287 marked this conversation as resolved.
Show resolved Hide resolved
pub enum Error<T> {
/// The Node identifier is too long.
NodeIdTooLong,
Expand Down
8 changes: 7 additions & 1 deletion pallets/node-authorization/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use super::*;
use crate::mock::*;
use frame_support::{assert_noop, assert_ok};
use frame_support::{assert_err, assert_noop, assert_ok};
use sp_runtime::traits::BadOrigin;

#[test]
Expand Down Expand Up @@ -453,3 +453,9 @@ fn adding_already_connected_connection_should_fail() {
);
});
}

#[test]
fn test_generate_peer_id_invalid_utf8() {
let invalid_node_id: NodeId = vec![0xFF, 0xFE, 0xFD];
assert_err!(NodeAuthorization::generate_peer_id(&invalid_node_id), Error::<Test>::InvalidUtf8);
}