@@ -13,6 +13,7 @@ import (
1313 "github.com/golang/mock/gomock"
1414 "github.com/stretchr/testify/suite"
1515
16+ "cosmossdk.io/core/address"
1617 coreevent "cosmossdk.io/core/event"
1718 "cosmossdk.io/core/header"
1819 coretesting "cosmossdk.io/core/testing"
@@ -24,7 +25,6 @@ import (
2425 banktypes "cosmossdk.io/x/bank/types"
2526
2627 "github.com/cosmos/cosmos-sdk/baseapp"
27- "github.com/cosmos/cosmos-sdk/codec/address"
2828 codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
2929 "github.com/cosmos/cosmos-sdk/runtime"
3030 "github.com/cosmos/cosmos-sdk/testutil"
@@ -114,6 +114,7 @@ type KeeperTestSuite struct {
114114
115115 ctx context.Context
116116 bankKeeper keeper.BaseKeeper
117+ addrCdc address.Codec
117118 authKeeper * banktestutil.MockAccountKeeper
118119
119120 queryClient banktypes.QueryClient
@@ -143,9 +144,10 @@ func (suite *KeeperTestSuite) SetupTest() {
143144 // gomock initializations
144145 ctrl := gomock .NewController (suite .T ())
145146 authKeeper := banktestutil .NewMockAccountKeeper (ctrl )
146- authKeeper .EXPECT ().AddressCodec ().Return (address . NewBech32Codec ( "cosmos" ) ).AnyTimes ()
147+ authKeeper .EXPECT ().AddressCodec ().Return (ac ).AnyTimes ()
147148 suite .ctx = ctx
148149 suite .authKeeper = authKeeper
150+ suite .addrCdc = ac
149151 suite .bankKeeper = keeper .NewBaseKeeper (
150152 env ,
151153 encCfg .Codec ,
@@ -320,9 +322,9 @@ func (suite *KeeperTestSuite) TestGetAuthority() {
320322 authority ,
321323 )
322324 }
323- govAddr , err := suite .authKeeper . AddressCodec () .BytesToString (authtypes .NewModuleAddress (banktypes .GovModuleName ))
325+ govAddr , err := suite .addrCdc .BytesToString (authtypes .NewModuleAddress (banktypes .GovModuleName ))
324326 suite .Require ().NoError (err )
325- modAddr , err := suite .authKeeper . AddressCodec () .BytesToString (authtypes .NewModuleAddress (banktypes .MintModuleName ))
327+ modAddr , err := suite .addrCdc .BytesToString (authtypes .NewModuleAddress (banktypes .MintModuleName ))
326328 suite .Require ().NoError (err )
327329
328330 tests := map [string ]string {
@@ -647,9 +649,9 @@ func (suite *KeeperTestSuite) TestInputOutputNewAccount() {
647649
648650 require .Empty (suite .bankKeeper .GetAllBalances (ctx , accAddrs [1 ]))
649651
650- acc0StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [0 ])
652+ acc0StrAddr , err := suite .addrCdc .BytesToString (accAddrs [0 ])
651653 suite .Require ().NoError (err )
652- acc1StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [1 ])
654+ acc1StrAddr , err := suite .addrCdc .BytesToString (accAddrs [1 ])
653655 suite .Require ().NoError (err )
654656
655657 suite .mockInputOutputCoins ([]sdk.AccountI {authtypes .NewBaseAccountWithAddress (accAddrs [0 ])}, []sdk.AccAddress {accAddrs [1 ]})
@@ -674,11 +676,11 @@ func (suite *KeeperTestSuite) TestInputOutputCoins() {
674676
675677 acc0 := authtypes .NewBaseAccountWithAddress (accAddrs [0 ])
676678
677- acc0StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [0 ])
679+ acc0StrAddr , err := suite .addrCdc .BytesToString (accAddrs [0 ])
678680 suite .Require ().NoError (err )
679- acc1StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [1 ])
681+ acc1StrAddr , err := suite .addrCdc .BytesToString (accAddrs [1 ])
680682 suite .Require ().NoError (err )
681- acc2StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [2 ])
683+ acc2StrAddr , err := suite .addrCdc .BytesToString (accAddrs [2 ])
682684 suite .Require ().NoError (err )
683685
684686 input := banktypes.Input {
@@ -786,16 +788,16 @@ func (suite *KeeperTestSuite) TestInputOutputCoinsWithRestrictions() {
786788 setupCtx := suite .ctx
787789 balances := sdk .NewCoins (newFooCoin (1000 ), newBarCoin (500 ))
788790 fromAddr := accAddrs [0 ]
789- fromStrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (fromAddr )
791+ fromStrAddr , err := suite .addrCdc .BytesToString (fromAddr )
790792 suite .Require ().NoError (err )
791793 fromAcc := authtypes .NewBaseAccountWithAddress (fromAddr )
792794 inputAccs := []sdk.AccountI {fromAcc }
793795 suite .authKeeper .EXPECT ().GetAccount (suite .ctx , inputAccs [0 ].GetAddress ()).Return (inputAccs [0 ]).AnyTimes ()
794796 toAddr1 := accAddrs [1 ]
795- toAddr1Str , err := suite .authKeeper . AddressCodec () .BytesToString (toAddr1 )
797+ toAddr1Str , err := suite .addrCdc .BytesToString (toAddr1 )
796798 suite .Require ().NoError (err )
797799 toAddr2 := accAddrs [2 ]
798- toAddr2Str , err := suite .authKeeper . AddressCodec () .BytesToString (toAddr2 )
800+ toAddr2Str , err := suite .addrCdc .BytesToString (toAddr2 )
799801 suite .Require ().NoError (err )
800802
801803 suite .mockFundAccount (accAddrs [0 ])
@@ -1365,9 +1367,9 @@ func (suite *KeeperTestSuite) TestMsgSendEvents() {
13651367
13661368 acc0 := authtypes .NewBaseAccountWithAddress (accAddrs [0 ])
13671369
1368- acc0StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [0 ])
1370+ acc0StrAddr , err := suite .addrCdc .BytesToString (accAddrs [0 ])
13691371 suite .Require ().NoError (err )
1370- acc1StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [1 ])
1372+ acc1StrAddr , err := suite .addrCdc .BytesToString (accAddrs [1 ])
13711373 suite .Require ().NoError (err )
13721374
13731375 newCoins := sdk .NewCoins (sdk .NewInt64Coin (fooDenom , 50 ))
@@ -1407,11 +1409,11 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() {
14071409
14081410 require .NoError (suite .bankKeeper .SetParams (ctx , banktypes .DefaultParams ()))
14091411
1410- acc0StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [0 ])
1412+ acc0StrAddr , err := suite .addrCdc .BytesToString (accAddrs [0 ])
14111413 suite .Require ().NoError (err )
1412- acc2StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [2 ])
1414+ acc2StrAddr , err := suite .addrCdc .BytesToString (accAddrs [2 ])
14131415 suite .Require ().NoError (err )
1414- acc3StrAddr , err := suite .authKeeper . AddressCodec () .BytesToString (accAddrs [3 ])
1416+ acc3StrAddr , err := suite .addrCdc .BytesToString (accAddrs [3 ])
14151417 suite .Require ().NoError (err )
14161418
14171419 coins := sdk .NewCoins (sdk .NewInt64Coin (fooDenom , 50 ), sdk .NewInt64Coin (barDenom , 100 ))
@@ -1932,15 +1934,15 @@ func (suite *KeeperTestSuite) TestBalanceTrackingEvents() {
19321934 case banktypes .EventTypeCoinSpent :
19331935 coinsSpent , err := sdk .ParseCoinsNormalized (e .Attributes [1 ].Value )
19341936 require .NoError (err )
1935- _ , err = suite .authKeeper . AddressCodec () .StringToBytes (e .Attributes [0 ].Value )
1937+ _ , err = suite .addrCdc .StringToBytes (e .Attributes [0 ].Value )
19361938 require .NoError (err )
19371939
19381940 balances [e .Attributes [0 ].Value ] = balances [e .Attributes [0 ].Value ].Sub (coinsSpent ... )
19391941
19401942 case banktypes .EventTypeCoinReceived :
19411943 coinsRecv , err := sdk .ParseCoinsNormalized (e .Attributes [1 ].Value )
19421944 require .NoError (err )
1943- _ , err = suite .authKeeper . AddressCodec () .StringToBytes (e .Attributes [0 ].Value )
1945+ _ , err = suite .addrCdc .StringToBytes (e .Attributes [0 ].Value )
19441946 require .NoError (err )
19451947 balances [e .Attributes [0 ].Value ] = balances [e .Attributes [0 ].Value ].Add (coinsRecv ... )
19461948 }
@@ -1958,7 +1960,7 @@ func (suite *KeeperTestSuite) TestBalanceTrackingEvents() {
19581960 return false
19591961 }
19601962
1961- addr , err := suite .authKeeper . AddressCodec () .BytesToString (address )
1963+ addr , err := suite .addrCdc .BytesToString (address )
19621964 suite .Require ().NoError (err )
19631965
19641966 balance , exists := balances [addr ]
0 commit comments