Skip to content

Commit e542184

Browse files
committed
chore: fix test
1 parent 905e3f4 commit e542184

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

pkg/chain/store_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ func (cbor *CborBlockStore) PutBlocks(ctx context.Context, blocks []*types.Block
4343
func newChainStore(r repo.Repo, genTS *types.TipSet) *CborBlockStore {
4444
tempBlock := r.Datastore()
4545
cborStore := cbor.NewCborStore(tempBlock)
46+
blkBytes, _ := genTS.Blocks()[0].ToStorageBlock()
47+
_ = tempBlock.Put(context.Background(), blkBytes)
4648
return &CborBlockStore{
4749
Store: chain.NewStore(r.ChainDatastore(), tempBlock, genTS.At(0).Cid(), chainselector.Weight),
4850
cborStore: cborStore,

pkg/chainsync/syncer/syncer.go

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -199,45 +199,41 @@ func (syncer *Syncer) syncOne(ctx context.Context, parent, next *types.TipSet) e
199199
stopwatch := syncOneTimer.Start()
200200
defer stopwatch(ctx)
201201

202-
var err error
203-
204-
if !parent.Key().Equals(syncer.chainStore.GetCheckPoint().Key()) {
205-
var wg errgroup.Group
206-
for i := 0; i < next.Len(); i++ {
207-
blk := next.At(i)
208-
wg.Go(func() error {
209-
// Fetch the URL.
210-
err := syncer.blockValidator.ValidateFullBlock(ctx, blk)
211-
if err == nil {
212-
if err := syncer.chainStore.AddToTipSetTracker(ctx, blk); err != nil {
213-
return fmt.Errorf("failed to add validated header to tipset tracker: %w", err)
214-
}
202+
var wg errgroup.Group
203+
for i := 0; i < next.Len(); i++ {
204+
blk := next.At(i)
205+
wg.Go(func() error {
206+
// Fetch the URL.
207+
err := syncer.blockValidator.ValidateFullBlock(ctx, blk)
208+
if err == nil {
209+
if err := syncer.chainStore.AddToTipSetTracker(ctx, blk); err != nil {
210+
return fmt.Errorf("failed to add validated header to tipset tracker: %w", err)
215211
}
216-
return err
217-
})
218-
}
219-
err = wg.Wait()
220-
if err != nil {
221-
var rootNotMatch bool // nolint
222-
223-
if merr, isok := err.(*multierror.Error); isok {
224-
for _, e := range merr.Errors {
225-
if isRootNotMatch(e) {
226-
rootNotMatch = true
227-
break
228-
}
229-
}
230-
} else {
231-
rootNotMatch = isRootNotMatch(err) // nolint
232212
}
213+
return err
214+
})
215+
}
216+
err := wg.Wait()
217+
if err != nil {
218+
var rootNotMatch bool // nolint
233219

234-
if rootNotMatch { // nolint
235-
// todo: should here rollback, and re-compute?
236-
_ = syncer.stmgr.Rollback(ctx, parent, next)
220+
if merr, isok := err.(*multierror.Error); isok {
221+
for _, e := range merr.Errors {
222+
if isRootNotMatch(e) {
223+
rootNotMatch = true
224+
break
225+
}
237226
}
227+
} else {
228+
rootNotMatch = isRootNotMatch(err) // nolint
229+
}
238230

239-
return fmt.Errorf("validate mining failed %w", err)
231+
if rootNotMatch { // nolint
232+
// todo: should here rollback, and re-compute?
233+
_ = syncer.stmgr.Rollback(ctx, parent, next)
240234
}
235+
236+
return fmt.Errorf("validate mining failed %w", err)
241237
}
242238

243239
syncer.chainStore.PersistTipSetKey(ctx, next.Key())

0 commit comments

Comments
 (0)