Skip to content

Commit b9504e4

Browse files
authored
miner: run tests in parallel (#28506)
Changes many of the tests in the miner package to run in parallel
1 parent 2814ee0 commit b9504e4

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

miner/miner_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func (bc *testBlockChain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent)
9999
}
100100

101101
func TestMiner(t *testing.T) {
102+
t.Parallel()
102103
miner, mux, cleanup := createMiner(t)
103104
defer cleanup(false)
104105

@@ -128,6 +129,7 @@ func TestMiner(t *testing.T) {
128129
// An initial FailedEvent should allow mining to stop on a subsequent
129130
// downloader StartEvent.
130131
func TestMinerDownloaderFirstFails(t *testing.T) {
132+
t.Parallel()
131133
miner, mux, cleanup := createMiner(t)
132134
defer cleanup(false)
133135

@@ -161,6 +163,7 @@ func TestMinerDownloaderFirstFails(t *testing.T) {
161163
}
162164

163165
func TestMinerStartStopAfterDownloaderEvents(t *testing.T) {
166+
t.Parallel()
164167
miner, mux, cleanup := createMiner(t)
165168
defer cleanup(false)
166169

@@ -185,6 +188,7 @@ func TestMinerStartStopAfterDownloaderEvents(t *testing.T) {
185188
}
186189

187190
func TestStartWhileDownload(t *testing.T) {
191+
t.Parallel()
188192
miner, mux, cleanup := createMiner(t)
189193
defer cleanup(false)
190194
waitForMiningState(t, miner, false)
@@ -199,6 +203,7 @@ func TestStartWhileDownload(t *testing.T) {
199203
}
200204

201205
func TestStartStopMiner(t *testing.T) {
206+
t.Parallel()
202207
miner, _, cleanup := createMiner(t)
203208
defer cleanup(false)
204209
waitForMiningState(t, miner, false)
@@ -209,6 +214,7 @@ func TestStartStopMiner(t *testing.T) {
209214
}
210215

211216
func TestCloseMiner(t *testing.T) {
217+
t.Parallel()
212218
miner, _, cleanup := createMiner(t)
213219
defer cleanup(true)
214220
waitForMiningState(t, miner, false)
@@ -222,6 +228,7 @@ func TestCloseMiner(t *testing.T) {
222228
// TestMinerSetEtherbase checks that etherbase becomes set even if mining isn't
223229
// possible at the moment
224230
func TestMinerSetEtherbase(t *testing.T) {
231+
t.Parallel()
225232
miner, mux, cleanup := createMiner(t)
226233
defer cleanup(false)
227234
miner.Start()

miner/ordering_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ import (
3030
)
3131

3232
func TestTransactionPriceNonceSortLegacy(t *testing.T) {
33+
t.Parallel()
3334
testTransactionPriceNonceSort(t, nil)
3435
}
3536

3637
func TestTransactionPriceNonceSort1559(t *testing.T) {
38+
t.Parallel()
3739
testTransactionPriceNonceSort(t, big.NewInt(0))
3840
testTransactionPriceNonceSort(t, big.NewInt(5))
3941
testTransactionPriceNonceSort(t, big.NewInt(50))
@@ -138,6 +140,7 @@ func testTransactionPriceNonceSort(t *testing.T, baseFee *big.Int) {
138140
// Tests that if multiple transactions have the same price, the ones seen earlier
139141
// are prioritized to avoid network spam attacks aiming for a specific ordering.
140142
func TestTransactionTimeSort(t *testing.T) {
143+
t.Parallel()
141144
// Generate a batch of accounts to start with
142145
keys := make([]*ecdsa.PrivateKey, 5)
143146
for i := 0; i < len(keys); i++ {

miner/payload_building_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
)
3131

3232
func TestBuildPayload(t *testing.T) {
33+
t.Parallel()
3334
var (
3435
db = rawdb.NewMemoryDatabase()
3536
recipient = common.HexToAddress("0xdeadbeef")
@@ -82,6 +83,7 @@ func TestBuildPayload(t *testing.T) {
8283
}
8384

8485
func TestPayloadId(t *testing.T) {
86+
t.Parallel()
8587
ids := make(map[string]int)
8688
for i, tt := range []*BuildPayloadArgs{
8789
{

miner/worker_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func newTestWorker(t *testing.T, chainConfig *params.ChainConfig, engine consens
167167
}
168168

169169
func TestGenerateAndImportBlock(t *testing.T) {
170+
t.Parallel()
170171
var (
171172
db = rawdb.NewMemoryDatabase()
172173
config = *params.AllCliqueProtocolChanges
@@ -210,9 +211,11 @@ func TestGenerateAndImportBlock(t *testing.T) {
210211
}
211212

212213
func TestEmptyWorkEthash(t *testing.T) {
214+
t.Parallel()
213215
testEmptyWork(t, ethashChainConfig, ethash.NewFaker())
214216
}
215217
func TestEmptyWorkClique(t *testing.T) {
218+
t.Parallel()
216219
testEmptyWork(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
217220
}
218221

@@ -252,10 +255,12 @@ func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consens
252255
}
253256

254257
func TestAdjustIntervalEthash(t *testing.T) {
258+
t.Parallel()
255259
testAdjustInterval(t, ethashChainConfig, ethash.NewFaker())
256260
}
257261

258262
func TestAdjustIntervalClique(t *testing.T) {
263+
t.Parallel()
259264
testAdjustInterval(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
260265
}
261266

@@ -346,14 +351,17 @@ func testAdjustInterval(t *testing.T, chainConfig *params.ChainConfig, engine co
346351
}
347352

348353
func TestGetSealingWorkEthash(t *testing.T) {
354+
t.Parallel()
349355
testGetSealingWork(t, ethashChainConfig, ethash.NewFaker())
350356
}
351357

352358
func TestGetSealingWorkClique(t *testing.T) {
359+
t.Parallel()
353360
testGetSealingWork(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
354361
}
355362

356363
func TestGetSealingWorkPostMerge(t *testing.T) {
364+
t.Parallel()
357365
local := new(params.ChainConfig)
358366
*local = *ethashChainConfig
359367
local.TerminalTotalDifficulty = big.NewInt(0)

0 commit comments

Comments
 (0)