Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add support for multiple events of same type in AssertEvents #2995

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions modules/apps/29-fee/keeper/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,26 @@ func (suite *KeeperTestSuite) TestDistributeFeeEvent() {
suite.Require().NoError(err)
suite.Require().NotNil(res)

// calculate the total paid out fees using "distribute_fee" events
var totalPaid sdk.Coins
for _, event := range res.Events {
if event.Type == types.EventTypeDistributeFee {
for _, attr := range event.Attributes {
switch string(attr.Key) {
case types.AttributeKeyFee:
coins, err := sdk.ParseCoinsNormalized(string(attr.Value))
suite.Require().NoError(err)

totalPaid = totalPaid.Add(coins...)
}
}

}
events := res.GetEvents()
expectedEvents := sdk.Events{
sdk.NewEvent(
types.EventTypeDistributeFee,
sdk.NewAttribute(types.AttributeKeyReceiver, suite.chainA.SenderAccount.GetAddress().String()),
sdk.NewAttribute(types.AttributeKeyFee, defaultRecvFee.String()),
),
sdk.NewEvent(
types.EventTypeDistributeFee,
sdk.NewAttribute(types.AttributeKeyReceiver, suite.chainA.SenderAccount.GetAddress().String()),
sdk.NewAttribute(types.AttributeKeyFee, defaultAckFee.String()),
),
sdk.NewEvent(
types.EventTypeDistributeFee,
sdk.NewAttribute(types.AttributeKeyReceiver, suite.chainA.SenderAccount.GetAddress().String()),
sdk.NewAttribute(types.AttributeKeyFee, defaultTimeoutFee.String()),
),
}

// assert the total fees paid out equal the total incentivization fees escrowed
suite.Require().Equal(fee.Total(), totalPaid)
for _, evt := range expectedEvents {
suite.Require().Contains(events, evt)
}
}
4 changes: 1 addition & 3 deletions modules/apps/transfer/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import (
)

func (suite *KeeperTestSuite) TestMsgTransfer() {
var (
msg *types.MsgTransfer
)
var msg *types.MsgTransfer

testCases := []struct {
name string
Expand Down