Fix MarkEventsToIndex (#7161)
* fix MarkEventsToIndex * lint++ * fix TestDeliverTx
This commit is contained in:
+3
-1
@@ -203,7 +203,9 @@ func StringifyEvents(events []abci.Event) StringEvents {
|
||||
// MarkEventsToIndex returns the set of ABCI events, where each event's attribute
|
||||
// has it's index value marked based on the provided set of events to index.
|
||||
func MarkEventsToIndex(events []abci.Event, indexSet map[string]struct{}) []abci.Event {
|
||||
indexAll := len(indexSet) == 0
|
||||
updatedEvents := make([]abci.Event, len(events))
|
||||
|
||||
for i, e := range events {
|
||||
updatedEvent := abci.Event{
|
||||
Type: e.Type,
|
||||
@@ -215,7 +217,7 @@ func MarkEventsToIndex(events []abci.Event, indexSet map[string]struct{}) []abci
|
||||
updatedAttr := abci.EventAttribute{
|
||||
Key: attr.Key,
|
||||
Value: attr.Value,
|
||||
Index: index,
|
||||
Index: index || indexAll,
|
||||
}
|
||||
|
||||
updatedEvent.Attributes[j] = updatedAttr
|
||||
|
||||
+17
-2
@@ -95,8 +95,23 @@ func TestMarkEventsToIndex(t *testing.T) {
|
||||
expected []abci.Event
|
||||
}{
|
||||
"empty index set": {
|
||||
events: events,
|
||||
expected: events,
|
||||
events: events,
|
||||
expected: []abci.Event{
|
||||
{
|
||||
Type: "message",
|
||||
Attributes: []abci.EventAttribute{
|
||||
{Key: []byte("sender"), Value: []byte("foo"), Index: true},
|
||||
{Key: []byte("recipient"), Value: []byte("bar"), Index: true},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: "staking",
|
||||
Attributes: []abci.EventAttribute{
|
||||
{Key: []byte("deposit"), Value: []byte("5"), Index: true},
|
||||
{Key: []byte("unbond"), Value: []byte("10"), Index: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
indexSet: map[string]struct{}{},
|
||||
},
|
||||
"index some events": {
|
||||
|
||||
Reference in New Issue
Block a user