Skip to content

Commit

Permalink
refactor: use mock module for ics29 genesis_test.go (#931)
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-axner authored Feb 17, 2022
1 parent 06f2730 commit ff15335
Showing 1 changed file with 6 additions and 10 deletions.
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

0 comments on commit ff15335

Please sign in to comment.