Skip to content

Commit 0c916f9

Browse files
authored
Merge pull request #312 from mocachain/refactor/slim-testutil
refactor(testutil): drop dead helpers; use cosmos/evm's fork-neutral test fns
2 parents f7c7bb4 + 16825e8 commit 0c916f9

11 files changed

Lines changed: 14 additions & 359 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
5757
- (docs) [#66](https://github.com/mocachain/moca/pull/66) Update RELEASE_GUIDE.md security notes for GITHUB_TOKEN
5858
- (rpc) [#309](https://github.com/mocachain/moca/pull/309) Replace the in-tree JSON-RPC server (`rpc/`, ~16k LOC forked from ethermint/evmos) with `github.com/cosmos/evm/rpc`: the backend, namespaces, and the newHeads/logs/pendingTx subscriptions now come from cosmos/evm (fed by an in-process CometBFT event stream and an ante `PendingTxListener` hook on `*Moca`), and the indexer moves to cosmos/evm's `server/types.TxResult`. Gains `safe`/`finalized` block tags, `eth_getBlockReceipts`, `eth_getHeaderBy*`, `eth_createAccessList`, `debug_traceBlock`, EIP-4844/7702 tx fields, and upstream tracking. New operator knobs (app.toml + flags): `json-rpc.ws-origins`, `json-rpc.enable-profiling`, `json-rpc.allow-insecure-unlock`, `json-rpc.batch-request-limit`, `json-rpc.batch-response-max-size`; the checked-in asset configs also pin `evm.evm-chain-id` per network. A thin `server/websockets.go` shim is retained so `newHeads` emits the canonical CometBFT block hash (completes `cosmos/evm#725`); removable once that lands upstream and we bump.
5959
- (indexer) [#310](https://github.com/mocachain/moca/pull/310) Use `github.com/cosmos/evm/indexer` directly instead of the in-tree functional copy (same `TxResult` proto and key encoding — no reindex needed). The KV-indexer test is retained under `tests/integration/indexer` (mirroring upstream's layout), retargeted at the upstream package, since cosmos/evm publishes no test files in its module — keeping the indexer path covered against moca's forked SDK in CI. The kind e2e now runs validators with `enable-indexer = true` and asserts the tx hash actually lands in `evmindexer.db` (receipt lookups silently fall back to CometBFT `tx_search`, so a green suite alone cannot prove the indexer works).
60+
- (testutil) [#312](https://github.com/mocachain/moca/pull/312) Slim `testutil/`: delete dead helpers (`contract.go`, `integration.go`, `statedb.go`, `CreateEthTx`) and use `cosmos/evm/testutil`'s fork-neutral `NoOpNextFn`/`NewHeader` instead of the in-tree copies. Fork-coupled helpers (key/codec/signing, `testutil/network`, funding) are deliberately kept in-tree — swapping them would change which `ethsecp256k1` type tests exercise.
6061

6162
### State Machine Breaking
6263

app/ante/cosmos/authz_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import (
1616
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
1717
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
1818

19+
evmtestutil "github.com/cosmos/evm/testutil"
1920
evmtypes "github.com/cosmos/evm/x/vm/types"
2021
"github.com/ethereum/go-ethereum/common"
2122
ethtypes "github.com/ethereum/go-ethereum/core/types"
2223
cosmosante "github.com/mocachain/moca/v2/app/ante/cosmos"
23-
testutil "github.com/mocachain/moca/v2/testutil"
2424
utiltx "github.com/mocachain/moca/v2/testutil/tx"
2525
)
2626

@@ -293,7 +293,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
293293
tx, err := createUnsignedTx(tc.msgs...)
294294
require.NoError(t, err)
295295

296-
_, err = decorator.AnteHandle(ctx, tx, false, testutil.NextFn)
296+
_, err = decorator.AnteHandle(ctx, tx, false, evmtestutil.NoOpNextFn)
297297
if tc.expectedErr != nil {
298298
require.Error(t, err)
299299
require.ErrorIs(t, err, tc.expectedErr)

app/ante/cosmos/fees_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package cosmos_test
22

33
import (
4-
sdkmath "cosmossdk.io/math"
54
"fmt"
65
"time"
76

8-
"cosmossdk.io/math"
7+
sdkmath "cosmossdk.io/math"
98
"cosmossdk.io/x/feegrant"
109
sdktestutil "github.com/cosmos/cosmos-sdk/testutil/testdata"
1110
sdk "github.com/cosmos/cosmos-sdk/types"
11+
evmtestutil "github.com/cosmos/evm/testutil"
1212
cosmosante "github.com/mocachain/moca/v2/app/ante/cosmos"
1313
"github.com/mocachain/moca/v2/testutil"
1414
testutiltx "github.com/mocachain/moca/v2/testutil/tx"
@@ -23,17 +23,17 @@ func (suite *AnteTestSuite) TestDeductFeeDecorator() {
2323
// fee granter
2424
fgAddr, _ = testutiltx.NewAccAddressAndKey()
2525
initBalance = sdkmath.NewInt(1e18)
26-
lowGasPrice = math.NewInt(1)
26+
lowGasPrice = sdkmath.NewInt(1)
2727
zero = sdkmath.ZeroInt()
2828
)
2929

3030
// Testcase definitions
3131
testcases := []struct {
3232
name string
33-
balance math.Int
34-
rewards math.Int
33+
balance sdkmath.Int
34+
rewards sdkmath.Int
3535
gas uint64
36-
gasPrice *math.Int
36+
gasPrice *sdkmath.Int
3737
feeGranter sdk.AccAddress
3838
checkTx bool
3939
simulate bool
@@ -292,7 +292,7 @@ func (suite *AnteTestSuite) TestDeductFeeDecorator() {
292292
suite.Require().NoError(err, "failed to create transaction")
293293

294294
// run the ante handler
295-
_, err = dfd.AnteHandle(suite.ctx, tx, tc.simulate, testutil.NextFn)
295+
_, err = dfd.AnteHandle(suite.ctx, tx, tc.simulate, evmtestutil.NoOpNextFn)
296296

297297
// assert the resulting error
298298
if tc.expPass {

app/ante/cosmos/min_price_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
sdkmath "cosmossdk.io/math"
55
sdk "github.com/cosmos/cosmos-sdk/types"
66
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
7+
evmtestutil "github.com/cosmos/evm/testutil"
78
cosmosante "github.com/mocachain/moca/v2/app/ante/cosmos"
8-
"github.com/mocachain/moca/v2/testutil"
99
testutiltx "github.com/mocachain/moca/v2/testutil/tx"
1010
"github.com/mocachain/moca/v2/utils"
1111
)
@@ -126,7 +126,7 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() {
126126
// s.SetupTest(et.isCheckTx)
127127
ctx := suite.ctx.WithIsReCheckTx(et.isCheckTx)
128128
dec := cosmosante.NewMinGasPriceDecorator(suite.app.FeeMarketKeeper, suite.app.EvmKeeper)
129-
_, err := dec.AnteHandle(ctx, tc.malleate(), et.simulate, testutil.NextFn)
129+
_, err := dec.AnteHandle(ctx, tc.malleate(), et.simulate, evmtestutil.NoOpNextFn)
130130

131131
if tc.expPass || (et.simulate && tc.allowPassOnSimulate) {
132132
suite.Require().NoError(err, tc.name)

testutil/ante.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

testutil/contract.go

Lines changed: 0 additions & 131 deletions
This file was deleted.

testutil/integration.go

Lines changed: 0 additions & 74 deletions
This file was deleted.

testutil/setup.go

Lines changed: 0 additions & 46 deletions
This file was deleted.

testutil/statedb.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)