Skip to content

Commit

Permalink
missing indexevent return + additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Sep 6, 2024
1 parent cb3edea commit 9816e8f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions indexers/blockindexer/kv/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func TestBlockIndexerPruning(t *testing.T) {
results, err = indexer.Search(context.Background(), q)
require.NoError(t, err)
require.Equal(t, 0, len(results))

}

func getBeginBlock() abci.ResponseBeginBlock {
Expand Down
2 changes: 1 addition & 1 deletion indexers/txindex/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (txi *TxIndex) indexEvents(result *abci.TxResult, hash []byte, store store.
}
}

return dmtypes.EventKeys{}, nil
return eventKeys, nil
}

// Search performs a search using the given query.
Expand Down
13 changes: 11 additions & 2 deletions indexers/txindex/kv/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ func TestTxIndexerPruning(t *testing.T) {
}
}

q := query.MustParse("account.number = 1")
// query all blocks and receive events for all txs
results, err := indexer.Search(context.Background(), query.MustParse("account.number = 1"))
results, err := indexer.Search(context.Background(), q)
require.NoError(t, err)
require.Equal(t, txsWithEvents, len(results))

Expand All @@ -343,10 +344,18 @@ func TestTxIndexerPruning(t *testing.T) {
require.Equal(t, uint64(numBlocks), pruned)

// check the query returns empty
results, err = indexer.Search(context.Background(), query.MustParse("account.number = 1"))
results, err = indexer.Search(context.Background(), q)
require.NoError(t, err)
require.Equal(t, 0, len(results))

conditions, err := q.Conditions()
require.NoError(t, err)
// check there are no unlinked events matching the query that are not found with Search
for _, c := range conditions {
results := indexer.match(context.Background(), c, startKeyForCondition(c, 0), nil, true)
require.Equal(t, 0, len(results))
}

}

func txResultWithEvents(events []abci.Event) *abci.TxResult {
Expand Down

0 comments on commit 9816e8f

Please sign in to comment.