Skip to content

serviceability: prune User test literals in multicastgroup/tenant/user commands - #4328

Open
ayushsingh82 wants to merge 1 commit into
malbeclabs:mainfrom
ayushsingh82:fix/4084-prune-sdk-daemon-user-literals
Open

ayushsingh82 wants to merge 1 commit into
malbeclabs:mainfrom
ayushsingh82:fix/4084-prune-sdk-daemon-user-literals

Conversation

@ayushsingh82

Copy link
Copy Markdown
Contributor

Problem

PR #4080 added a manual impl Default for User and switched test literals across smartcontract/cli, smartcontract/sdk/rs, and crates/doublezero-daemon-cli to end with ..Default::default() — but as merged, the struct-update tail only absorbed feed_pks; every literal still named the other ~20 fields explicitly. #4084 asks to lean into the pattern: prune each literal down to only the fields a test actually asserts on or that drive the command's behavior.

#4235 did the first slice (smartcontract/cli/src/user/*). This is the second slice: smartcontract/sdk/rs.

Changes

Pruned User literals in:

  • commands/tenant/delete.rs
  • commands/multicastgroup/{subscribe,subscribe_feed,unsubscribe_feed}.rs
  • commands/user/{delete,requestban,update}.rs

For each literal I traced which fields the command under test actually reads (or which the test's own mock setup independently depends on) before dropping the rest — e.g. DeleteUserCommand reads owner/device_pk/tenant_pk/publishers/subscribers but never user_type/cyoa_type/dz_ip/tunnel_net/etc., so only the former survive per-test. commands/accesspass/get.rs was already at this shape (from the earlier #4244 work), so it's untouched here.

crates/doublezero-daemon-cli is not included — connect.rs alone has ~70 more User literals, well past this repo's ~500-line PR guidance, so that's left for a follow-up PR.

Testing Verification

  • cargo test -p doublezero_sdk --lib: 212/212 passing (no literal's pruning changed a test's outcome).
  • cargo clippy -p doublezero_sdk --all-targets -- -Dclippy::all -Dwarnings: clean.
  • cargo +nightly fmt -p doublezero_sdk -- --check: clean.
  • Removed now-unused imports (NetworkV4, UserCYOA, UserStatus, UserType, Ipv4Addr) file-by-file as literals no longer referenced them.

…r commands

Second slice of malbeclabs#4084: tenant/delete.rs, multicastgroup/{subscribe,
subscribe_feed,unsubscribe_feed}.rs, and user/{delete,requestban,update}.rs
each built a full ~20-field User literal per test even though the command
under test only reads a handful of those fields (owner, device_pk,
client_ip, tenant_pk, publishers/subscribers, user_type — whichever ones
the specific command actually branches on or forwards into the instruction
it builds). Pruned each literal down to just the fields that are read by
the command or asserted on by the test, letting User::default() (malbeclabs#4080)
fill the rest.

accesspass/get.rs was already at this shape from the malbeclabs#4244 work. sdk/rs
is now fully done; crates/doublezero-daemon-cli is left for a follow-up —
connect.rs alone has ~70 more User literals, too large for one PR.
@ayushsingh82
ayushsingh82 requested a review from a team September 13, 2026 17:52
@ayushsingh82

Copy link
Copy Markdown
Contributor Author

@nikw9944 could you take a look when you have a chance?

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