-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for emission of cumulative incentivized fees
- Loading branch information
1 parent
acda4e9
commit dabac81
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package keeper_test | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
abcitypes "github.com/tendermint/tendermint/abci/types" | ||
|
||
"github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" | ||
) | ||
|
||
func (suite *KeeperTestSuite) TestIncentivizePacketEvent() { | ||
var ( | ||
expRecvFees sdk.Coins | ||
expAckFees sdk.Coins | ||
expTimeoutFees sdk.Coins | ||
) | ||
|
||
suite.coordinator.Setup(suite.path) | ||
|
||
fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) | ||
msg := types.NewMsgPayPacketFee( | ||
fee, | ||
suite.path.EndpointA.ChannelConfig.PortID, | ||
suite.path.EndpointA.ChannelID, | ||
suite.chainA.SenderAccount.GetAddress().String(), | ||
nil, | ||
) | ||
|
||
expRecvFees.Add(fee.RecvFee...) | ||
expAckFees.Add(fee.AckFee...) | ||
expAckFees.Add(fee.TimeoutFee...) | ||
|
||
result, err := suite.chainA.SendMsgs(msg) | ||
suite.Require().NoError(err) | ||
|
||
var incentivizedPacketEvent abcitypes.Event | ||
for _, event := range result.Events { | ||
if event.Type == types.EventTypeIncentivizedPacket { | ||
incentivizedPacketEvent = event | ||
} | ||
} | ||
|
||
for _, attr := range incentivizedPacketEvent.Attributes { | ||
switch string(attr.Key) { | ||
case types.AttributeKeyRecvFee: | ||
suite.Require().Equal(expRecvFees.String(), string(attr.Value)) | ||
|
||
case types.AttributeKeyAckFee: | ||
suite.Require().Equal(expAckFees.String(), string(attr.Value)) | ||
|
||
case types.AttributeKeyTimeoutFee: | ||
suite.Require().Equal(expTimeoutFees.String(), string(attr.Value)) | ||
} | ||
} | ||
|
||
// send the same messages again a few times | ||
for i := 0; i < 3; i++ { | ||
expRecvFees.Add(fee.RecvFee...) | ||
expAckFees.Add(fee.AckFee...) | ||
expAckFees.Add(fee.TimeoutFee...) | ||
|
||
result, err = suite.chainA.SendMsgs(msg) | ||
suite.Require().NoError(err) | ||
} | ||
|
||
for _, event := range result.Events { | ||
if event.Type == types.EventTypeIncentivizedPacket { | ||
incentivizedPacketEvent = event | ||
} | ||
} | ||
|
||
for _, attr := range incentivizedPacketEvent.Attributes { | ||
switch string(attr.Key) { | ||
case types.AttributeKeyRecvFee: | ||
suite.Require().Equal(expRecvFees.String(), string(attr.Value)) | ||
|
||
case types.AttributeKeyAckFee: | ||
suite.Require().Equal(expAckFees.String(), string(attr.Value)) | ||
|
||
case types.AttributeKeyTimeoutFee: | ||
suite.Require().Equal(expTimeoutFees.String(), string(attr.Value)) | ||
} | ||
} | ||
} |