Skip to content

Commit

Permalink
Apply Rustfmt to fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasan2k5 committed Jan 3, 2025
1 parent cfbec47 commit c3b4d19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 36 deletions.
60 changes: 25 additions & 35 deletions pallets/node-authorization/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,51 +457,41 @@ fn adding_already_connected_connection_should_fail() {
// Test to check whether the peerId is TooLong or not.
#[test]
fn test_generate_peer_id_invalid_utf8() {
// Invalid UTF-8 node ID
let invalid_node_id: NodeId = vec![0xFF, 0xFE, 0xFD];
assert_err!(
NodeAuthorization::generate_peer_id(&invalid_node_id),
Error::<Test>::InvalidUtf8
);
// Invalid UTF-8 node ID
let invalid_node_id: NodeId = vec![0xFF, 0xFE, 0xFD];
assert_err!(NodeAuthorization::generate_peer_id(&invalid_node_id), Error::<Test>::InvalidUtf8);
}

#[test]
fn test_generate_peer_id_too_long() {
// Node ID exceeding the maximum length
let long_node_id: NodeId = vec![0x01; MAX_NODE_ID_LEN + 1]; // Exceeds max length
assert_err!(
NodeAuthorization::generate_peer_id(&long_node_id),
Error::<Test>::PeerIdTooLong
);
// Node ID exceeding the maximum length
let long_node_id: NodeId = vec![0x01; MAX_NODE_ID_LEN + 1]; // Exceeds max length
assert_err!(NodeAuthorization::generate_peer_id(&long_node_id), Error::<Test>::PeerIdTooLong);
}

#[test]
fn add_well_known_node_with_peer_id_too_long_should_fail() {
new_test_ext().execute_with(|| {
// Attempt to add a node with an excessively long peer ID
assert_noop!(
NodeAuthorization::add_well_known_node(
RuntimeOrigin::signed(1),
test_node(TEST_NODE_LEN), // Exceeds max length
15
),
Error::<Test>::PeerIdTooLong
);
});
new_test_ext().execute_with(|| {
// Attempt to add a node with an excessively long peer ID
assert_noop!(
NodeAuthorization::add_well_known_node(
RuntimeOrigin::signed(1),
test_node(TEST_NODE_LEN), // Exceeds max length
15
),
Error::<Test>::PeerIdTooLong
);
});
}

#[test]
fn remove_well_known_node_with_peer_id_too_long_should_fail() {
new_test_ext().execute_with(|| {
// Attempt to remove a node with an excessively long peer ID
let long_peer_id: PeerId = vec![0x01; MAX_PEER_ID_LEN + 1]; // Exceeds max length
assert_noop!(
NodeAuthorization::remove_well_known_node(
RuntimeOrigin::signed(1),
long_peer_id
),
Error::<Test>::PeerIdTooLong
);
});
new_test_ext().execute_with(|| {
// Attempt to remove a node with an excessively long peer ID
let long_peer_id: PeerId = vec![0x01; MAX_PEER_ID_LEN + 1]; // Exceeds max length
assert_noop!(
NodeAuthorization::remove_well_known_node(RuntimeOrigin::signed(1), long_peer_id),
Error::<Test>::PeerIdTooLong
);
});
}

1 change: 0 additions & 1 deletion test-utils/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ where

if full_nodes.iter().all(|(id, service, _, _)| full_predicate(*id, service)) {
break;

}
}
};
Expand Down

0 comments on commit c3b4d19

Please sign in to comment.