multi: Various test improvements.#3612
Merged
davecgh merged 3 commits intodecred:masterfrom Feb 5, 2026
Merged
Conversation
The Context returned by t.Context() is automatically canceled when tests complete, (before cleanup-registered functions are called), therefore manually creating and closing a func is not required.
The directories created by t.TempDir are always new and unique, and are automatically deleted after the tests complete, therefore manually deleting them before/after tests is not required.
Making effective use of t.Cleanup removes the need for test helper functions to return teardown callbacks, and allows the teardown to exist in just one place.
davecgh
reviewed
Feb 5, 2026
Member
davecgh
left a comment
There was a problem hiding this comment.
I was worried about the fact t.Context wasn't introduced until Go 1.24, but it's only being done in the internal packages which require that now, so no issue there.
It really doesn't matter for any of this code, but one short line is cleaner than two.
Thanks for the PR!
davecgh
approved these changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Making use of
t.Contextandt.Cleanupto make some minor improvements to existing tests. Took inspiration from decred/dcrdex#3491 and then got carried away making further changes.