diff --git a/pallets/node-authorization/src/lib.rs b/pallets/node-authorization/src/lib.rs index 27f6c11f..6eeff230 100644 --- a/pallets/node-authorization/src/lib.rs +++ b/pallets/node-authorization/src/lib.rs @@ -150,6 +150,7 @@ pub mod pallet { } #[pallet::error] + #[derive(PartialEq)] pub enum Error { /// The Node identifier is too long. NodeIdTooLong, diff --git a/pallets/node-authorization/src/tests.rs b/pallets/node-authorization/src/tests.rs index 5ceb1dc7..24af33ae 100644 --- a/pallets/node-authorization/src/tests.rs +++ b/pallets/node-authorization/src/tests.rs @@ -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] @@ -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::::InvalidUtf8); +}