Fix initialization race (#12374)

* block all the sync startup code on init signal

* don't need chainStarted if everything blocks

* set empty clock by default to work around panics

* remove unused clock, zero-value for init-sync

---------

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
Co-authored-by: Nishant Das <nishdas93@gmail.com>
This commit is contained in:
kasey
2023-05-09 23:09:15 -05:00
committed by GitHub
parent 98f8ca4e34
commit 7d9f36985e
4 changed files with 2 additions and 5 deletions

View File

@@ -552,7 +552,6 @@ func TestBlocksFetcher_RequestBlocksRateLimitingLocks(t *testing.T) {
gt := time.Now()
vr := [32]byte{}
fetcher.chain = &mock.ChainService{Genesis: gt, ValidatorsRoot: vr}
fetcher.clock = startup.NewClock(gt, vr)
hook := logTest.NewGlobal()
wg := new(sync.WaitGroup)
wg.Add(1)
@@ -621,7 +620,6 @@ func TestBlocksFetcher_WaitForBandwidth(t *testing.T) {
gt := time.Now()
vr := [32]byte{}
fetcher.chain = &mock.ChainService{Genesis: gt, ValidatorsRoot: vr}
fetcher.clock = startup.NewClock(gt, vr)
start := time.Now()
assert.NoError(t, fetcher.waitForBandwidth(p2.PeerID(), 10))
dur := time.Since(start)