50 lines
1.5 KiB
Go
50 lines
1.5 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
|
|
|
|
queryClient types.QueryClient
|
|
}
|
|
|
|
func (suite *KeeperTestSuite) SetupTest() {
|
|
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
|
|
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0))
|
|
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1))
|
|
|
|
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))
|
|
}
|