miner: run tests in parallel (#28506)
Changes many of the tests in the miner package to run in parallel
This commit is contained in:
parent
2814ee0547
commit
b9504e4966
@ -99,6 +99,7 @@ func (bc *testBlockChain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMiner(t *testing.T) {
|
func TestMiner(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
miner, mux, cleanup := createMiner(t)
|
miner, mux, cleanup := createMiner(t)
|
||||||
defer cleanup(false)
|
defer cleanup(false)
|
||||||
|
|
||||||
@ -128,6 +129,7 @@ func TestMiner(t *testing.T) {
|
|||||||
// An initial FailedEvent should allow mining to stop on a subsequent
|
// An initial FailedEvent should allow mining to stop on a subsequent
|
||||||
// downloader StartEvent.
|
// downloader StartEvent.
|
||||||
func TestMinerDownloaderFirstFails(t *testing.T) {
|
func TestMinerDownloaderFirstFails(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
miner, mux, cleanup := createMiner(t)
|
miner, mux, cleanup := createMiner(t)
|
||||||
defer cleanup(false)
|
defer cleanup(false)
|
||||||
|
|
||||||
@ -161,6 +163,7 @@ func TestMinerDownloaderFirstFails(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMinerStartStopAfterDownloaderEvents(t *testing.T) {
|
func TestMinerStartStopAfterDownloaderEvents(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
miner, mux, cleanup := createMiner(t)
|
miner, mux, cleanup := createMiner(t)
|
||||||
defer cleanup(false)
|
defer cleanup(false)
|
||||||
|
|
||||||
@ -185,6 +188,7 @@ func TestMinerStartStopAfterDownloaderEvents(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStartWhileDownload(t *testing.T) {
|
func TestStartWhileDownload(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
miner, mux, cleanup := createMiner(t)
|
miner, mux, cleanup := createMiner(t)
|
||||||
defer cleanup(false)
|
defer cleanup(false)
|
||||||
waitForMiningState(t, miner, false)
|
waitForMiningState(t, miner, false)
|
||||||
@ -199,6 +203,7 @@ func TestStartWhileDownload(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStartStopMiner(t *testing.T) {
|
func TestStartStopMiner(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
miner, _, cleanup := createMiner(t)
|
miner, _, cleanup := createMiner(t)
|
||||||
defer cleanup(false)
|
defer cleanup(false)
|
||||||
waitForMiningState(t, miner, false)
|
waitForMiningState(t, miner, false)
|
||||||
@ -209,6 +214,7 @@ func TestStartStopMiner(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCloseMiner(t *testing.T) {
|
func TestCloseMiner(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
miner, _, cleanup := createMiner(t)
|
miner, _, cleanup := createMiner(t)
|
||||||
defer cleanup(true)
|
defer cleanup(true)
|
||||||
waitForMiningState(t, miner, false)
|
waitForMiningState(t, miner, false)
|
||||||
@ -222,6 +228,7 @@ func TestCloseMiner(t *testing.T) {
|
|||||||
// TestMinerSetEtherbase checks that etherbase becomes set even if mining isn't
|
// TestMinerSetEtherbase checks that etherbase becomes set even if mining isn't
|
||||||
// possible at the moment
|
// possible at the moment
|
||||||
func TestMinerSetEtherbase(t *testing.T) {
|
func TestMinerSetEtherbase(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
miner, mux, cleanup := createMiner(t)
|
miner, mux, cleanup := createMiner(t)
|
||||||
defer cleanup(false)
|
defer cleanup(false)
|
||||||
miner.Start()
|
miner.Start()
|
||||||
|
@ -30,10 +30,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestTransactionPriceNonceSortLegacy(t *testing.T) {
|
func TestTransactionPriceNonceSortLegacy(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
testTransactionPriceNonceSort(t, nil)
|
testTransactionPriceNonceSort(t, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTransactionPriceNonceSort1559(t *testing.T) {
|
func TestTransactionPriceNonceSort1559(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
testTransactionPriceNonceSort(t, big.NewInt(0))
|
testTransactionPriceNonceSort(t, big.NewInt(0))
|
||||||
testTransactionPriceNonceSort(t, big.NewInt(5))
|
testTransactionPriceNonceSort(t, big.NewInt(5))
|
||||||
testTransactionPriceNonceSort(t, big.NewInt(50))
|
testTransactionPriceNonceSort(t, big.NewInt(50))
|
||||||
@ -138,6 +140,7 @@ func testTransactionPriceNonceSort(t *testing.T, baseFee *big.Int) {
|
|||||||
// Tests that if multiple transactions have the same price, the ones seen earlier
|
// Tests that if multiple transactions have the same price, the ones seen earlier
|
||||||
// are prioritized to avoid network spam attacks aiming for a specific ordering.
|
// are prioritized to avoid network spam attacks aiming for a specific ordering.
|
||||||
func TestTransactionTimeSort(t *testing.T) {
|
func TestTransactionTimeSort(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
// Generate a batch of accounts to start with
|
// Generate a batch of accounts to start with
|
||||||
keys := make([]*ecdsa.PrivateKey, 5)
|
keys := make([]*ecdsa.PrivateKey, 5)
|
||||||
for i := 0; i < len(keys); i++ {
|
for i := 0; i < len(keys); i++ {
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestBuildPayload(t *testing.T) {
|
func TestBuildPayload(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var (
|
var (
|
||||||
db = rawdb.NewMemoryDatabase()
|
db = rawdb.NewMemoryDatabase()
|
||||||
recipient = common.HexToAddress("0xdeadbeef")
|
recipient = common.HexToAddress("0xdeadbeef")
|
||||||
@ -82,6 +83,7 @@ func TestBuildPayload(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPayloadId(t *testing.T) {
|
func TestPayloadId(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
ids := make(map[string]int)
|
ids := make(map[string]int)
|
||||||
for i, tt := range []*BuildPayloadArgs{
|
for i, tt := range []*BuildPayloadArgs{
|
||||||
{
|
{
|
||||||
|
@ -167,6 +167,7 @@ func newTestWorker(t *testing.T, chainConfig *params.ChainConfig, engine consens
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGenerateAndImportBlock(t *testing.T) {
|
func TestGenerateAndImportBlock(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var (
|
var (
|
||||||
db = rawdb.NewMemoryDatabase()
|
db = rawdb.NewMemoryDatabase()
|
||||||
config = *params.AllCliqueProtocolChanges
|
config = *params.AllCliqueProtocolChanges
|
||||||
@ -210,9 +211,11 @@ func TestGenerateAndImportBlock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEmptyWorkEthash(t *testing.T) {
|
func TestEmptyWorkEthash(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
testEmptyWork(t, ethashChainConfig, ethash.NewFaker())
|
testEmptyWork(t, ethashChainConfig, ethash.NewFaker())
|
||||||
}
|
}
|
||||||
func TestEmptyWorkClique(t *testing.T) {
|
func TestEmptyWorkClique(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
testEmptyWork(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
|
testEmptyWork(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,10 +255,12 @@ func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consens
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAdjustIntervalEthash(t *testing.T) {
|
func TestAdjustIntervalEthash(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
testAdjustInterval(t, ethashChainConfig, ethash.NewFaker())
|
testAdjustInterval(t, ethashChainConfig, ethash.NewFaker())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAdjustIntervalClique(t *testing.T) {
|
func TestAdjustIntervalClique(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
testAdjustInterval(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
|
testAdjustInterval(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,14 +351,17 @@ func testAdjustInterval(t *testing.T, chainConfig *params.ChainConfig, engine co
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetSealingWorkEthash(t *testing.T) {
|
func TestGetSealingWorkEthash(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
testGetSealingWork(t, ethashChainConfig, ethash.NewFaker())
|
testGetSealingWork(t, ethashChainConfig, ethash.NewFaker())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetSealingWorkClique(t *testing.T) {
|
func TestGetSealingWorkClique(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
testGetSealingWork(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
|
testGetSealingWork(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetSealingWorkPostMerge(t *testing.T) {
|
func TestGetSealingWorkPostMerge(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
local := new(params.ChainConfig)
|
local := new(params.ChainConfig)
|
||||||
*local = *ethashChainConfig
|
*local = *ethashChainConfig
|
||||||
local.TerminalTotalDifficulty = big.NewInt(0)
|
local.TerminalTotalDifficulty = big.NewInt(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user