Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
technicallyty committed Feb 4, 2025
1 parent 8bdb488 commit b3754bd
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 32 deletions.
1 change: 0 additions & 1 deletion tests/app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func NewAnteHandler(options AnteHandlerOptions) (sdk.AnteHandler, error) {
options.TxFeeChecker,
),
) // fees are deducted in the fee market deduct post handler
_ = feemarketDecorator
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(options.Environment, options.ConsensusKeeper), // outermost AnteDecorator. SetUpContext must be called first
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/cosmos/cosmos-sdk/codec/address"
testutil2 "github.com/cosmos/cosmos-sdk/codec/testutil"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/strangelove-ventures/interchaintest/v9"
Expand Down Expand Up @@ -36,7 +36,7 @@ var (
Version: "latest",
UidGid: "1000:1000",
}
codecOpts = testutil2.CodecOptions{
codecOpts = codectestutil.CodecOptions{
AccAddressPrefix: "cosmos",
ValAddressPrefix: "cosmosvaloper",
AddressCodec: address.NewBech32Codec("cosmos"),
Expand Down
5 changes: 0 additions & 5 deletions tests/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,3 @@ func AlphaString(r *rand.Rand, n int) string {
}
return string(randomString)
}

/*
simd tx bank send cosmos1akl02chz6s65r3hda56j0l6e8e68ulxhmar2u9 cosmos1feg8kqevnkz5p5qyr9f5ta2qyszmqlv48hhr4a 10stake --fees 200000stake --chain-id chain-id-0 --from cosmos1akl02chz6s65r3hda56j0l6e8e68ulxhmar2u9
*/
2 changes: 1 addition & 1 deletion tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestIntegrationTestSuite(t *testing.T) {
}

func (s *IntegrationTestSuite) SetupTest() {
s.fixture = testkeeper.NewTestFixture(s.T(), nil)
s.fixture = testkeeper.NewTestFixture(s.T())
s.ctx = s.fixture.Ctx
}

Expand Down
16 changes: 4 additions & 12 deletions testutils/fixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"cosmossdk.io/store/metrics"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/accounts"
"cosmossdk.io/x/accounts/accountstd"
baseaccount "cosmossdk.io/x/accounts/defaults/base"
accountsv1 "cosmossdk.io/x/accounts/v1"
"cosmossdk.io/x/bank"
Expand Down Expand Up @@ -72,7 +71,7 @@ func setupDBs() (store.CommitMultiStore, *dbm.MemDB) {
return stateStore, db
}

func NewTestFixture(t *testing.T, extraAccs map[string]accountstd.Interface) *TestFixture {
func NewTestFixture(t *testing.T) *TestFixture {
cms, db := setupDBs()
t.Helper()
keys := storetypes.NewKVStoreKeys(
Expand All @@ -94,20 +93,11 @@ func NewTestFixture(t *testing.T, extraAccs map[string]accountstd.Interface) *Te
)
cdc := encodingCfg.Codec

// router := baseapp.NewMsgServiceRouter()
queryRouter := baseapp.NewGRPCQueryRouter()

handler := directHandler{}
account := baseaccount.NewAccount("base", signing.NewHandlerMap(handler), baseaccount.WithSecp256K1PubKey())

var accs []accountstd.AccountCreatorFunc
for name, acc := range extraAccs {
f := accountstd.AddAccount(name, func(_ accountstd.Dependencies) (accountstd.Interface, error) {
return acc, nil
})
accs = append(accs, f)
}

accKey := keys[accounts.StoreKey]
cms.MountStoreWithDB(accKey, storetypes.StoreTypeIAVL, db)
accStore := runtime.NewKVStoreService(accKey)
Expand All @@ -117,7 +107,7 @@ func NewTestFixture(t *testing.T, extraAccs map[string]accountstd.Interface) *Te
addresscodec.NewBech32Codec("cosmos"),
cdc.InterfaceRegistry(),
nil,
append(accs, account)...,
account,
)
assert.NilError(t, err)
accountsv1.RegisterQueryServer(queryRouter, accounts.NewQueryServer(accountsKeeper))
Expand Down Expand Up @@ -214,6 +204,8 @@ func NewTestFixture(t *testing.T, extraAccs map[string]accountstd.Interface) *Te
}
}

var _ signing.SignModeHandler = &directHandler{}

type directHandler struct{}

func (s directHandler) Mode() signingv1beta1.SignMode {
Expand Down
5 changes: 3 additions & 2 deletions x/feemarket/ante/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (s *TestSuite) SetAccountBalances(accounts []TestAccountBalance) {
func SetupTestSuite(t *testing.T, mock bool) *TestSuite {
s := &TestSuite{}

fixture := testfixture.NewTestFixture(t, nil)
fixture := testfixture.NewTestFixture(t)
s.Ctx = fixture.Ctx
s.EncCfg = fixture.EncodingConfig

Expand All @@ -124,7 +124,8 @@ func SetupTestSuite(t *testing.T, mock bool) *TestSuite {
s.ClientCtx = client.Context{}.WithTxConfig(s.EncCfg.TxConfig)
s.TxBuilder = s.ClientCtx.TxConfig.NewTxBuilder()

s.FeeMarketKeeper.SetEnabledHeight(s.Ctx, -1)
err := s.FeeMarketKeeper.SetEnabledHeight(s.Ctx, -1)
s.Require().NoError(err)
s.MsgServer = feemarketkeeper.NewMsgServer(s.FeeMarketKeeper)

s.SetupHandlers(mock)
Expand Down
4 changes: 3 additions & 1 deletion x/feemarket/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func (k *Keeper) InitGenesis(ctx context.Context, gs types.GenesisState) {
}

// always init enabled height to -1 until it is explicitly set later in the application
k.SetEnabledHeight(sdk.UnwrapSDKContext(ctx), -1)
if err := k.SetEnabledHeight(sdk.UnwrapSDKContext(ctx), -1); err != nil {
panic(err)
}
}

// ExportGenesis returns a GenesisState for a given context.
Expand Down
5 changes: 3 additions & 2 deletions x/feemarket/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ func (k *Keeper) GetEnabledHeight(ctx sdk.Context) (int64, error) {
}

// SetEnabledHeight sets the height at which the feemarket was enabled.
func (k *Keeper) SetEnabledHeight(ctx sdk.Context, height int64) {
func (k *Keeper) SetEnabledHeight(ctx sdk.Context, height int64) error {
store := k.Environment.KVStoreService.OpenKVStore(ctx)

bz := []byte(strconv.FormatInt(height, 10))

if err := store.Set(types.KeyEnabledHeight, bz); err != nil {
panic(err) // TODO(technicallyty): fix this.
return err
}
return nil
}

// ResolveToDenom converts the given coin to the given denomination.
Expand Down
8 changes: 5 additions & 3 deletions x/feemarket/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ func (s *KeeperTestSuite) SetupTest() {
s.encCfg = MakeTestEncodingConfig()
s.authorityAccount = authtypes.NewModuleAddress(govtypes.ModuleName)
s.accountKeeper = mocks.NewAccountKeeper(s.T())
fixture := testkeeper.NewTestFixture(s.T(), nil)
fixture := testkeeper.NewTestFixture(s.T())

s.ctx = fixture.Ctx
s.feeMarketKeeper = fixture.FeeMarketKeeper
s.msgServer = keeper.NewMsgServer(s.feeMarketKeeper)
s.queryServer = keeper.NewQueryServer(*s.feeMarketKeeper)
s.feeMarketKeeper.SetEnabledHeight(s.ctx, -1)
err := s.feeMarketKeeper.SetEnabledHeight(s.ctx, -1)
s.Require().NoError(err)
}

func (s *KeeperTestSuite) TestState() {
Expand Down Expand Up @@ -123,7 +124,8 @@ func (s *KeeperTestSuite) TestParams() {

func (s *KeeperTestSuite) TestEnabledHeight() {
s.Run("get and set values", func() {
s.feeMarketKeeper.SetEnabledHeight(s.ctx, 10)
err := s.feeMarketKeeper.SetEnabledHeight(s.ctx, 10)
s.Require().NoError(err)

got, err := s.feeMarketKeeper.GetEnabledHeight(s.ctx)
s.Require().NoError(err)
Expand Down
4 changes: 3 additions & 1 deletion x/feemarket/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ func (ms MsgServer) Params(goCtx context.Context, msg *types.MsgParams) (*types.

// if going from disabled -> enabled, set enabled height
if !gotParams.Enabled && msg.Params.Enabled {
ms.k.SetEnabledHeight(ctx, ctx.BlockHeight())
if err := ms.k.SetEnabledHeight(ctx, ctx.BlockHeight()); err != nil {
return nil, fmt.Errorf("error setting enabled height: %w", err)
}
}

params := msg.Params
Expand Down
5 changes: 3 additions & 2 deletions x/feemarket/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import (
const ConsensusVersion = 1

var (
_ module.HasGenesis = AppModule{}
_ module.HasGRPCGateway = AppModule{}
_ module.HasGenesis = AppModule{}
_ module.HasGRPCGateway = AppModule{}
_ module.HasRegisterServices = AppModule{}

_ appmodule.AppModule = AppModule{}
_ appmodule.HasBeginBlocker = AppModule{}
Expand Down

0 comments on commit b3754bd

Please sign in to comment.