Browse Source

more test cases

pull/835/head
Anton Kaliaev 7 years ago
parent
commit
864ad8546e
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 24 additions and 14 deletions
  1. +20
    -14
      state/txindex/kv/kv.go
  2. +4
    -0
      state/txindex/kv/kv_test.go

+ 20
- 14
state/txindex/kv/kv.go View File

@ -284,22 +284,24 @@ LOOP:
if !isTagKey(it.Key()) {
continue
}
// no other way to stop iterator other than checking for upperBound
switch (r.upperBound).(type) {
case int64:
v, err := strconv.ParseInt(extractValueFromKey(it.Key()), 10, 64)
if err == nil && v == r.upperBound {
if r.includeUpperBound {
hashes = append(hashes, it.Value())
if r.upperBound != nil {
// no other way to stop iterator other than checking for upperBound
switch (r.upperBound).(type) {
case int64:
v, err := strconv.ParseInt(extractValueFromKey(it.Key()), 10, 64)
if err == nil && v == r.upperBound {
if r.includeUpperBound {
hashes = append(hashes, it.Value())
}
break LOOP
}
break LOOP
// XXX: passing time in a ABCI Tags is not yet implemented
// case time.Time:
// v := strconv.ParseInt(extractValueFromKey(it.Key()), 10, 64)
// if v == r.upperBound {
// break
// }
}
// XXX: passing time in a ABCI Tags is not yet implemented
// case time.Time:
// v := strconv.ParseInt(extractValueFromKey(it.Key()), 10, 64)
// if v == r.upperBound {
// break
// }
}
hashes = append(hashes, it.Value())
}
@ -320,6 +322,10 @@ func startKey(c query.Condition, height uint64) []byte {
}
func startKeyForRange(r queryRange, height uint64) []byte {
if r.lowerBound == nil {
return []byte(fmt.Sprintf("%s", r.key))
}
var lowerBound interface{}
if r.includeLowerBound {
lowerBound = r.lowerBound


+ 4
- 0
state/txindex/kv/kv_test.go View File

@ -75,6 +75,10 @@ func TestTxSearch(t *testing.T) {
{"account.number = 1 AND account.owner = 'Vlad'", 0},
// search by range
{"account.number >= 1 AND account.number <= 5", 1},
// search by range (lower bound)
{"account.number >= 1", 1},
// search by range (upper bound)
{"account.number <= 5", 1},
// search using not allowed tag
{"not_allowed = 'boom'", 0},
// search for not existing tx result


Loading…
Cancel
Save