Skip to content

Conversation

@ANISH-SR
Copy link
Contributor

Summary of Changes

  • CreateDeviceInterfaceCommand: Added a client-side duplicate-interface check in execute().
  • If device.find_interface(&self.name).is_ok(), the command now returns an error and does not send the CreateDeviceInterface transaction.
  • Extended test imports to include required interface types.
  • Added test_commands_device_create_interface_command_duplicate_name_fails, which:
    • Builds a Device containing an existing "Ethernet0" interface.
    • Mocks client.get(device_pubkey) to return this device.
    • Asserts that executing the command with "Ethernet0" returns an error.

Testing Verification

  • rust tests all green

fixes #2243

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds client-side validation to prevent duplicate interface names when creating device interfaces. The change introduces an early check that returns an error if an interface with the same name already exists, avoiding unnecessary transaction execution.

Key changes:

  • Added duplicate interface name validation in CreateDeviceInterfaceCommand::execute()
  • Extended test imports to support comprehensive duplicate-name testing
  • Added new test case verifying duplicate interface names are rejected

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

In CreateDeviceInterface, a de-duplicating check for device.interfaces should be added using interface name

2 participants