Skip to content

test(zcash_address): Add unit tests for has_receiver_of_type, contains_receiver, and can_receive_memo#2195

Open
Cosmos-Harry wants to merge 1 commit intozcash:mainfrom
Cosmos-Harry:harry/address-receiver-queries
Open

test(zcash_address): Add unit tests for has_receiver_of_type, contains_receiver, and can_receive_memo#2195
Cosmos-Harry wants to merge 1 commit intozcash:mainfrom
Cosmos-Harry:harry/address-receiver-queries

Conversation

@Cosmos-Harry
Copy link
Copy Markdown

@Cosmos-Harry Cosmos-Harry commented Mar 5, 2026

Summary

The three public query methods on unified::Address, has_receiver_of_type,
contains_receiver, and can_receive_memo, had no test coverage. This PR adds
a focused unit test covering their behaviour across meaningful cases.

What's tested

  • has_receiver_of_type returns correct results for Orchard, Sapling, and
    Transparent pool types
  • can_receive_memo returns true when shielded receivers are present, and
    false for transparent-only addresses
  • contains_receiver requires exact byte-for-byte equality, not just type match
  • A transparent-only address correctly reports no memo capability and no shielded
    pool support
  • An Unknown receiver does not contribute to any pool type query — guarding
    against future regressions where a new receiver type might accidentally be
    mapped incorrectly
Screenshot 2026-03-05 at 12 44 49 PM

Why

These methods are part of the public API and are likely called by wallets to make
decisions about memo sending and receiver selection. A silent regression here
could cause real user-facing bugs. The Unknown receiver case in particular is
non-obvious from reading the code alone and benefits from being pinned by a test.

Notes

No behaviour changes. Test-only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant