Skip to content

Commit

Permalink
move AccountKeeper -> AuthKeeper
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Sep 17, 2024
1 parent 9c63946 commit 455e404
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() {
icaHostAccount := icatypes.GenerateAddress(suite.chainB.GetContext(), suite.chainB.GetSimApp().ICAHostKeeper.Environment, path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID)
err := suite.chainB.GetSimApp().BankKeeper.SendCoins(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), icaHostAccount, sdk.Coins{sdk.NewCoin("stake", sdkmath.NewInt(1))})
suite.Require().NoError(err)
suite.Require().True(suite.chainB.GetSimApp().AccountKeeper.HasAccount(suite.chainB.GetContext(), icaHostAccount))
suite.Require().True(suite.chainB.GetSimApp().AuthKeeper.HasAccount(suite.chainB.GetContext(), icaHostAccount))

// ensure account registration is simulated in a separate block
suite.chainB.NextBlock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() {
addr, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID)
suite.Require().True(found)

acc := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), sdk.MustAccAddressFromBech32(addr))
suite.chainB.GetSimApp().AccountKeeper.RemoveAccount(suite.chainB.GetContext(), acc)
acc := suite.chainB.GetSimApp().AuthKeeper.GetAccount(suite.chainB.GetContext(), sdk.MustAccAddressFromBech32(addr))
suite.chainB.GetSimApp().AuthKeeper.RemoveAccount(suite.chainB.GetContext(), acc)
},
icatypes.ErrInvalidAccountReopening,
},
Expand All @@ -159,13 +159,13 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() {
suite.Require().True(found)

accAddress := sdk.MustAccAddressFromBech32(addr)
acc := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), accAddress)
acc := suite.chainB.GetSimApp().AuthKeeper.GetAccount(suite.chainB.GetContext(), accAddress)

icaAcc, ok := acc.(*icatypes.InterchainAccount)
suite.Require().True(ok)

// overwrite existing account with only base account type, not intercahin account type
suite.chainB.GetSimApp().AccountKeeper.SetAccount(suite.chainB.GetContext(), icaAcc.BaseAccount)
suite.chainB.GetSimApp().AuthKeeper.SetAccount(suite.chainB.GetContext(), icaAcc.BaseAccount)
},
icatypes.ErrInvalidAccountReopening,
},
Expand All @@ -175,7 +175,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() {
interchainAccAddr := icatypes.GenerateAddress(suite.chainB.GetContext(), suite.chainB.GetSimApp().ICAHostKeeper.Environment, path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID)
err := suite.chainB.GetSimApp().BankKeeper.SendCoins(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), interchainAccAddr, sdk.Coins{sdk.NewCoin("stake", sdkmath.NewInt(1))})
suite.Require().NoError(err)
suite.Require().True(suite.chainB.GetSimApp().AccountKeeper.HasAccount(suite.chainB.GetContext(), interchainAccAddr))
suite.Require().True(suite.chainB.GetSimApp().AuthKeeper.HasAccount(suite.chainB.GetContext(), interchainAccAddr))
},
icatypes.ErrAccountAlreadyExist,
},
Expand Down Expand Up @@ -321,7 +321,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() {
suite.Require().NoError(err)

// Check if account is created
interchainAccount := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), interchainAccAddr)
interchainAccount := suite.chainB.GetSimApp().AuthKeeper.GetAccount(suite.chainB.GetContext(), interchainAccAddr)
suite.Require().Equal(interchainAccount.GetAddress().String(), storedAddr)

expectedMetadata.Address = storedAddr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.PortKeeper,
suite.chainA.GetSimApp().AccountKeeper,
suite.chainA.GetSimApp().AuthKeeper,
suite.chainA.GetSimApp().ScopedICAHostKeeper,
suite.chainA.GetSimApp().MsgServiceRouter(),
suite.chainA.GetSimApp().GRPCQueryRouter(),
Expand Down Expand Up @@ -176,7 +176,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.PortKeeper,
suite.chainA.GetSimApp().AccountKeeper,
suite.chainA.GetSimApp().AuthKeeper,
suite.chainA.GetSimApp().ScopedICAHostKeeper,
suite.chainA.GetSimApp().MsgServiceRouter(),
suite.chainA.GetSimApp().GRPCQueryRouter(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (suite *KeeperTestSuite) TestMigratorMigrateParams() {
suite.chainA.GetSimApp().IBCFeeKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.PortKeeper,
suite.chainA.GetSimApp().AccountKeeper,
suite.chainA.GetSimApp().AuthKeeper,
suite.chainA.GetSimApp().ScopedICAHostKeeper,
suite.chainA.GetSimApp().MsgServiceRouter(),
suite.chainA.GetSimApp().GRPCQueryRouter(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() {
suite.Require().NoError(err)

// Check if account is created
interchainAccount := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), icaAddr)
interchainAccount := suite.chainB.GetSimApp().AuthKeeper.GetAccount(suite.chainB.GetContext(), icaAddr)
suite.Require().Equal(interchainAccount.GetAddress().String(), storedAddr)

suite.fundICAWallet(suite.chainB.GetContext(), path.EndpointA.ChannelConfig.PortID, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000000))))
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/29-fee/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {
{
"success: fail to distribute recv fee (blocked address), returned to refund account",
func() {
blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
blockedAddr := suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()

// reassign ack.ForwardRelayerAddress to a blocked address
ack = types.NewIncentivizedAcknowledgement(blockedAddr.String(), ibcmock.MockAcknowledgement.Acknowledgement(), true).Acknowledgement()
Expand Down Expand Up @@ -954,7 +954,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() {
{
"success: fail to distribute timeout fee (blocked address), returned to refund account",
func() {
relayerAddr = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
relayerAddr = suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
},
nil,
func() {},
Expand Down
18 changes: 9 additions & 9 deletions modules/apps/29-fee/keeper/escrow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() {
// set the timeout fee to be greater than recv + ack fee so that the refund amount is non-zero
fee.TimeoutFee = fee.Total().Add(ibctesting.TestCoin)

refundAcc = suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(mock.ModuleName)
refundAcc = suite.chainA.GetSimApp().AuthKeeper.GetModuleAddress(mock.ModuleName)

packetFee = types.NewPacketFee(fee, refundAcc.String(), []string{})
packetFees = []types.PacketFee{packetFee, packetFee}
Expand Down Expand Up @@ -168,7 +168,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() {
packetFee = types.NewPacketFee(fee, refundAcc.String(), []string{})
packetFees = []types.PacketFee{packetFee, packetFee}

forwardRelayer = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
forwardRelayer = suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
},
func() {
// check if the refund acc has been refunded the timeoutFee & recvFee
Expand All @@ -183,7 +183,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() {
packetFee = types.NewPacketFee(fee, refundAcc.String(), []string{})
packetFees = []types.PacketFee{packetFee, packetFee}

reverseRelayer = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
reverseRelayer = suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
},
func() {
// check if the refund acc has been refunded the ackFee
Expand All @@ -201,8 +201,8 @@ func (suite *KeeperTestSuite) TestDistributeFee() {
packetFee = types.NewPacketFee(fee, refundAcc.String(), []string{})
packetFees = []types.PacketFee{packetFee, packetFee}

packetFees[0].RefundAddress = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
packetFees[1].RefundAddress = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
packetFees[0].RefundAddress = suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
packetFees[1].RefundAddress = suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
},
func() {
// check if the module acc contains the timeoutFee
Expand Down Expand Up @@ -328,7 +328,7 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() {
{
"invalid timeout relayer address: timeout fee returned to sender",
func() {
timeoutRelayer = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
timeoutRelayer = suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
},
func() {
// check if the refund acc has been refunded the all the fees
Expand All @@ -345,8 +345,8 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() {
packetFee = types.NewPacketFee(fee, refundAcc.String(), []string{})
packetFees = []types.PacketFee{packetFee, packetFee}

packetFees[0].RefundAddress = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
packetFees[1].RefundAddress = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
packetFees[0].RefundAddress = suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
packetFees[1].RefundAddress = suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
},
func() {
// check if the module acc contains the correct amount of fees
Expand Down Expand Up @@ -531,7 +531,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannelClosure() {
},
{
"distributing to blocked address is skipped", func() {
blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
blockedAddr := suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()

// store the fee in state & update escrow account balance
packetID := channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, uint64(1))
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (suite *KeeperTestSuite) TestMigrate1to2() {

refundAcc = suite.chainA.SenderAccount.GetAddress()
packetFee = types.NewPacketFee(fee, refundAcc.String(), []string(nil))
moduleAcc = suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(types.ModuleName)
moduleAcc = suite.chainA.GetSimApp().AuthKeeper.GetModuleAddress(types.ModuleName)
packetID = channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, 1)
packetFees = nil

Expand Down
8 changes: 4 additions & 4 deletions modules/apps/29-fee/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (suite *KeeperTestSuite) TestRegisterPayee() {
{
"payee is a blocked address",
func() {
msg.Payee = suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(transfertypes.ModuleName).String()
msg.Payee = suite.chainA.GetSimApp().AuthKeeper.GetModuleAddress(transfertypes.ModuleName).String()
},
ibcerrors.ErrUnauthorized,
},
Expand Down Expand Up @@ -248,7 +248,7 @@ func (suite *KeeperTestSuite) TestPayPacketFee() {
"refund account is module account",
func() {
suite.chainA.GetSimApp().BankKeeper.SendCoinsFromAccountToModule(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibcmock.ModuleName, fee.Total()) //nolint:errcheck // ignore error for testing
msg.Signer = suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(ibcmock.ModuleName).String()
msg.Signer = suite.chainA.GetSimApp().AuthKeeper.GetModuleAddress(ibcmock.ModuleName).String()
expPacketFee := types.NewPacketFee(fee, msg.Signer, nil)
expFeesInEscrow = []types.PacketFee{expPacketFee}
},
Expand Down Expand Up @@ -298,7 +298,7 @@ func (suite *KeeperTestSuite) TestPayPacketFee() {
{
"refund account is a blocked address",
func() {
blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
blockedAddr := suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
msg.Signer = blockedAddr.String()
},
ibcerrors.ErrUnauthorized,
Expand Down Expand Up @@ -528,7 +528,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() {
{
"refund account is a blocked address",
func() {
blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
blockedAddr := suite.chainA.GetSimApp().AuthKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()
msg.PacketFee.RefundAddress = blockedAddr.String()
},
ibcerrors.ErrUnauthorized,
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (suite *FeeTestSuite) TestTransferFeeUpgrade() {
res, err := suite.chainA.SendMsgs(msgs...)
suite.Require().NoError(err) // message committed

feeEscrowAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(types.ModuleName)
feeEscrowAddr := suite.chainA.GetSimApp().AuthKeeper.GetModuleAddress(types.ModuleName)
escrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), feeEscrowAddr, sdk.DefaultBondDenom)
suite.Require().Equal(escrowBalance.Amount, fee.Total().AmountOf(sdk.DefaultBondDenom))

Expand Down
8 changes: 4 additions & 4 deletions modules/apps/transfer/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.PortKeeper,
suite.chainA.GetSimApp().AccountKeeper,
suite.chainA.GetSimApp().AuthKeeper,
suite.chainA.GetSimApp().BankKeeper,
suite.chainA.GetSimApp().ScopedTransferKeeper,
suite.chainA.GetSimApp().ICAControllerKeeper.GetAuthority(),
Expand Down Expand Up @@ -101,7 +101,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.PortKeeper,
suite.chainA.GetSimApp().AccountKeeper,
suite.chainA.GetSimApp().AuthKeeper,
suite.chainA.GetSimApp().BankKeeper,
suite.chainA.GetSimApp().ScopedTransferKeeper,
"", // authority
Expand Down Expand Up @@ -410,7 +410,7 @@ func (suite *KeeperTestSuite) TestIsBlockedAddr() {
}{
{
"transfer module account address",
suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(types.ModuleName),
suite.chainA.GetSimApp().AuthKeeper.GetModuleAddress(types.ModuleName),
false,
},
{
Expand All @@ -420,7 +420,7 @@ func (suite *KeeperTestSuite) TestIsBlockedAddr() {
},
{
"blocked address",
suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(minttypes.ModuleName),
suite.chainA.GetSimApp().AuthKeeper.GetModuleAddress(minttypes.ModuleName),
true,
},
}
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/transfer/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() {
{
"failure: sender is a blocked address",
func() {
msg.Sender = suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(minttypes.ModuleName).String()
msg.Sender = suite.chainA.GetSimApp().AuthKeeper.GetModuleAddress(minttypes.ModuleName).String()
},
ibcerrors.ErrUnauthorized,
},
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/transfer/keeper/relay_forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ func (suite *ForwardingTestSuite) TestOnTimeoutPacketForwarding() {
suite.Require().True(found, "Chain B has no forwarded packet")
suite.Require().Equal(packet, forwardedPacket, "ForwardedPacket stored in ChainB is not the same that was sent")

address := suite.chainB.GetSimApp().AccountKeeper.GetModuleAddress(types.ModuleName).String()
address := suite.chainB.GetSimApp().AuthKeeper.GetModuleAddress(types.ModuleName).String()
data := types.NewFungibleTokenPacketDataV2(
[]types.Token{
{
Expand Down
6 changes: 3 additions & 3 deletions modules/apps/transfer/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
{
"failure: sender account is blocked",
func() {
sender = suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(minttypes.ModuleName)
sender = suite.chainA.GetSimApp().AuthKeeper.GetModuleAddress(minttypes.ModuleName)
},
ibcerrors.ErrUnauthorized,
},
Expand Down Expand Up @@ -352,7 +352,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsNotSource() {
{
"failure: receiver is module account",
func() {
packetData.Receiver = suite.chainB.GetSimApp().AccountKeeper.GetModuleAddress(minttypes.ModuleName).String()
packetData.Receiver = suite.chainB.GetSimApp().AuthKeeper.GetModuleAddress(minttypes.ModuleName).String()
},
ibcerrors.ErrUnauthorized,
},
Expand Down Expand Up @@ -501,7 +501,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsSource() {
{
"failure: receiver is module account",
func() {
packetData.Receiver = suite.chainB.GetSimApp().AccountKeeper.GetModuleAddress(minttypes.ModuleName).String()
packetData.Receiver = suite.chainB.GetSimApp().AuthKeeper.GetModuleAddress(minttypes.ModuleName).String()
},
ibcerrors.ErrUnauthorized,
},
Expand Down

0 comments on commit 455e404

Please sign in to comment.