Skip to content

feat(tck): Add getTopicInfo method to TCK#2395

Merged
MonaaEid merged 8 commits into
hiero-ledger:mainfrom
manishdait:feat/tck-topic-info
Jul 6, 2026
Merged

feat(tck): Add getTopicInfo method to TCK#2395
MonaaEid merged 8 commits into
hiero-ledger:mainfrom
manishdait:feat/tck-topic-info

Conversation

@manishdait

Copy link
Copy Markdown
Contributor

Description:
This PR introduce the getTopicId method to tck module.

Changes Made:

  • Added the getTopicInfo method to tck.
  • Update the topic_info_query to handle None topic_id.

Related issue(s):

Fixes #2394

Notes for reviewer:

  • Updated topic_info to include topicId and replace the proto type to use sdk-types for autoRenewAccount, adminKey, submitKey
  • Update the unit/integration test for this changes.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@github-actions github-actions Bot added approved Issue has been approved by team member scope: TCK involves engineering for the implementation of TCK method and module labels Jun 29, 2026
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2395      +/-   ##
==========================================
- Coverage   95.04%   95.01%   -0.04%     
==========================================
  Files         163      163              
  Lines       10461    10465       +4     
==========================================
  Hits         9943     9943              
- Misses        518      522       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@manishdait
manishdait force-pushed the feat/tck-topic-info branch from f9a7208 to 7e59016 Compare June 29, 2026 19:11
@github-actions

Copy link
Copy Markdown

Hi, this is WorkflowBot.
Your pull request cannot be merged as it is not passing all our workflow checks.
Please click on each check to review the logs and resolve issues so all checks pass.
To help you:

@manishdait
manishdait marked this pull request as ready for review June 29, 2026 19:52
@manishdait
manishdait requested review from a team as code owners June 29, 2026 19:52
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

TopicInfo now carries topic_id and parses from ConsensusGetTopicInfoResponse, TopicInfoQuery forwards that wrapper, and the TCK module adds getTopicInfo support with new params, response types, mapping helpers, and shared key serialization. Tests and examples were updated to match the new shapes.

Changes

TopicInfo refactor and getTopicInfo TCK handler

Layer / File(s) Summary
TopicInfo and query wrapper parsing
src/hiero_sdk_python/consensus/topic_info.py, src/hiero_sdk_python/query/topic_info_query.py
TopicInfo.__init__ adds topic_id: TopicId; _from_proto now accepts ConsensusGetTopicInfoResponse and reads nested topicInfo/topicID; key and account conversions use Key.from_proto_key and AccountId._from_proto; __str__ includes topic_id. TopicInfoQuery._make_request makes topicID population conditional on non-None; execute passes response.consensusGetTopicInfo directly to _from_proto.
TCK params, response types, and key serialization
tck/param/topic.py, tck/response/topic.py, tck/util/key_utils.py, tck/handlers/account.py
TopicMessageInfoParams is added with topicId, queryPayment, and maxQueryPayment. TopicInfoResponse, CustomFeeResponse, and FixedFeeResponse are added. key_to_string is added and account key output switches to it.
getTopicInfo RPC handler
tck/handlers/topic.py
getTopicInfo builds and executes TopicInfoQuery, then maps TopicInfo fields to TopicInfoResponse covering keys, durations, running hash, fee-exempt keys, custom fees, and ledgerId.
Tests and example updated
tests/unit/topic_info_test.py, tests/unit/topic_info_query_test.py, tests/integration/topic_*.py, examples/consensus/topic_info.py
Unit test fixtures wrap proto in ConsensusGetTopicInfoResponse; topic_id is added to TopicInfo constructions; query tests replace the ValueError check with a None topic-id proto assertion. Integration tests replace _to_proto() admin key comparisons with isinstance(PublicKey) + to_bytes_raw(). The example is updated to match the new constructor and proto builder.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Most changes fit the topic-info work, but tck/handlers/account.py changes GetAccountInfoResponse serialization and is unrelated to #2394. Move the account handler serialization refactor into a separate PR unless it is required as supporting work for getTopicInfo.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding getTopicInfo to TCK.
Description check ✅ Passed The description is related to the changeset and mentions the new getTopicInfo method and TopicInfoQuery updates.
Linked Issues check ✅ Passed The PR appears to implement #2394 by adding getTopicInfo and the related query/response plumbing for TopicInfoQuery.
Docstring Coverage ✅ Passed Docstring coverage is 80.49% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 7


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e34349a6-aa3a-46ec-b62f-cf8af31a0bae

📥 Commits

Reviewing files that changed from the base of the PR and between 2f1705a and 7e59016.

📒 Files selected for processing (13)
  • examples/consensus/topic_info.py
  • src/hiero_sdk_python/consensus/topic_info.py
  • src/hiero_sdk_python/query/topic_info_query.py
  • tck/handlers/account.py
  • tck/handlers/topic.py
  • tck/param/topic.py
  • tck/response/topic.py
  • tck/util/key_utils.py
  • tests/integration/topic_create_transaction_e2e_test.py
  • tests/integration/topic_info_query_e2e_test.py
  • tests/integration/topic_update_transaction_e2e_test.py
  • tests/unit/topic_info_query_test.py
  • tests/unit/topic_info_test.py

Comment thread src/hiero_sdk_python/consensus/topic_info.py Outdated
Comment thread src/hiero_sdk_python/query/topic_info_query.py
Comment thread tck/handlers/topic.py Outdated
Comment thread tck/handlers/topic.py
Comment thread tck/response/topic.py
Comment thread tests/unit/topic_info_query_test.py
Comment thread tests/unit/topic_info_test.py
@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Jun 29, 2026
Comment thread tck/handlers/topic.py Outdated
Comment thread src/hiero_sdk_python/consensus/topic_info.py Outdated
Comment thread examples/consensus/topic_info.py Outdated
@aceppaluni aceppaluni added reviewer: maintainer PR needs a review from the maintainer team reviewer: committer request review help from a committer status: Needs Developer Revision Author needs to apply suggested changes/improvements and removed approved Issue has been approved by team member labels Jun 30, 2026
@github-actions github-actions Bot added the approved Issue has been approved by team member label Jun 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hiero_sdk_python/consensus/topic_info.py (1)

69-80: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Align the constructor contract with the new SDK wrapper types.

These fields are now stored and parsed as AccountId / generic Key, but the public __init__ surface still advertises AccountID / PublicKey. That incorrectly narrows valid topic key shapes and leaves the SDK model out of sync with what _from_proto() returns.

Suggested fix
-        auto_renew_account: AccountID | None,
+        auto_renew_account: AccountId | None,
...
-        fee_schedule_key: PublicKey | None,
-        fee_exempt_keys: list[PublicKey] | None,
+        fee_schedule_key: Key | None,
+        fee_exempt_keys: list[Key] | None,

As per path instructions, proto message fields should use the corresponding SDK wrapper class in the SDK surface.

Source: Path instructions


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fb542e36-c8a2-45c2-9ccc-99872ebe7e33

📥 Commits

Reviewing files that changed from the base of the PR and between ed72b5d and 3a597fe.

📒 Files selected for processing (3)
  • examples/consensus/topic_info.py
  • src/hiero_sdk_python/consensus/topic_info.py
  • tck/handlers/topic.py

MonaaEid
MonaaEid previously approved these changes Jul 4, 2026
@github-actions github-actions Bot added queue:maintainers PR awaiting maintainer final review and removed queue:junior-committer PR awaiting initial quality review labels Jul 4, 2026
aceppaluni
aceppaluni previously approved these changes Jul 6, 2026
@aceppaluni aceppaluni added status: update branch developer needs to click update branch status: ready-to-merge PR has 1+ maintainer and 2+ total approvals, ready to merge and removed approved Issue has been approved by team member labels Jul 6, 2026
@github-actions github-actions Bot added approved Issue has been approved by team member and removed status: ready-to-merge PR has 1+ maintainer and 2+ total approvals, ready to merge labels Jul 6, 2026
@aceppaluni aceppaluni removed the approved Issue has been approved by team member label Jul 6, 2026
@github-actions github-actions Bot added queue:junior-committer PR awaiting initial quality review and removed queue:maintainers PR awaiting maintainer final review labels Jul 6, 2026
Comment thread src/hiero_sdk_python/query/topic_info_query.py Outdated
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
@manishdait
manishdait dismissed stale reviews from aceppaluni and MonaaEid via 97e741b July 6, 2026 20:01
@manishdait
manishdait force-pushed the feat/tck-topic-info branch from 0a7a85e to 97e741b Compare July 6, 2026 20:01
@github-actions github-actions Bot added the approved Issue has been approved by team member label Jul 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hiero_sdk_python/consensus/topic_info.py (1)

45-49: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Type-hint mismatch: auto_renew_account/fee_schedule_key still typed for the old protobuf/PublicKey types.

This diff switches the stored attribute types to SDK types but leaves the constructor parameter type hints stale:

  • Line 77: self.auto_renew_account: AccountId | None = auto_renew_account, but the __init__ parameter (line 45) is still typed auto_renew_account: AccountID | None (the raw protobuf type, imported at line 20). _from_proto now passes AccountId._from_proto(...) (SDK type), not AccountID.
  • Line 79: self.fee_schedule_key: Key = fee_schedule_key declares a required Key, but the parameter (line 47) is still fee_schedule_key: PublicKey | None (optional, wrong type name). _from_proto populates this via Key.from_proto_key(...), which can be None.
  • Same stale PublicKey typing applies to fee_exempt_keys: list[PublicKey] | None (line 48) vs. the actual list[Key] produced by _from_proto and stored at line 80.

These inconsistencies will mislead type checkers/IDE users of this public class.

🩹 Proposed fix
         auto_renew_period: Duration | None,
-        auto_renew_account: AccountID | None,
+        auto_renew_account: AccountId | None,
         ledger_id: bytes | None,
-        fee_schedule_key: PublicKey | None,
-        fee_exempt_keys: list[PublicKey] | None,
+        fee_schedule_key: Key | None,
+        fee_exempt_keys: list[Key] | None,
         custom_fees: list[CustomFixedFee] | None,
     ) -> None:
...
-        self.fee_schedule_key: Key = fee_schedule_key
+        self.fee_schedule_key: Key | None = fee_schedule_key

Also update the docstring (Args: block) and remove the now-unused AccountID/PublicKey imports if no longer referenced elsewhere in the signature.

As per path instructions for src/hiero_sdk_python/**/*.py, "Check that each SDK field type correctly represents the proto type" and flag any SDK attribute referencing a mismatched type.

Also applies to: 69-84

Source: Path instructions

♻️ Duplicate comments (1)
src/hiero_sdk_python/query/topic_info_query.py (1)

88-94: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Client-side topic_id validation removed from _make_request().

This drops the previous guard that rejected a missing topic_id before sending the query, matching a concern already raised in a prior review round (still unresolved in this revision). A TopicInfoQuery with no topic_id set will now silently produce a ConsensusGetTopicInfoQuery without topicID and round-trip to the network instead of failing fast locally.

This appears intentional to let the TCK's getTopicInfo handler exercise "missing topicId" as a server-side negative-path scenario (see tck/handlers/topic.py's if params.topicId is not None: query.set_topic_id(...)), and is covered by a new unit test (test_topic_id_not_set_when_none). However, it also changes behavior for any general SDK caller who constructs TopicInfoQuery() and calls .execute() without ever setting topic_id — they now pay for a network round trip and get a less specific error instead of an immediate client-side ValueError.

Please confirm this is an intentional, permanent contract change (not just an oversight retained from the TCK requirement) since Query path instructions treat identifier validation in _make_request() as a MUST.

As per path instructions, "_make_request() MUST: Validate all required identifiers (accountId, tokenId, topicId, etc.)".

Source: Path instructions


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ff1068d5-0578-4f14-b29d-6133291d97bc

📥 Commits

Reviewing files that changed from the base of the PR and between 3a597fe and 97e741b.

📒 Files selected for processing (13)
  • examples/consensus/topic_info.py
  • src/hiero_sdk_python/consensus/topic_info.py
  • src/hiero_sdk_python/query/topic_info_query.py
  • tck/handlers/account.py
  • tck/handlers/topic.py
  • tck/param/topic.py
  • tck/response/topic.py
  • tck/util/key_utils.py
  • tests/integration/topic_create_transaction_e2e_test.py
  • tests/integration/topic_info_query_e2e_test.py
  • tests/integration/topic_update_transaction_e2e_test.py
  • tests/unit/topic_info_query_test.py
  • tests/unit/topic_info_test.py

Comment thread tck/param/topic.py
Comment thread tck/response/topic.py
Comment thread tck/util/key_utils.py
@MonaaEid MonaaEid added this to the v0.2.8 milestone Jul 6, 2026
@MonaaEid
MonaaEid merged commit d4ea816 into hiero-ledger:main Jul 6, 2026
28 checks passed
@manishdait
manishdait deleted the feat/tck-topic-info branch July 20, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Issue has been approved by team member open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review reviewer: committer request review help from a committer reviewer: maintainer PR needs a review from the maintainer team scope: TCK involves engineering for the implementation of TCK method and module status: Needs Developer Revision Author needs to apply suggested changes/improvements status: update branch developer needs to click update branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add getTopicInfo method to tck module

5 participants