Group setup_with_timeouts timeout parameters into a struct

Open Beginner friendly
#239 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
testing

Research direction

Start by locating state_machine::coordinator::test::setup_with_timeouts and its call sites, then inspect the test harness API and its #[allow(clippy::too_many_arguments)] comment. Group the timeout options into a Timeouts struct with named fields and a Default, updating callers to specify the phases they use. Done when the harness and callers compile without the allow and timeout arguments are unambiguous.

Written by the indexing model from the issue text.

Description

state_machine::coordinator::test::setup_with_timeouts takes eight positional parameters, five of them bare Option<Duration>:

setup_with_timeouts::<C, S>(num_signers, keys_per_signer,
    dkg_public_timeout, dkg_private_timeout, dkg_end_timeout,
    nonce_timeout, sign_timeout, verify_packet_sigs)

Call sites read like this, which is effectively unreviewable:

setup_with_timeouts::<FireCoordinator<Aggregator>, SignerType>(
    num_signers, keys_per_signer,
    Some(timeout), Some(timeout), Some(timeout), Some(timeout), Some(timeout),
    false,
)

Five same-typed adjacent arguments means a transposition is invisible at the call site and silently changes which phase times out.

The eighth parameter (added in #234, replacing a mutable config accessor) tripped clippy::too_many_arguments, so the function currently carries an #[allow] with a comment pointing here.

Suggested fix

Group the timeouts into a Timeouts struct with named fields and a Default, so callers write Timeouts { nonce: Some(t), ..Default::default() } and only name what they mean. That also removes the clippy allow.

This is exported test-harness API, so it is a breaking change for anyone calling it with features = ["testing"] — fine inside a major, and worth batching with other breaking harness changes.

Dominant language
Rust
Stars
34
Forks
19
Avg merge
9h 19m
Merged PRs (30d)
12

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xoloki/wsts

All issues in xoloki/wsts

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.