diff --git a/indexers/blockindexer/kv/kv_test.go b/indexers/blockindexer/kv/kv_test.go index abf9a6c32..da0134552 100644 --- a/indexers/blockindexer/kv/kv_test.go +++ b/indexers/blockindexer/kv/kv_test.go @@ -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 { diff --git a/indexers/txindex/kv/kv.go b/indexers/txindex/kv/kv.go index 483347514..53b521e70 100644 --- a/indexers/txindex/kv/kv.go +++ b/indexers/txindex/kv/kv.go @@ -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. diff --git a/indexers/txindex/kv/kv_test.go b/indexers/txindex/kv/kv_test.go index 02c3f96a0..de1159101 100644 --- a/indexers/txindex/kv/kv_test.go +++ b/indexers/txindex/kv/kv_test.go @@ -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)) @@ -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 {