cosmos-sdk/x/ibc/applications/transfer/keeper/keeper_test.go

52 lines
1.6 KiB
Go

package keeper_test
import (
"testing"
"github.com/stretchr/testify/suite"
"github.com/tendermint/tendermint/crypto"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
)
type KeeperTestSuite struct {
suite.Suite
coordinator *ibctesting.Coordinator
// testing chains used for convenience and readability
chainA *ibctesting.TestChain
chainB *ibctesting.TestChain
chainC *ibctesting.TestChain
queryClient types.QueryClient
}
func (suite *KeeperTestSuite) SetupTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1))
suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(2))
queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.App.InterfaceRegistry())
types.RegisterQueryServer(queryHelper, suite.chainA.App.TransferKeeper)
suite.queryClient = types.NewQueryClient(queryHelper)
}
func (suite *KeeperTestSuite) TestGetTransferAccount() {
expectedMaccAddr := sdk.AccAddress(crypto.AddressHash([]byte(types.ModuleName)))
macc := suite.chainA.App.TransferKeeper.GetTransferAccount(suite.chainA.GetContext())
suite.Require().NotNil(macc)
suite.Require().Equal(types.ModuleName, macc.GetName())
suite.Require().Equal(expectedMaccAddr, macc.GetAddress())
}
func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
}