Skip to content

Commit

Permalink
feat: tests for the chain indexer (#12521)
Browse files Browse the repository at this point in the history
* ddl tests

* tests for the chain indexer

* finish unit tests for chain indexer

* fix formatting
  • Loading branch information
aarshkshah1992 authored Oct 4, 2024
1 parent 0207fa2 commit 3c48644
Show file tree
Hide file tree
Showing 12 changed files with 1,891 additions and 17 deletions.
5 changes: 3 additions & 2 deletions chain/index/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ func (si *SqliteIndexer) verifyIndexedData(ctx context.Context, ts *types.TipSet
return xerrors.Errorf("failed to get next tipset for height %d: %w", ts.Height(), err)
}

// if non-reverted events exist which means that tipset `ts` has been executed, there should be 0 reverted events in the DB
// given that `ts` is on the canonical chain and `executionTs` is the next tipset in the chain
// `ts` can not have reverted events
var hasRevertedEventsInTipset bool
err = si.stmts.hasRevertedEventsInTipsetStmt.QueryRowContext(ctx, tsKeyCid.Bytes()).Scan(&hasRevertedEventsInTipset)
if err != nil {
Expand All @@ -233,7 +234,7 @@ func (si *SqliteIndexer) verifyIndexedData(ctx context.Context, ts *types.TipSet
return xerrors.Errorf("index corruption: reverted events found for an executed tipset %s at height %d", tsKeyCid, ts.Height())
}

executedMsgs, err := si.loadExecutedMessages(ctx, ts, executionTs)
executedMsgs, err := si.eventLoaderFunc(ctx, si.cs, ts, executionTs)
if err != nil {
return xerrors.Errorf("failed to load executed messages for height %d: %w", ts.Height(), err)
}
Expand Down
Loading

0 comments on commit 3c48644

Please sign in to comment.