Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danburck authored and fedekunze committed Aug 3, 2022
1 parent d01db97 commit 6c39147
Show file tree
Hide file tree
Showing 10 changed files with 2,097 additions and 477 deletions.
9 changes: 4 additions & 5 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

2,173 changes: 1,868 additions & 305 deletions client/docs/swagger-ui/swagger.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions x/evm/keeper/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

func SetupContract(b *testing.B) (*KeeperTestSuite, common.Address) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()

amt := sdk.Coins{ethermint.NewPhotonCoinInt64(1000000000000000000)}
err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt)
Expand All @@ -33,7 +33,7 @@ func SetupContract(b *testing.B) (*KeeperTestSuite, common.Address) {

func SetupTestMessageCall(b *testing.B) (*KeeperTestSuite, common.Address) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()

amt := sdk.Coins{ethermint.NewPhotonCoinInt64(1000000000000000000)}
err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt)
Expand Down
4 changes: 1 addition & 3 deletions x/evm/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ import (
)

var _ = Describe("Feemarket", func() {
var (
privKey *ethsecp256k1.PrivKey
)
var privKey *ethsecp256k1.PrivKey

Describe("Performing EVM transactions", func() {
type txParams struct {
Expand Down
39 changes: 26 additions & 13 deletions x/evm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"testing"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

Expand All @@ -31,6 +34,7 @@ import (
ethermint "github.com/evmos/ethermint/types"
"github.com/evmos/ethermint/x/evm/statedb"
"github.com/evmos/ethermint/x/evm/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down Expand Up @@ -66,12 +70,31 @@ type KeeperTestSuite struct {
enableFeemarket bool
enableLondonHF bool
mintFeeCollector bool
denom string
}

/// DoSetupTest setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`.
func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) {
var s *KeeperTestSuite

func TestKeeperTestSuite(t *testing.T) {
s = new(KeeperTestSuite)
s.enableFeemarket = false
s.enableLondonHF = true
suite.Run(t, s)

// Run Ginkgo integration tests
RegisterFailHandler(Fail)
RunSpecs(t, "Keeper Suite")
}

func (suite *KeeperTestSuite) SetupTest() {
checkTx := false
suite.app = app.Setup(checkTx, nil)
suite.SetupApp(checkTx)
}

/// SetupApp setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`.
func (suite *KeeperTestSuite) SetupApp(checkTx bool) {
t := suite.T()
// account key, use a constant account to keep unit test deterministic.
ecdsaPriv, err := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
require.NoError(t, err)
Expand Down Expand Up @@ -184,10 +207,7 @@ func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) {
suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig)
suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID())
suite.appCodec = encodingConfig.Marshaler
}

func (suite *KeeperTestSuite) SetupTest() {
suite.DoSetupTest(suite.T())
suite.denom = evmtypes.DefaultEVMDenom
}

func (suite *KeeperTestSuite) EvmDenom() string {
Expand Down Expand Up @@ -411,10 +431,3 @@ func (suite *KeeperTestSuite) TestBaseFee() {
suite.enableFeemarket = false
suite.enableLondonHF = true
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, &KeeperTestSuite{
enableFeemarket: false,
enableLondonHF: true,
})
}
12 changes: 6 additions & 6 deletions x/evm/keeper/state_transition_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func newNativeMessage(

func BenchmarkApplyTransaction(b *testing.B) {
suite := KeeperTestSuite{enableLondonHF: true}
suite.DoSetupTest(b)
suite.SetupTest()

ethSigner := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID())

Expand All @@ -170,7 +170,7 @@ func BenchmarkApplyTransaction(b *testing.B) {

func BenchmarkApplyTransactionWithLegacyTx(b *testing.B) {
suite := KeeperTestSuite{enableLondonHF: true}
suite.DoSetupTest(b)
suite.SetupTest()

ethSigner := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID())

Expand All @@ -197,7 +197,7 @@ func BenchmarkApplyTransactionWithLegacyTx(b *testing.B) {

func BenchmarkApplyTransactionWithDynamicFeeTx(b *testing.B) {
suite := KeeperTestSuite{enableFeemarket: true, enableLondonHF: true}
suite.DoSetupTest(b)
suite.SetupTest()

ethSigner := ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID())

Expand All @@ -224,7 +224,7 @@ func BenchmarkApplyTransactionWithDynamicFeeTx(b *testing.B) {

func BenchmarkApplyMessage(b *testing.B) {
suite := KeeperTestSuite{enableLondonHF: true}
suite.DoSetupTest(b)
suite.SetupTest()

params := suite.app.EvmKeeper.GetParams(suite.ctx)
ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID())
Expand Down Expand Up @@ -259,7 +259,7 @@ func BenchmarkApplyMessage(b *testing.B) {

func BenchmarkApplyMessageWithLegacyTx(b *testing.B) {
suite := KeeperTestSuite{enableLondonHF: true}
suite.DoSetupTest(b)
suite.SetupTest()

params := suite.app.EvmKeeper.GetParams(suite.ctx)
ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID())
Expand Down Expand Up @@ -294,7 +294,7 @@ func BenchmarkApplyMessageWithLegacyTx(b *testing.B) {

func BenchmarkApplyMessageWithDynamicFeeTx(b *testing.B) {
suite := KeeperTestSuite{enableFeemarket: true, enableLondonHF: true}
suite.DoSetupTest(b)
suite.SetupTest()

params := suite.app.EvmKeeper.GetParams(suite.ctx)
ethCfg := params.ChainConfig.EthereumConfig(suite.app.EvmKeeper.ChainID())
Expand Down
22 changes: 11 additions & 11 deletions x/evm/keeper/statedb_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func BenchmarkCreateAccountNew(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

b.ResetTimer()
Expand All @@ -31,7 +31,7 @@ func BenchmarkCreateAccountNew(b *testing.B) {

func BenchmarkCreateAccountExisting(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

b.ResetTimer()
Expand All @@ -44,7 +44,7 @@ func BenchmarkCreateAccountExisting(b *testing.B) {

func BenchmarkAddBalance(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

amt := big.NewInt(10)
Expand All @@ -59,7 +59,7 @@ func BenchmarkAddBalance(b *testing.B) {

func BenchmarkSetCode(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

hash := crypto.Keccak256Hash([]byte("code")).Bytes()
Expand All @@ -74,7 +74,7 @@ func BenchmarkSetCode(b *testing.B) {

func BenchmarkSetState(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

hash := crypto.Keccak256Hash([]byte("topic")).Bytes()
Expand All @@ -89,7 +89,7 @@ func BenchmarkSetState(b *testing.B) {

func BenchmarkAddLog(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

topic := crypto.Keccak256Hash([]byte("topic"))
Expand All @@ -116,7 +116,7 @@ func BenchmarkAddLog(b *testing.B) {

func BenchmarkSnapshot(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

b.ResetTimer()
Expand All @@ -136,7 +136,7 @@ func BenchmarkSnapshot(b *testing.B) {

func BenchmarkSubBalance(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

amt := big.NewInt(10)
Expand All @@ -151,7 +151,7 @@ func BenchmarkSubBalance(b *testing.B) {

func BenchmarkSetNonce(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

b.ResetTimer()
Expand All @@ -164,7 +164,7 @@ func BenchmarkSetNonce(b *testing.B) {

func BenchmarkAddRefund(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

b.ResetTimer()
Expand All @@ -177,7 +177,7 @@ func BenchmarkAddRefund(b *testing.B) {

func BenchmarkSuicide(b *testing.B) {
suite := KeeperTestSuite{}
suite.DoSetupTest(b)
suite.SetupTest()
vmdb := suite.StateDB()

b.ResetTimer()
Expand Down
4 changes: 4 additions & 0 deletions x/evm/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
codeErrInvalidBaseFee
codeErrGasOverflow
codeErrInvalidAccount
codeErrInvalidGasLimit
)

var ErrPostTxProcessing = errors.New("failed to execute post processing")
Expand Down Expand Up @@ -97,6 +98,9 @@ var (

// ErrInvalidAccount returns an error if the account is not an EVM compatible account
ErrInvalidAccount = sdkerrors.Register(ModuleName, codeErrInvalidAccount, "account type is not a valid ethereum account")

// ErrInvalidGasLimit returns an error if gas limit value is invalid
ErrInvalidGasLimit = sdkerrors.Register(ModuleName, codeErrInvalidGasLimit, "invalid gas limit")
)

// NewExecErrorWithReason unpacks the revert return bytes and returns a wrapped error
Expand Down
Loading

0 comments on commit 6c39147

Please sign in to comment.