From 9816e8fc3e40c472ea942f705a0cea697d2543a3 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 6 Sep 2024 18:57:59 +0200 Subject: [PATCH] missing indexevent return + additional test --- indexers/blockindexer/kv/kv_test.go | 1 + indexers/txindex/kv/kv.go | 2 +- indexers/txindex/kv/kv_test.go | 13 +++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) 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 {