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: use mock module for ics29 genesis_test.go #931

Merged
merged 4 commits into from
Feb 17, 2022
Merged
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
16 changes: 6 additions & 10 deletions modules/apps/29-fee/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ package keeper_test

import (
"github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
)

func (suite *KeeperTestSuite) TestInitGenesis() {
suite.SetupTest()

// build PacketId & Fee
refundAcc := suite.chainA.SenderAccount.GetAddress()
packetId := channeltypes.NewPacketId(
ibctesting.FirstChannelID,
transfertypes.PortID,
ibctesting.MockFeePort,
uint64(1),
)
fee := types.Fee{
Expand All @@ -38,7 +35,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
},
FeeEnabledChannels: []types.FeeEnabledChannel{
{
PortId: transfertypes.PortID,
PortId: ibctesting.MockFeePort,
ChannelId: ibctesting.FirstChannelID,
},
},
Expand All @@ -58,7 +55,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
suite.Require().Equal(genesisState.IdentifiedFees[0], identifiedFee)

// check fee is enabled
isEnabled := suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID)
isEnabled := suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID)
suite.Require().True(isEnabled)

// check relayers
Expand All @@ -68,13 +65,12 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
}

func (suite *KeeperTestSuite) TestExportGenesis() {
suite.SetupTest()
// set fee enabled
suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID)
suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID)

// setup & escrow the packet fee
refundAcc := suite.chainA.SenderAccount.GetAddress()
packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 1)
packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1)
fee := types.Fee{
RecvFee: defaultReceiveFee,
AckFee: defaultAckFee,
Expand All @@ -98,7 +94,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() {

// check fee enabled
suite.Require().Equal(ibctesting.FirstChannelID, genesisState.FeeEnabledChannels[0].ChannelId)
suite.Require().Equal(transfertypes.PortID, genesisState.FeeEnabledChannels[0].PortId)
suite.Require().Equal(ibctesting.MockFeePort, genesisState.FeeEnabledChannels[0].PortId)

// check fee
suite.Require().Equal(packetID, genesisState.IdentifiedFees[0].PacketId)
Expand Down