Skip to content

Conversation

@StephenButtolph
Copy link
Contributor

Why this should be merged

Holistically enforces the suggestion in #4429.

Additionally, this adds a lint-fix task 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?

Copilot AI review requested due to automatic review settings October 24, 2025 20:11
Copy link
Contributor

Copilot AI left a 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.

@joshua-kim joshua-kim enabled auto-merge October 24, 2025 20:13
Copy link
Contributor Author

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

Copy link
Contributor Author

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

@StephenButtolph StephenButtolph self-assigned this Oct 24, 2025
@StephenButtolph StephenButtolph moved this to In Progress 🏗️ in avalanchego Oct 24, 2025
Copy link
Contributor

@alarso16 alarso16 left a 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

@StephenButtolph StephenButtolph merged commit 987bf53 into master Oct 27, 2025
35 checks passed
@StephenButtolph StephenButtolph deleted the add-usetesting-linter branch October 27, 2025 17:33
@github-project-automation github-project-automation bot moved this from In Progress 🏗️ to Done 🎉 in avalanchego Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done 🎉

Development

Successfully merging this pull request may close these issues.

4 participants