mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
Add defer cleanup for global variables and remove t.Parallel() where
global state is modified to prevent race conditions and test pollution.
Changes:
1. tests/vm_test.go:
- Add defer to restore common.TIPXDCXCancellationFee
- Remove t.Parallel() since modifying global variable makes concurrent
execution unsafe, even with defer cleanup
- Prevents potential race conditions with other tests in the package
2. contracts/tests/Inherited_test.go:
- Add defer to restore common.TIPXDCXCancellationFee
- No t.Parallel() present, so safe with defer alone
3. contracts/trc21issuer/trc21issuer_test.go:
- Add defer to restore common.TRC21IssuerSMC (was missing)
- Fix existing bug: restore correct variable common.TRC21GasPriceBefore
instead of common.TIPTRC21Fee
- Remove unused variables: token, delay
Rationale for removing t.Parallel():
While defer ensures cleanup after test completion, during test execution
the modified global variable is visible to all concurrent tests. Even
though tests/vm_test.go is currently the only test modifying
TIPXDCXCancellationFee, removing t.Parallel() is the safer approach to
ensure complete test isolation and prevent timing-dependent behavior.
This follows the same principles as the txpool MinGasPrice fix: global
variable modifications should not occur during concurrent test execution.
|
||
|---|---|---|
| .. | ||
| contract | ||
| Inherited.go | ||
| Inherited_test.go | ||