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

chore: remove unnecessary testing functions from ics29 #954

Merged
merged 1 commit into from
Feb 21, 2022
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
40 changes: 0 additions & 40 deletions modules/apps/29-fee/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package fee_test
import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"

"github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
Expand All @@ -25,27 +23,11 @@ type FeeTestSuite struct {
path *ibctesting.Path
}

// TODO: remove and rename 'SetupMockTest' to 'SetupTest'
func (suite *FeeTestSuite) SetupTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2))

path := ibctesting.NewPath(suite.chainA, suite.chainB)
feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version}))
path.EndpointA.ChannelConfig.Version = feeTransferVersion
path.EndpointB.ChannelConfig.Version = feeTransferVersion
path.EndpointA.ChannelConfig.PortID = transfertypes.PortID
path.EndpointB.ChannelConfig.PortID = transfertypes.PortID
suite.path = path
}

// TODO: rename to 'SetupTest' when the above function is removed
func (suite *FeeTestSuite) SetupMockTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2))

path := ibctesting.NewPath(suite.chainA, suite.chainB)
mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version}))
path.EndpointA.ChannelConfig.Version = mockFeeVersion
Expand All @@ -59,28 +41,6 @@ func TestIBCFeeTestSuite(t *testing.T) {
suite.Run(t, new(FeeTestSuite))
}

// TODO: remove
func (suite *FeeTestSuite) CreateICS20Packet(coin sdk.Coin) channeltypes.Packet {

fungibleTokenPacket := transfertypes.NewFungibleTokenPacketData(
coin.Denom,
sdk.NewInt(100).String(),
suite.chainA.SenderAccount.GetAddress().String(),
suite.chainB.SenderAccount.GetAddress().String(),
)

return channeltypes.NewPacket(
fungibleTokenPacket.GetBytes(),
suite.chainA.SenderAccount.GetSequence(),
suite.path.EndpointA.ChannelConfig.PortID,
suite.path.EndpointA.ChannelID,
suite.path.EndpointB.ChannelConfig.PortID,
suite.path.EndpointB.ChannelID,
clienttypes.NewHeight(0, 100),
0,
)
}

func (suite *FeeTestSuite) CreateMockPacket() channeltypes.Packet {
return channeltypes.NewPacket(
ibcmock.MockPacketData,
Expand Down
14 changes: 7 additions & 7 deletions modules/apps/29-fee/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() {

suite.Run(tc.name, func() {
// reset suite
suite.SetupMockTest()
suite.SetupTest()
suite.coordinator.SetupConnections(suite.path)

// setup mock callback
Expand Down Expand Up @@ -150,7 +150,7 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() {

suite.Run(tc.name, func() {
// reset suite
suite.SetupMockTest()
suite.SetupTest()
suite.coordinator.SetupConnections(suite.path)
suite.path.EndpointB.ChanOpenInit()

Expand Down Expand Up @@ -255,7 +255,7 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() {
for _, tc := range testCases {
tc := tc
suite.Run(tc.name, func() {
suite.SetupMockTest()
suite.SetupTest()
suite.coordinator.SetupConnections(suite.path)

// setup mock callback
Expand Down Expand Up @@ -337,7 +337,7 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() {
for _, tc := range testCases {
tc := tc
suite.Run(tc.name, func() {
suite.SetupMockTest()
suite.SetupTest()
suite.coordinator.Setup(suite.path) // setup channel

origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress())
Expand Down Expand Up @@ -415,7 +415,7 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() {
for _, tc := range testCases {
tc := tc
suite.Run(tc.name, func() {
suite.SetupMockTest()
suite.SetupTest()
suite.coordinator.Setup(suite.path) // setup channel

origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress())
Expand Down Expand Up @@ -481,7 +481,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() {
for _, tc := range testCases {
tc := tc
suite.Run(tc.name, func() {
suite.SetupMockTest()
suite.SetupTest()
suite.coordinator.Setup(suite.path)

// set up a different channel to make sure that the test will error if the destination channel of the packet is not fee enabled
Expand Down Expand Up @@ -724,7 +724,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() {
for _, tc := range testCases {
tc := tc
suite.Run(tc.name, func() {
suite.SetupMockTest()
suite.SetupTest()
suite.coordinator.Setup(suite.path)
packet := suite.CreateMockPacket()

Expand Down
23 changes: 0 additions & 23 deletions modules/apps/29-fee/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/stretchr/testify/suite"

"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"
ibcmock "github.com/cosmos/ibc-go/v3/testing/mock"
Expand All @@ -34,31 +33,11 @@ type KeeperTestSuite struct {
queryClient types.QueryClient
}

// TODO: remove and rename 'SetupMockTest' to 'SetupTest'
func (suite *KeeperTestSuite) SetupTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2))

path := ibctesting.NewPath(suite.chainA, suite.chainB)
feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version}))
path.EndpointA.ChannelConfig.Version = feeTransferVersion
path.EndpointB.ChannelConfig.Version = feeTransferVersion
path.EndpointA.ChannelConfig.PortID = transfertypes.PortID
path.EndpointB.ChannelConfig.PortID = transfertypes.PortID
suite.path = path

queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry())
types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().IBCFeeKeeper)
suite.queryClient = types.NewQueryClient(queryHelper)
}

// TODO: rename to 'SetupTest' when the above function is removed
func (suite *KeeperTestSuite) SetupMockTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2))

path := ibctesting.NewPath(suite.chainA, suite.chainB)
mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version}))
path.EndpointA.ChannelConfig.Version = mockFeeVersion
Expand All @@ -77,7 +56,6 @@ func TestKeeperTestSuite(t *testing.T) {
}

func (suite *KeeperTestSuite) TestFeeInEscrow() {
suite.SetupMockTest()
suite.coordinator.Setup(suite.path)

fee := types.Fee{RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee}
Expand Down Expand Up @@ -119,7 +97,6 @@ func (suite *KeeperTestSuite) TestDisableAllChannels() {
}

func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() {
suite.SetupMockTest()
suite.coordinator.Setup(suite.path)

// escrow a fee
Expand Down