diff --git a/accounts/abi/bind/backends/simulated_test.go b/accounts/abi/bind/backends/simulated_test.go index 2ccfdc652a..d8e700f986 100644 --- a/accounts/abi/bind/backends/simulated_test.go +++ b/accounts/abi/bind/backends/simulated_test.go @@ -1345,6 +1345,8 @@ func TestForkResendTx(t *testing.T) { } func TestCommitReturnValue(t *testing.T) { + t.Parallel() + testAddr := crypto.PubkeyToAddress(testKey.PublicKey) sim := simTestBackend(testAddr) defer sim.Close() @@ -1386,6 +1388,8 @@ func TestCommitReturnValue(t *testing.T) { // TestAdjustTimeAfterFork ensures that after a fork, AdjustTime uses the pending fork // block's parent rather than the canonical head's parent. func TestAdjustTimeAfterFork(t *testing.T) { + t.Parallel() + testAddr := crypto.PubkeyToAddress(testKey.PublicKey) sim := simTestBackend(testAddr) defer sim.Close() diff --git a/accounts/abi/bind/base_test.go b/accounts/abi/bind/base_test.go index ca0128148f..0576b268c0 100644 --- a/accounts/abi/bind/base_test.go +++ b/accounts/abi/bind/base_test.go @@ -115,6 +115,8 @@ func (mc *mockPendingCaller) PendingCallContract(ctx context.Context, call ether } func TestPassingBlockNumber(t *testing.T) { + t.Parallel() + mc := &mockPendingCaller{ mockCaller: &mockCaller{ codeAtBytes: []byte{1, 2, 3}, @@ -187,6 +189,8 @@ func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) { } func TestUnpackAnonymousLogIntoMap(t *testing.T) { + t.Parallel() + mockLog := newMockLog(nil, common.HexToHash("0x0")) abiString := `[{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"received","type":"event"}]` @@ -377,6 +381,8 @@ func newMockLog(topics []common.Hash, txHash common.Hash) types.Log { } func TestCall(t *testing.T) { + t.Parallel() + var method, methodWithArg = "something", "somethingArrrrg" tests := []struct { name, method string @@ -507,6 +513,8 @@ func TestCall(t *testing.T) { // TestCrashers contains some strings which previously caused the abi codec to crash. func TestCrashers(t *testing.T) { + t.Parallel() + abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"_1"}]}]}]`)) abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"&"}]}]}]`)) abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"----"}]}]}]`)) diff --git a/accounts/abi/type_test.go b/accounts/abi/type_test.go index a72531ba27..655751902c 100644 --- a/accounts/abi/type_test.go +++ b/accounts/abi/type_test.go @@ -368,6 +368,8 @@ func TestGetTypeSize(t *testing.T) { } func TestNewFixedBytesOver32(t *testing.T) { + t.Parallel() + _, err := NewType("bytes4096", "", nil) if err == nil { t.Errorf("fixed bytes with size over 32 is not spec'd") diff --git a/accounts/abi/unpack_test.go b/accounts/abi/unpack_test.go index 6dd2db0d58..1a5b7b2bb0 100644 --- a/accounts/abi/unpack_test.go +++ b/accounts/abi/unpack_test.go @@ -946,6 +946,8 @@ func TestOOMMaliciousInput(t *testing.T) { } func TestPackAndUnpackIncompatibleNumber(t *testing.T) { + t.Parallel() + var encodeABI Arguments uint256Ty, err := NewType("uint256", "", nil) if err != nil { diff --git a/cmd/abigen/namefilter_test.go b/cmd/abigen/namefilter_test.go index 42ba55be5e..981ee7695e 100644 --- a/cmd/abigen/namefilter_test.go +++ b/cmd/abigen/namefilter_test.go @@ -8,6 +8,8 @@ import ( ) func TestNameFilter(t *testing.T) { + t.Parallel() + _, err := newNameFilter("Foo") require.Error(t, err) _, err = newNameFilter("too/many:colons:Foo") diff --git a/cmd/clef/consolecmd_test.go b/cmd/clef/consolecmd_test.go index 283d7e8def..b5cc1209c6 100644 --- a/cmd/clef/consolecmd_test.go +++ b/cmd/clef/consolecmd_test.go @@ -31,7 +31,9 @@ func TestImportRaw(t *testing.T) { t.Cleanup(func() { os.Remove(keyPath) }) t.Parallel() + t.Run("happy-path", func(t *testing.T) { + t.Parallel() // Run clef importraw clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath) clef.input("myverylongpassword").input("myverylongpassword") @@ -43,6 +45,7 @@ func TestImportRaw(t *testing.T) { }) // tests clef --importraw with mismatched passwords. t.Run("pw-mismatch", func(t *testing.T) { + t.Parallel() // Run clef importraw clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath) clef.input("myverylongpassword1").input("myverylongpassword2").WaitExit() @@ -52,6 +55,7 @@ func TestImportRaw(t *testing.T) { }) // tests clef --importraw with a too short password. t.Run("short-pw", func(t *testing.T) { + t.Parallel() // Run clef importraw clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath) clef.input("shorty").input("shorty").WaitExit() @@ -69,7 +73,9 @@ func TestListAccounts(t *testing.T) { t.Cleanup(func() { os.Remove(keyPath) }) t.Parallel() + t.Run("no-accounts", func(t *testing.T) { + t.Parallel() clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "list-accounts") if out := string(clef.Output()); !strings.Contains(out, "The keystore is empty.") { t.Logf("Output\n%v", out) @@ -77,6 +83,7 @@ func TestListAccounts(t *testing.T) { } }) t.Run("one-account", func(t *testing.T) { + t.Parallel() // First, we need to import clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath) clef.input("myverylongpassword").input("myverylongpassword").WaitExit() @@ -96,7 +103,9 @@ func TestListWallets(t *testing.T) { t.Cleanup(func() { os.Remove(keyPath) }) t.Parallel() + t.Run("no-accounts", func(t *testing.T) { + t.Parallel() clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "list-wallets") if out := string(clef.Output()); !strings.Contains(out, "There are no wallets.") { t.Logf("Output\n%v", out) @@ -104,6 +113,7 @@ func TestListWallets(t *testing.T) { } }) t.Run("one-account", func(t *testing.T) { + t.Parallel() // First, we need to import clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath) clef.input("myverylongpassword").input("myverylongpassword").WaitExit() diff --git a/cmd/clef/run_test.go b/cmd/clef/run_test.go index fc3145b1e0..cd7cd0e6f1 100644 --- a/cmd/clef/run_test.go +++ b/cmd/clef/run_test.go @@ -57,6 +57,8 @@ func TestMain(m *testing.M) { // This method creates a temporary keystore folder which will be removed after // the test exits. func runClef(t *testing.T, args ...string) *testproc { + t.Helper() + ddir, err := os.MkdirTemp("", "cleftest-*") if err != nil { return nil @@ -71,6 +73,8 @@ func runClef(t *testing.T, args ...string) *testproc { // This method does _not_ create the keystore folder, but it _does_ add the arg // to the args. func runWithKeystore(t *testing.T, keystore string, args ...string) *testproc { + t.Helper() + args = append([]string{"--keystore", keystore}, args...) tt := &testproc{Datadir: keystore} tt.TestCmd = cmdtest.NewTestCmd(t, tt) diff --git a/cmd/geth/accountcmd_test.go b/cmd/geth/accountcmd_test.go index 84b9c33c24..3aec802d02 100644 --- a/cmd/geth/accountcmd_test.go +++ b/cmd/geth/accountcmd_test.go @@ -118,6 +118,8 @@ func TestAccountImport(t *testing.T) { } func TestAccountHelp(t *testing.T) { + t.Parallel() + geth := runGeth(t, "account", "-h") geth.WaitExit() if have, want := geth.ExitStatus(), 0; have != want { diff --git a/cmd/geth/attach_test.go b/cmd/geth/attach_test.go index 7c5f951750..7dd8bcd50d 100644 --- a/cmd/geth/attach_test.go +++ b/cmd/geth/attach_test.go @@ -61,6 +61,8 @@ func TestRemoteDbWithHeaders(t *testing.T) { } func testReceiveHeaders(t *testing.T, ln net.Listener, gethArgs ...string) { + t.Helper() + var ok uint32 server := &http.Server{ Addr: "localhost:0", diff --git a/cmd/geth/exportcmd_test.go b/cmd/geth/exportcmd_test.go index bbf08d820e..c280adcd61 100644 --- a/cmd/geth/exportcmd_test.go +++ b/cmd/geth/exportcmd_test.go @@ -27,6 +27,8 @@ import ( // TestExport does a basic test of "geth export", exporting the test-genesis. func TestExport(t *testing.T) { + t.Parallel() + outfile := fmt.Sprintf("%v/testExport.out", os.TempDir()) defer os.Remove(outfile) geth := runGeth(t, "--datadir", initGeth(t), "export", outfile) diff --git a/common/lru/basiclru_test.go b/common/lru/basiclru_test.go index e2d3559f55..27ba770879 100644 --- a/common/lru/basiclru_test.go +++ b/common/lru/basiclru_test.go @@ -102,6 +102,8 @@ func TestBasicLRU(t *testing.T) { } func TestBasicLRUAddExistingKey(t *testing.T) { + t.Parallel() + cache := NewBasicLRU[int, int](1) cache.Add(1, 1) @@ -115,6 +117,8 @@ func TestBasicLRUAddExistingKey(t *testing.T) { // This test checks GetOldest and RemoveOldest. func TestBasicLRUGetOldest(t *testing.T) { + t.Parallel() + cache := NewBasicLRU[int, int](128) for i := 0; i < 256; i++ { cache.Add(i, i) @@ -147,6 +151,8 @@ func TestBasicLRUGetOldest(t *testing.T) { // Test that Add returns true/false if an eviction occurred func TestBasicLRUAddReturnValue(t *testing.T) { + t.Parallel() + cache := NewBasicLRU[int, int](1) if cache.Add(1, 1) { t.Errorf("first add shouldn't have evicted") @@ -158,6 +164,8 @@ func TestBasicLRUAddReturnValue(t *testing.T) { // This test verifies that Contains doesn't change item recency. func TestBasicLRUContains(t *testing.T) { + t.Parallel() + cache := NewBasicLRU[int, int](2) cache.Add(1, 1) cache.Add(2, 2) diff --git a/common/lru/blob_lru_test.go b/common/lru/blob_lru_test.go index ca1b0ddd74..83e12c99ee 100644 --- a/common/lru/blob_lru_test.go +++ b/common/lru/blob_lru_test.go @@ -30,6 +30,8 @@ func mkKey(i int) (key testKey) { } func TestSizeConstrainedCache(t *testing.T) { + t.Parallel() + lru := NewSizeConstrainedCache[testKey, []byte](100) var want uint64 // Add 11 items of 10 byte each. First item should be swapped out @@ -68,6 +70,8 @@ func TestSizeConstrainedCache(t *testing.T) { // This test adds inserting an element exceeding the max size. func TestSizeConstrainedCacheOverflow(t *testing.T) { + t.Parallel() + lru := NewSizeConstrainedCache[testKey, []byte](100) // Add 10 items of 10 byte each, filling the cache @@ -107,6 +111,8 @@ func TestSizeConstrainedCacheOverflow(t *testing.T) { // This checks what happens when inserting the same k/v multiple times. func TestSizeConstrainedCacheSameItem(t *testing.T) { + t.Parallel() + lru := NewSizeConstrainedCache[testKey, []byte](100) // Add one 10 byte-item 10 times. @@ -124,6 +130,8 @@ func TestSizeConstrainedCacheSameItem(t *testing.T) { // This tests that empty/nil values are handled correctly. func TestSizeConstrainedCacheEmpties(t *testing.T) { + t.Parallel() + lru := NewSizeConstrainedCache[testKey, []byte](100) // This test abuses the lru a bit, using different keys for identical value(s). diff --git a/common/mclock/alarm_test.go b/common/mclock/alarm_test.go index d2ad9913fd..01ba7299ec 100644 --- a/common/mclock/alarm_test.go +++ b/common/mclock/alarm_test.go @@ -20,6 +20,8 @@ import "testing" // This test checks basic functionality of Alarm. func TestAlarm(t *testing.T) { + t.Parallel() + clk := new(Simulated) clk.Run(20) a := NewAlarm(clk) @@ -64,6 +66,8 @@ func TestAlarm(t *testing.T) { // This test checks that scheduling an Alarm to an earlier time than the // one already scheduled works properly. func TestAlarmScheduleEarlier(t *testing.T) { + t.Parallel() + clk := new(Simulated) clk.Run(20) a := NewAlarm(clk) @@ -80,6 +84,8 @@ func TestAlarmScheduleEarlier(t *testing.T) { // This test checks that scheduling an Alarm to a later time than the // one already scheduled works properly. func TestAlarmScheduleLater(t *testing.T) { + t.Parallel() + clk := new(Simulated) clk.Run(20) a := NewAlarm(clk) @@ -95,6 +101,8 @@ func TestAlarmScheduleLater(t *testing.T) { // This test checks that scheduling an Alarm in the past makes it fire immediately. func TestAlarmNegative(t *testing.T) { + t.Parallel() + clk := new(Simulated) clk.Run(50) a := NewAlarm(clk) diff --git a/common/size_test.go b/common/size_test.go index 28f053d39f..7317fd91f6 100644 --- a/common/size_test.go +++ b/common/size_test.go @@ -40,6 +40,8 @@ func TestStorageSizeString(t *testing.T) { } func TestStorageSizeTerminalString(t *testing.T) { + t.Parallel() + tests := []struct { size StorageSize str string diff --git a/common/types_test.go b/common/types_test.go index 88c642522d..02a92f8c6c 100644 --- a/common/types_test.go +++ b/common/types_test.go @@ -161,6 +161,8 @@ func BenchmarkAddressHex(b *testing.B) { // but not the pointer level, so that this customized marshalled can be used // for both MixedcaseAddress object and pointer. func TestMixedcaseAddressMarshal(t *testing.T) { + t.Parallel() + var ( output string input = "0xae967917c465db8578ca9024c205720b1a3651A9" diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index 462f109564..ac0115b42b 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -183,7 +183,7 @@ type lru[T cacheOrDataset] struct { // newlru create a new least-recently-used cache for either the verification caches // or the mining datasets. -func newlru[T cacheOrDataset](maxItems int, new func(epoch uint64) T) *lru[T] { +func newlru[T cacheOrDataset](maxItems int, newLru func(epoch uint64) T) *lru[T] { var what string switch any(T(nil)).(type) { case *cache: @@ -195,7 +195,7 @@ func newlru[T cacheOrDataset](maxItems int, new func(epoch uint64) T) *lru[T] { } return &lru[T]{ what: what, - new: new, + new: newLru, cache: lrupkg.NewBasicLRU[uint64, T](maxItems), } } diff --git a/consensus/misc/eip4844_test.go b/consensus/misc/eip4844_test.go index 5838cab8e6..4f23fae3ab 100644 --- a/consensus/misc/eip4844_test.go +++ b/consensus/misc/eip4844_test.go @@ -25,6 +25,8 @@ import ( ) func TestCalcBlobFee(t *testing.T) { + t.Parallel() + tests := []struct { excessDataGas int64 blobfee int64 @@ -47,6 +49,8 @@ func TestCalcBlobFee(t *testing.T) { } func TestFakeExponential(t *testing.T) { + t.Parallel() + tests := []struct { factor int64 numerator int64 diff --git a/core/blockchain_test.go b/core/blockchain_test.go index af2c445adb..5f068c9195 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -3858,6 +3858,8 @@ func TestCanonicalHashMarker(t *testing.T) { // TestTxIndexer tests the tx indexes are updated correctly. func TestTxIndexer(t *testing.T) { + t.Parallel() + var ( testBankKey, _ = crypto.GenerateKey() testBankAddress = crypto.PubkeyToAddress(testBankKey.PublicKey) @@ -4063,6 +4065,8 @@ func TestTxIndexer(t *testing.T) { } func TestCreateThenDeletePreByzantium(t *testing.T) { + t.Parallel() + // We use Ropsten chain config instead of Testchain config, this is // deliberate: we want to use pre-byz rules where we have intermediate state roots // between transactions. @@ -4076,12 +4080,15 @@ func TestCreateThenDeletePreByzantium(t *testing.T) { }) } func TestCreateThenDeletePostByzantium(t *testing.T) { + t.Parallel() testCreateThenDelete(t, params.TestChainConfig) } // testCreateThenDelete tests a creation and subsequent deletion of a contract, happening // within the same block. func testCreateThenDelete(t *testing.T, config *params.ChainConfig) { + t.Helper() + var ( engine = ethash.NewFaker() // A sender who makes transactions, has some funds @@ -4158,6 +4165,8 @@ func testCreateThenDelete(t *testing.T, config *params.ChainConfig) { // TestTransientStorageReset ensures the transient storage is wiped correctly // between transactions. func TestTransientStorageReset(t *testing.T) { + t.Parallel() + var ( engine = ethash.NewFaker() key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") @@ -4250,6 +4259,8 @@ func TestTransientStorageReset(t *testing.T) { } func TestEIP3651(t *testing.T) { + t.Parallel() + var ( aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") bb = common.HexToAddress("0x000000000000000000000000000000000000bbbb") diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go index 73e485b292..9b94895b71 100644 --- a/core/chain_makers_test.go +++ b/core/chain_makers_test.go @@ -32,6 +32,8 @@ import ( ) func TestGenerateWithdrawalChain(t *testing.T) { + t.Parallel() + var ( keyHex = "9c647b8b7c4e7c3490668fb6c11473619db80c93704c70893d3813af4090c39c" key, _ = crypto.HexToECDSA(keyHex) diff --git a/core/rawdb/database.go b/core/rawdb/database.go index b8cc36a811..5d3bc1f3de 100644 --- a/core/rawdb/database.go +++ b/core/rawdb/database.go @@ -576,7 +576,10 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error { for _, ancient := range ancients { for _, table := range ancient.sizes { stats = append(stats, []string{ - fmt.Sprintf("Ancient store (%s)", strings.Title(ancient.name)), + fmt.Sprintf("Ancient store (%s)", + //nolint: staticcheck + strings.Title(ancient.name)), + //nolint: staticcheck strings.Title(table.name), table.size.String(), fmt.Sprintf("%d", ancient.count()), diff --git a/core/rawdb/freezer_resettable_test.go b/core/rawdb/freezer_resettable_test.go index d741bc14e5..d1331442ff 100644 --- a/core/rawdb/freezer_resettable_test.go +++ b/core/rawdb/freezer_resettable_test.go @@ -25,6 +25,8 @@ import ( ) func TestResetFreezer(t *testing.T) { + t.Parallel() + items := []struct { id uint64 blob []byte @@ -78,6 +80,8 @@ func TestResetFreezer(t *testing.T) { } func TestFreezerCleanup(t *testing.T) { + t.Parallel() + items := []struct { id uint64 blob []byte diff --git a/core/state/snapshot/generate.go b/core/state/snapshot/generate.go index a2442728ac..a3fb7a8c27 100644 --- a/core/state/snapshot/generate.go +++ b/core/state/snapshot/generate.go @@ -509,6 +509,7 @@ func (dl *diskLayer) checkAndFlush(ctx *generatorContext, current []byte) error // generateStorages generates the missing storage slots of the specific contract. // It's supposed to restart the generation from the given origin position. func generateStorages(ctx *generatorContext, dl *diskLayer, stateRoot common.Hash, account common.Hash, storageRoot common.Hash, storeMarker []byte) error { + //nolint: predeclared onStorage := func(key []byte, val []byte, write bool, delete bool) error { defer func(start time.Time) { snapStorageWriteCounter.Inc(time.Since(start).Nanoseconds()) diff --git a/core/state/snapshot/generate_test.go b/core/state/snapshot/generate_test.go index 546132e7dd..4b4bd32a8d 100644 --- a/core/state/snapshot/generate_test.go +++ b/core/state/snapshot/generate_test.go @@ -813,6 +813,8 @@ func populateDangling(disk ethdb.KeyValueStore) { // // This test will populate some dangling storages to see if they can be cleaned up. func TestGenerateCompleteSnapshotWithDanglingStorage(t *testing.T) { + t.Parallel() + var helper = newHelper() stRoot := helper.makeStorageTrie(common.Hash{}, hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true) @@ -848,6 +850,8 @@ func TestGenerateCompleteSnapshotWithDanglingStorage(t *testing.T) { // // This test will populate some dangling storages to see if they can be cleaned up. func TestGenerateBrokenSnapshotWithDanglingStorage(t *testing.T) { + t.Parallel() + var helper = newHelper() stRoot := helper.makeStorageTrie(common.Hash{}, hashData([]byte("acc-1")), []string{"key-1", "key-2", "key-3"}, []string{"val-1", "val-2", "val-3"}, true) diff --git a/core/state/snapshot/holdable_iterator_test.go b/core/state/snapshot/holdable_iterator_test.go index ce4cf6bb8a..80fe95af78 100644 --- a/core/state/snapshot/holdable_iterator_test.go +++ b/core/state/snapshot/holdable_iterator_test.go @@ -25,6 +25,8 @@ import ( ) func TestIteratorHold(t *testing.T) { + t.Parallel() + // Create the key-value data store var ( content = map[string]string{"k1": "v1", "k2": "v2", "k3": "v3"} @@ -87,6 +89,8 @@ func TestIteratorHold(t *testing.T) { } func TestReopenIterator(t *testing.T) { + t.Parallel() + var ( content = map[common.Hash]string{ common.HexToHash("a1"): "v1", diff --git a/core/state/statedb_test.go b/core/state/statedb_test.go index 7f4c2c848e..a2202aac3f 100644 --- a/core/state/statedb_test.go +++ b/core/state/statedb_test.go @@ -1382,6 +1382,8 @@ func TestStateDBAccessList(t *testing.T) { // Tests that account and storage tries are flushed in the correct order and that // no data loss occurs. func TestFlushOrderDataLoss(t *testing.T) { + t.Parallel() + // Create a state trie with many accounts and slots var ( memdb = rawdb.NewMemoryDatabase() @@ -1420,6 +1422,8 @@ func TestFlushOrderDataLoss(t *testing.T) { } func TestStateDBTransientStorage(t *testing.T) { + t.Parallel() + memDb := rawdb.NewMemoryDatabase() db := NewDatabase(memDb) state, _ := New(common.Hash{}, db, nil) diff --git a/core/txpool/list_test.go b/core/txpool/list_test.go index 47db1605ad..cb6a24c1c2 100644 --- a/core/txpool/list_test.go +++ b/core/txpool/list_test.go @@ -29,6 +29,8 @@ import ( // Tests that transactions can be added to strict lists and list contents and // nonce boundaries are correctly maintained. func TestStrictListAdd(t *testing.T) { + t.Parallel() + // Generate a list of transactions to insert key, _ := crypto.GenerateKey() diff --git a/core/txpool/txpool2_test.go b/core/txpool/txpool2_test.go index 7e2a9eb908..697dfca65a 100644 --- a/core/txpool/txpool2_test.go +++ b/core/txpool/txpool2_test.go @@ -42,8 +42,8 @@ func count(t *testing.T, pool *TxPool) (pending int, queued int) { return pending, queued } -func fillPool(t testing.TB, pool *TxPool) { - t.Helper() +func fillPool(tb testing.TB, pool *TxPool) { + tb.Helper() // Create a number of test accounts, fund them and make transactions executableTxs := types.Transactions{} nonExecutableTxs := types.Transactions{} @@ -62,14 +62,14 @@ func fillPool(t testing.TB, pool *TxPool) { slots := pool.all.Slots() // sanity-check that the test prerequisites are ok (pending full) if have, want := pending, slots; have != want { - t.Fatalf("have %d, want %d", have, want) + tb.Fatalf("have %d, want %d", have, want) } if have, want := queued, 0; have != want { - t.Fatalf("have %d, want %d", have, want) + tb.Fatalf("have %d, want %d", have, want) } - t.Logf("pool.config: GlobalSlots=%d, GlobalQueue=%d\n", pool.config.GlobalSlots, pool.config.GlobalQueue) - t.Logf("pending: %d queued: %d, all: %d\n", pending, queued, slots) + tb.Logf("pool.config: GlobalSlots=%d, GlobalQueue=%d\n", pool.config.GlobalSlots, pool.config.GlobalQueue) + tb.Logf("pending: %d queued: %d, all: %d\n", pending, queued, slots) } // Tests that if a batch high-priced of non-executables arrive, they do not kick out diff --git a/core/txpool/txpool_test.go b/core/txpool/txpool_test.go index 30f7cb23cd..e7d739f198 100644 --- a/core/txpool/txpool_test.go +++ b/core/txpool/txpool_test.go @@ -1019,13 +1019,16 @@ func TestAllowUnprotectedTransactionWhenSet(t *testing.T) { // This logic should not hold for local transactions, unless the local tracking // mechanism is disabled. func TestQueueGlobalLimiting(t *testing.T) { + t.Parallel() testQueueGlobalLimiting(t, false) } func TestQueueGlobalLimitingNoLocals(t *testing.T) { + t.Parallel() testQueueGlobalLimiting(t, true) } func testQueueGlobalLimiting(t *testing.T, nolocals bool) { + t.Helper() t.Parallel() // Create the pool to test the limit enforcement with @@ -1110,9 +1113,11 @@ func testQueueGlobalLimiting(t *testing.T, nolocals bool) { // This logic should not hold for local transactions, unless the local tracking // mechanism is disabled. func TestQueueTimeLimiting(t *testing.T) { + t.Parallel() testQueueTimeLimiting(t, false) } func TestQueueTimeLimitingNoLocals(t *testing.T) { + t.Parallel() testQueueTimeLimiting(t, true) } @@ -2495,10 +2500,17 @@ func TestReplacementDynamicFee(t *testing.T) { // Tests that local transactions are journaled to disk, but remote transactions // get discarded between restarts. -func TestJournaling(t *testing.T) { testJournaling(t, false) } -func TestJournalingNoLocals(t *testing.T) { testJournaling(t, true) } +func TestJournaling(t *testing.T) { + t.Parallel() + testJournaling(t, false) +} +func TestJournalingNoLocals(t *testing.T) { + t.Parallel() + testJournaling(t, true) +} func testJournaling(t *testing.T, nolocals bool) { + t.Helper() t.Parallel() // Create a temporary file for the journal @@ -2741,6 +2753,8 @@ func BenchmarkBatchLocalInsert10000(b *testing.B) { benchmarkBatchInsert(b, 1000 // Benchmarks the speed of batched transaction insertion. func benchmarkBatchInsert(b *testing.B, size int, local bool) { + b.Helper() + // Generate a batch of transactions to enqueue into the pool pool, key := setupPool() defer pool.Stop() diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 71565d2ef8..c2e7d7705f 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -557,6 +557,8 @@ func assertEqual(orig *Transaction, cpy *Transaction) error { } func TestTransactionSizes(t *testing.T) { + t.Parallel() + signer := NewLondonSigner(big.NewInt(123)) key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") to := common.HexToAddress("0x01") diff --git a/core/vm/gas_table_test.go b/core/vm/gas_table_test.go index 564bfff562..c36ce707bf 100644 --- a/core/vm/gas_table_test.go +++ b/core/vm/gas_table_test.go @@ -131,6 +131,8 @@ var createGasTests = []struct { } func TestCreateGas(t *testing.T) { + t.Parallel() + for i, tt := range createGasTests { var gasUsed = uint64(0) doCheck := func(testGas int) bool { diff --git a/core/vm/instructions_test.go b/core/vm/instructions_test.go index 61f001a692..5fd817556d 100644 --- a/core/vm/instructions_test.go +++ b/core/vm/instructions_test.go @@ -578,6 +578,8 @@ func BenchmarkOpMstore(bench *testing.B) { } func TestOpTstore(t *testing.T) { + t.Parallel() + var ( statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil) env = NewEVM(BlockContext{}, TxContext{}, statedb, params.TestChainConfig, Config{}) diff --git a/core/vm/jump_table_test.go b/core/vm/jump_table_test.go index f67915fff3..6230032905 100644 --- a/core/vm/jump_table_test.go +++ b/core/vm/jump_table_test.go @@ -24,6 +24,8 @@ import ( // TestJumpTableCopy tests that deep copy is necessery to prevent modify shared jump table func TestJumpTableCopy(t *testing.T) { + t.Parallel() + tbl := newMergeInstructionSet() require.Equal(t, uint64(0), tbl[SLOAD].constantGas) diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index c083f5e65b..8a94722b1f 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -389,45 +389,45 @@ func TestEth2DeepReorg(t *testing.T) { // TODO (MariusVanDerWijden) TestEth2DeepReorg is currently broken, because it tries to reorg // before the totalTerminalDifficulty threshold /* - genesis, preMergeBlocks := generateMergeChain(core.TriesInMemory * 2, false) - n, ethservice := startEthService(t, genesis, preMergeBlocks) - defer n.Close() + genesis, preMergeBlocks := generateMergeChain(core.TriesInMemory * 2, false) + n, ethservice := startEthService(t, genesis, preMergeBlocks) + defer n.Close() - var ( - api = NewConsensusAPI(ethservice, nil) - parent = preMergeBlocks[len(preMergeBlocks)-core.TriesInMemory-1] - head = ethservice.BlockChain().CurrentBlock().Number.Uint64()() - ) - if ethservice.BlockChain().HasBlockAndState(parent.Hash(), parent.NumberU64()) { - t.Errorf("Block %d not pruned", parent.NumberU64()) + var ( + api = NewConsensusAPI(ethservice, nil) + parent = preMergeBlocks[len(preMergeBlocks)-core.TriesInMemory-1] + head = ethservice.BlockChain().CurrentBlock().Number.Uint64()() + ) + if ethservice.BlockChain().HasBlockAndState(parent.Hash(), parent.NumberU64()) { + t.Errorf("Block %d not pruned", parent.NumberU64()) + } + for i := 0; i < 10; i++ { + execData, err := api.assembleBlock(AssembleBlockParams{ + ParentHash: parent.Hash(), + Timestamp: parent.Time() + 5, + }) + if err != nil { + t.Fatalf("Failed to create the executable data %v", err) + } + block, err := ExecutableDataToBlock(ethservice.BlockChain().Config(), parent.Header(), *execData) + if err != nil { + t.Fatalf("Failed to convert executable data to block %v", err) + } + newResp, err := api.ExecutePayload(*execData) + if err != nil || newResp.Status != "VALID" { + t.Fatalf("Failed to insert block: %v", err) + } + if ethservice.BlockChain().CurrentBlock().Number.Uint64()() != head { + t.Fatalf("Chain head shouldn't be updated") + } + if err := api.setHead(block.Hash()); err != nil { + t.Fatalf("Failed to set head: %v", err) + } + if ethservice.BlockChain().CurrentBlock().Number.Uint64()() != block.NumberU64() { + t.Fatalf("Chain head should be updated") + } + parent, head = block, block.NumberU64() } - for i := 0; i < 10; i++ { - execData, err := api.assembleBlock(AssembleBlockParams{ - ParentHash: parent.Hash(), - Timestamp: parent.Time() + 5, - }) - if err != nil { - t.Fatalf("Failed to create the executable data %v", err) - } - block, err := ExecutableDataToBlock(ethservice.BlockChain().Config(), parent.Header(), *execData) - if err != nil { - t.Fatalf("Failed to convert executable data to block %v", err) - } - newResp, err := api.ExecutePayload(*execData) - if err != nil || newResp.Status != "VALID" { - t.Fatalf("Failed to insert block: %v", err) - } - if ethservice.BlockChain().CurrentBlock().Number.Uint64()() != head { - t.Fatalf("Chain head shouldn't be updated") - } - if err := api.setHead(block.Hash()); err != nil { - t.Fatalf("Failed to set head: %v", err) - } - if ethservice.BlockChain().CurrentBlock().Number.Uint64()() != block.NumberU64() { - t.Fatalf("Chain head should be updated") - } - parent, head = block, block.NumberU64() - } */ } @@ -584,6 +584,8 @@ We expect └── P1'' */ func TestNewPayloadOnInvalidChain(t *testing.T) { + t.Parallel() + genesis, preMergeBlocks := generateMergeChain(10, false) n, ethservice := startEthService(t, genesis, preMergeBlocks) defer n.Close() @@ -679,6 +681,8 @@ func assembleBlock(api *ConsensusAPI, parentHash common.Hash, params *engine.Pay } func TestEmptyBlocks(t *testing.T) { + t.Parallel() + genesis, preMergeBlocks := generateMergeChain(10, false) n, ethservice := startEthService(t, genesis, preMergeBlocks) defer n.Close() @@ -739,6 +743,8 @@ func TestEmptyBlocks(t *testing.T) { } func getNewPayload(t *testing.T, api *ConsensusAPI, parent *types.Header, withdrawals []*types.Withdrawal) *engine.ExecutableData { + t.Helper() + params := engine.PayloadAttributes{ Timestamp: parent.Time + 1, Random: crypto.Keccak256Hash([]byte{byte(1)}), @@ -794,6 +800,8 @@ func decodeTransactions(enc [][]byte) ([]*types.Transaction, error) { } func TestTrickRemoteBlockCache(t *testing.T) { + t.Parallel() + // Setup two nodes genesis, preMergeBlocks := generateMergeChain(10, false) nodeA, ethserviceA := startEthService(t, genesis, preMergeBlocks) @@ -858,6 +866,8 @@ func TestTrickRemoteBlockCache(t *testing.T) { } func TestInvalidBloom(t *testing.T) { + t.Parallel() + genesis, preMergeBlocks := generateMergeChain(10, false) n, ethservice := startEthService(t, genesis, preMergeBlocks) ethservice.Merger().ReachTTD() @@ -882,6 +892,8 @@ func TestInvalidBloom(t *testing.T) { } func TestNewPayloadOnInvalidTerminalBlock(t *testing.T) { + t.Parallel() + genesis, preMergeBlocks := generateMergeChain(100, false) n, ethservice := startEthService(t, genesis, preMergeBlocks) defer n.Close() @@ -949,6 +961,8 @@ func TestNewPayloadOnInvalidTerminalBlock(t *testing.T) { // newPayLoad and forkchoiceUpdate. This is to test that the api behaves // well even of the caller is not being 'serial'. func TestSimultaneousNewBlock(t *testing.T) { + t.Parallel() + genesis, preMergeBlocks := generateMergeChain(10, false) n, ethservice := startEthService(t, genesis, preMergeBlocks) defer n.Close() @@ -1036,6 +1050,8 @@ func TestSimultaneousNewBlock(t *testing.T) { // TestWithdrawals creates and verifies two post-Shanghai blocks. The first // includes zero withdrawals and the second includes two. func TestWithdrawals(t *testing.T) { + t.Parallel() + genesis, blocks := generateMergeChain(10, true) // Set shanghai time to last block + 5 seconds (first post-merge block) time := blocks[len(blocks)-1].Time() + 5 @@ -1150,6 +1166,8 @@ func TestWithdrawals(t *testing.T) { } func TestNilWithdrawals(t *testing.T) { + t.Parallel() + genesis, blocks := generateMergeChain(10, true) // Set shanghai time to last block + 4 seconds (first post-merge block) time := blocks[len(blocks)-1].Time() + 4 @@ -1262,6 +1280,8 @@ func TestNilWithdrawals(t *testing.T) { } func setupBodies(t *testing.T) (*node.Node, *eth.Ethereum, []*types.Block) { + t.Helper() + genesis, blocks := generateMergeChain(10, true) // enable shanghai on the last block time := blocks[len(blocks)-1].Header().Time + 1 @@ -1316,6 +1336,8 @@ func allBodies(blocks []*types.Block) []*types.Body { } func TestGetBlockBodiesByHash(t *testing.T) { + t.Parallel() + node, eth, blocks := setupBodies(t) api := NewConsensusAPI(eth) defer node.Close() @@ -1372,6 +1394,8 @@ func TestGetBlockBodiesByHash(t *testing.T) { } func TestGetBlockBodiesByRange(t *testing.T) { + t.Parallel() + node, eth, blocks := setupBodies(t) api := NewConsensusAPI(eth) defer node.Close() @@ -1453,6 +1477,8 @@ func TestGetBlockBodiesByRange(t *testing.T) { } func TestGetBlockBodiesByRangeInvalidParams(t *testing.T) { + t.Parallel() + node, eth, _ := setupBodies(t) api := NewConsensusAPI(eth) defer node.Close() diff --git a/eth/downloader/api.go b/eth/downloader/api.go index b3f7113bcd..27cea07233 100644 --- a/eth/downloader/api.go +++ b/eth/downloader/api.go @@ -38,6 +38,7 @@ type DownloaderAPI struct { // listens for events from the downloader through the global event mux. In case it receives one of // these events it broadcasts it to all syncing subscriptions that are installed through the // installSyncSubscription channel. +// nolint: staticcheck func NewDownloaderAPI(d *Downloader, m *event.TypeMux) *DownloaderAPI { api := &DownloaderAPI{ d: d, diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index 1fbd0287bc..b9eedde5b6 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -58,6 +58,7 @@ type downloadTester struct { // newTester creates a new downloader test mocker. func newTester(t *testing.T) *downloadTester { + t.Helper() return newTesterWithNotification(t, nil) } @@ -393,7 +394,7 @@ func (dlp *downloadTesterPeer) RequestStorageRanges(id uint64, root common.Hash, go dlp.dl.downloader.SnapSyncer.OnStorage(dlp, id, hashes, slots, proofs) return nil - } +} // RequestByteCodes fetches a batch of bytecodes by hash. func (dlp *downloadTesterPeer) RequestByteCodes(id uint64, hashes []common.Hash, bytes uint64) error { @@ -401,7 +402,7 @@ func (dlp *downloadTesterPeer) RequestByteCodes(id uint64, hashes []common.Hash, ID: id, Hashes: hashes, Bytes: bytes, - } + } codes := snap.ServiceGetByteCodesQuery(dlp.chain, req) go dlp.dl.downloader.SnapSyncer.OnByteCodes(dlp, id, codes) return nil @@ -447,12 +448,30 @@ func assertOwnChain(t *testing.T, tester *downloadTester, length int) { } } -func TestCanonicalSynchronisation66Full(t *testing.T) { testCanonSync(t, eth.ETH66, FullSync) } -func TestCanonicalSynchronisation66Snap(t *testing.T) { testCanonSync(t, eth.ETH66, SnapSync) } -func TestCanonicalSynchronisation66Light(t *testing.T) { testCanonSync(t, eth.ETH66, LightSync) } -func TestCanonicalSynchronisation67Full(t *testing.T) { testCanonSync(t, eth.ETH67, FullSync) } -func TestCanonicalSynchronisation67Snap(t *testing.T) { testCanonSync(t, eth.ETH67, SnapSync) } -func TestCanonicalSynchronisation67Light(t *testing.T) { testCanonSync(t, eth.ETH67, LightSync) } +func TestCanonicalSynchronisation66Full(t *testing.T) { + t.Parallel() + testCanonSync(t, eth.ETH66, FullSync) +} +func TestCanonicalSynchronisation66Snap(t *testing.T) { + t.Parallel() + testCanonSync(t, eth.ETH66, SnapSync) +} +func TestCanonicalSynchronisation66Light(t *testing.T) { + t.Parallel() + testCanonSync(t, eth.ETH66, LightSync) +} +func TestCanonicalSynchronisation67Full(t *testing.T) { + t.Parallel() + testCanonSync(t, eth.ETH67, FullSync) +} +func TestCanonicalSynchronisation67Snap(t *testing.T) { + t.Parallel() + testCanonSync(t, eth.ETH67, SnapSync) +} +func TestCanonicalSynchronisation67Light(t *testing.T) { + t.Parallel() + testCanonSync(t, eth.ETH67, LightSync) +} func testCanonSync(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -471,10 +490,22 @@ func testCanonSync(t *testing.T, protocol uint, mode SyncMode) { // Tests that if a large batch of blocks are being downloaded, it is throttled // until the cached blocks are retrieved. -func TestThrottling66Full(t *testing.T) { testThrottling(t, eth.ETH66, FullSync) } -func TestThrottling66Snap(t *testing.T) { testThrottling(t, eth.ETH66, SnapSync) } -func TestThrottling67Full(t *testing.T) { testThrottling(t, eth.ETH67, FullSync) } -func TestThrottling67Snap(t *testing.T) { testThrottling(t, eth.ETH67, SnapSync) } +func TestThrottling66Full(t *testing.T) { + t.Parallel() + testThrottling(t, eth.ETH66, FullSync) +} +func TestThrottling66Snap(t *testing.T) { + t.Parallel() + testThrottling(t, eth.ETH66, SnapSync) +} +func TestThrottling67Full(t *testing.T) { + t.Parallel() + testThrottling(t, eth.ETH67, FullSync) +} +func TestThrottling67Snap(t *testing.T) { + t.Parallel() + testThrottling(t, eth.ETH67, SnapSync) +} func testThrottling(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -553,12 +584,30 @@ func testThrottling(t *testing.T, protocol uint, mode SyncMode) { // Tests that simple synchronization against a forked chain works correctly. In // this test common ancestor lookup should *not* be short circuited, and a full // binary search should be executed. -func TestForkedSync66Full(t *testing.T) { testForkedSync(t, eth.ETH66, FullSync) } -func TestForkedSync66Snap(t *testing.T) { testForkedSync(t, eth.ETH66, SnapSync) } -func TestForkedSync66Light(t *testing.T) { testForkedSync(t, eth.ETH66, LightSync) } -func TestForkedSync67Full(t *testing.T) { testForkedSync(t, eth.ETH67, FullSync) } -func TestForkedSync67Snap(t *testing.T) { testForkedSync(t, eth.ETH67, SnapSync) } -func TestForkedSync67Light(t *testing.T) { testForkedSync(t, eth.ETH67, LightSync) } +func TestForkedSync66Full(t *testing.T) { + t.Parallel() + testForkedSync(t, eth.ETH66, FullSync) +} +func TestForkedSync66Snap(t *testing.T) { + t.Parallel() + testForkedSync(t, eth.ETH66, SnapSync) +} +func TestForkedSync66Light(t *testing.T) { + t.Parallel() + testForkedSync(t, eth.ETH66, LightSync) +} +func TestForkedSync67Full(t *testing.T) { + t.Parallel() + testForkedSync(t, eth.ETH67, FullSync) +} +func TestForkedSync67Snap(t *testing.T) { + t.Parallel() + testForkedSync(t, eth.ETH67, SnapSync) +} +func TestForkedSync67Light(t *testing.T) { + t.Parallel() + testForkedSync(t, eth.ETH67, LightSync) +} func testForkedSync(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -583,12 +632,30 @@ func testForkedSync(t *testing.T, protocol uint, mode SyncMode) { // Tests that synchronising against a much shorter but much heavier fork works // currently and is not dropped. -func TestHeavyForkedSync66Full(t *testing.T) { testHeavyForkedSync(t, eth.ETH66, FullSync) } -func TestHeavyForkedSync66Snap(t *testing.T) { testHeavyForkedSync(t, eth.ETH66, SnapSync) } -func TestHeavyForkedSync66Light(t *testing.T) { testHeavyForkedSync(t, eth.ETH66, LightSync) } -func TestHeavyForkedSync67Full(t *testing.T) { testHeavyForkedSync(t, eth.ETH67, FullSync) } -func TestHeavyForkedSync67Snap(t *testing.T) { testHeavyForkedSync(t, eth.ETH67, SnapSync) } -func TestHeavyForkedSync67Light(t *testing.T) { testHeavyForkedSync(t, eth.ETH67, LightSync) } +func TestHeavyForkedSync66Full(t *testing.T) { + t.Parallel() + testHeavyForkedSync(t, eth.ETH66, FullSync) +} +func TestHeavyForkedSync66Snap(t *testing.T) { + t.Parallel() + testHeavyForkedSync(t, eth.ETH66, SnapSync) +} +func TestHeavyForkedSync66Light(t *testing.T) { + t.Parallel() + testHeavyForkedSync(t, eth.ETH66, LightSync) +} +func TestHeavyForkedSync67Full(t *testing.T) { + t.Parallel() + testHeavyForkedSync(t, eth.ETH67, FullSync) +} +func TestHeavyForkedSync67Snap(t *testing.T) { + t.Parallel() + testHeavyForkedSync(t, eth.ETH67, SnapSync) +} +func TestHeavyForkedSync67Light(t *testing.T) { + t.Parallel() + testHeavyForkedSync(t, eth.ETH67, LightSync) +} func testHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -615,12 +682,30 @@ func testHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) { // Tests that chain forks are contained within a certain interval of the current // chain head, ensuring that malicious peers cannot waste resources by feeding // long dead chains. -func TestBoundedForkedSync66Full(t *testing.T) { testBoundedForkedSync(t, eth.ETH66, FullSync) } -func TestBoundedForkedSync66Snap(t *testing.T) { testBoundedForkedSync(t, eth.ETH66, SnapSync) } -func TestBoundedForkedSync66Light(t *testing.T) { testBoundedForkedSync(t, eth.ETH66, LightSync) } -func TestBoundedForkedSync67Full(t *testing.T) { testBoundedForkedSync(t, eth.ETH67, FullSync) } -func TestBoundedForkedSync67Snap(t *testing.T) { testBoundedForkedSync(t, eth.ETH67, SnapSync) } -func TestBoundedForkedSync67Light(t *testing.T) { testBoundedForkedSync(t, eth.ETH67, LightSync) } +func TestBoundedForkedSync66Full(t *testing.T) { + t.Parallel() + testBoundedForkedSync(t, eth.ETH66, FullSync) +} +func TestBoundedForkedSync66Snap(t *testing.T) { + t.Parallel() + testBoundedForkedSync(t, eth.ETH66, SnapSync) +} +func TestBoundedForkedSync66Light(t *testing.T) { + t.Parallel() + testBoundedForkedSync(t, eth.ETH66, LightSync) +} +func TestBoundedForkedSync67Full(t *testing.T) { + t.Parallel() + testBoundedForkedSync(t, eth.ETH67, FullSync) +} +func TestBoundedForkedSync67Snap(t *testing.T) { + t.Parallel() + testBoundedForkedSync(t, eth.ETH67, SnapSync) +} +func TestBoundedForkedSync67Light(t *testing.T) { + t.Parallel() + testBoundedForkedSync(t, eth.ETH67, LightSync) +} func testBoundedForkedSync(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -647,21 +732,27 @@ func testBoundedForkedSync(t *testing.T, protocol uint, mode SyncMode) { // chain head for short but heavy forks too. These are a bit special because they // take different ancestor lookup paths. func TestBoundedHeavyForkedSync66Full(t *testing.T) { + t.Parallel() testBoundedHeavyForkedSync(t, eth.ETH66, FullSync) } func TestBoundedHeavyForkedSync66Snap(t *testing.T) { + t.Parallel() testBoundedHeavyForkedSync(t, eth.ETH66, SnapSync) } func TestBoundedHeavyForkedSync66Light(t *testing.T) { + t.Parallel() testBoundedHeavyForkedSync(t, eth.ETH66, LightSync) } func TestBoundedHeavyForkedSync67Full(t *testing.T) { + t.Parallel() testBoundedHeavyForkedSync(t, eth.ETH67, FullSync) } func TestBoundedHeavyForkedSync67Snap(t *testing.T) { + t.Parallel() testBoundedHeavyForkedSync(t, eth.ETH67, SnapSync) } func TestBoundedHeavyForkedSync67Light(t *testing.T) { + t.Parallel() testBoundedHeavyForkedSync(t, eth.ETH67, LightSync) } @@ -688,12 +779,30 @@ func testBoundedHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) { } // Tests that a canceled download wipes all previously accumulated state. -func TestCancel66Full(t *testing.T) { testCancel(t, eth.ETH66, FullSync) } -func TestCancel66Snap(t *testing.T) { testCancel(t, eth.ETH66, SnapSync) } -func TestCancel66Light(t *testing.T) { testCancel(t, eth.ETH66, LightSync) } -func TestCancel67Full(t *testing.T) { testCancel(t, eth.ETH67, FullSync) } -func TestCancel67Snap(t *testing.T) { testCancel(t, eth.ETH67, SnapSync) } -func TestCancel67Light(t *testing.T) { testCancel(t, eth.ETH67, LightSync) } +func TestCancel66Full(t *testing.T) { + t.Parallel() + testCancel(t, eth.ETH66, FullSync) +} +func TestCancel66Snap(t *testing.T) { + t.Parallel() + testCancel(t, eth.ETH66, SnapSync) +} +func TestCancel66Light(t *testing.T) { + t.Parallel() + testCancel(t, eth.ETH66, LightSync) +} +func TestCancel67Full(t *testing.T) { + t.Parallel() + testCancel(t, eth.ETH67, FullSync) +} +func TestCancel67Snap(t *testing.T) { + t.Parallel() + testCancel(t, eth.ETH67, SnapSync) +} +func TestCancel67Light(t *testing.T) { + t.Parallel() + testCancel(t, eth.ETH67, LightSync) +} func testCancel(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -718,12 +827,30 @@ func testCancel(t *testing.T, protocol uint, mode SyncMode) { } // Tests that synchronisation from multiple peers works as intended (multi thread sanity test). -func TestMultiSynchronisation66Full(t *testing.T) { testMultiSynchronisation(t, eth.ETH66, FullSync) } -func TestMultiSynchronisation66Snap(t *testing.T) { testMultiSynchronisation(t, eth.ETH66, SnapSync) } -func TestMultiSynchronisation66Light(t *testing.T) { testMultiSynchronisation(t, eth.ETH66, LightSync) } -func TestMultiSynchronisation67Full(t *testing.T) { testMultiSynchronisation(t, eth.ETH67, FullSync) } -func TestMultiSynchronisation67Snap(t *testing.T) { testMultiSynchronisation(t, eth.ETH67, SnapSync) } -func TestMultiSynchronisation67Light(t *testing.T) { testMultiSynchronisation(t, eth.ETH67, LightSync) } +func TestMultiSynchronisation66Full(t *testing.T) { + t.Parallel() + testMultiSynchronisation(t, eth.ETH66, FullSync) +} +func TestMultiSynchronisation66Snap(t *testing.T) { + t.Parallel() + testMultiSynchronisation(t, eth.ETH66, SnapSync) +} +func TestMultiSynchronisation66Light(t *testing.T) { + t.Parallel() + testMultiSynchronisation(t, eth.ETH66, LightSync) +} +func TestMultiSynchronisation67Full(t *testing.T) { + t.Parallel() + testMultiSynchronisation(t, eth.ETH67, FullSync) +} +func TestMultiSynchronisation67Snap(t *testing.T) { + t.Parallel() + testMultiSynchronisation(t, eth.ETH67, SnapSync) +} +func TestMultiSynchronisation67Light(t *testing.T) { + t.Parallel() + testMultiSynchronisation(t, eth.ETH67, LightSync) +} func testMultiSynchronisation(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -745,12 +872,30 @@ func testMultiSynchronisation(t *testing.T, protocol uint, mode SyncMode) { // Tests that synchronisations behave well in multi-version protocol environments // and not wreak havoc on other nodes in the network. -func TestMultiProtoSynchronisation66Full(t *testing.T) { testMultiProtoSync(t, eth.ETH66, FullSync) } -func TestMultiProtoSynchronisation66Snap(t *testing.T) { testMultiProtoSync(t, eth.ETH66, SnapSync) } -func TestMultiProtoSynchronisation66Light(t *testing.T) { testMultiProtoSync(t, eth.ETH66, LightSync) } -func TestMultiProtoSynchronisation67Full(t *testing.T) { testMultiProtoSync(t, eth.ETH67, FullSync) } -func TestMultiProtoSynchronisation67Snap(t *testing.T) { testMultiProtoSync(t, eth.ETH67, SnapSync) } -func TestMultiProtoSynchronisation67Light(t *testing.T) { testMultiProtoSync(t, eth.ETH67, LightSync) } +func TestMultiProtoSynchronisation66Full(t *testing.T) { + t.Parallel() + testMultiProtoSync(t, eth.ETH66, FullSync) +} +func TestMultiProtoSynchronisation66Snap(t *testing.T) { + t.Parallel() + testMultiProtoSync(t, eth.ETH66, SnapSync) +} +func TestMultiProtoSynchronisation66Light(t *testing.T) { + t.Parallel() + testMultiProtoSync(t, eth.ETH66, LightSync) +} +func TestMultiProtoSynchronisation67Full(t *testing.T) { + t.Parallel() + testMultiProtoSync(t, eth.ETH67, FullSync) +} +func TestMultiProtoSynchronisation67Snap(t *testing.T) { + t.Parallel() + testMultiProtoSync(t, eth.ETH67, SnapSync) +} +func TestMultiProtoSynchronisation67Light(t *testing.T) { + t.Parallel() + testMultiProtoSync(t, eth.ETH67, LightSync) +} func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -780,12 +925,30 @@ func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) { // Tests that if a block is empty (e.g. header only), no body request should be // made, and instead the header should be assembled into a whole block in itself. -func TestEmptyShortCircuit66Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, FullSync) } -func TestEmptyShortCircuit66Snap(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, SnapSync) } -func TestEmptyShortCircuit66Light(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, LightSync) } -func TestEmptyShortCircuit67Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH67, FullSync) } -func TestEmptyShortCircuit67Snap(t *testing.T) { testEmptyShortCircuit(t, eth.ETH67, SnapSync) } -func TestEmptyShortCircuit67Light(t *testing.T) { testEmptyShortCircuit(t, eth.ETH67, LightSync) } +func TestEmptyShortCircuit66Full(t *testing.T) { + t.Parallel() + testEmptyShortCircuit(t, eth.ETH66, FullSync) +} +func TestEmptyShortCircuit66Snap(t *testing.T) { + t.Parallel() + testEmptyShortCircuit(t, eth.ETH66, SnapSync) +} +func TestEmptyShortCircuit66Light(t *testing.T) { + t.Parallel() + testEmptyShortCircuit(t, eth.ETH66, LightSync) +} +func TestEmptyShortCircuit67Full(t *testing.T) { + t.Parallel() + testEmptyShortCircuit(t, eth.ETH67, FullSync) +} +func TestEmptyShortCircuit67Snap(t *testing.T) { + t.Parallel() + testEmptyShortCircuit(t, eth.ETH67, SnapSync) +} +func TestEmptyShortCircuit67Light(t *testing.T) { + t.Parallel() + testEmptyShortCircuit(t, eth.ETH67, LightSync) +} func testEmptyShortCircuit(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -831,12 +994,30 @@ func testEmptyShortCircuit(t *testing.T, protocol uint, mode SyncMode) { // Tests that headers are enqueued continuously, preventing malicious nodes from // stalling the downloader by feeding gapped header chains. -func TestMissingHeaderAttack66Full(t *testing.T) { testMissingHeaderAttack(t, eth.ETH66, FullSync) } -func TestMissingHeaderAttack66Snap(t *testing.T) { testMissingHeaderAttack(t, eth.ETH66, SnapSync) } -func TestMissingHeaderAttack66Light(t *testing.T) { testMissingHeaderAttack(t, eth.ETH66, LightSync) } -func TestMissingHeaderAttack67Full(t *testing.T) { testMissingHeaderAttack(t, eth.ETH67, FullSync) } -func TestMissingHeaderAttack67Snap(t *testing.T) { testMissingHeaderAttack(t, eth.ETH67, SnapSync) } -func TestMissingHeaderAttack67Light(t *testing.T) { testMissingHeaderAttack(t, eth.ETH67, LightSync) } +func TestMissingHeaderAttack66Full(t *testing.T) { + t.Parallel() + testMissingHeaderAttack(t, eth.ETH66, FullSync) +} +func TestMissingHeaderAttack66Snap(t *testing.T) { + t.Parallel() + testMissingHeaderAttack(t, eth.ETH66, SnapSync) +} +func TestMissingHeaderAttack66Light(t *testing.T) { + t.Parallel() + testMissingHeaderAttack(t, eth.ETH66, LightSync) +} +func TestMissingHeaderAttack67Full(t *testing.T) { + t.Parallel() + testMissingHeaderAttack(t, eth.ETH67, FullSync) +} +func TestMissingHeaderAttack67Snap(t *testing.T) { + t.Parallel() + testMissingHeaderAttack(t, eth.ETH67, SnapSync) +} +func TestMissingHeaderAttack67Light(t *testing.T) { + t.Parallel() + testMissingHeaderAttack(t, eth.ETH67, LightSync) +} func testMissingHeaderAttack(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -860,12 +1041,30 @@ func testMissingHeaderAttack(t *testing.T, protocol uint, mode SyncMode) { // Tests that if requested headers are shifted (i.e. first is missing), the queue // detects the invalid numbering. -func TestShiftedHeaderAttack66Full(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH66, FullSync) } -func TestShiftedHeaderAttack66Snap(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH66, SnapSync) } -func TestShiftedHeaderAttack66Light(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH66, LightSync) } -func TestShiftedHeaderAttack67Full(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH67, FullSync) } -func TestShiftedHeaderAttack67Snap(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH67, SnapSync) } -func TestShiftedHeaderAttack67Light(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH67, LightSync) } +func TestShiftedHeaderAttack66Full(t *testing.T) { + t.Parallel() + testShiftedHeaderAttack(t, eth.ETH66, FullSync) +} +func TestShiftedHeaderAttack66Snap(t *testing.T) { + t.Parallel() + testShiftedHeaderAttack(t, eth.ETH66, SnapSync) +} +func TestShiftedHeaderAttack66Light(t *testing.T) { + t.Parallel() + testShiftedHeaderAttack(t, eth.ETH66, LightSync) +} +func TestShiftedHeaderAttack67Full(t *testing.T) { + t.Parallel() + testShiftedHeaderAttack(t, eth.ETH67, FullSync) +} +func TestShiftedHeaderAttack67Snap(t *testing.T) { + t.Parallel() + testShiftedHeaderAttack(t, eth.ETH67, SnapSync) +} +func TestShiftedHeaderAttack67Light(t *testing.T) { + t.Parallel() + testShiftedHeaderAttack(t, eth.ETH67, LightSync) +} func testShiftedHeaderAttack(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -891,8 +1090,14 @@ func testShiftedHeaderAttack(t *testing.T, protocol uint, mode SyncMode) { // Tests that upon detecting an invalid header, the recent ones are rolled back // for various failure scenarios. Afterwards a full sync is attempted to make // sure no state was corrupted. -func TestInvalidHeaderRollback66Snap(t *testing.T) { testInvalidHeaderRollback(t, eth.ETH66, SnapSync) } -func TestInvalidHeaderRollback67Snap(t *testing.T) { testInvalidHeaderRollback(t, eth.ETH67, SnapSync) } +func TestInvalidHeaderRollback66Snap(t *testing.T) { + t.Parallel() + testInvalidHeaderRollback(t, eth.ETH66, SnapSync) +} +func TestInvalidHeaderRollback67Snap(t *testing.T) { + t.Parallel() + testInvalidHeaderRollback(t, eth.ETH67, SnapSync) +} func testInvalidHeaderRollback(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -971,21 +1176,27 @@ func testInvalidHeaderRollback(t *testing.T, protocol uint, mode SyncMode) { // Tests that a peer advertising a high TD doesn't get to stall the downloader // afterwards by not sending any useful hashes. func TestHighTDStarvationAttack66Full(t *testing.T) { + t.Parallel() testHighTDStarvationAttack(t, eth.ETH66, FullSync) } func TestHighTDStarvationAttack66Snap(t *testing.T) { + t.Parallel() testHighTDStarvationAttack(t, eth.ETH66, SnapSync) } func TestHighTDStarvationAttack66Light(t *testing.T) { + t.Parallel() testHighTDStarvationAttack(t, eth.ETH66, LightSync) } func TestHighTDStarvationAttack67Full(t *testing.T) { + t.Parallel() testHighTDStarvationAttack(t, eth.ETH67, FullSync) } func TestHighTDStarvationAttack67Snap(t *testing.T) { + t.Parallel() testHighTDStarvationAttack(t, eth.ETH67, SnapSync) } func TestHighTDStarvationAttack67Light(t *testing.T) { + t.Parallel() testHighTDStarvationAttack(t, eth.ETH67, LightSync) } @@ -1001,8 +1212,14 @@ func testHighTDStarvationAttack(t *testing.T, protocol uint, mode SyncMode) { } // Tests that misbehaving peers are disconnected, whilst behaving ones are not. -func TestBlockHeaderAttackerDropping66(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH66) } -func TestBlockHeaderAttackerDropping67(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH67) } +func TestBlockHeaderAttackerDropping66(t *testing.T) { + t.Parallel() + testBlockHeaderAttackerDropping(t, eth.ETH66) +} +func TestBlockHeaderAttackerDropping67(t *testing.T) { + t.Parallel() + testBlockHeaderAttackerDropping(t, eth.ETH67) +} func testBlockHeaderAttackerDropping(t *testing.T, protocol uint) { // Define the disconnection requirement for individual hash fetch errors @@ -1050,12 +1267,30 @@ func testBlockHeaderAttackerDropping(t *testing.T, protocol uint) { // Tests that synchronisation progress (origin block number, current block number // and highest block number) is tracked and updated correctly. -func TestSyncProgress66Full(t *testing.T) { testSyncProgress(t, eth.ETH66, FullSync) } -func TestSyncProgress66Snap(t *testing.T) { testSyncProgress(t, eth.ETH66, SnapSync) } -func TestSyncProgress66Light(t *testing.T) { testSyncProgress(t, eth.ETH66, LightSync) } -func TestSyncProgress67Full(t *testing.T) { testSyncProgress(t, eth.ETH67, FullSync) } -func TestSyncProgress67Snap(t *testing.T) { testSyncProgress(t, eth.ETH67, SnapSync) } -func TestSyncProgress67Light(t *testing.T) { testSyncProgress(t, eth.ETH67, LightSync) } +func TestSyncProgress66Full(t *testing.T) { + t.Parallel() + testSyncProgress(t, eth.ETH66, FullSync) +} +func TestSyncProgress66Snap(t *testing.T) { + t.Parallel() + testSyncProgress(t, eth.ETH66, SnapSync) +} +func TestSyncProgress66Light(t *testing.T) { + t.Parallel() + testSyncProgress(t, eth.ETH66, LightSync) +} +func TestSyncProgress67Full(t *testing.T) { + t.Parallel() + testSyncProgress(t, eth.ETH67, FullSync) +} +func TestSyncProgress67Snap(t *testing.T) { + t.Parallel() + testSyncProgress(t, eth.ETH67, SnapSync) +} +func TestSyncProgress67Light(t *testing.T) { + t.Parallel() + testSyncProgress(t, eth.ETH67, LightSync) +} func testSyncProgress(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -1130,12 +1365,30 @@ func checkProgress(t *testing.T, d *Downloader, stage string, want ethereum.Sync // Tests that synchronisation progress (origin block number and highest block // number) is tracked and updated correctly in case of a fork (or manual head // revertal). -func TestForkedSyncProgress66Full(t *testing.T) { testForkedSyncProgress(t, eth.ETH66, FullSync) } -func TestForkedSyncProgress66Snap(t *testing.T) { testForkedSyncProgress(t, eth.ETH66, SnapSync) } -func TestForkedSyncProgress66Light(t *testing.T) { testForkedSyncProgress(t, eth.ETH66, LightSync) } -func TestForkedSyncProgress67Full(t *testing.T) { testForkedSyncProgress(t, eth.ETH67, FullSync) } -func TestForkedSyncProgress67Snap(t *testing.T) { testForkedSyncProgress(t, eth.ETH67, SnapSync) } -func TestForkedSyncProgress67Light(t *testing.T) { testForkedSyncProgress(t, eth.ETH67, LightSync) } +func TestForkedSyncProgress66Full(t *testing.T) { + t.Parallel() + testForkedSyncProgress(t, eth.ETH66, FullSync) +} +func TestForkedSyncProgress66Snap(t *testing.T) { + t.Parallel() + testForkedSyncProgress(t, eth.ETH66, SnapSync) +} +func TestForkedSyncProgress66Light(t *testing.T) { + t.Parallel() + testForkedSyncProgress(t, eth.ETH66, LightSync) +} +func TestForkedSyncProgress67Full(t *testing.T) { + t.Parallel() + testForkedSyncProgress(t, eth.ETH67, FullSync) +} +func TestForkedSyncProgress67Snap(t *testing.T) { + t.Parallel() + testForkedSyncProgress(t, eth.ETH67, SnapSync) +} +func TestForkedSyncProgress67Light(t *testing.T) { + t.Parallel() + testForkedSyncProgress(t, eth.ETH67, LightSync) +} func testForkedSyncProgress(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -1204,12 +1457,30 @@ func testForkedSyncProgress(t *testing.T, protocol uint, mode SyncMode) { // Tests that if synchronisation is aborted due to some failure, then the progress // origin is not updated in the next sync cycle, as it should be considered the // continuation of the previous sync and not a new instance. -func TestFailedSyncProgress66Full(t *testing.T) { testFailedSyncProgress(t, eth.ETH66, FullSync) } -func TestFailedSyncProgress66Snap(t *testing.T) { testFailedSyncProgress(t, eth.ETH66, SnapSync) } -func TestFailedSyncProgress66Light(t *testing.T) { testFailedSyncProgress(t, eth.ETH66, LightSync) } -func TestFailedSyncProgress67Full(t *testing.T) { testFailedSyncProgress(t, eth.ETH67, FullSync) } -func TestFailedSyncProgress67Snap(t *testing.T) { testFailedSyncProgress(t, eth.ETH67, SnapSync) } -func TestFailedSyncProgress67Light(t *testing.T) { testFailedSyncProgress(t, eth.ETH67, LightSync) } +func TestFailedSyncProgress66Full(t *testing.T) { + t.Parallel() + testFailedSyncProgress(t, eth.ETH66, FullSync) +} +func TestFailedSyncProgress66Snap(t *testing.T) { + t.Parallel() + testFailedSyncProgress(t, eth.ETH66, SnapSync) +} +func TestFailedSyncProgress66Light(t *testing.T) { + t.Parallel() + testFailedSyncProgress(t, eth.ETH66, LightSync) +} +func TestFailedSyncProgress67Full(t *testing.T) { + t.Parallel() + testFailedSyncProgress(t, eth.ETH67, FullSync) +} +func TestFailedSyncProgress67Snap(t *testing.T) { + t.Parallel() + testFailedSyncProgress(t, eth.ETH67, SnapSync) +} +func TestFailedSyncProgress67Light(t *testing.T) { + t.Parallel() + testFailedSyncProgress(t, eth.ETH67, LightSync) +} func testFailedSyncProgress(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -1273,12 +1544,30 @@ func testFailedSyncProgress(t *testing.T, protocol uint, mode SyncMode) { // Tests that if an attacker fakes a chain height, after the attack is detected, // the progress height is successfully reduced at the next sync invocation. -func TestFakedSyncProgress66Full(t *testing.T) { testFakedSyncProgress(t, eth.ETH66, FullSync) } -func TestFakedSyncProgress66Snap(t *testing.T) { testFakedSyncProgress(t, eth.ETH66, SnapSync) } -func TestFakedSyncProgress66Light(t *testing.T) { testFakedSyncProgress(t, eth.ETH66, LightSync) } -func TestFakedSyncProgress67Full(t *testing.T) { testFakedSyncProgress(t, eth.ETH67, FullSync) } -func TestFakedSyncProgress67Snap(t *testing.T) { testFakedSyncProgress(t, eth.ETH67, SnapSync) } -func TestFakedSyncProgress67Light(t *testing.T) { testFakedSyncProgress(t, eth.ETH67, LightSync) } +func TestFakedSyncProgress66Full(t *testing.T) { + t.Parallel() + testFakedSyncProgress(t, eth.ETH66, FullSync) +} +func TestFakedSyncProgress66Snap(t *testing.T) { + t.Parallel() + testFakedSyncProgress(t, eth.ETH66, SnapSync) +} +func TestFakedSyncProgress66Light(t *testing.T) { + t.Parallel() + testFakedSyncProgress(t, eth.ETH66, LightSync) +} +func TestFakedSyncProgress67Full(t *testing.T) { + t.Parallel() + testFakedSyncProgress(t, eth.ETH67, FullSync) +} +func TestFakedSyncProgress67Snap(t *testing.T) { + t.Parallel() + testFakedSyncProgress(t, eth.ETH67, SnapSync) +} +func TestFakedSyncProgress67Light(t *testing.T) { + t.Parallel() + testFakedSyncProgress(t, eth.ETH67, LightSync) +} func testFakedSyncProgress(t *testing.T, protocol uint, mode SyncMode) { tester := newTester(t) @@ -1424,14 +1713,28 @@ func TestRemoteHeaderRequestSpan(t *testing.T) { // Tests that peers below a pre-configured checkpoint block are prevented from // being fast-synced from, avoiding potential cheap eclipse attacks. -func TestCheckpointEnforcement66Full(t *testing.T) { testCheckpointEnforcement(t, eth.ETH66, FullSync) } -func TestCheckpointEnforcement66Snap(t *testing.T) { testCheckpointEnforcement(t, eth.ETH66, SnapSync) } +func TestCheckpointEnforcement66Full(t *testing.T) { + t.Parallel() + testCheckpointEnforcement(t, eth.ETH66, FullSync) +} +func TestCheckpointEnforcement66Snap(t *testing.T) { + t.Parallel() + testCheckpointEnforcement(t, eth.ETH66, SnapSync) +} func TestCheckpointEnforcement66Light(t *testing.T) { + t.Parallel() testCheckpointEnforcement(t, eth.ETH66, LightSync) } -func TestCheckpointEnforcement67Full(t *testing.T) { testCheckpointEnforcement(t, eth.ETH67, FullSync) } -func TestCheckpointEnforcement67Snap(t *testing.T) { testCheckpointEnforcement(t, eth.ETH67, SnapSync) } +func TestCheckpointEnforcement67Full(t *testing.T) { + t.Parallel() + testCheckpointEnforcement(t, eth.ETH67, FullSync) +} +func TestCheckpointEnforcement67Snap(t *testing.T) { + t.Parallel() + testCheckpointEnforcement(t, eth.ETH67, SnapSync) +} func TestCheckpointEnforcement67Light(t *testing.T) { + t.Parallel() testCheckpointEnforcement(t, eth.ETH67, LightSync) } @@ -1464,10 +1767,18 @@ func testCheckpointEnforcement(t *testing.T, protocol uint, mode SyncMode) { // Tests that peers below a pre-configured checkpoint block are prevented from // being fast-synced from, avoiding potential cheap eclipse attacks. -func TestBeaconSync66Full(t *testing.T) { testBeaconSync(t, eth.ETH66, FullSync) } -func TestBeaconSync66Snap(t *testing.T) { testBeaconSync(t, eth.ETH66, SnapSync) } +func TestBeaconSync66Full(t *testing.T) { + t.Parallel() + testBeaconSync(t, eth.ETH66, FullSync) +} +func TestBeaconSync66Snap(t *testing.T) { + t.Parallel() + testBeaconSync(t, eth.ETH66, SnapSync) +} func testBeaconSync(t *testing.T, protocol uint, mode SyncMode) { + t.Helper() + t.Parallel() //log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) var cases = []struct { @@ -1481,6 +1792,8 @@ func testBeaconSync(t *testing.T, protocol uint, mode SyncMode) { } for _, c := range cases { t.Run(c.name, func(t *testing.T) { + t.Parallel() + success := make(chan struct{}) tester := newTesterWithNotification(t, func() { close(success) diff --git a/eth/handler.go b/eth/handler.go index fb105277a9..9eb3518cb2 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -80,17 +80,18 @@ type txPool interface { // handlerConfig is the collection of initialization parameters to create a full // node network handler. type handlerConfig struct { - Database ethdb.Database // Database for direct sync insertions - Chain *core.BlockChain // Blockchain to serve data from - TxPool txPool // Transaction pool to propagate from - Merger *consensus.Merger // The manager for eth1/2 transition - Network uint64 // Network identifier to adfvertise - Sync downloader.SyncMode // Whether to snap or full sync - BloomCache uint64 // Megabytes to alloc for snap sync bloom + Database ethdb.Database // Database for direct sync insertions + Chain *core.BlockChain // Blockchain to serve data from + TxPool txPool // Transaction pool to propagate from + Merger *consensus.Merger // The manager for eth1/2 transition + Network uint64 // Network identifier to adfvertise + Sync downloader.SyncMode // Whether to snap or full sync + BloomCache uint64 // Megabytes to alloc for snap sync bloom + //nolint: staticcheck EventMux *event.TypeMux // Legacy event mux, deprecate for `feed` Checkpoint *params.TrustedCheckpoint // Hard coded checkpoint for sync challenges RequiredBlocks map[uint64]common.Hash // Hard coded map of required block hashes for sync challenges - EthAPI *ethapi.BlockChainAPI // EthAPI to interact + EthAPI *ethapi.BlockChainAPI // EthAPI to interact checker ethereum.ChainValidator txArrivalWait time.Duration // Maximum duration to wait for an announced tx before requesting it } @@ -148,7 +149,7 @@ func newHandler(config *handlerConfig) (*handler, error) { chain: config.Chain, peers: newPeerSet(), merger: config.Merger, - ethAPI: config.EthAPI, + ethAPI: config.EthAPI, requiredBlocks: config.RequiredBlocks, quitSync: make(chan struct{}), } diff --git a/eth/handler_eth_test.go b/eth/handler_eth_test.go index 8d74746070..2e7ba1183a 100644 --- a/eth/handler_eth_test.go +++ b/eth/handler_eth_test.go @@ -84,9 +84,18 @@ func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error { // Tests that peers are correctly accepted (or rejected) based on the advertised // fork IDs in the protocol handshake. -func TestForkIDSplit66(t *testing.T) { testForkIDSplit(t, eth.ETH66) } -func TestForkIDSplit67(t *testing.T) { testForkIDSplit(t, eth.ETH67) } -func TestForkIDSplit68(t *testing.T) { testForkIDSplit(t, eth.ETH68) } +func TestForkIDSplit66(t *testing.T) { + t.Parallel() + testForkIDSplit(t, eth.ETH66) +} +func TestForkIDSplit67(t *testing.T) { + t.Parallel() + testForkIDSplit(t, eth.ETH67) +} +func TestForkIDSplit68(t *testing.T) { + t.Parallel() + testForkIDSplit(t, eth.ETH68) +} func testForkIDSplit(t *testing.T, protocol uint) { t.Parallel() @@ -240,9 +249,18 @@ func testForkIDSplit(t *testing.T, protocol uint) { } // Tests that received transactions are added to the local pool. -func TestRecvTransactions66(t *testing.T) { testRecvTransactions(t, eth.ETH66) } -func TestRecvTransactions67(t *testing.T) { testRecvTransactions(t, eth.ETH67) } -func TestRecvTransactions68(t *testing.T) { testRecvTransactions(t, eth.ETH68) } +func TestRecvTransactions66(t *testing.T) { + t.Parallel() + testRecvTransactions(t, eth.ETH66) +} +func TestRecvTransactions67(t *testing.T) { + t.Parallel() + testRecvTransactions(t, eth.ETH67) +} +func TestRecvTransactions68(t *testing.T) { + t.Parallel() + testRecvTransactions(t, eth.ETH68) +} func testRecvTransactions(t *testing.T, protocol uint) { t.Parallel() @@ -299,9 +317,18 @@ func testRecvTransactions(t *testing.T, protocol uint) { } // This test checks that pending transactions are sent. -func TestSendTransactions66(t *testing.T) { testSendTransactions(t, eth.ETH66) } -func TestSendTransactions67(t *testing.T) { testSendTransactions(t, eth.ETH67) } -func TestSendTransactions68(t *testing.T) { testSendTransactions(t, eth.ETH68) } +func TestSendTransactions66(t *testing.T) { + t.Parallel() + testSendTransactions(t, eth.ETH66) +} +func TestSendTransactions67(t *testing.T) { + t.Parallel() + testSendTransactions(t, eth.ETH67) +} +func TestSendTransactions68(t *testing.T) { + t.Parallel() + testSendTransactions(t, eth.ETH68) +} func testSendTransactions(t *testing.T, protocol uint) { t.Parallel() @@ -386,9 +413,18 @@ func testSendTransactions(t *testing.T, protocol uint) { // Tests that transactions get propagated to all attached peers, either via direct // broadcasts or via announcements/retrievals. -func TestTransactionPropagation66(t *testing.T) { testTransactionPropagation(t, eth.ETH66) } -func TestTransactionPropagation67(t *testing.T) { testTransactionPropagation(t, eth.ETH67) } -func TestTransactionPropagation68(t *testing.T) { testTransactionPropagation(t, eth.ETH68) } +func TestTransactionPropagation66(t *testing.T) { + t.Parallel() + testTransactionPropagation(t, eth.ETH66) +} +func TestTransactionPropagation67(t *testing.T) { + t.Parallel() + testTransactionPropagation(t, eth.ETH67) +} +func TestTransactionPropagation68(t *testing.T) { + t.Parallel() + testTransactionPropagation(t, eth.ETH68) +} func testTransactionPropagation(t *testing.T, protocol uint) { t.Parallel() @@ -690,9 +726,18 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) { // Tests that a propagated malformed block (uncles or transactions don't match // with the hashes in the header) gets discarded and not broadcast forward. -func TestBroadcastMalformedBlock66(t *testing.T) { testBroadcastMalformedBlock(t, eth.ETH66) } -func TestBroadcastMalformedBlock67(t *testing.T) { testBroadcastMalformedBlock(t, eth.ETH67) } -func TestBroadcastMalformedBlock68(t *testing.T) { testBroadcastMalformedBlock(t, eth.ETH68) } +func TestBroadcastMalformedBlock66(t *testing.T) { + t.Parallel() + testBroadcastMalformedBlock(t, eth.ETH66) +} +func TestBroadcastMalformedBlock67(t *testing.T) { + t.Parallel() + testBroadcastMalformedBlock(t, eth.ETH67) +} +func TestBroadcastMalformedBlock68(t *testing.T) { + t.Parallel() + testBroadcastMalformedBlock(t, eth.ETH68) +} func testBroadcastMalformedBlock(t *testing.T, protocol uint) { t.Parallel() diff --git a/eth/protocols/eth/handler_test.go b/eth/protocols/eth/handler_test.go index 730c3d840f..cb26327b7c 100644 --- a/eth/protocols/eth/handler_test.go +++ b/eth/protocols/eth/handler_test.go @@ -148,9 +148,18 @@ func (b *testBackend) Handle(*Peer, Packet) error { } // Tests that block headers can be retrieved from a remote chain based on user queries. -func TestGetBlockHeaders66(t *testing.T) { testGetBlockHeaders(t, ETH66) } -func TestGetBlockHeaders67(t *testing.T) { testGetBlockHeaders(t, ETH67) } -func TestGetBlockHeaders68(t *testing.T) { testGetBlockHeaders(t, ETH68) } +func TestGetBlockHeaders66(t *testing.T) { + t.Parallel() + testGetBlockHeaders(t, ETH66) +} +func TestGetBlockHeaders67(t *testing.T) { + t.Parallel() + testGetBlockHeaders(t, ETH67) +} +func TestGetBlockHeaders68(t *testing.T) { + t.Parallel() + testGetBlockHeaders(t, ETH68) +} func testGetBlockHeaders(t *testing.T, protocol uint) { t.Parallel() @@ -335,9 +344,18 @@ func testGetBlockHeaders(t *testing.T, protocol uint) { } // Tests that block contents can be retrieved from a remote chain based on their hashes. -func TestGetBlockBodies66(t *testing.T) { testGetBlockBodies(t, ETH66) } -func TestGetBlockBodies67(t *testing.T) { testGetBlockBodies(t, ETH67) } -func TestGetBlockBodies68(t *testing.T) { testGetBlockBodies(t, ETH68) } +func TestGetBlockBodies66(t *testing.T) { + t.Parallel() + testGetBlockBodies(t, ETH66) +} +func TestGetBlockBodies67(t *testing.T) { + t.Parallel() + testGetBlockBodies(t, ETH67) +} +func TestGetBlockBodies68(t *testing.T) { + t.Parallel() + testGetBlockBodies(t, ETH68) +} func testGetBlockBodies(t *testing.T, protocol uint) { t.Parallel() @@ -431,11 +449,21 @@ func testGetBlockBodies(t *testing.T, protocol uint) { } // Tests that the state trie nodes can be retrieved based on hashes. -func TestGetNodeData66(t *testing.T) { testGetNodeData(t, ETH66, false) } -func TestGetNodeData67(t *testing.T) { testGetNodeData(t, ETH67, true) } -func TestGetNodeData68(t *testing.T) { testGetNodeData(t, ETH68, true) } +func TestGetNodeData66(t *testing.T) { + t.Parallel() + testGetNodeData(t, ETH66, false) +} +func TestGetNodeData67(t *testing.T) { + t.Parallel() + testGetNodeData(t, ETH67, true) +} +func TestGetNodeData68(t *testing.T) { + t.Parallel() + testGetNodeData(t, ETH68, true) +} func testGetNodeData(t *testing.T, protocol uint, drop bool) { + t.Helper() t.Parallel() // Define three accounts to simulate transactions with @@ -549,9 +577,18 @@ func testGetNodeData(t *testing.T, protocol uint, drop bool) { } // Tests that the transaction receipts can be retrieved based on hashes. -func TestGetBlockReceipts66(t *testing.T) { testGetBlockReceipts(t, ETH66) } -func TestGetBlockReceipts67(t *testing.T) { testGetBlockReceipts(t, ETH67) } -func TestGetBlockReceipts68(t *testing.T) { testGetBlockReceipts(t, ETH68) } +func TestGetBlockReceipts66(t *testing.T) { + t.Parallel() + testGetBlockReceipts(t, ETH66) +} +func TestGetBlockReceipts67(t *testing.T) { + t.Parallel() + testGetBlockReceipts(t, ETH67) +} +func TestGetBlockReceipts68(t *testing.T) { + t.Parallel() + testGetBlockReceipts(t, ETH68) +} func testGetBlockReceipts(t *testing.T, protocol uint) { t.Parallel() diff --git a/eth/protocols/snap/sort_test.go b/eth/protocols/snap/sort_test.go index be0a8c5706..a6bbe2f09f 100644 --- a/eth/protocols/snap/sort_test.go +++ b/eth/protocols/snap/sort_test.go @@ -37,6 +37,8 @@ func hexToNibbles(s string) []byte { } func TestRequestSorting(t *testing.T) { + t.Parallel() + // - Path 0x9 -> {0x19} // - Path 0x99 -> {0x0099} // - Path 0x01234567890123456789012345678901012345678901234567890123456789019 -> {0x0123456789012345678901234567890101234567890123456789012345678901, 0x19} diff --git a/eth/sync_test.go b/eth/sync_test.go index 0b9f9e1bba..e0e0e0d512 100644 --- a/eth/sync_test.go +++ b/eth/sync_test.go @@ -29,8 +29,14 @@ import ( ) // Tests that snap sync is disabled after a successful sync cycle. -func TestSnapSyncDisabling66(t *testing.T) { testSnapSyncDisabling(t, eth.ETH66, snap.SNAP1) } -func TestSnapSyncDisabling67(t *testing.T) { testSnapSyncDisabling(t, eth.ETH67, snap.SNAP1) } +func TestSnapSyncDisabling66(t *testing.T) { + t.Parallel() + testSnapSyncDisabling(t, eth.ETH66, snap.SNAP1) +} +func TestSnapSyncDisabling67(t *testing.T) { + t.Parallel() + testSnapSyncDisabling(t, eth.ETH67, snap.SNAP1) +} // Tests that snap sync gets disabled as soon as a real block is successfully // imported into the blockchain. diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 0261b6b04d..fb3af662f4 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -1306,43 +1306,43 @@ func APIs(backend Backend) []rpc.API { // along with a boolean that indicates whether the copy is canonical (equivalent to the original). // Note: the Clique-part is _not_ deep copied func overrideConfig(original *params.ChainConfig, override *params.ChainConfig) (*params.ChainConfig, bool) { - copy := new(params.ChainConfig) - *copy = *original + chainConfigCopy := new(params.ChainConfig) + *chainConfigCopy = *original canon := true - // Apply forks (after Berlin) to the copy. + // Apply forks (after Berlin) to the chainConfigCopy. if block := override.BerlinBlock; block != nil { - copy.BerlinBlock = block + chainConfigCopy.BerlinBlock = block canon = false } if block := override.LondonBlock; block != nil { - copy.LondonBlock = block + chainConfigCopy.LondonBlock = block canon = false } if block := override.ArrowGlacierBlock; block != nil { - copy.ArrowGlacierBlock = block + chainConfigCopy.ArrowGlacierBlock = block canon = false } if block := override.GrayGlacierBlock; block != nil { - copy.GrayGlacierBlock = block + chainConfigCopy.GrayGlacierBlock = block canon = false } if block := override.MergeNetsplitBlock; block != nil { - copy.MergeNetsplitBlock = block + chainConfigCopy.MergeNetsplitBlock = block canon = false } if timestamp := override.ShanghaiTime; timestamp != nil { - copy.ShanghaiTime = timestamp + chainConfigCopy.ShanghaiTime = timestamp canon = false } if timestamp := override.CancunTime; timestamp != nil { - copy.CancunTime = timestamp + chainConfigCopy.CancunTime = timestamp canon = false } if timestamp := override.PragueTime; timestamp != nil { - copy.PragueTime = timestamp + chainConfigCopy.PragueTime = timestamp canon = false } - return copy, canon + return chainConfigCopy, canon } diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index 130ff77fbe..441b26f052 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -848,10 +848,10 @@ func TestTracingWithOverrides(t *testing.T) { } continue } - if err != nil { + if err != nil { t.Errorf("test %d: want no error, have %v", i, err) - continue - } + continue + } // Turn result into res-struct var ( have res @@ -910,6 +910,8 @@ func newStates(keys []common.Hash, vals []common.Hash) *map[common.Hash]common.H } func TestTraceChain(t *testing.T) { + t.Parallel() + // Initialize test accounts accounts := newAccounts(3) genesis := &core.Genesis{ diff --git a/eth/tracers/internal/tracetest/calltrace_test.go b/eth/tracers/internal/tracetest/calltrace_test.go index 037723e26c..db220e566c 100644 --- a/eth/tracers/internal/tracetest/calltrace_test.go +++ b/eth/tracers/internal/tracetest/calltrace_test.go @@ -90,6 +90,7 @@ func TestCallTracerNative(t *testing.T) { } func TestCallTracerNativeWithLog(t *testing.T) { + t.Parallel() testCallTracer("callTracer", "call_tracer_withLog", t) } @@ -261,6 +262,8 @@ func benchTracer(tracerName string, test *callTracerTest, b *testing.B) { } func TestInternals(t *testing.T) { + t.Parallel() + var ( to = common.HexToAddress("0x00000000000000000000000000000000deadbeef") origin = common.HexToAddress("0x00000000000000000000000000000000feed") diff --git a/eth/tracers/internal/tracetest/flat_calltrace_test.go b/eth/tracers/internal/tracetest/flat_calltrace_test.go index 73a74f7476..5f5a222495 100644 --- a/eth/tracers/internal/tracetest/flat_calltrace_test.go +++ b/eth/tracers/internal/tracetest/flat_calltrace_test.go @@ -71,7 +71,9 @@ type flatCallTracerTest struct { Result []flatCallTrace `json:"result"` } -func flatCallTracerTestRunner(tracerName string, filename string, dirPath string, t testing.TB) error { +func flatCallTracerTestRunner(tb testing.TB, tracerName string, filename string, dirPath string) error { + tb.Helper() + // Call tracer test found, read if from disk blob, err := os.ReadFile(filepath.Join("testdata", dirPath, filename)) if err != nil { @@ -130,21 +132,21 @@ func flatCallTracerTestRunner(tracerName string, filename string, dirPath string return fmt.Errorf("failed to unmarshal trace result: %v", err) } if !jsonEqualFlat(ret, test.Result) { - t.Logf("tracer name: %s", tracerName) + tb.Logf("tracer name: %s", tracerName) // uncomment this for easier debugging // have, _ := json.MarshalIndent(ret, "", " ") // want, _ := json.MarshalIndent(test.Result, "", " ") - // t.Logf("trace mismatch: \nhave %+v\nwant %+v", string(have), string(want)) + // tb.Logf("trace mismatch: \nhave %+v\nwant %+v", string(have), string(want)) // uncomment this for harder debugging <3 meowsbits // lines := deep.Equal(ret, test.Result) // for _, l := range lines { - // t.Logf("%s", l) - // t.FailNow() + // tb.Logf("%s", l) + // tb.FailNow() // } - t.Fatalf("trace mismatch: \nhave %+v\nwant %+v", ret, test.Result) + tb.Fatalf("trace mismatch: \nhave %+v\nwant %+v", ret, test.Result) } return nil } @@ -152,10 +154,13 @@ func flatCallTracerTestRunner(tracerName string, filename string, dirPath string // Iterates over all the input-output datasets in the tracer parity test harness and // runs the Native tracer against them. func TestFlatCallTracerNative(t *testing.T) { - testFlatCallTracer("flatCallTracer", "call_tracer_flat", t) + t.Parallel() + testFlatCallTracer(t, "flatCallTracer", "call_tracer_flat") } -func testFlatCallTracer(tracerName string, dirPath string, t *testing.T) { +func testFlatCallTracer(t *testing.T, tracerName string, dirPath string) { + t.Helper() + files, err := os.ReadDir(filepath.Join("testdata", dirPath)) if err != nil { t.Fatalf("failed to retrieve tracer test suite: %v", err) @@ -168,7 +173,7 @@ func testFlatCallTracer(tracerName string, dirPath string, t *testing.T) { t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) { t.Parallel() - err := flatCallTracerTestRunner(tracerName, file.Name(), dirPath, t) + err := flatCallTracerTestRunner(t, tracerName, file.Name(), dirPath) if err != nil { t.Fatal(err) } @@ -204,7 +209,7 @@ func BenchmarkFlatCallTracer(b *testing.B) { filename := strings.TrimPrefix(file, "testdata/call_tracer_flat/") b.Run(camel(strings.TrimSuffix(filename, ".json")), func(b *testing.B) { for n := 0; n < b.N; n++ { - err := flatCallTracerTestRunner("flatCallTracer", filename, "call_tracer_flat", b) + err := flatCallTracerTestRunner(b, "flatCallTracer", filename, "call_tracer_flat") if err != nil { b.Fatal(err) } diff --git a/eth/tracers/internal/tracetest/prestate_test.go b/eth/tracers/internal/tracetest/prestate_test.go index 7852c56957..3edc60cfa9 100644 --- a/eth/tracers/internal/tracetest/prestate_test.go +++ b/eth/tracers/internal/tracetest/prestate_test.go @@ -54,14 +54,17 @@ type testcase struct { } func TestPrestateTracerLegacy(t *testing.T) { + t.Parallel() testPrestateDiffTracer("prestateTracerLegacy", "prestate_tracer_legacy", t) } func TestPrestateTracer(t *testing.T) { + t.Parallel() testPrestateDiffTracer("prestateTracer", "prestate_tracer", t) } func TestPrestateWithDiffModeTracer(t *testing.T) { + t.Parallel() testPrestateDiffTracer("prestateTracer", "prestate_tracer_with_diff_mode", t) } diff --git a/eth/tracers/js/tracer_test.go b/eth/tracers/js/tracer_test.go index d3949b1349..75f8d54acd 100644 --- a/eth/tracers/js/tracer_test.go +++ b/eth/tracers/js/tracer_test.go @@ -289,6 +289,8 @@ func TestEnterExit(t *testing.T) { } func TestSetup(t *testing.T) { + t.Parallel() + // Test empty config _, err := newJsTracer(`{setup: function(cfg) { if (cfg !== "{}") { throw("invalid empty config") } }, fault: function() {}, result: function() {}}`, new(tracers.Context), nil) if err != nil { diff --git a/eth/tracers/logger/logger_test.go b/eth/tracers/logger/logger_test.go index 53834dfa71..6a5889aabf 100644 --- a/eth/tracers/logger/logger_test.go +++ b/eth/tracers/logger/logger_test.go @@ -78,6 +78,8 @@ func TestStoreCapture(t *testing.T) { // Tests that blank fields don't appear in logs when JSON marshalled, to reduce // logs bloat and confusion. See https://github.com/ethereum/go-ethereum/issues/24487 func TestStructLogMarshalingOmitEmpty(t *testing.T) { + t.Parallel() + tests := []struct { name string log *StructLog @@ -94,7 +96,10 @@ func TestStructLogMarshalingOmitEmpty(t *testing.T) { } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() + blob, err := json.Marshal(tt.log) if err != nil { t.Fatal(err) diff --git a/eth/tracers/tracers_test.go b/eth/tracers/tracers_test.go index a959704389..72e406ffd9 100644 --- a/eth/tracers/tracers_test.go +++ b/eth/tracers/tracers_test.go @@ -112,6 +112,8 @@ func BenchmarkTransactionTrace(b *testing.B) { } func TestMemCopying(t *testing.T) { + t.Parallel() + for i, tc := range []struct { memsize int64 offset int64 diff --git a/eth/tracers/tracker_test.go b/eth/tracers/tracker_test.go index 46f6ac8e51..f17b9a08a3 100644 --- a/eth/tracers/tracker_test.go +++ b/eth/tracers/tracker_test.go @@ -23,6 +23,8 @@ import ( ) func TestTracker(t *testing.T) { + t.Parallel() + var cases = []struct { limit int calls []uint64 @@ -118,6 +120,8 @@ func TestTracker(t *testing.T) { } func TestTrackerWait(t *testing.T) { + t.Parallel() + var ( tracker = newStateTracker(5, 0) // limit = 5, oldest = 0 result = make(chan error, 1) diff --git a/ethclient/gethclient/gethclient_test.go b/ethclient/gethclient/gethclient_test.go index bcb980b981..30812ed10e 100644 --- a/ethclient/gethclient/gethclient_test.go +++ b/ethclient/gethclient/gethclient_test.go @@ -122,10 +122,16 @@ func TestGethClient(t *testing.T) { func(t *testing.T) { testGetNodeInfo(t, client) }, }, { "TestSubscribePendingTxHashes", - func(t *testing.T) { testSubscribePendingTransactions(t, client) }, + func(t *testing.T) { + t.Helper() + testSubscribePendingTransactions(t, client) + }, }, { "TestSubscribePendingTxs", - func(t *testing.T) { testSubscribeFullPendingTransactions(t, client) }, + func(t *testing.T) { + t.Helper() + testSubscribeFullPendingTransactions(t, client) + }, }, { "TestCallContract", func(t *testing.T) { testCallContract(t, client) }, @@ -136,10 +142,16 @@ func TestGethClient(t *testing.T) { // Hence: this test should be last, execute the tests serially. { "TestAccessList", - func(t *testing.T) { testAccessList(t, client) }, + func(t *testing.T) { + t.Helper() + testAccessList(t, client) + }, }, { "TestSetHead", - func(t *testing.T) { testSetHead(t, client) }, + func(t *testing.T) { + t.Helper() + testSetHead(t, client) + }, }, } for _, tt := range tests { @@ -309,6 +321,8 @@ func testSubscribePendingTransactions(t *testing.T, client *rpc.Client) { } func testSubscribeFullPendingTransactions(t *testing.T, client *rpc.Client) { + t.Helper() + ec := New(client) ethcl := ethclient.NewClient(client) // Subscribe to Transactions @@ -367,6 +381,8 @@ func testCallContract(t *testing.T, client *rpc.Client) { } func TestOverrideAccountMarshal(t *testing.T) { + t.Parallel() + om := map[common.Address]OverrideAccount{ common.Address{0x11}: OverrideAccount{ // Zero-valued nonce is not overriddden, but simply dropped by the encoder. diff --git a/ethdb/dbtest/testsuite.go b/ethdb/dbtest/testsuite.go index e455215cb0..bd924f97d0 100644 --- a/ethdb/dbtest/testsuite.go +++ b/ethdb/dbtest/testsuite.go @@ -381,6 +381,8 @@ func TestDatabaseSuite(t *testing.T, New func() ethdb.KeyValueStore) { // BenchDatabaseSuite runs a suite of benchmarks against a KeyValueStore database // implementation. func BenchDatabaseSuite(b *testing.B, New func() ethdb.KeyValueStore) { + b.Helper() + var ( keys, vals = makeDataset(1_000_000, 32, 32, false) sKeys, sVals = makeDataset(1_000_000, 32, 32, true) @@ -388,6 +390,8 @@ func BenchDatabaseSuite(b *testing.B, New func() ethdb.KeyValueStore) { // Run benchmarks sequentially b.Run("Write", func(b *testing.B) { benchWrite := func(b *testing.B, keys, vals [][]byte) { + b.Helper() + b.ResetTimer() b.ReportAllocs() @@ -407,6 +411,8 @@ func BenchDatabaseSuite(b *testing.B, New func() ethdb.KeyValueStore) { }) b.Run("Read", func(b *testing.B) { benchRead := func(b *testing.B, keys, vals [][]byte) { + b.Helper() + db := New() defer db.Close() @@ -429,6 +435,8 @@ func BenchDatabaseSuite(b *testing.B, New func() ethdb.KeyValueStore) { }) b.Run("Iteration", func(b *testing.B) { benchIteration := func(b *testing.B, keys, vals [][]byte) { + b.Helper() + db := New() defer db.Close() @@ -452,6 +460,8 @@ func BenchDatabaseSuite(b *testing.B, New func() ethdb.KeyValueStore) { }) b.Run("BatchWrite", func(b *testing.B) { benchBatchWrite := func(b *testing.B, keys, vals [][]byte) { + b.Helper() + b.ResetTimer() b.ReportAllocs() @@ -484,9 +494,9 @@ func iterateKeys(it ethdb.Iterator) []string { } // randomHash generates a random blob of data and returns it as a hash. -func randBytes(len int) []byte { - buf := make([]byte, len) - if n, err := rand.Read(buf); n != len || err != nil { +func randBytes(length int) []byte { + buf := make([]byte, length) + if n, err := rand.Read(buf); n != length || err != nil { panic(err) } return buf diff --git a/ethdb/pebble/pebble_test.go b/ethdb/pebble/pebble_test.go index 590d5bf035..4ab40389bf 100644 --- a/ethdb/pebble/pebble_test.go +++ b/ethdb/pebble/pebble_test.go @@ -28,7 +28,10 @@ import ( ) func TestPebbleDB(t *testing.T) { + t.Parallel() + t.Run("DatabaseSuite", func(t *testing.T) { + t.Parallel() dbtest.TestDatabaseSuite(t, func() ethdb.KeyValueStore { db, err := pebble.Open("", &pebble.Options{ FS: vfs.NewMem(), diff --git a/event/feedof_test.go b/event/feedof_test.go index 846afc9ee1..a776308268 100644 --- a/event/feedof_test.go +++ b/event/feedof_test.go @@ -23,6 +23,8 @@ import ( ) func TestFeedOf(t *testing.T) { + t.Parallel() + var feed FeedOf[int] var done, subscribed sync.WaitGroup subscriber := func(i int) { @@ -71,6 +73,8 @@ func TestFeedOf(t *testing.T) { } func TestFeedOfSubscribeSameChannel(t *testing.T) { + t.Parallel() + var ( feed FeedOf[int] done sync.WaitGroup @@ -114,6 +118,8 @@ func TestFeedOfSubscribeSameChannel(t *testing.T) { } func TestFeedOfSubscribeBlockedPost(t *testing.T) { + t.Parallel() + var ( feed FeedOf[int] nsends = 2000 @@ -147,6 +153,8 @@ func TestFeedOfSubscribeBlockedPost(t *testing.T) { } func TestFeedOfUnsubscribeBlockedPost(t *testing.T) { + t.Parallel() + var ( feed FeedOf[int] nsends = 200 @@ -184,6 +192,8 @@ func TestFeedOfUnsubscribeBlockedPost(t *testing.T) { // Checks that unsubscribing a channel during Send works even if that // channel has already been sent on. func TestFeedOfUnsubscribeSentChan(t *testing.T) { + t.Parallel() + var ( feed FeedOf[int] ch1 = make(chan int) @@ -221,6 +231,8 @@ func TestFeedOfUnsubscribeSentChan(t *testing.T) { } func TestFeedOfUnsubscribeFromInbox(t *testing.T) { + t.Parallel() + var ( feed FeedOf[int] ch1 = make(chan int) diff --git a/graphql/graphql_test.go b/graphql/graphql_test.go index ff49073801..5fc5fcee83 100644 --- a/graphql/graphql_test.go +++ b/graphql/graphql_test.go @@ -272,6 +272,8 @@ func TestGraphQLHTTPOnSamePort_GQLRequest_Unsuccessful(t *testing.T) { } func TestGraphQLConcurrentResolvers(t *testing.T) { + t.Parallel() + var ( key, _ = crypto.GenerateKey() addr = crypto.PubkeyToAddress(key.PublicKey) @@ -366,6 +368,8 @@ func TestGraphQLConcurrentResolvers(t *testing.T) { } func createNode(t *testing.T) *node.Node { + t.Helper() + stack, err := node.New(&node.Config{ HTTPHost: "127.0.0.1", HTTPPort: 0, @@ -380,6 +384,8 @@ func createNode(t *testing.T) *node.Node { } func newGQLService(t *testing.T, stack *node.Node, gspec *core.Genesis, genBlocks int, genfunc func(i int, gen *core.BlockGen)) (*handler, []*types.Block) { + t.Helper() + ethConf := ðconfig.Config{ Genesis: gspec, Ethash: ethash.Config{ diff --git a/internal/ethapi/transaction_args_test.go b/internal/ethapi/transaction_args_test.go index 5f4dfc0ad5..fe2e500f4d 100644 --- a/internal/ethapi/transaction_args_test.go +++ b/internal/ethapi/transaction_args_test.go @@ -42,6 +42,8 @@ import ( // TestSetFeeDefaults tests the logic for filling in default fee values works as expected. func TestSetFeeDefaults(t *testing.T) { + t.Parallel() + type test struct { name string isLondon bool @@ -345,41 +347,51 @@ func (b *backendMock) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) func (b *backendMock) Engine() consensus.Engine { return nil } func (b *backendMock) RPCRpcReturnDataLimit() uint64 { + //nolint: staticcheck return b.RPCRpcReturnDataLimit() } func (b *backendMock) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription { + //nolint: staticcheck return b.SubscribeStateSyncEvent(ch) } func (b *backendMock) GetRootHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64) (string, error) { + //nolint: staticcheck return b.GetRootHash(ctx, starBlockNr, endBlockNr) } func (b *backendMock) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) { + //nolint: staticcheck return b.GetBorBlockReceipt(ctx, hash) } func (b *backendMock) GetBorBlockLogs(ctx context.Context, hash common.Hash) ([]*types.Log, error) { + //nolint: staticcheck return b.GetBorBlockLogs(ctx, hash) } func (b *backendMock) GetBorBlockTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) { + //nolint: staticcheck return b.GetBorBlockTransaction(ctx, txHash) } func (b *backendMock) GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) { + //nolint: staticcheck return b.GetBorBlockTransactionWithBlockHash(ctx, txHash, blockHash) } func (b *backendMock) SubscribeChain2HeadEvent(ch chan<- core.Chain2HeadEvent) event.Subscription { + //nolint: staticcheck return b.SubscribeChain2HeadEvent(ch) } func (b *backendMock) GetCheckpointWhitelist() map[uint64]common.Hash { + //nolint: staticcheck return b.GetCheckpointWhitelist() } func (b *backendMock) PurgeCheckpointWhitelist() { + //nolint: staticcheck b.PurgeCheckpointWhitelist() } diff --git a/internal/flags/flags_test.go b/internal/flags/flags_test.go index 681586b46c..3fe92c84cc 100644 --- a/internal/flags/flags_test.go +++ b/internal/flags/flags_test.go @@ -17,13 +17,14 @@ package flags import ( - "os" "os/user" "runtime" "testing" ) func TestPathExpansion(t *testing.T) { + t.Parallel() + user, _ := user.Current() var tests map[string]string @@ -51,7 +52,7 @@ func TestPathExpansion(t *testing.T) { } } - os.Setenv(`DDDXXX`, `/tmp`) + t.Setenv(`DDDXXX`, `/tmp`) for test, expected := range tests { got := expandPath(test) if got != expected { diff --git a/internal/jsre/jsre_test.go b/internal/jsre/jsre_test.go index bb4ff5fa4f..60fdb12720 100644 --- a/internal/jsre/jsre_test.go +++ b/internal/jsre/jsre_test.go @@ -40,6 +40,8 @@ func (no *testNativeObjectBinding) TestMethod(call goja.FunctionCall) goja.Value } func newWithTestJS(t *testing.T, testjs string) *JSRE { + t.Helper() + dir := t.TempDir() if testjs != "" { if err := os.WriteFile(path.Join(dir, "test.js"), []byte(testjs), os.ModePerm); err != nil { diff --git a/internal/version/version.go b/internal/version/version.go index 0daea02b57..e044deee5c 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -58,6 +58,7 @@ func VCS() (VCSInfo, bool) { func ClientName(clientIdentifier string) string { git, _ := VCS() return fmt.Sprintf("%s/v%v/%v-%v/%v", + //nolint: staticcheck strings.Title(clientIdentifier), params.VersionWithCommit(git.Commit, git.Date), runtime.GOOS, runtime.GOARCH, diff --git a/les/downloader/api.go b/les/downloader/api.go index 21200b676c..caab5a0da2 100644 --- a/les/downloader/api.go +++ b/les/downloader/api.go @@ -38,6 +38,7 @@ type DownloaderAPI struct { // listens for events from the downloader through the global event mux. In case it receives one of // these events it broadcasts it to all syncing subscriptions that are installed through the // installSyncSubscription channel. +// nolint: staticcheck func NewDownloaderAPI(d *Downloader, m *event.TypeMux) *DownloaderAPI { api := &DownloaderAPI{ d: d, diff --git a/les/flowcontrol/manager_test.go b/les/flowcontrol/manager_test.go index 3afc31272f..059bbbec3d 100644 --- a/les/flowcontrol/manager_test.go +++ b/les/flowcontrol/manager_test.go @@ -56,6 +56,8 @@ func TestConstantTotalCapacity(t *testing.T) { } func testConstantTotalCapacity(t *testing.T, nodeCount, maxCapacityNodes, randomSend int, priorityOverflow bool) { + t.Helper() + clock := &mclock.Simulated{} nodes := make([]*testNode, nodeCount) var totalCapacity uint64 diff --git a/les/ulc_test.go b/les/ulc_test.go index 9a29a24cee..d304674fb1 100644 --- a/les/ulc_test.go +++ b/les/ulc_test.go @@ -38,6 +38,8 @@ func testULCAnnounceThreshold(t *testing.T, protocol int) { // newTestLightPeer creates node with light sync mode newTestLightPeer := func(t *testing.T, protocol int, ulcServers []string, ulcFraction int) (*testClient, func()) { + t.Helper() + netconfig := testnetConfig{ protocol: protocol, ulcServers: ulcServers, @@ -146,6 +148,8 @@ func connect(server *serverHandler, serverId enode.ID, client *clientHandler, pr // newTestServerPeer creates server peer. func newTestServerPeer(t *testing.T, blocks int, protocol int, indexFn indexerCallback) (*testServer, *enode.Node, func()) { + t.Helper() + netconfig := testnetConfig{ blocks: blocks, protocol: protocol, diff --git a/les/vflux/server/balance_test.go b/les/vflux/server/balance_test.go index 7c100aab50..12a24a09fa 100644 --- a/les/vflux/server/balance_test.go +++ b/les/vflux/server/balance_test.go @@ -299,6 +299,7 @@ func TestEstimatedPriority(t *testing.T) { } func TestPositiveBalanceCounting(t *testing.T) { + t.Parallel() b := newBalanceTestSetup(nil, nil, nil) defer b.stop() diff --git a/log/format_test.go b/log/format_test.go index e08c1d1a4a..63811dd8e8 100644 --- a/log/format_test.go +++ b/log/format_test.go @@ -83,6 +83,8 @@ func TestPrettyBigInt(t *testing.T) { } func TestPrettyUint256(t *testing.T) { + t.Parallel() + tests := []struct { int string s string @@ -117,6 +119,8 @@ func BenchmarkPrettyUint64Logfmt(b *testing.B) { } func TestSanitation(t *testing.T) { + t.Parallel() + msg := "\u001b[1G\u001b[K\u001b[1A" msg2 := "\u001b \u0000" msg3 := "NiceMessage" diff --git a/metrics/counter_float_64_test.go b/metrics/counter_float_64_test.go index f17aca330c..c07ed4b33e 100644 --- a/metrics/counter_float_64_test.go +++ b/metrics/counter_float_64_test.go @@ -33,6 +33,7 @@ func BenchmarkCounterFloat64Parallel(b *testing.B) { } func TestCounterFloat64Clear(t *testing.T) { + t.Parallel() c := NewCounterFloat64() c.Inc(1.0) c.Clear() @@ -42,6 +43,7 @@ func TestCounterFloat64Clear(t *testing.T) { } func TestCounterFloat64Dec1(t *testing.T) { + t.Parallel() c := NewCounterFloat64() c.Dec(1.0) if count := c.Count(); count != -1.0 { @@ -50,6 +52,7 @@ func TestCounterFloat64Dec1(t *testing.T) { } func TestCounterFloat64Dec2(t *testing.T) { + t.Parallel() c := NewCounterFloat64() c.Dec(2.0) if count := c.Count(); count != -2.0 { @@ -58,6 +61,7 @@ func TestCounterFloat64Dec2(t *testing.T) { } func TestCounterFloat64Inc1(t *testing.T) { + t.Parallel() c := NewCounterFloat64() c.Inc(1.0) if count := c.Count(); count != 1.0 { @@ -66,6 +70,7 @@ func TestCounterFloat64Inc1(t *testing.T) { } func TestCounterFloat64Inc2(t *testing.T) { + t.Parallel() c := NewCounterFloat64() c.Inc(2.0) if count := c.Count(); count != 2.0 { @@ -74,6 +79,7 @@ func TestCounterFloat64Inc2(t *testing.T) { } func TestCounterFloat64Snapshot(t *testing.T) { + t.Parallel() c := NewCounterFloat64() c.Inc(1.0) snapshot := c.Snapshot() @@ -84,6 +90,7 @@ func TestCounterFloat64Snapshot(t *testing.T) { } func TestCounterFloat64Zero(t *testing.T) { + t.Parallel() c := NewCounterFloat64() if count := c.Count(); count != 0 { t.Errorf("c.Count(): 0 != %v\n", count) @@ -91,6 +98,7 @@ func TestCounterFloat64Zero(t *testing.T) { } func TestGetOrRegisterCounterFloat64(t *testing.T) { + t.Parallel() r := NewRegistry() NewRegisteredCounterFloat64("foo", r).Inc(47.0) if c := GetOrRegisterCounterFloat64("foo", r); c.Count() != 47.0 { diff --git a/metrics/metrics_test.go b/metrics/metrics_test.go index 534c44139b..1af0fa9217 100644 --- a/metrics/metrics_test.go +++ b/metrics/metrics_test.go @@ -10,6 +10,7 @@ import ( const FANOUT = 128 func TestReadRuntimeValues(t *testing.T) { + t.Parallel() var v runtimeStats readRuntimeStats(&v) t.Logf("%+v", v) diff --git a/metrics/runtimehistogram_test.go b/metrics/runtimehistogram_test.go index d53a014383..88e6f9da08 100644 --- a/metrics/runtimehistogram_test.go +++ b/metrics/runtimehistogram_test.go @@ -26,6 +26,7 @@ type runtimeHistogramTest struct { // This test checks the results of statistical functions implemented // by runtimeHistogramSnapshot. func TestRuntimeHistogramStats(t *testing.T) { + t.Parallel() tests := []runtimeHistogramTest{ 0: { h: metrics.Float64Histogram{ @@ -73,7 +74,10 @@ func TestRuntimeHistogramStats(t *testing.T) { } for i, test := range tests { + i, test := i, test + t.Run(fmt.Sprint(i), func(t *testing.T) { + t.Parallel() s := runtimeHistogramSnapshot(test.h) if v := s.Count(); v != test.Count { @@ -121,6 +125,7 @@ func approxEqual(x, y, ε float64) bool { // This test verifies that requesting Percentiles in unsorted order // returns them in the requested order. func TestRuntimeHistogramStatsPercentileOrder(t *testing.T) { + t.Parallel() p := runtimeHistogramSnapshot{ Counts: []uint64{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, Buckets: []float64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, diff --git a/node/api_test.go b/node/api_test.go index 8761c4883e..7a967afdbf 100644 --- a/node/api_test.go +++ b/node/api_test.go @@ -49,6 +49,7 @@ func TestStartRPC(t *testing.T) { name: "all off", cfg: Config{}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() }, wantReachable: false, wantHandlers: false, @@ -59,6 +60,7 @@ func TestStartRPC(t *testing.T) { name: "rpc enabled through config", cfg: Config{HTTPHost: "127.0.0.1"}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() }, wantReachable: true, wantHandlers: true, @@ -69,6 +71,8 @@ func TestStartRPC(t *testing.T) { name: "rpc enabled through API", cfg: Config{}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + _, err := api.StartHTTP(sp("127.0.0.1"), ip(0), nil, nil, nil) assert.NoError(t, err) }, @@ -81,6 +85,8 @@ func TestStartRPC(t *testing.T) { name: "rpc start again after failure", cfg: Config{}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + // Listen on a random port. listener, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { @@ -109,6 +115,8 @@ func TestStartRPC(t *testing.T) { name: "rpc stopped through API", cfg: Config{HTTPHost: "127.0.0.1"}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + _, err := api.StopHTTP() assert.NoError(t, err) }, @@ -121,6 +129,8 @@ func TestStartRPC(t *testing.T) { name: "rpc stopped twice", cfg: Config{HTTPHost: "127.0.0.1"}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + _, err := api.StopHTTP() assert.NoError(t, err) @@ -144,6 +154,8 @@ func TestStartRPC(t *testing.T) { name: "ws enabled through API", cfg: Config{}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + _, err := api.StartWS(sp("127.0.0.1"), ip(0), nil, nil) assert.NoError(t, err) }, @@ -156,6 +168,8 @@ func TestStartRPC(t *testing.T) { name: "ws stopped through API", cfg: Config{WSHost: "127.0.0.1"}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + _, err := api.StopWS() assert.NoError(t, err) }, @@ -168,6 +182,8 @@ func TestStartRPC(t *testing.T) { name: "ws stopped twice", cfg: Config{WSHost: "127.0.0.1"}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + _, err := api.StopWS() assert.NoError(t, err) @@ -183,6 +199,8 @@ func TestStartRPC(t *testing.T) { name: "ws enabled after RPC", cfg: Config{HTTPHost: "127.0.0.1"}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + wsport := n.http.port _, err := api.StartWS(sp("127.0.0.1"), ip(wsport), nil, nil) assert.NoError(t, err) @@ -196,6 +214,8 @@ func TestStartRPC(t *testing.T) { name: "ws enabled after RPC then stopped", cfg: Config{HTTPHost: "127.0.0.1"}, fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + wsport := n.http.port _, err := api.StartWS(sp("127.0.0.1"), ip(wsport), nil, nil) assert.NoError(t, err) @@ -211,6 +231,8 @@ func TestStartRPC(t *testing.T) { { name: "rpc stopped with ws enabled", fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + _, err := api.StartHTTP(sp("127.0.0.1"), ip(0), nil, nil, nil) assert.NoError(t, err) @@ -229,6 +251,8 @@ func TestStartRPC(t *testing.T) { { name: "rpc enabled after ws", fn: func(t *testing.T, n *Node, api *adminAPI) { + t.Helper() + _, err := api.StartWS(sp("127.0.0.1"), ip(0), nil, nil) assert.NoError(t, err) diff --git a/node/node_auth_test.go b/node/node_auth_test.go index 597cd8531f..b558cf5ac7 100644 --- a/node/node_auth_test.go +++ b/node/node_auth_test.go @@ -92,7 +92,10 @@ func (at *authTest) Run(t *testing.T) { } } +// nolint: tparallel, paralleltest func TestAuthEndpoints(t *testing.T) { + t.Parallel() + var secret [32]byte if _, err := crand.Read(secret[:]); err != nil { t.Fatalf("failed to create jwt secret: %v", err) @@ -193,6 +196,7 @@ func TestAuthEndpoints(t *testing.T) { } for _, testCase := range testCases { + t.Parallel() t.Run(testCase.name, testCase.Run) } } diff --git a/node/rpcstack_test.go b/node/rpcstack_test.go index 6eeb609395..672fd9fb95 100644 --- a/node/rpcstack_test.go +++ b/node/rpcstack_test.go @@ -281,6 +281,8 @@ func rpcRequest(t *testing.T, url, method string, extraHeaders ...string) *http. } func batchRpcRequest(t *testing.T, url string, methods []string, extraHeaders ...string) *http.Response { + t.Helper() + reqs := make([]string, len(methods)) for i, m := range methods { reqs[i] = fmt.Sprintf(`{"jsonrpc":"2.0","id":1,"method":"%s","params":[]}`, m) @@ -448,6 +450,8 @@ func TestJWT(t *testing.T) { } func TestGzipHandler(t *testing.T) { + t.Parallel() + type gzipTest struct { name string handler http.HandlerFunc @@ -522,6 +526,7 @@ func TestGzipHandler(t *testing.T) { for _, test := range tests { test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() srv := httptest.NewServer(newGzipHandler(test.handler)) defer srv.Close() @@ -556,6 +561,8 @@ func TestGzipHandler(t *testing.T) { } func TestHTTPWriteTimeout(t *testing.T) { + t.Parallel() + const ( timeoutRes = `{"jsonrpc":"2.0","id":1,"error":{"code":-32002,"message":"request timed out"}}` greetRes = `{"jsonrpc":"2.0","id":1,"result":"Hello"}` @@ -568,6 +575,7 @@ func TestHTTPWriteTimeout(t *testing.T) { // Send normal request t.Run("message", func(t *testing.T) { + t.Parallel() resp := rpcRequest(t, url, "test_sleep") defer resp.Body.Close() body, err := io.ReadAll(resp.Body) @@ -581,6 +589,7 @@ func TestHTTPWriteTimeout(t *testing.T) { // Batch request t.Run("batch", func(t *testing.T) { + t.Parallel() want := fmt.Sprintf("[%s,%s,%s]", greetRes, timeoutRes, timeoutRes) resp := batchRpcRequest(t, url, []string{"test_greet", "test_sleep", "test_greet"}) defer resp.Body.Close() diff --git a/p2p/discover/table_test.go b/p2p/discover/table_test.go index 1ef63fe010..747bddad6a 100644 --- a/p2p/discover/table_test.go +++ b/p2p/discover/table_test.go @@ -397,6 +397,7 @@ func TestTable_revalidateSyncRecord(t *testing.T) { } func TestNodesPush(t *testing.T) { + t.Parallel() var target enode.ID n1 := nodeAtDistance(target, 255, intIP(1)) n2 := nodeAtDistance(target, 254, intIP(2)) diff --git a/p2p/discover/v5_udp_test.go b/p2p/discover/v5_udp_test.go index 59e126bcfa..727ec11fd5 100644 --- a/p2p/discover/v5_udp_test.go +++ b/p2p/discover/v5_udp_test.go @@ -519,34 +519,40 @@ func TestUDPv5_talkRequest(t *testing.T) { // This test checks that lookupDistances works. func TestUDPv5_lookupDistances(t *testing.T) { + t.Parallel() test := newUDPV5Test(t) lnID := test.table.self().ID() t.Run("target distance of 1", func(t *testing.T) { + t.Parallel() node := nodeAtDistance(lnID, 1, intIP(0)) dists := lookupDistances(lnID, node.ID()) require.Equal(t, []uint{1, 2, 3}, dists) }) t.Run("target distance of 2", func(t *testing.T) { + t.Parallel() node := nodeAtDistance(lnID, 2, intIP(0)) dists := lookupDistances(lnID, node.ID()) require.Equal(t, []uint{2, 3, 1}, dists) }) t.Run("target distance of 128", func(t *testing.T) { + t.Parallel() node := nodeAtDistance(lnID, 128, intIP(0)) dists := lookupDistances(lnID, node.ID()) require.Equal(t, []uint{128, 129, 127}, dists) }) t.Run("target distance of 255", func(t *testing.T) { + t.Parallel() node := nodeAtDistance(lnID, 255, intIP(0)) dists := lookupDistances(lnID, node.ID()) require.Equal(t, []uint{255, 256, 254}, dists) }) t.Run("target distance of 256", func(t *testing.T) { + t.Parallel() node := nodeAtDistance(lnID, 256, intIP(0)) dists := lookupDistances(lnID, node.ID()) require.Equal(t, []uint{256, 255, 254}, dists) diff --git a/p2p/enr/enr_test.go b/p2p/enr/enr_test.go index b85ee209d5..dec181ce5f 100644 --- a/p2p/enr/enr_test.go +++ b/p2p/enr/enr_test.go @@ -170,6 +170,7 @@ func TestDirty(t *testing.T) { } func TestSize(t *testing.T) { + t.Parallel() var r Record // Empty record size is 3 bytes. diff --git a/params/config_test.go b/params/config_test.go index 5634569e29..57ae6d4def 100644 --- a/params/config_test.go +++ b/params/config_test.go @@ -120,6 +120,8 @@ func TestCheckCompatible(t *testing.T) { } func TestConfigRules(t *testing.T) { + t.Parallel() + c := &ChainConfig{ ShanghaiTime: newUint64(500), } diff --git a/rlp/raw_test.go b/rlp/raw_test.go index 7b3255eca3..3b4a528152 100644 --- a/rlp/raw_test.go +++ b/rlp/raw_test.go @@ -61,6 +61,8 @@ func TestCountValues(t *testing.T) { } func TestSplitString(t *testing.T) { + t.Parallel() + for i, test := range []string{ "C0", "C100", @@ -75,6 +77,8 @@ func TestSplitString(t *testing.T) { } func TestSplitList(t *testing.T) { + t.Parallel() + for i, test := range []string{ "80", "00", @@ -305,6 +309,8 @@ func TestAppendUint64Random(t *testing.T) { } func TestBytesSize(t *testing.T) { + t.Parallel() + tests := []struct { v []byte size uint64 diff --git a/rpc/client_test.go b/rpc/client_test.go index 08e24f3154..c792bef82e 100644 --- a/rpc/client_test.go +++ b/rpc/client_test.go @@ -74,6 +74,8 @@ func TestClientResponseType(t *testing.T) { // This test checks calling a method that returns 'null'. func TestClientNullResponse(t *testing.T) { + t.Parallel() + server := newTestServer() defer server.Stop() @@ -172,7 +174,10 @@ func TestClientBatchRequest(t *testing.T) { } } +// nolint: tparallel func TestClientBatchRequest_len(t *testing.T) { + t.Parallel() + b, err := json.Marshal([]jsonrpcMessage{ {Version: "2.0", ID: json.RawMessage("1"), Method: "foo", Result: json.RawMessage(`"0x1"`)}, {Version: "2.0", ID: json.RawMessage("2"), Method: "bar", Result: json.RawMessage(`"0x2"`)}, @@ -195,6 +200,8 @@ func TestClientBatchRequest_len(t *testing.T) { defer client.Close() t.Run("too-few", func(t *testing.T) { + t.Parallel() + batch := []BatchElem{ {Method: "foo"}, {Method: "bar"}, @@ -208,6 +215,8 @@ func TestClientBatchRequest_len(t *testing.T) { }) t.Run("too-many", func(t *testing.T) { + t.Parallel() + batch := []BatchElem{ {Method: "foo"}, } diff --git a/rpc/http_test.go b/rpc/http_test.go index 88cf5496f8..fba1a40f0d 100644 --- a/rpc/http_test.go +++ b/rpc/http_test.go @@ -203,6 +203,8 @@ func TestHTTPPeerInfo(t *testing.T) { } func TestNewContextWithHeaders(t *testing.T) { + t.Parallel() + expectedHeaders := 0 server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { for i := 0; i < expectedHeaders; i++ { diff --git a/signer/core/apitypes/signed_data_internal_test.go b/signer/core/apitypes/signed_data_internal_test.go index af7fc93ed8..266bb98fce 100644 --- a/signer/core/apitypes/signed_data_internal_test.go +++ b/signer/core/apitypes/signed_data_internal_test.go @@ -87,6 +87,8 @@ func TestBytesPadding(t *testing.T) { } func TestParseAddress(t *testing.T) { + t.Parallel() + tests := []struct { Input interface{} Output []byte // nil => error @@ -200,6 +202,8 @@ func TestParseInteger(t *testing.T) { } func TestConvertStringDataToSlice(t *testing.T) { + t.Parallel() + slice := []string{"a", "b", "c"} var it interface{} = slice _, err := convertDataToSlice(it) @@ -209,6 +213,8 @@ func TestConvertStringDataToSlice(t *testing.T) { } func TestConvertUint256DataToSlice(t *testing.T) { + t.Parallel() + slice := []*math.HexOrDecimal256{ math.NewHexOrDecimal256(1), math.NewHexOrDecimal256(2), @@ -222,6 +228,8 @@ func TestConvertUint256DataToSlice(t *testing.T) { } func TestConvertAddressDataToSlice(t *testing.T) { + t.Parallel() + slice := []common.Address{ common.HexToAddress("0x0000000000000000000000000000000000000001"), common.HexToAddress("0x0000000000000000000000000000000000000002"), diff --git a/signer/core/apitypes/types_test.go b/signer/core/apitypes/types_test.go index eef3cae00c..15438db1d7 100644 --- a/signer/core/apitypes/types_test.go +++ b/signer/core/apitypes/types_test.go @@ -19,6 +19,8 @@ package apitypes import "testing" func TestIsPrimitive(t *testing.T) { + t.Parallel() + // Expected positives for i, tc := range []string{ "int24", "int24[]", "uint88", "uint88[]", "uint", "uint[]", "int256", "int256[]", diff --git a/signer/core/signed_data_test.go b/signer/core/signed_data_test.go index 3e3837cae2..69ca198420 100644 --- a/signer/core/signed_data_test.go +++ b/signer/core/signed_data_test.go @@ -829,6 +829,8 @@ func TestComplexTypedData(t *testing.T) { } func TestGnosisSafe(t *testing.T) { + t.Parallel() + // json missing chain id js := "{\n \"safe\": \"0x899FcB1437DE65DC6315f5a69C017dd3F2837557\",\n \"to\": \"0x899FcB1437DE65DC6315f5a69C017dd3F2837557\",\n \"value\": \"0\",\n \"data\": \"0x0d582f13000000000000000000000000d3ed2b8756b942c98c851722f3bd507a17b4745f0000000000000000000000000000000000000000000000000000000000000005\",\n \"operation\": 0,\n \"gasToken\": \"0x0000000000000000000000000000000000000000\",\n \"safeTxGas\": 0,\n \"baseGas\": 0,\n \"gasPrice\": \"0\",\n \"refundReceiver\": \"0x0000000000000000000000000000000000000000\",\n \"nonce\": 0,\n \"executionDate\": null,\n \"submissionDate\": \"2022-02-23T14:09:00.018475Z\",\n \"modified\": \"2022-12-01T15:52:21.214357Z\",\n \"blockNumber\": null,\n \"transactionHash\": null,\n \"safeTxHash\": \"0x6f0f5cffee69087c9d2471e477a63cab2ae171cf433e754315d558d8836274f4\",\n \"executor\": null,\n \"isExecuted\": false,\n \"isSuccessful\": null,\n \"ethGasPrice\": null,\n \"maxFeePerGas\": null,\n \"maxPriorityFeePerGas\": null,\n \"gasUsed\": null,\n \"fee\": null,\n \"origin\": \"https://gnosis-safe.io\",\n \"dataDecoded\": {\n \"method\": \"addOwnerWithThreshold\",\n \"parameters\": [\n {\n \"name\": \"owner\",\n \"type\": \"address\",\n \"value\": \"0xD3Ed2b8756b942c98c851722F3bd507a17B4745F\"\n },\n {\n \"name\": \"_threshold\",\n \"type\": \"uint256\",\n \"value\": \"5\"\n }\n ]\n },\n \"confirmationsRequired\": 4,\n \"confirmations\": [\n {\n \"owner\": \"0x30B714E065B879F5c042A75Bb40a220A0BE27966\",\n \"submissionDate\": \"2022-03-01T14:56:22Z\",\n \"transactionHash\": \"0x6d0a9c83ac7578ef3be1f2afce089fb83b619583dfa779b82f4422fd64ff3ee9\",\n \"signature\": \"0x00000000000000000000000030b714e065b879f5c042a75bb40a220a0be27966000000000000000000000000000000000000000000000000000000000000000001\",\n \"signatureType\": \"APPROVED_HASH\"\n },\n {\n \"owner\": \"0x8300dFEa25Da0eb744fC0D98c23283F86AB8c10C\",\n \"submissionDate\": \"2022-12-01T15:52:21.214357Z\",\n \"transactionHash\": null,\n \"signature\": \"0xbce73de4cc6ee208e933a93c794dcb8ba1810f9848d1eec416b7be4dae9854c07dbf1720e60bbd310d2159197a380c941cfdb55b3ce58f9dd69efd395d7bef881b\",\n \"signatureType\": \"EOA\"\n }\n ],\n \"trusted\": true,\n \"signatures\": null\n}\n" var gnosisTx core.GnosisSafeTx @@ -984,6 +986,8 @@ var complexTypedDataLCRefType = ` ` func TestComplexTypedDataWithLowercaseReftype(t *testing.T) { + t.Parallel() + var td apitypes.TypedData err := json.Unmarshal([]byte(complexTypedDataLCRefType), &td) if err != nil { diff --git a/trie/secure_trie_test.go b/trie/secure_trie_test.go index a55c10a60b..469dba681e 100644 --- a/trie/secure_trie_test.go +++ b/trie/secure_trie_test.go @@ -110,6 +110,8 @@ func TestSecureGetKey(t *testing.T) { } func TestStateTrieConcurrency(t *testing.T) { + t.Parallel() + // Create an initial trie and copy if for concurrent access _, trie, _ := makeTestStateTrie() diff --git a/trie/tracer_test.go b/trie/tracer_test.go index 1b9f441084..ec89c6622a 100644 --- a/trie/tracer_test.go +++ b/trie/tracer_test.go @@ -51,6 +51,7 @@ var ( ) func TestTrieTracer(t *testing.T) { + t.Parallel() testTrieTracer(t, tiny) testTrieTracer(t, nonAligned) testTrieTracer(t, standard) @@ -59,6 +60,8 @@ func TestTrieTracer(t *testing.T) { // Tests if the trie diffs are tracked correctly. Tracer should capture // all non-leaf dirty nodes, no matter the node is embedded or not. func testTrieTracer(t *testing.T, vals []struct{ k, v string }) { + t.Helper() + db := NewDatabase(rawdb.NewMemoryDatabase()) trie := NewEmpty(db) @@ -96,12 +99,15 @@ func testTrieTracer(t *testing.T, vals []struct{ k, v string }) { // Test that after inserting a new batch of nodes and deleting them immediately, // the trie tracer should be cleared normally as no operation happened. func TestTrieTracerNoop(t *testing.T) { + t.Parallel() testTrieTracerNoop(t, tiny) testTrieTracerNoop(t, nonAligned) testTrieTracerNoop(t, standard) } func testTrieTracerNoop(t *testing.T, vals []struct{ k, v string }) { + t.Helper() + trie := NewEmpty(NewDatabase(rawdb.NewMemoryDatabase())) for _, val := range vals { trie.MustUpdate([]byte(val.k), []byte(val.v)) @@ -119,12 +125,15 @@ func testTrieTracerNoop(t *testing.T, vals []struct{ k, v string }) { // Tests if the accessList is correctly tracked. func TestAccessList(t *testing.T) { + t.Parallel() testAccessList(t, tiny) testAccessList(t, nonAligned) testAccessList(t, standard) } func testAccessList(t *testing.T, vals []struct{ k, v string }) { + t.Helper() + var ( db = NewDatabase(rawdb.NewMemoryDatabase()) trie = NewEmpty(db) @@ -204,6 +213,7 @@ func testAccessList(t *testing.T, vals []struct{ k, v string }) { // Tests origin values won't be tracked in Iterator or Prover func TestAccessListLeak(t *testing.T) { + t.Parallel() var ( db = NewDatabase(rawdb.NewMemoryDatabase()) trie = NewEmpty(db) @@ -255,6 +265,7 @@ func TestAccessListLeak(t *testing.T) { // Tests whether the original tree node is correctly deleted after being embedded // in its parent due to the smaller size of the original tree node. func TestTinyTree(t *testing.T) { + t.Parallel() var ( db = NewDatabase(rawdb.NewMemoryDatabase()) trie = NewEmpty(db) diff --git a/trie/trie_test.go b/trie/trie_test.go index 82ead8b441..a73e8b9380 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -402,8 +402,8 @@ func (randTest) Generate(r *rand.Rand, size int) reflect.Value { return reflect.ValueOf(steps) } -func verifyAccessList(old *Trie, new *Trie, set *NodeSet) error { - deletes, inserts, updates := diffTries(old, new) +func verifyAccessList(oldTrie *Trie, newTrie *Trie, set *NodeSet) error { + deletes, inserts, updates := diffTries(oldTrie, newTrie) // Check insertion set for path := range inserts { @@ -590,6 +590,8 @@ func BenchmarkUpdateLE(b *testing.B) { benchUpdate(b, binary.LittleEndian) } const benchElemCount = 20000 func benchGet(b *testing.B) { + b.Helper() + triedb := NewDatabase(rawdb.NewMemoryDatabase()) trie := NewEmpty(triedb) k := make([]byte, 32) @@ -666,6 +668,8 @@ func BenchmarkCommitAfterHash(b *testing.B) { } func benchmarkCommitAfterHash(b *testing.B, collectLeaf bool) { + b.Helper() + // Make the random benchmark deterministic addresses, accounts := makeAccounts(b.N) trie := NewEmpty(NewDatabase(rawdb.NewMemoryDatabase()))