Browse Source

add missing element (tag.Value) to keyForTag

encoded as %s. not sure this will work with raw bytes
pull/1184/head
Anton Kaliaev 7 years ago
committed by Ethan Buchman
parent
commit
bb2bdbc0e1
2 changed files with 5 additions and 5 deletions
  1. +1
    -1
      state/txindex/kv/kv.go
  2. +4
    -4
      state/txindex/kv/kv_test.go

+ 1
- 1
state/txindex/kv/kv.go View File

@ -377,7 +377,7 @@ func extractValueFromKey(key []byte) string {
}
func keyForTag(tag cmn.KVPair, result *types.TxResult) []byte {
return []byte(fmt.Sprintf("%s/%d/%d", tag.Key, result.Height, result.Index))
return []byte(fmt.Sprintf("%s/%s/%d/%d", tag.Key, tag.Value, result.Height, result.Index))
}
///////////////////////////////////////////////////////////////////////////////


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

@ -51,7 +51,7 @@ func TestTxSearch(t *testing.T) {
indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags))
txResult := txResultWithTags([]cmn.KVPair{
{Key: []byte("account.number"), Value: []byte{1}},
{Key: []byte("account.number"), Value: []byte("1")},
{Key: []byte("account.owner"), Value: []byte("Ivan")},
{Key: []byte("not_allowed"), Value: []byte("Vlad")},
})
@ -108,8 +108,8 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) {
indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags))
txResult := txResultWithTags([]cmn.KVPair{
{Key: []byte("account.number"), Value: []byte{1}},
{Key: []byte("account.number"), Value: []byte{2}},
{Key: []byte("account.number"), Value: []byte("1")},
{Key: []byte("account.number"), Value: []byte("2")},
})
err := indexer.Index(txResult)
@ -127,7 +127,7 @@ func TestIndexAllTags(t *testing.T) {
txResult := txResultWithTags([]cmn.KVPair{
cmn.KVPair{[]byte("account.owner"), []byte("Ivan")},
cmn.KVPair{[]byte("account.number"), []byte{1}},
cmn.KVPair{[]byte("account.number"), []byte("1")},
})
err := indexer.Index(txResult)


Loading…
Cancel
Save