Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Nov 26, 2024
1 parent bd66c6c commit 85b2830
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 7 deletions.
12 changes: 7 additions & 5 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
)

const upgradeName = "0.6.6"
const upgradeName = "0.6.7"

// RegisterUpgradeHandlers returns upgrade handlers
func (app *MinitiaApp) RegisterUpgradeHandlers(cfg module.Configurator) {
Expand All @@ -38,11 +38,13 @@ func (app *MinitiaApp) RegisterUpgradeHandlers(cfg module.Configurator) {
}

// set non-zero default values for new params
params.HookMaxGas = opchildtypes.DefaultHookMaxGas
if params.HookMaxGas == 0 {
params.HookMaxGas = opchildtypes.DefaultHookMaxGas

err = app.OPChildKeeper.SetParams(ctx, params)
if err != nil {
return nil, err
err = app.OPChildKeeper.SetParams(ctx, params)
if err != nil {
return nil, err
}
}

//////////////////////////// MINIEVM ///////////////////////////////////
Expand Down
78 changes: 78 additions & 0 deletions jsonrpc/namespaces/eth/filters/api_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package filters_test

import (
"context"
"crypto/ecdsa"
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/ethereum/go-ethereum/common"

minitiaapp "github.com/initia-labs/minievm/app"
"github.com/initia-labs/minievm/indexer"
"github.com/initia-labs/minievm/jsonrpc/backend"
"github.com/initia-labs/minievm/jsonrpc/config"
"github.com/initia-labs/minievm/jsonrpc/namespaces/eth/filters"
"github.com/initia-labs/minievm/tests"
)

type testInput struct {
app *minitiaapp.MinitiaApp
indexer indexer.EVMIndexer
backend *backend.JSONRPCBackend
addrs []common.Address
privKeys []*ecdsa.PrivateKey
cometRPC *tests.MockCometRPC
filterAPI *filters.FilterAPI
}

func setupFilterAPI(t *testing.T) testInput {
app, addrs, privKeys := tests.CreateApp(t)
indexer := app.EVMIndexer()

ctx := context.Background()
svrCtx := server.NewDefaultContext()
clientCtx := client.Context{}.WithCodec(app.AppCodec()).
WithInterfaceRegistry(app.AppCodec().InterfaceRegistry()).
WithTxConfig(app.TxConfig()).
WithLegacyAmino(app.LegacyAmino()).
WithAccountRetriever(authtypes.AccountRetriever{})

cfg := config.DefaultJSONRPCConfig()
cfg.Enable = true
cfg.FilterTimeout = 3 * time.Second

mockCometRPC := tests.NewMockCometRPC(app.BaseApp)
clientCtx = clientCtx.WithClient(mockCometRPC)

backend, err := backend.NewJSONRPCBackend(ctx, app, app.Logger(), svrCtx, clientCtx, cfg)
require.NoError(t, err)

filterAPI := filters.NewFilterAPI(ctx, app, backend, app.Logger())

return testInput{
app: app,
indexer: indexer,
backend: backend,
addrs: addrs,
privKeys: privKeys,
cometRPC: mockCometRPC,
filterAPI: filterAPI,
}
}

func Test_NewPendingTransactionFilter(t *testing.T) {
input := setupFilterAPI(t)
defer input.app.Close()

fullTx := false
filterID, err := input.filterAPI.NewPendingTransactionFilter(&fullTx)
require.NoError(t, err)
require.NotEmpty(t, filterID)
}
3 changes: 2 additions & 1 deletion tests/app_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func CreateApp(t *testing.T) (*minitiaapp.MinitiaApp, []common.Address, []*ecdsa
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1})
require.NoError(t, err)

app.Commit()
_, err = app.Commit()
require.NoError(t, err)

return app, addrs, privKeys
}
3 changes: 2 additions & 1 deletion tests/tx_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ func ExecuteTxs(t *testing.T, app *minitiaapp.MinitiaApp, txs ...sdk.Tx) (*abcit
TxResults: resBlock.TxResults,
}

app.Commit()
_, err = app.Commit()
require.NoError(t, err)

return finalizeReq, finalizeRes
}
Expand Down

0 comments on commit 85b2830

Please sign in to comment.