Skip to content

Add unit tests for new JSON-RPC methods (PRT dispute entities) #726

@vfusco

Description

@vfusco

Context / Problem

We recently added new JSON-RPC methods for PRT dispute data, but the internal/jsonrpc package does not yet have unit tests covering them. Existing JSON-RPC methods are already being tested; only the new ones are missing coverage.

Methods to cover:

  • cartesi_getTournament
  • cartesi_listTournaments
  • cartesi_getCommitment
  • cartesi_listCommitments
  • cartesi_getMatch
  • cartesi_listMatches
  • cartesi_getMatchAdvanced
  • cartesi_listMatchAdvances

Scope

Add unit tests in the internal/jsonrpc package to validate:

  • request parsing (params decoding and validation)
  • repository interaction (correct repo method called with expected arguments)
  • response shape and error mapping (not found, invalid params, internal errors)

Out of scope:

  • changing method semantics or response formats

Deliverables

  • Add unit tests for each method listed above.
  • Add/extend repository mocks/fakes used by internal/jsonrpc tests to support tournaments/commitments/matches/match_advances queries.
  • Ensure tests cover at least:
    • happy path (single get / list)
    • pagination path for list methods (when applicable)
    • invalid params (missing required param, malformed hex/uint, invalid address/name)
    • not found behavior for get* methods
    • repository error propagation mapped to JSON-RPC errors

Acceptance criteria

  • All listed methods have unit test coverage in internal/jsonrpc (or the package where JSON-RPC handlers live).
  • Each get* method test includes:
    • success response
    • not found response
    • invalid params response
  • Each list* method test includes:
    • success response
    • pagination arguments passed through correctly (limit/offset, or equivalent)
    • invalid params response
  • Tests assert the JSON-RPC response structure (result vs error) and error codes/messages follow the project conventions.
  • make test passes.

Notes

  • Prefer mirroring the style/patterns used by existing JSON-RPC handler tests in this repo (same helpers, same mock style, same error assertions).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions