abci: Port EventAttribute field type change to main (#9335)

* types: Refactor EventAttribute (#6408)

Cherry-pick of 09a6ad7b1e

* Ensure context is honored

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Replace with tagged switch

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Ensure contexts are honored

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add UPGRADING note about type change

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Remove unnecessary conversion

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Thane Thomson
2022-08-30 10:13:55 -04:00
committed by GitHub
co-authored by Aleksandr Bezobchuk
parent 2313f35800
commit 7b40167f58
17 changed files with 156 additions and 143 deletions
+2 -2
View File
@@ -123,8 +123,8 @@ func (b *EventBus) validateAndStringifyEvents(events []types.Event, logger log.L
continue
}
compositeTag := fmt.Sprintf("%s.%s", event.Type, string(attr.Key))
result[compositeTag] = append(result[compositeTag], string(attr.Value))
compositeTag := fmt.Sprintf("%s.%s", event.Type, attr.Key)
result[compositeTag] = append(result[compositeTag], attr.Value)
}
}
+14 -14
View File
@@ -30,7 +30,7 @@ func TestEventBusPublishEventTx(t *testing.T) {
result := abci.ResponseDeliverTx{
Data: []byte("bar"),
Events: []abci.Event{
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("baz"), Value: []byte("1")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: "baz", Value: "1"}}},
},
}
@@ -78,12 +78,12 @@ func TestEventBusPublishEventNewBlock(t *testing.T) {
block := MakeBlock(0, []Tx{}, nil, []Evidence{})
resultBeginBlock := abci.ResponseBeginBlock{
Events: []abci.Event{
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("baz"), Value: []byte("1")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: "baz", Value: "1"}}},
},
}
resultEndBlock := abci.ResponseEndBlock{
Events: []abci.Event{
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("foz"), Value: []byte("2")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: "foz", Value: "2"}}},
},
}
@@ -133,25 +133,25 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
{
Type: "transfer",
Attributes: []abci.EventAttribute{
{Key: []byte("sender"), Value: []byte("foo")},
{Key: []byte("recipient"), Value: []byte("bar")},
{Key: []byte("amount"), Value: []byte("5")},
{Key: "sender", Value: "foo"},
{Key: "recipient", Value: "bar"},
{Key: "amount", Value: "5"},
},
},
{
Type: "transfer",
Attributes: []abci.EventAttribute{
{Key: []byte("sender"), Value: []byte("baz")},
{Key: []byte("recipient"), Value: []byte("cat")},
{Key: []byte("amount"), Value: []byte("13")},
{Key: "sender", Value: "baz"},
{Key: "recipient", Value: "cat"},
{Key: "amount", Value: "13"},
},
},
{
Type: "withdraw.rewards",
Attributes: []abci.EventAttribute{
{Key: []byte("address"), Value: []byte("bar")},
{Key: []byte("source"), Value: []byte("iceman")},
{Key: []byte("amount"), Value: []byte("33")},
{Key: "address", Value: "bar"},
{Key: "source", Value: "iceman"},
{Key: "amount", Value: "33"},
},
},
},
@@ -237,12 +237,12 @@ func TestEventBusPublishEventNewBlockHeader(t *testing.T) {
block := MakeBlock(0, []Tx{}, nil, []Evidence{})
resultBeginBlock := abci.ResponseBeginBlock{
Events: []abci.Event{
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("baz"), Value: []byte("1")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: "baz", Value: "1"}}},
},
}
resultEndBlock := abci.ResponseEndBlock{
Events: []abci.Event{
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("foz"), Value: []byte("2")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: "foz", Value: "2"}}},
},
}