go-ethereum/contracts
Daniel Liu 639531aae9
contracts, tests: fix global variable modifications and remove unsafe parallelism (#1882)
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.
2025-12-22 12:00:39 +05:30
..
blocksigner all: fix goimports (#1560) 2025-09-24 07:51:10 +08:00
multisigwallet all: fix goimports (#1495) 2025-09-17 08:15:43 +08:00
randomize core: move genesis alloc types to core/types (#29003) 2025-01-24 16:54:12 +08:00
solidity_0.6 new EVM Upgrade 2021-09-21 16:53:46 +05:30
tests contracts, tests: fix global variable modifications and remove unsafe parallelism (#1882) 2025-12-22 12:00:39 +05:30
trc21issuer contracts, tests: fix global variable modifications and remove unsafe parallelism (#1882) 2025-12-22 12:00:39 +05:30
validator all: use 0x-prefix for Address type in log (#1830) 2025-12-07 15:36:36 +05:30
XDCx all: remove extra empty lines (#1574) 2025-10-08 12:25:10 +08:00
utils.go all: use 0x-prefix string for type Address in log message (#1874) 2025-12-19 08:55:21 +04:00
utils_test.go all: pre-allocate memory for slices and maps, close XFN-148 (#1714) 2025-11-14 20:13:36 +05:30