Skip to content

Commit

Permalink
mock
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Nov 9, 2023
1 parent 36af853 commit f0fa6b1
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 0 deletions.
6 changes: 6 additions & 0 deletions feemarket/plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# FeeMarket Plugins

This directory contains implementations of the `FeeMarket` interface to be plugged into the `x/feemarket` module.

Current implementations include:
- [Mock:](./mock/feemarket.go) fee market that can be used for basic testing. DO NOT use in production.
1 change: 1 addition & 0 deletions feemarket/plugins/mock/ante.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package mock
75 changes: 75 additions & 0 deletions feemarket/plugins/mock/feemarket.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package mock

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/skip-mev/feemarket/feemarket"
)

var _ feemarket.FeeMarket = FeeMarket{}

// FeeMarket is a simple mock fee market implmentation that should only be used for testing.
type FeeMarket struct{}

// Init which initializes the fee market (in InitGenesis)
func (fm FeeMarket) Init(ctx sdk.Context) error {
return nil
}

// EndBlockUpdateHandler allows the fee market to be updated
// after every block. This will be added to the EndBlock chain.
func (fm FeeMarket) EndBlockUpdateHandler(ctx sdk.Context) feemarket.UpdateHandler {
return nil
}

// EpochUpdateHandler allows the fee market to be updated
// after every given epoch identifier. This maps the epoch
// identifier to the UpdateHandler that should be executed.
func (fm FeeMarket) EpochUpdateHandler(ctx sdk.Context) map[string]feemarket.UpdateHandler {
return nil
}

// GetMinGasPrice retrieves the minimum gas price(s) needed
// to be included in the block for the given transaction
func (fm FeeMarket) GetMinGasPrice(ctx sdk.Context, tx sdk.Tx) sdk.Coins {
return sdk.NewCoins()
}

// GetFeeMarketInfo retrieves the fee market's information about
// how to pay for a transaction (min gas price, min tip,
// where the fees are being distributed, etc.).
func (fm FeeMarket) GetFeeMarketInfo(ctx sdk.Context) map[string]string {
return nil
}

// GetID returns the identifier of the fee market
func (fm FeeMarket) GetID() string {
return "mock"
}

// FeeAnteHandler will be called in the module AnteHandler.
// Performs no actions.
func (fm FeeMarket) FeeAnteHandler(
ctx sdk.Context,
tx sdk.Tx,
simulate bool,
next sdk.AnteHandler,
) sdk.AnteHandler {
return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
return ctx, nil
}
}

// FeePostHandler will be called in the module PostHandler
// if PostHandlers are implemented. Performs no actions.
func (fm FeeMarket) FeePostHandler(
ctx sdk.Context,
tx sdk.Tx,
simulate,
success bool,
next sdk.PostHandler,
) sdk.PostHandler {
return func(ctx sdk.Context, tx sdk.Tx, simulate, success bool) (newCtx sdk.Context, err error) {
return ctx, nil
}
}
1 change: 1 addition & 0 deletions tests/simapp/feemarketd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"cosmossdk.io/log"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

"github.com/skip-mev/feemarket/tests/simapp"
cmd "github.com/skip-mev/feemarket/tests/simapp/feemarketd/testappd"
)
Expand Down
1 change: 1 addition & 0 deletions tests/simapp/feemarketd/testappd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"cosmossdk.io/depinject"
"cosmossdk.io/log"
confixcmd "cosmossdk.io/tools/confix/cmd"

"github.com/skip-mev/feemarket/tests/simapp"

"github.com/cosmos/cosmos-sdk/client"
Expand Down
1 change: 1 addition & 0 deletions tests/simapp/feemarketd/testappd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/skip-mev/feemarket/tests/simapp"
)

Expand Down

0 comments on commit f0fa6b1

Please sign in to comment.