chore: All tests use builders#600
Conversation
… that restart servers to keep key material alive. Delete regenerate_central_keys as it's no longer used.
…id silent regen of testing keys.
…es unused helpers and unifies the call paths for key material access.
Consolidated Tests Results 2026-05-22 - 10:14:24Test ResultsDetails
test-reporter: Run #2356
🎉 All tests passed!TestsView All Tests
🍂 No flaky tests in this run. Github Test Reporter by CTRF 💚 🔄 This comment has been updated |
kc1212
left a comment
There was a problem hiding this comment.
Very nice! It's good that all these big, ugly helpers disappeared.
Here are a couple of things AI also flagged to me, they're not in the PR changes but somewhat related
- verify_material_exists is too shallow (material/manager.rs:95-132). It only checks the top-level dir. Consider verifying at least one expected PUB/<key_type>/<key_id> under it, or making copy_key_files return an error when an expected source is missing instead of silently skipping. Otherwise the "hard error" guarantee is leaky.
- generation_hint message is missing cargo run -p prefix (material/manager.rs:113-114). Says generate-test-material --profile insecure --parties 4, but the PR description and
helpers.rs:40 use cargo run -p generate-test-material -- …. Minor docs nit. - prss_from_storage_test at engine/threshold/service/epoch_manager.rs:1668 still has an undocumented sleep(Duration::from_secs(1)). Wasn't touched here, but flagging since the PR touches this surface.
- Missing test-material is still not a hard error.
helpers.rs (line 22) only resolves a workspace root if test-material/ already exists; otherwise it returns a TestMaterialManager with source_path = None. Then manager.rs (line 98) explicitly skips verification when source_path is None. That means a local run without generated material does not fail at setup with the promised actionable error; it can proceed into empty tempdirs and fail later or regenerate some material. - Partial or wrong-party-count fixtures are silently accepted.
manager.rs (line 111) only checks that the profile directory exists. The actual copy helpers return Ok(()) when required files or epoch directories are missing: manager.rs (line 467), manager.rs (line 497). So test-material/testing/ can exist while the requested 13-party key, CRS, PRSS, or per-party signing files are absent, and setup still succeeds. That does not satisfy “missing testing material is now a hard error.”
These are actually some very good points here but fixing these led to a substantial diff. I think it's better to do them in a separate PR. |
`generate-test-material` does not produce PRSS fixtures, never did; PRSS is bootstrapped at server startup. This PR makes missing data a hard error, surfacing this "lie".
@kc1212 This plan fell through and I had to do the fixes here instead, adding to the noise. The addition is essentially that this PR makes missing testing material into a hard error instead of silently re-generating the missing pieces. This surfaced a wart: our fixture setup code was pretending to copy PRSS data that was never actually generated by I also had to merge in I apologise for the noisy PR. I did try to keep it contained! |
What
Migrates the last set of tests to use per-test isolated temp dirs and centralized/threshold builders (centralized/threshold custodian, keygen, CRS etc).
As a consequence we can delete plenty of helpers (
threshold_handles*,centralized_custodian_handles, and theensure_*_material_exists/setupmodules inutil/key_setup/test_tools.rsandtesting/utils.rs).generate-test-materialnow callsgenerate_material_to_pathdirectly.Gets rid of all (?)
sleep(TIME_TO_SLEEP_MS)waits.It got a lot noisier than I thought it would; apologies to reviewers but the diff is mostly mechanical. Focus review on the path/lifetime changes.
Why
The motivation for this PR is that during work on #589 I realized that there were a set of tests that are very slow in CI but fast locally (huge discrepancy: more than 200s in CI; 10s locally). It turns out that I had gotten the paths mixed up in previous PRs so many tests ended up re-generating material.
After this PR there is no longer any silent fallback to re-generate testing material at runtime; missing testing material is now a hard error.
CI has its "Generate Testing Material" job that ensures the data is there. Locally users must run:
The above populates
{WORKSPACE_ROOT}/test-material/{testing,default}/and must be run once. Each test uses a tempdir that is created and populated byTestMaterialManager::setup_test_material_tempvia a copy from the immutable pre-generated source.Our local
{WORKSPACE_ROOT}/core/service/keysfolders can be safely removed now. No tests use it.