miner: set etherbase even if mining isn't possible at the moment (#21707)
This commit is contained in:
parent
bdc7554918
commit
4eb01b21c8
@ -128,8 +128,8 @@ func (miner *Miner) update() {
|
|||||||
events.Unsubscribe()
|
events.Unsubscribe()
|
||||||
}
|
}
|
||||||
case addr := <-miner.startCh:
|
case addr := <-miner.startCh:
|
||||||
if canStart {
|
|
||||||
miner.SetEtherbase(addr)
|
miner.SetEtherbase(addr)
|
||||||
|
if canStart {
|
||||||
miner.worker.start()
|
miner.worker.start()
|
||||||
}
|
}
|
||||||
shouldStart = true
|
shouldStart = true
|
||||||
|
@ -192,6 +192,28 @@ func TestCloseMiner(t *testing.T) {
|
|||||||
waitForMiningState(t, miner, false)
|
waitForMiningState(t, miner, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestMinerSetEtherbase checks that etherbase becomes set even if mining isn't
|
||||||
|
// possible at the moment
|
||||||
|
func TestMinerSetEtherbase(t *testing.T) {
|
||||||
|
miner, mux := createMiner(t)
|
||||||
|
// Start with a 'bad' mining address
|
||||||
|
miner.Start(common.HexToAddress("0xdead"))
|
||||||
|
waitForMiningState(t, miner, true)
|
||||||
|
// Start the downloader
|
||||||
|
mux.Post(downloader.StartEvent{})
|
||||||
|
waitForMiningState(t, miner, false)
|
||||||
|
// Now user tries to configure proper mining address
|
||||||
|
miner.Start(common.HexToAddress("0x1337"))
|
||||||
|
// Stop the downloader and wait for the update loop to run
|
||||||
|
mux.Post(downloader.DoneEvent{})
|
||||||
|
|
||||||
|
waitForMiningState(t, miner, true)
|
||||||
|
// The miner should now be using the good address
|
||||||
|
if got, exp := miner.coinbase, common.HexToAddress("0x1337"); got != exp {
|
||||||
|
t.Fatalf("Wrong coinbase, got %x expected %x", got, exp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// waitForMiningState waits until either
|
// waitForMiningState waits until either
|
||||||
// * the desired mining state was reached
|
// * the desired mining state was reached
|
||||||
// * a timeout was reached which fails the test
|
// * a timeout was reached which fails the test
|
||||||
|
Loading…
Reference in New Issue
Block a user