hiero-ledger / hiero-ledger/hiero-sdk-cpp

[Beginner]: Add `operator==` to `NodeAddress`

Open Beginner friendly
#1,571 2 comments 0 reactions 0 assignees View on GitHub
priority: low scope: api skill: beginner status: ready for dev
Dominant language
C++
Stars
42
Forks
108
Avg merge
11h 45m
Merged PRs (30d)
2

Description

### 🐥 Beginner Friendly

This issue is a great fit for contributors who are ready to explore the Hiero C++ codebase a little more and take on slightly more independent work.

Beginner Issues often involve reading existing C++ code, understanding how different parts of the SDK fit together, and making small, thoughtful updates that follow established patterns.

The goal is to support skill growth while keeping the experience approachable, well-scoped, and enjoyable.

> [!IMPORTANT]
> ### 🐥 About Beginner Issues
>
> Beginner Issues are a great next step for contributors who feel comfortable with the basic project workflow and want to explore the codebase a little more.
>
> These issues often involve:
> - Reading existing C++ code
> - Understanding how different parts of the SDK fit together
> - Making small, thoughtful updates that follow established patterns
>
> You'll usually see Beginner Issues focused on things like:
> - Small, well-scoped improvements to existing tests
> - Narrow updates to `src` functionality (e.g. refining helpers or improving readability)
> - Documentation or comment clarity
> - Enhancements to existing examples
>
> Other types of contributions — such as brand-new features, broader system changes, or deeper technical work — are just as valuable and may use different labels.

### 👾 Description of the Issue

The `NodeAddress` class is missing an `operator==` implementation.

Relevant files:
```
src/sdk/main/include/NodeAddress.h
src/sdk/main/src/NodeAddress.cc
```

Without `operator==`, callers must compare node address objects field-by-field. Other SDK value types (e.g. `AccountId`, `PendingAirdropId`) already implement `operator==` as a pattern — `NodeAddress` should follow suit.

Note: `NodeAddress` uses **private member variables** with public getter methods (unlike most other SDK value types that use public members). Declaring `operator==` as a `const` member function gives it direct access to private members without needing `friend`.

Note: this issue depends on `Endpoint` also having `operator==` — see the companion issue for `Endpoint`. If `Endpoint` doesn't have `operator==` yet when you start this issue, either work on both together or wait for that issue to be merged first.

### 💡 Proposed Solution

Add `operator==` to `NodeAddress` as a `const` member function:

- Declare `[[nodiscard]] bool operator==(const NodeAddress& rhs) const` in the header
- Implement it in `NodeAddress.cc`, comparing all meaningful member fields:
- `mRSAPublicKey`, `mNodeId`, `mNodeAccountId`
- `mNodeCertHash`, `mEndpoints`, `mDescription`
- Add or extend the unit test file in `src/sdk/tests/unit/NodeAddressTest.cc`

The change should not affect any existing behavior or public API.

### 👩‍💻 Implementation Steps

- [ ] Confirm that `Endpoint` has `operator==` (check `src/sdk/main/include/Endpoint.h`)
- [ ] Open `src/sdk/main/include/NodeAddress.h` and review the private members and public getter methods
- [ ] Add the member `operator==` declaration inside the class body
- [ ] Open `src/sdk/main/src/NodeAddress.cc` and implement `operator==` comparing all six member fields
- [ ] Open `src/sdk/tests/unit/NodeAddressTest.cc` and add equality tests:
- Two default-constructed instances are equal
- Two identically-constructed instances are equal
- Instances differing in each field are not equal
- [ ] Build the SDK and confirm all tests pass

### ✅ Acceptance Criteria

- [ ] **Scope:** Changes are limited to `NodeAddress.h`, `NodeAddress.cc`, and its unit test
- [ ] **Behavior:** No other SDK behavior or API changes
- [ ] **Tests:** Existing and new equality tests pass
- [ ] **Review:** All code review feedback addressed

---

### 📋 Step-by-Step Contribution Guide

To help keep contributions consistent and easy to review, we recommend following these steps:

- [ ] Comment `/assign` to request the issue
- [ ] Wait for assignment
- [ ] Fork the repository and create a branch
- [ ] Set up the project using the instructions in `README.md`
- [ ] Make the requested changes
- [ ] Sign each commit using `-s -S`
- [ ] Push your branch and open a pull request

Read [Workflow Guide](https://github.com/hiero-ledger/hiero-sdk-cpp/blob/main/docs/training/workflow.md) for step-by-step workflow guidance.
Read [README.md](https://github.com/hiero-ledger/hiero-sdk-cpp/blob/main/README.md) for setup instructions.

❗ Pull requests **cannot be merged** without `S` and `s` signed commits.
See the [Signing Guide](https://github.com/hiero-ledger/hiero-sdk-cpp/blob/main/docs/training/signing.md).

### 🤔 Additional Information

Declare `operator==` as a `const` member function — not a `friend`. The declaration in the header is `[[nodiscard]] bool operator==(const T& rhs) const;` and the definition in the `.cc` file uses `mField` directly (not `lhs.mField`) since `this` is the left-hand side.

If you have questions while working on this issue, feel free to ask! [Hiero-SDK-C++ Discord](https://discord.com/channels/905194001349627914/1337424839761465364)

Contributor guide

Open the contributing guide

Research direction

Start by checking operator== in src/sdk/main/include/Endpoint.h and comparable SDK value types such as AccountId or PendingAirdropId. Review NodeAddress.h and NodeAddress.cc, then add equality tests in src/sdk/tests/unit/NodeAddressTest.cc covering default, identical, and each differing field. Done means the scoped files change, equality tests pass, and the SDK builds successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.