From c2c121bfabcc87949e2937d60bd57a9e584aa280 Mon Sep 17 00:00:00 2001 From: tarumi Date: Tue, 31 Oct 2023 08:43:37 +0100 Subject: [PATCH] check module balance --- ...msg_server_withdraw_registration_fee_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/x/registry/keeper/msg_server_withdraw_registration_fee_test.go b/x/registry/keeper/msg_server_withdraw_registration_fee_test.go index 30a1ca36..7b87e2a8 100644 --- a/x/registry/keeper/msg_server_withdraw_registration_fee_test.go +++ b/x/registry/keeper/msg_server_withdraw_registration_fee_test.go @@ -5,6 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/mycel-domain/mycel/testutil" "github.com/mycel-domain/mycel/x/registry/types" @@ -54,7 +55,9 @@ func (suite *KeeperTestSuite) TestWithdrawRegistrationFee() { // Before balance withdrawerAddress, err := sdk.AccAddressFromBech32(tc.withdrawer) suite.Require().Nil(err) - beforeBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, withdrawerAddress) + beforeWithdrawerBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, withdrawerAddress) + registryAddress := authtypes.NewModuleAddress(types.ModuleName) + beforeRegistryAddress := suite.app.BankKeeper.GetAllBalances(suite.ctx, registryAddress) // Withdraw registration fee withdrawMsg := &types.MsgWithdrawRegistrationFee{ @@ -75,8 +78,16 @@ func (suite *KeeperTestSuite) TestWithdrawRegistrationFee() { } // Check balance - afterBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, withdrawerAddress) - suite.Require().Equal(beforeBalance.Add(fees.RegistrationFee...), afterBalance) + afterWithdrawerBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, withdrawerAddress) + suite.Require().Equal(beforeWithdrawerBalance.Add(fees.RegistrationFee...), afterWithdrawerBalance) + afterRegistyAddress := suite.app.BankKeeper.GetAllBalances(suite.ctx, registryAddress) + suite.Require().Equal(beforeRegistryAddress.Sub(fees.RegistrationFee...), afterRegistyAddress) + + // Check top level domain + topLevelDomain, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, tc.topLevelDomainName) + suite.Require().True(found) + suite.Require().True(topLevelDomain.RegistrationFee.IsEqual(sdk.NewCoins())) + } else { suite.Require().EqualError(err, tc.expErr.Error()) }