Skip to content

Implement deleteFile JSON-RPC method #19

Description

@aceppaluni

Problem

The TCK server does not implement deleteFile, so the TCK driver's FileDeleteTransaction suite cannot run against the Python SDK. The SDK transaction (src/hiero_sdk_python/file/file_delete_transaction.py) already exists.

Blocked by hiero-ledger#2488 (createFile) — this handler goes in the file-service TCK modules hiero-ledger#2488 creates, and the driver needs a created file to delete. Implementing this also unblocks a currently-skipped test in the appendFile spec ("Appends to a deleted file — Skipped (delete file not implemented)").

Solution

Add a deleteFile handler wrapping FileDeleteTransaction, modelled on the existing deleteTopic handler in tck/handlers/topic.py — same shape, substituting FileDeleteTransaction and set_file_id(FileId.from_string(...)).

Method contract (from the spec):

Input Type Required Notes
fileID string optional Capital ID — see trap below
commonTransactionParams object optional

Output: status — reuse StatusOnlyResponse from tck/response/base.py.

Implementation steps:

  1. Add DeleteFileParams(BaseTransactionParams) to tck/param/file.py.
  2. Add the handler to tck/handlers/file.py (mirror deleteTopic).
  3. Add a unit test under tests/tck/.

Two traps — both are spec-conformance issues that will fail driver tests if missed:

  1. The spec's parameter is fileID, not fileId. Every other file-service method uses fileId; this one alone uses fileID. Bind the JSON key verbatim (params.get("fileID")) or the driver's parameter won't map. Leave a comment so a future reader doesn't "fix" the inconsistency.

  2. Empty string vs. omitted must behave differently. The spec's property tests expect:

    • fileId=""SDK internal error
    • fileId omitted entirely → network INVALID_FILE_ID

    The SDK raises ValueError("Missing required FileID") for an unset file ID (file_delete_transaction.py, _require check before building), which would collapse both cases into a local error. The handler must therefore: pass "" through in a way that triggers SDK-side validation (e.g. attempt FileId.from_string(""), which raises), but when the param is absent, do not short-circuit — submit without a file ID so the network returns INVALID_FILE_ID. If the SDK's local ValueError makes the omitted case impossible to send, note that in the PR and raise it — that's a genuine SDK/spec conformance question, not something to paper over in the handler.

Other spec expectations to test: delete without the file's admin key in signersINVALID_SIGNATURE; delete an already-deleted file → FILE_DELETED.

Acceptance criteria

  • deleteFile registered and dispatchable, bound to the fileID (capital ID) parameter
  • fileID="" → SDK internal error; fileID omitted → network INVALID_FILE_ID (or SDK limitation documented in PR)
  • Unsigned delete → INVALID_SIGNATURE; double delete → FILE_DELETED
  • Unit test added; uv run pytest tests/tck -q passes

Spec: https://github.com/hiero-ledger/hiero-sdk-tck/blob/main/docs/test-specifications/file-service/FileDeleteTransaction.md

JS reference: https://github.com/hiero-ledger/hiero-sdk-js/blob/main/tck/methods/file.ts (deleteFile)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions