|
|
@ -215,12 +215,16 @@ func testGenerateBlockAndImport(t *testing.T, isClique bool) { |
|
|
|
chain, _ := core.NewBlockChain(db2, nil, b.chain.Config(), engine, vm.Config{}, nil) |
|
|
|
chain, _ := core.NewBlockChain(db2, nil, b.chain.Config(), engine, vm.Config{}, nil) |
|
|
|
defer chain.Stop() |
|
|
|
defer chain.Stop() |
|
|
|
|
|
|
|
|
|
|
|
loopErr := make(chan error) |
|
|
|
var ( |
|
|
|
newBlock := make(chan struct{}) |
|
|
|
loopErr = make(chan error) |
|
|
|
|
|
|
|
newBlock = make(chan struct{}) |
|
|
|
|
|
|
|
subscribe = make(chan struct{}) |
|
|
|
|
|
|
|
) |
|
|
|
listenNewBlock := func() { |
|
|
|
listenNewBlock := func() { |
|
|
|
sub := w.mux.Subscribe(core.NewMinedBlockEvent{}) |
|
|
|
sub := w.mux.Subscribe(core.NewMinedBlockEvent{}) |
|
|
|
defer sub.Unsubscribe() |
|
|
|
defer sub.Unsubscribe() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subscribe <- struct{}{} |
|
|
|
for item := range sub.Chan() { |
|
|
|
for item := range sub.Chan() { |
|
|
|
block := item.Data.(core.NewMinedBlockEvent).Block |
|
|
|
block := item.Data.(core.NewMinedBlockEvent).Block |
|
|
|
_, err := chain.InsertChain([]*types.Block{block}) |
|
|
|
_, err := chain.InsertChain([]*types.Block{block}) |
|
|
@ -234,9 +238,11 @@ func testGenerateBlockAndImport(t *testing.T, isClique bool) { |
|
|
|
w.skipSealHook = func(task *task) bool { |
|
|
|
w.skipSealHook = func(task *task) bool { |
|
|
|
return len(task.receipts) == 0 |
|
|
|
return len(task.receipts) == 0 |
|
|
|
} |
|
|
|
} |
|
|
|
w.start() // Start mining!
|
|
|
|
|
|
|
|
go listenNewBlock() |
|
|
|
go listenNewBlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<-subscribe // Ensure the subscription is created
|
|
|
|
|
|
|
|
w.start() // Start mining!
|
|
|
|
|
|
|
|
|
|
|
|
for i := 0; i < 5; i++ { |
|
|
|
for i := 0; i < 5; i++ { |
|
|
|
b.txPool.AddLocal(b.newRandomTx(true)) |
|
|
|
b.txPool.AddLocal(b.newRandomTx(true)) |
|
|
|
b.txPool.AddLocal(b.newRandomTx(false)) |
|
|
|
b.txPool.AddLocal(b.newRandomTx(false)) |
|
|
|