diff --git a/go.work.sum b/go.work.sum index f28faeab..df4d1e5d 100644 --- a/go.work.sum +++ b/go.work.sum @@ -317,6 +317,8 @@ github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKz github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM= github.com/Joker/jade v1.1.3 h1:Qbeh12Vq6BxURXT1qZBRHsDxeURB8ztcL6f3EXSGeHk= github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM= +github.com/KYVENetwork/interchaintest/v8 v8.0.0-20240520124515-fd4cc797e6fd h1:lKJ7X9Q+KbQviDxpY4OaalC8/oZ64rXfTNTny4jfuE0= +github.com/KYVENetwork/interchaintest/v8 v8.0.0-20240520124515-fd4cc797e6fd/go.mod h1:pupV0YN3A56/u9kHj9U1F8MdDUEolBIn05F0W1q/0oI= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= diff --git a/interchaintest/global/abci_test.go b/interchaintest/global/abci_test.go new file mode 100644 index 00000000..a29fd14f --- /dev/null +++ b/interchaintest/global/abci_test.go @@ -0,0 +1,204 @@ +package global_test + +import ( + "context" + "testing" + + "cosmossdk.io/math" + i "github.com/KYVENetwork/chain/testutil/integration" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" +) + +/* + +TEST CASES - x/global/abci.go + +* BurnRatio = 0.0 +* BurnRatio = 2/3 - test truncate +* BurnRatio = 0.5 +* BurnRatio = 1.0 + +*/ + +func TestProposalHandler(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "interchaintest/x/global Test Suite") +} + +var _ = Describe("x/global/abci.go - Endblocker", func() { + It("BurnRatio = 0.0", func() { + // ARRANGE + ctx := context.Background() + burnRatio := math.LegacyZeroDec() + + chain, interchain, broadcaster, wallet := startNewChainWithCustomBurnRatio(ctx, burnRatio) + DeferCleanup(func() { + _ = chain.StopAllNodes(context.Background()) + _ = interchain.Close() + }) + + balanceBefore, err := chain.GetBalance(ctx, wallet.FormattedAddress(), chain.Config().Denom) + Expect(err).To(BeNil()) + result, err := chain.BankQueryTotalSupply(ctx) + Expect(err).To(BeNil()) + totalSupplyBefore := result.AmountOf(chain.Config().Denom) + + // ACT + msgSend := &banktypes.MsgSend{ + FromAddress: wallet.FormattedAddress(), + ToAddress: wallet.FormattedAddress(), + Amount: sdk.NewCoins(sdk.NewCoin(chain.Config().Denom, math.NewInt(i.T_KYVE))), + } + tx, err := cosmos.BroadcastTx(ctx, broadcaster, wallet, msgSend) + + // ASSERT + Expect(err).To(BeNil()) + Expect(tx.Code).To(Equal(uint32(0))) + + balance, err := chain.GetBalance(ctx, wallet.FormattedAddress(), chain.Config().Denom) + Expect(err).To(BeNil()) + + accountBalanceDifference := balanceBefore.Sub(balance) + Expect(accountBalanceDifference.Int64()).To(Equal(int64(200_000))) + + result, err = chain.BankQueryTotalSupply(ctx) + Expect(err).To(BeNil()) + totalSupply := result.AmountOf(chain.Config().Denom) + Expect(totalSupply).To(Equal(totalSupplyBefore)) + }) + + It("BurnRatio = 2/3 - test truncate", func() { + // ARRANGE + ctx := context.Background() + burnRatio := math.LegacyOneDec().MulInt64(2).QuoInt64(3) + + chain, interchain, broadcaster, wallet := startNewChainWithCustomBurnRatio(ctx, burnRatio) + DeferCleanup(func() { + _ = chain.StopAllNodes(context.Background()) + _ = interchain.Close() + }) + + balanceBefore, err := chain.GetBalance(ctx, wallet.FormattedAddress(), chain.Config().Denom) + Expect(err).To(BeNil()) + result, err := chain.BankQueryTotalSupply(ctx) + Expect(err).To(BeNil()) + totalSupplyBefore := result.AmountOf(chain.Config().Denom) + + // ACT + msgSend := &banktypes.MsgSend{ + FromAddress: wallet.FormattedAddress(), + ToAddress: wallet.FormattedAddress(), + Amount: sdk.NewCoins(sdk.NewCoin(chain.Config().Denom, math.NewInt(i.T_KYVE))), + } + tx, err := cosmos.BroadcastTx(ctx, broadcaster, wallet, msgSend) + + // ASSERT + Expect(err).To(BeNil()) + Expect(tx.Code).To(Equal(uint32(0))) + + balance, err := chain.GetBalance(ctx, wallet.FormattedAddress(), chain.Config().Denom) + Expect(err).To(BeNil()) + + accountBalanceDifference := balanceBefore.Sub(balance) + Expect(accountBalanceDifference.Int64()).To(Equal(int64(200_000))) + + result, err = chain.BankQueryTotalSupply(ctx) + Expect(err).To(BeNil()) + totalSupply := result.AmountOf(chain.Config().Denom) + totalSupplyDifference := totalSupplyBefore.Sub(totalSupply) + + // Expect ..666 not ..667 + Expect(totalSupplyDifference).To(Equal(math.NewInt(133_333))) + }) + + It("BurnRatio = 0.5", func() { + // ARRANGE + ctx := context.Background() + burnRatio := math.LegacyMustNewDecFromStr("0.5") + + chain, interchain, broadcaster, wallet := startNewChainWithCustomBurnRatio(ctx, burnRatio) + DeferCleanup(func() { + _ = chain.StopAllNodes(context.Background()) + _ = interchain.Close() + }) + + balanceBefore, err := chain.GetBalance(ctx, wallet.FormattedAddress(), chain.Config().Denom) + Expect(err).To(BeNil()) + result, err := chain.BankQueryTotalSupply(ctx) + Expect(err).To(BeNil()) + totalSupplyBefore := result.AmountOf(chain.Config().Denom) + + // ACT + msgSend := &banktypes.MsgSend{ + FromAddress: wallet.FormattedAddress(), + ToAddress: wallet.FormattedAddress(), + Amount: sdk.NewCoins(sdk.NewCoin(chain.Config().Denom, math.NewInt(i.T_KYVE))), + } + tx, err := cosmos.BroadcastTx(ctx, broadcaster, wallet, msgSend) + + // ASSERT + Expect(err).To(BeNil()) + Expect(tx.Code).To(Equal(uint32(0))) + + balance, err := chain.GetBalance(ctx, wallet.FormattedAddress(), chain.Config().Denom) + Expect(err).To(BeNil()) + + accountBalanceDifference := balanceBefore.Sub(balance) + Expect(accountBalanceDifference.Int64()).To(Equal(int64(200_000))) + + result, err = chain.BankQueryTotalSupply(ctx) + Expect(err).To(BeNil()) + totalSupply := result.AmountOf(chain.Config().Denom) + totalSupplyDifference := totalSupplyBefore.Sub(totalSupply) + + Expect(totalSupplyDifference).To(Equal(math.NewInt(100_000))) + }) + + It("BurnRatio = 1.0", func() { + // ARRANGE + ctx := context.Background() + burnRatio := math.LegacyMustNewDecFromStr("1.0") + + chain, interchain, broadcaster, wallet := startNewChainWithCustomBurnRatio(ctx, burnRatio) + DeferCleanup(func() { + _ = chain.StopAllNodes(context.Background()) + _ = interchain.Close() + }) + + balanceBefore, err := chain.GetBalance(ctx, wallet.FormattedAddress(), chain.Config().Denom) + Expect(err).To(BeNil()) + result, err := chain.BankQueryTotalSupply(ctx) + Expect(err).To(BeNil()) + totalSupplyBefore := result.AmountOf(chain.Config().Denom) + + // ACT + msgSend := &banktypes.MsgSend{ + FromAddress: wallet.FormattedAddress(), + ToAddress: wallet.FormattedAddress(), + Amount: sdk.NewCoins(sdk.NewCoin(chain.Config().Denom, math.NewInt(i.T_KYVE))), + } + tx, err := cosmos.BroadcastTx(ctx, broadcaster, wallet, msgSend) + + // ASSERT + Expect(err).To(BeNil()) + Expect(tx.Code).To(Equal(uint32(0))) + + balance, err := chain.GetBalance(ctx, wallet.FormattedAddress(), chain.Config().Denom) + Expect(err).To(BeNil()) + + accountBalanceDifference := balanceBefore.Sub(balance) + Expect(accountBalanceDifference.Int64()).To(Equal(int64(200_000))) + + result, err = chain.BankQueryTotalSupply(ctx) + Expect(err).To(BeNil()) + totalSupply := result.AmountOf(chain.Config().Denom) + totalSupplyDifference := totalSupplyBefore.Sub(totalSupply) + + Expect(totalSupplyDifference).To(Equal(math.NewInt(200_000))) + }) +}) diff --git a/interchaintest/global/abci_utils_test.go b/interchaintest/global/abci_utils_test.go new file mode 100644 index 00000000..bf2ddba0 --- /dev/null +++ b/interchaintest/global/abci_utils_test.go @@ -0,0 +1,135 @@ +package global_test + +import ( + "context" + "encoding/json" + "strconv" + + "cosmossdk.io/math" + + "github.com/KYVENetwork/chain/app" + i "github.com/KYVENetwork/chain/testutil/integration" + sdk "github.com/cosmos/cosmos-sdk/types" + sdktestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/icza/dyno" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/strangelove-ventures/interchaintest/v8" + "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" + "github.com/strangelove-ventures/interchaintest/v8/ibc" + "go.uber.org/zap/zaptest" +) + +const ( + uidGid = "1025:1025" +) + +func encodingConfig() *sdktestutil.TestEncodingConfig { + cfg := sdktestutil.TestEncodingConfig{} + a := app.Setup() + + cfg.Codec = a.AppCodec() + cfg.TxConfig = authtx.NewTxConfig(a.AppCodec(), authtx.DefaultSignModes) + cfg.InterfaceRegistry = a.InterfaceRegistry() + cfg.Amino = a.LegacyAmino() + + return &cfg +} + +func mainnetChainSpec(numValidators int, numFullNodes int, burnRatio math.LegacyDec) *interchaintest.ChainSpec { + return &interchaintest.ChainSpec{ + NumValidators: &numValidators, + NumFullNodes: &numFullNodes, + ChainConfig: ibc.ChainConfig{ + Type: "cosmos", + Name: "kyve", + ChainID: "kyve-1", + Bin: "kyved", + Bech32Prefix: "kyve", + Denom: "ukyve", + GasPrices: "1ukyve", + GasAdjustment: 10, + TrustingPeriod: "112h", + NoHostMount: false, + EncodingConfig: encodingConfig(), + ModifyGenesis: modifyGenesis(burnRatio), + Images: []ibc.DockerImage{{ + Repository: "kyve", + Version: "local", + UidGid: uidGid, + }}, + }, + } +} + +func modifyGenesis(burnRatio math.LegacyDec) func(config ibc.ChainConfig, genbz []byte) ([]byte, error) { + return func(config ibc.ChainConfig, genbz []byte) ([]byte, error) { + genesis := make(map[string]interface{}) + _ = json.Unmarshal(genbz, &genesis) + + teamSupply := math.NewInt(165_000_000_000_000) + balances, _ := dyno.GetSlice(genesis, "app_state", "bank", "balances") + balances = append(balances, bankTypes.Balance{ + Address: "kyve1e29j95xmsw3zmvtrk4st8e89z5n72v7nf70ma4", + Coins: sdk.NewCoins(sdk.NewCoin(config.Denom, teamSupply)), + }) + _ = dyno.Set(genesis, balances, "app_state", "bank", "balances") + totalSupply, _ := dyno.GetSlice(genesis, "app_state", "bank", "supply") + + // Update total supply + coin := totalSupply[0].(map[string]interface{}) + amountStr := coin["amount"].(string) + amount, _ := strconv.Atoi(amountStr) + totalSupply[0] = sdk.NewCoin(config.Denom, math.NewInt(int64(amount)+teamSupply.Int64())) + _ = dyno.Set(genesis, totalSupply, "app_state", "bank", "supply") + + // Set burn ratio to given value + _ = dyno.Set(genesis, burnRatio, + "app_state", "global", "params", "burn_ratio", + ) + + // Set inflation to zero + _ = dyno.Set(genesis, math.LegacyZeroDec(), + "app_state", "mint", "params", "inflation_min", + ) + _ = dyno.Set(genesis, math.LegacyZeroDec(), + "app_state", "mint", "params", "inflation_max", + ) + + newGenesis, _ := json.Marshal(genesis) + return newGenesis, nil + } +} + +// startNewChainWithCustomBurnRatio starts a new chain with the given burn ratio and an inflation of zero. +func startNewChainWithCustomBurnRatio(ctx context.Context, burnRatio math.LegacyDec) (*cosmos.CosmosChain, *interchaintest.Interchain, *cosmos.Broadcaster, *cosmos.CosmosWallet) { + numFullNodes := 0 + numValidators := 2 + factory := interchaintest.NewBuiltinChainFactory( + zaptest.NewLogger(GinkgoT()), + []*interchaintest.ChainSpec{mainnetChainSpec(numValidators, numFullNodes, burnRatio)}, + ) + + chains, err := factory.Chains(GinkgoT().Name()) + Expect(err).To(BeNil()) + chain := chains[0].(*cosmos.CosmosChain) + + interchain := interchaintest.NewInterchain().AddChain(chain) + + broadcaster := cosmos.NewBroadcaster(GinkgoT(), chain) + + dockerClient, network := interchaintest.DockerSetup(GinkgoT()) + + err = interchain.Build(ctx, nil, interchaintest.InterchainBuildOptions{ + TestName: GinkgoT().Name(), + Client: dockerClient, + NetworkID: network, + SkipPathCreation: true, + }) + Expect(err).To(BeNil()) + + wallet := interchaintest.GetAndFundTestUsers(GinkgoT(), ctx, GinkgoT().Name(), math.NewInt(10*i.T_KYVE), chain)[0].(*cosmos.CosmosWallet) + return chain, interchain, broadcaster, wallet +} diff --git a/interchaintest/ibc/ibc_test.go b/interchaintest/ibc/ibc_test.go index c4c82b42..66a5842b 100644 --- a/interchaintest/ibc/ibc_test.go +++ b/interchaintest/ibc/ibc_test.go @@ -2,6 +2,8 @@ package relayer_test import ( "context" + "testing" + "cosmossdk.io/math" "github.com/KYVENetwork/chain/testutil/integration" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" @@ -9,7 +11,6 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testreporter" "github.com/strangelove-ventures/interchaintest/v8/testutil" - "testing" "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" "go.uber.org/zap/zaptest" @@ -98,8 +99,8 @@ var _ = Describe("ibc", Ordered, func() { It("Transfer 1 $KYVE to Osmosis and back", func() { // ARRANGE startBalance := math.NewInt(10 * integration.T_KYVE) - var kyveWallet = interchaintest.GetAndFundTestUsers(GinkgoT(), ctx, GinkgoT().Name(), startBalance, kyve)[0].(*cosmos.CosmosWallet) - var osmosisWallet = interchaintest.GetAndFundTestUsers(GinkgoT(), ctx, GinkgoT().Name(), startBalance, osmosis)[0].(*cosmos.CosmosWallet) + kyveWallet := interchaintest.GetAndFundTestUsers(GinkgoT(), ctx, GinkgoT().Name(), startBalance, kyve)[0].(*cosmos.CosmosWallet) + osmosisWallet := interchaintest.GetAndFundTestUsers(GinkgoT(), ctx, GinkgoT().Name(), startBalance, osmosis)[0].(*cosmos.CosmosWallet) kyveChans, err := rel.GetChannels(ctx, eRep, kyve.Config().ChainID) Expect(err).To(BeNil()) diff --git a/interchaintest/ibc/ibc_utils_test.go b/interchaintest/ibc/ibc_utils_test.go index 1c8e86f5..8f3ec29c 100644 --- a/interchaintest/ibc/ibc_utils_test.go +++ b/interchaintest/ibc/ibc_utils_test.go @@ -1,8 +1,11 @@ package relayer_test import ( - "cosmossdk.io/math" "encoding/json" + "strconv" + + "cosmossdk.io/math" + "github.com/KYVENetwork/chain/app" sdk "github.com/cosmos/cosmos-sdk/types" sdktestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -13,7 +16,6 @@ import ( "github.com/onsi/gomega/types" "github.com/strangelove-ventures/interchaintest/v8" "github.com/strangelove-ventures/interchaintest/v8/ibc" - "strconv" ) const ( diff --git a/x/global/abci_test.go b/x/global/abci_test.go deleted file mode 100644 index 8338640d..00000000 --- a/x/global/abci_test.go +++ /dev/null @@ -1,174 +0,0 @@ -package global_test - -import ( - "cosmossdk.io/math" - i "github.com/KYVENetwork/chain/testutil/integration" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - // Global - "github.com/KYVENetwork/chain/x/global" - "github.com/KYVENetwork/chain/x/global/types" -) - -/* - -TEST CASES - DeductFeeDecorator - -* BurnRatio = 0.0 -* BurnRatio = 2/3 - test truncate -* BurnRatio = 0.5 -* BurnRatio = 1.0 - -* TODO(@max): combine with refund - -*/ - -// TODO(@rapha): This test is not working anymore. Here is why: -// Before: -// -// 1 AnteHandle is called which deducts the fee -// 2 CommitAfterSeconds(1) is called which... -// 2.1 Calls the EndBlocker's which runs the EndBlocker of our global module that we want to test -// 2.1.1 The EndBlocker function (x/global/abci.go) burns a part of the fee depending on the BurnRatio -// 2.2 The BeginBlocker's are called -// 2.2.1 The BeginBlocker of the distribution module is called, which sends the remaining fee to the distribution module -// -// Now: -// -// 1 AnteHandle is called which deducts the fee -// 2 CommitAfterSeconds(1) is called which... -// 2.1 Calls the BeginBlocker's -// 2.1.1 The BeginBlocker of the distribution module is called, which sends the remaining fee to the distribution module -// 2.2 The EndBlocker's are called -// 2.2.1 The EndBlocker function (x/global/abci.go) has nothing to do because the fee is already sent to the distribution module -// -// Why is this happening? -// Because our Commit/CommitAfterSeconds function changed because of the underlying changes in CometBFT. So we have to rewrite our tests. -// The AnteHandle has to be called after the BeginBlocker's are called (not after the EndBlocker's). -var _ = Describe("AbciEndBlocker", Ordered, func() { - s := i.NewCleanChain() - encodingConfig := BuildEncodingConfig() - dfd := global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, s.App().StakingKeeper) - - accountBalanceBefore := s.GetBalanceFromAddress(i.DUMMY[0]) - totalSupplyBefore := s.App().BankKeeper.GetSupply(s.Ctx(), types.Denom).Amount.Uint64() - - BeforeEach(func() { - s = i.NewCleanChain() - - mintParams, _ := s.App().MintKeeper.Params.Get(s.Ctx()) - mintParams.InflationMax = math.LegacyZeroDec() - mintParams.InflationMin = math.LegacyZeroDec() - _ = s.App().MintKeeper.Params.Set(s.Ctx(), mintParams) - - accountBalanceBefore = s.GetBalanceFromAddress(i.DUMMY[0]) - totalSupplyBefore = s.App().BankKeeper.GetSupply(s.Ctx(), types.Denom).Amount.Uint64() - dfd = global.NewDeductFeeDecorator(s.App().AccountKeeper, s.App().BankKeeper, s.App().FeeGrantKeeper, s.App().GlobalKeeper, s.App().StakingKeeper) - }) - - AfterEach(func() { - s.PerformValidityChecks() - }) - - PIt("BurnRatio = 0.0", func() { - // ARRANGE - // default burn ratio is zero - denom, _ := s.App().StakingKeeper.BondDenom(s.Ctx()) - tx := BuildTestTx(math.NewInt(1), denom, i.DUMMY[0], encodingConfig) - - // ACT - _, err := dfd.AnteHandle(s.Ctx(), tx, false, AnteNextFn) - s.CommitAfterSeconds(1) - - // ASSERT - Expect(err).Should(Not(HaveOccurred())) - - accountBalanceAfter := s.GetBalanceFromAddress(i.DUMMY[0]) - accountBalanceDifference := accountBalanceBefore - accountBalanceAfter - Expect(accountBalanceDifference).To(Equal(uint64(200_000))) - - totalSupplyAfter := s.App().BankKeeper.GetSupply(s.Ctx(), types.Denom).Amount.Uint64() - totalSupplyDifference := totalSupplyBefore - totalSupplyAfter - Expect(totalSupplyDifference).To(Equal(uint64(0))) - }) - - PIt("BurnRatio = 2/3 - test truncate", func() { - // ARRANGE - // set burn ratio to 0.3 - params := types.DefaultParams() - params.BurnRatio = math.LegacyOneDec().MulInt64(2).QuoInt64(3) - s.App().GlobalKeeper.SetParams(s.Ctx(), params) - - // default burn ratio is zero - denom, _ := s.App().StakingKeeper.BondDenom(s.Ctx()) - tx := BuildTestTx(math.NewInt(1), denom, i.DUMMY[0], encodingConfig) - - // ACT - _, err := dfd.AnteHandle(s.Ctx(), tx, false, AnteNextFn) - s.CommitAfterSeconds(1) - - // ASSERT - Expect(err).Should(Not(HaveOccurred())) - - accountBalanceAfter := s.GetBalanceFromAddress(i.DUMMY[0]) - accountBalanceDifference := accountBalanceBefore - accountBalanceAfter - Expect(accountBalanceDifference).To(Equal(uint64(200_000))) - - totalSupplyAfter := s.App().BankKeeper.GetSupply(s.Ctx(), types.Denom).Amount.Uint64() - totalSupplyDifference := totalSupplyBefore - totalSupplyAfter - // Expect ..666 not ..667 - Expect(totalSupplyDifference).To(Equal(uint64(133_333))) - }) - - PIt("BurnRatio = 0.5", func() { - // ARRANGE - // set burn ratio to 0.5 - params := types.DefaultParams() - params.BurnRatio = math.LegacyOneDec().QuoInt64(2) - s.App().GlobalKeeper.SetParams(s.Ctx(), params) - - denom, _ := s.App().StakingKeeper.BondDenom(s.Ctx()) - tx := BuildTestTx(math.NewInt(1), denom, i.DUMMY[0], encodingConfig) - - // ACT - _, err := dfd.AnteHandle(s.Ctx(), tx, false, AnteNextFn) - s.CommitAfterSeconds(1) - - // ASSERT - Expect(err).Should(Not(HaveOccurred())) - - accountBalanceAfter := s.GetBalanceFromAddress(i.DUMMY[0]) - accountBalanceDifference := accountBalanceBefore - accountBalanceAfter - Expect(accountBalanceDifference).To(Equal(uint64(200_000))) - - totalSupplyAfter := s.App().BankKeeper.GetSupply(s.Ctx(), types.Denom).Amount.Uint64() - totalSupplyDifference := totalSupplyBefore - totalSupplyAfter - Expect(totalSupplyDifference).To(Equal(uint64(100_000))) - }) - - PIt("BurnRatio = 1.0", func() { - // ARRANGE - // set burn ratio to 0.5 - params := types.DefaultParams() - params.BurnRatio = math.LegacyOneDec() - s.App().GlobalKeeper.SetParams(s.Ctx(), params) - - denom, _ := s.App().StakingKeeper.BondDenom(s.Ctx()) - tx := BuildTestTx(math.NewInt(1), denom, i.DUMMY[0], encodingConfig) - - // ACT - _, err := dfd.AnteHandle(s.Ctx(), tx, false, AnteNextFn) - s.CommitAfterSeconds(1) - - // ASSERT - Expect(err).Should(Not(HaveOccurred())) - - accountBalanceAfter := s.GetBalanceFromAddress(i.DUMMY[0]) - accountBalanceDifference := accountBalanceBefore - accountBalanceAfter - Expect(accountBalanceDifference).To(Equal(uint64(200_000))) - - totalSupplyAfter := s.App().BankKeeper.GetSupply(s.Ctx(), types.Denom).Amount.Uint64() - totalSupplyDifference := totalSupplyBefore - totalSupplyAfter - Expect(totalSupplyDifference).To(Equal(uint64(200_000))) - }) -})