-
Couldn't load subscription status.
- Fork 813
Add usetesting linter #4433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add usetesting linter #4433
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enforces the use of t.Context() or b.Context() in test code by adding a usetesting linter. The changes systematically replace context.Background() calls with t.Context() or b.Context() across all test files in the repository.
Reviewed Changes
Copilot reviewed 114 out of 114 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| x/merkledb/view_test.go | Updated context creation in hash changed nodes tests and view iterator tests to use testing context |
| x/merkledb/view_iterator_test.go | Replaced context.Background() with t.Context() in view iterator tests and removed unused context import |
| x/merkledb/trie_test.go | Updated all trie tests to use t.Context() instead of context.Background() |
| x/merkledb/sync_test.go | Updated sync tests to use t.Context() for database and syncer operations |
| x/merkledb/proof_test.go | Modified proof verification and generation tests to use t.Context() and removed context import |
| x/merkledb/network_server_test.go | Updated network server tests to use t.Context() for handler operations |
| x/merkledb/metrics_test.go | Changed metrics tests to use t.Context() for database operations |
| x/merkledb/history_test.go | Updated history-related tests to use t.Context() for proof operations |
| x/merkledb/db_test.go | Modified database tests to use t.Context() or b.Context() throughout |
| wallet/subnet/primary/common/utxotest/utxotest.go | Updated UTXO tests to use t.Context() |
| vms/txs/mempool/mempool_test.go | Changed mempool tests to use t.Context() for context creation |
| vms/rpcchainvm/with_context_vm_test.go | Updated RPC chain VM tests to use t.Context() |
| vms/rpcchainvm/vm_test.go | Modified VM tests to use t.Context() and changed os.Setenv to t.Setenv |
| vms/rpcchainvm/state_syncable_vm_test.go | Updated state syncable VM tests to use t.Context() |
| vms/rpcchainvm/grpcutils/client_test.go | Changed gRPC utils tests to use t.Context() |
| vms/rpcchainvm/ghttp/greader/greader_test.go | Updated greader tests to use t.Context() |
| vms/rpcchainvm/ghttp/gconn/gconn_test.go | Modified gconn tests to use t.Context() |
| vms/rpcchainvm/batched_vm_test.go | Changed batched VM tests to use t.Context() |
| vms/registry/vm_registry_test.go | Updated VM registry tests to use t.Context() |
| vms/proposervm/vm_test.go | Modified proposer VM tests to use t.Context() or b.Context() |
| vms/proposervm/vm_byzantine_test.go | Updated Byzantine test scenarios to use t.Context() |
| vms/proposervm/state_syncable_vm_test.go | Changed state syncable tests to use t.Context() |
| vms/proposervm/service_test.go | Updated service tests to use t.Context() |
| vms/proposervm/proposer/windower_test.go | Modified windower tests to use t.Context() or b.Context() |
| vms/proposervm/pre_fork_block_test.go | Updated pre-fork block tests to use t.Context() |
| vms/proposervm/post_fork_option_test.go | Changed post-fork option tests to use t.Context() |
| vms/proposervm/post_fork_block_test.go | Modified post-fork block tests to use t.Context() |
| vms/proposervm/block_test.go | Updated block tests to use t.Context() or b.Context() |
| vms/proposervm/batched_vm_test.go | Changed batched VM tests to use t.Context() |
| vms/platformvm/warp/validator_test.go | Modified warp validator tests to use t.Context() or b.Context() |
| vms/platformvm/vm_test.go | Updated platform VM tests to use t.Context() |
| vms/platformvm/validators/manager_test.go | Changed validator manager tests to use t.Context() |
| vms/platformvm/validators/manager_benchmark_test.go | Modified validator benchmark tests to use b.Context() |
| vms/platformvm/txs/txstest/wallet.go | Updated wallet test utilities to use t.Context() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file adds the linting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file fixes the linting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, and should be added to coreth/subnet-evm too. The lint-fix action is slightly more complicated, but should be pretty doable
Why this should be merged
Holistically enforces the suggestion in #4429.
Additionally, this adds a
lint-fixtask which was used to fix all of these instances.How this works
Adds and appeases the usetesting linter.
How this was tested
CI
Need to be documented in RELEASES.md?