github.com/okex/exchain@v1.8.0/libs/ibc-go/modules/apps/transfer/keeper/keeper_test.go (about) 1 package keeper_test 2 3 import ( 4 "github.com/okex/exchain/libs/tendermint/crypto" 5 "testing" 6 7 "github.com/stretchr/testify/suite" 8 // "github.com/tendermint/tendermint/crypto" 9 10 sdk "github.com/okex/exchain/libs/cosmos-sdk/types" 11 "github.com/okex/exchain/libs/ibc-go/modules/apps/transfer/types" 12 ibctesting "github.com/okex/exchain/libs/ibc-go/testing" 13 ) 14 15 type KeeperTestSuite struct { 16 suite.Suite 17 18 coordinator *ibctesting.Coordinator 19 20 // testing chains used for convenience and readability 21 chainA ibctesting.TestChainI 22 chainB ibctesting.TestChainI 23 chainC ibctesting.TestChainI 24 25 queryClient types.QueryClient 26 } 27 28 func (suite *KeeperTestSuite) SetupTest() { 29 suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) 30 suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0)) 31 suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) 32 suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(2)) 33 34 //todo no query 35 //queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry()) 36 //types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().TransferKeeper) 37 //suite.queryClient = types.NewQueryClient(queryHelper) 38 } 39 40 func NewTransferPath(chainA, chainB ibctesting.TestChainI) *ibctesting.Path { 41 path := ibctesting.NewPath(chainA, chainB) 42 path.EndpointA.ChannelConfig.PortID = ibctesting.TransferPort 43 path.EndpointB.ChannelConfig.PortID = ibctesting.TransferPort 44 45 return path 46 } 47 48 func (suite *KeeperTestSuite) TestGetTransferAccount() { 49 expectedMaccAddr := sdk.AccAddress(crypto.AddressHash([]byte(types.ModuleName))) 50 51 macc := suite.chainA.GetSimApp().TransferKeeper.GetTransferAccount(suite.chainA.GetContext()) 52 53 suite.Require().NotNil(macc) 54 suite.Require().Equal(types.ModuleName, macc.GetName()) 55 suite.Require().Equal(expectedMaccAddr, macc.GetAddress()) 56 } 57 58 func TestKeeperTestSuite(t *testing.T) { 59 suite.Run(t, new(KeeperTestSuite)) 60 }