From c5fe7334dc6166d9ada9818464f38734190a74ec Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Fri, 28 Feb 2020 14:29:48 +0100 Subject: [PATCH] test: simplified txsearch cancellation test (#4500) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- state/txindex/kv/kv_test.go | 54 +++---------------------------------- 1 file changed, 3 insertions(+), 51 deletions(-) diff --git a/state/txindex/kv/kv_test.go b/state/txindex/kv/kv_test.go index 8756bc344..fcd2eba13 100644 --- a/state/txindex/kv/kv_test.go +++ b/state/txindex/kv/kv_test.go @@ -144,62 +144,14 @@ func TestTxSearchWithCancelation(t *testing.T) { {Type: "account", Attributes: []kv.Pair{{Key: []byte("owner"), Value: []byte("Ivan")}}}, {Type: "", Attributes: []kv.Pair{{Key: []byte("not_allowed"), Value: []byte("Vlad")}}}, }) - hash := txResult.Tx.Hash() - err := indexer.Index(txResult) require.NoError(t, err) - testCases := []struct { - q string - resultsLength int - }{ - // search by hash - {fmt.Sprintf("tx.hash = '%X'", hash), 0}, - // search by exact match (one key) - {"account.number = 1", 0}, - // search by exact match (two keys) - {"account.number = 1 AND account.owner = 'Ivan'", 0}, - // search by exact match (two keys) - {"account.number = 1 AND account.owner = 'Vlad'", 0}, - {"account.owner = 'Vlad' AND account.number = 1", 0}, - {"account.number >= 1 AND account.owner = 'Vlad'", 0}, - {"account.owner = 'Vlad' AND account.number >= 1", 0}, - {"account.number <= 0", 0}, - {"account.number <= 0 AND account.owner = 'Ivan'", 0}, - // search using a prefix of the stored value - {"account.owner = 'Iv'", 0}, - // search by range - {"account.number >= 1 AND account.number <= 5", 0}, - // search by range (lower bound) - {"account.number >= 1", 0}, - // search by range (upper bound) - {"account.number <= 5", 0}, - // search using not allowed key - {"not_allowed = 'boom'", 0}, - // search for not existing tx result - {"account.number >= 2 AND account.number <= 5", 0}, - // search using not existing key - {"account.date >= TIME 2013-05-03T14:45:00Z", 0}, - // search using CONTAINS - {"account.owner CONTAINS 'an'", 0}, - // search for non existing value using CONTAINS - {"account.owner CONTAINS 'Vlad'", 0}, - // search using the wrong key (of numeric type) using CONTAINS - {"account.number CONTAINS 'Iv'", 0}, - } - ctx, cancel := context.WithCancel(context.Background()) - cancel() - - for _, tc := range testCases { - tc := tc - t.Run(tc.q, func(t *testing.T) { - results, err := indexer.Search(ctx, query.MustParse(tc.q)) - assert.NoError(t, err) - assert.Len(t, results, tc.resultsLength) - }) - } + results, err := indexer.Search(ctx, query.MustParse("account.number = 1")) + assert.NoError(t, err) + assert.Empty(t, results) } func TestTxSearchDeprecatedIndexing(t *testing.T) {