hiero-ledger / hiero-ledger/hiero-sdk-python
test: add CI parity test between ResponseCode and generated response_code_pb2.ResponseCodeEnum
- Dominant language
- Python
- Stars
- 63
- Forks
- 298
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 38
Description
> [!WARNING]
> **Blocked by #2608.** The parity test this issue adds will fail until the enum fixes in #2608 land. Do not start the PR before #2608 is merged.
### 🧑🎓 Beginner Issue
Welcome! This is a **[Beginner Issue](https://github.com/issues?q=is%3Aopen%20is%3Aissue%20org%3Ahiero-ledger%20archived%3Afalse%20no%3Aassignee%20(label%3A%22beginner%22%20OR%20label%3A%22skill%3A%20beginner%22)%20(repo%3Ahiero-ledger%2Fhiero-sdk-cpp%20OR%20repo%3Ahiero-ledger%2Fhiero-sdk-swift%20OR%20repo%3Ahiero-ledger%2Fhiero-sdk-python%20OR%20repo%3Ahiero-ledger%2Fhiero-sdk-js%20OR%20repo%3Ahiero-ledger%2Fhiero-website))** designed to help you learn the codebase.
🏁 **When this issue is complete, you will have:**
✅ Researched a file or method in detail
✅ Followed SDK patterns to implement a solution
✅ Researched and identified appropriate programming constructs to solve the problem
✅ Created basic tests
✅ Delivered a clean, review-ready pull request
### 🐞 Problem Description
`src/hiero_sdk_python/response_code.py` hand-maintains the `ResponseCode` enum, duplicating an enum the repo already generates from protobufs: `src/hiero_sdk_python/hapi/services/response_code_pb2.py`. Nothing checks the two against each other, which is how #2608 happened — swapped numbers, misspelled names, and missing codes went unnoticed for a long time.
Every future protobuf update is another chance to drift. We need CI to catch any mismatch the moment it appears.
### 💡 Expected Solution
A unit test (e.g. `tests/unit/response_code_parity_test.py`) asserting exact name→value parity between `ResponseCode` and the generated `response_code_pb2.ResponseCodeEnum`, in both directions:
1. Every name in the generated proto enum exists in `ResponseCode` with the same integer value.
2. Every declared `ResponseCode` member exists in the proto enum with the same value — **excluding** the deprecated aliases introduced in #2608 (aliases don't appear in `__members__` iteration the way canonical members do; verify this yourself).
On mismatch, the assertion message must list the offending names and values so the failure is self-explanatory without a debugger. The whole test should be roughly 10–20 lines.
### 🔍 Research Pointers
**Before you start — required reading:**
- `src/hiero_sdk_python/hapi/services/response_code_pb2.py` — the generated enum. Research protobuf's `EnumTypeWrapper`: `ResponseCodeEnum.items()` yields `(name, number)` pairs.
- `src/hiero_sdk_python/response_code.py` — note the `_missing_` hook: `ResponseCode(x)` never raises for unknown ints, so compare **declared members** (`ResponseCode.__members__`) rather than doing lookups.
- Python docs on `enum` — the difference between `__members__` (includes aliases) and iterating the class (canonical members only): [enum HOWTO](https://docs.python.org/3/howto/enum.html).
- An existing test in `tests/unit/` — follow its file naming (`*_test.py`), imports, and style.
- `CONTRIBUTING.md`
### 🛠️ Implementation Notes
- Build a dict from each side, diff the key sets and the values for shared keys, and assert the diffs are empty with a readable message. Avoid asserting inside a loop — one aggregated assertion produces a far better failure report.
- Decide (and document in a comment) how the test tolerates the intentional deprecated aliases from #2608 without letting real drift hide behind that exclusion.
- No source-code changes should be needed. If your test fails on current `main`, #2608 has likely not merged yet — see the blocker at the top.
### 🧠 Beginner Contributors — Prerequisites & Expectations
> [!CAUTION]
> **Beginner issues are low-risk but we expect a working solution.**
> [!IMPORTANT]
> We recommend completing at least 3 Good First Issues before attempting a beginner issue.
**Difficulty:**
- Requires understanding both a generated protobuf enum wrapper and Python `enum` internals
- Beginner to intermediate coding skills
> [!TIP]
> **You should be comfortable with:**
> - Forking, branching, committing (with DCO + GPG signing), and opening a pull request without a tutorial
> - Reading beginner to intermediate code you did not write and following its patterns
> - Handling simple merge conflicts
> - Keeping your fork up to date with main by [rebasing](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/rebasing.md)
> - Looking things up on your own before asking for help
### ⚠️ AI Usage Policy
- AI can help you understand the codebase and the problem
- Using AI to generate code for beginner issues is **strictly discouraged**
- Using AI as the main source of research is **strictly discouraged** — refer to the Python `enum` documentation and the protobuf-generated code itself.
### ⏱️ Timeline & Workflow
- **Typical time:** ~1 week / ~8 hours (most of it research; the test itself is small).
- 🔴 Completing a beginner issue in 1–3 hours is a **red flag**.
> [!TIP]
> **Suggested:** share your proposed implementation approach as a comment before writing code to get early feedback and avoid wasted effort.
### 🧪 Testing Requirements
This issue **is** a test, so the bar is that it works and fails well:
- `uv run pytest tests/unit/response_code_parity_test.py -v` passes on current `main` (after #2608).
- Temporarily break one enum value locally and confirm the failure message clearly names the mismatched code — include a screenshot or paste of that failure output in your PR description as evidence.
### 🛡️ Quality & Review Standards
Beginner PRs must be **working and follow best practices**.
1. **Working:** The test passes on `main` and fails informatively on any drift.
2. **SDK Best Practices:** Follows existing `tests/unit/` conventions.
3. **No production code changes** — this PR touches tests only.
### ✅ PR Quality Checklist
Before opening your PR, confirm:
- [ ] I have spent the majority of my time researching the problem and building my understanding of the codebase and methods.
- [ ] My test passes on `main` and I have demonstrated its failure output on an artificial mismatch.
- [ ] Every line of code is personally understood and explainable.
- [ ] My changes address what the issue asked for — nothing more, nothing less
- [ ] I have applied appropriate linting, code quality, and formatting tools used in this repo.
Before requesting a review, confirm:
- [ ] I did not modify files unrelated to this issue
- [ ] Clean git history — no rebase artifacts, merge commits, or unrelated files
- [ ] My commits are signed: `git commit -S -s -m "test: description"` — [Signing guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/signing.md)
- [ ] All CI checks pass.
### 📋 Workflow quick reference
| Step | Guide |
|------|-------|
| Claim this issue | Comment `/assign` below |
| Sync with main | [Rebasing guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/rebasing.md) |
| Open a PR and link this issue | [PR guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-workflow.md) |
| Resolve merge conflicts | [Merge conflicts guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/merge_conflicts.md) |
### 📚 Resources & Support
**🆘 Stuck?**
> [!TIP]
> **Comment on this issue** and describe what you have tried. A maintainer will respond.
**Python SDK References:**
- [Windows Setup Guide](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/sdk_developers/setup_windows.md)
- [Pylance guide](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/sdk_developers/pylance.md)
- [Browse closed beginner PRs](https://github.com/hiero-ledger/hiero-sdk-python/pulls?q=is%3Apr+is%3Amerged+label%3A%22skill%3A+beginner%22)
**References:**
- [Python enum HOWTO](https://docs.python.org/3/howto/enum.html)
- [Community Calls](https://zoom-lfx.platform.linuxfoundation.org/meetings/hiero?view=week)
- [Discord](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/discord.md)
Contributor guide
Assessment
This issue has not been assessed yet.