Skip to content

Commit

Permalink
itests: Fix TestEthFilterAPIDisabledViaConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Feb 2, 2023
1 parent fe1e097 commit e7d058b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
24 changes: 12 additions & 12 deletions itests/eth_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/stretchr/testify/require"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/node/impl/full"
)

func TestEthFilterAPIDisabledViaConfig(t *testing.T) {
Expand All @@ -22,41 +22,41 @@ func TestEthFilterAPIDisabledViaConfig(t *testing.T) {

_, err := client.EthNewPendingTransactionFilter(ctx)
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())

_, err = client.EthGetLogs(ctx, &ethtypes.EthFilterSpec{})
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())

_, err = client.EthGetFilterChanges(ctx, ethtypes.EthFilterID{})
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())

_, err = client.EthGetFilterLogs(ctx, ethtypes.EthFilterID{})
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())

_, err = client.EthNewFilter(ctx, &ethtypes.EthFilterSpec{})
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())

_, err = client.EthNewBlockFilter(ctx)
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())

_, err = client.EthNewPendingTransactionFilter(ctx)
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())

_, err = client.EthUninstallFilter(ctx, ethtypes.EthFilterID{})
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())

_, err = client.EthSubscribe(ctx, []byte{})
_, err = client.EthSubscribe(ctx, []byte("{}"))
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())

_, err = client.EthUnsubscribe(ctx, ethtypes.EthSubscriptionID{})
require.NotNil(t, err)
require.Equal(t, err.Error(), api.ErrNotSupported.Error())
require.Equal(t, err.Error(), full.ErrModuleDisabled.Error())
}
12 changes: 8 additions & 4 deletions node/builder_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,14 @@ func ConfigFullNode(c interface{}) Option {

// in lite-mode Eth api is provided by gateway
ApplyIf(isFullNode,
Override(new(full.EthEventAPI), modules.EthEventAPI(cfg.Fevm)),

If(cfg.Fevm.EnableEthRPC, Override(new(full.EthModuleAPI), modules.EthModuleAPI(cfg.Fevm))),
If(!cfg.Fevm.EnableEthRPC, Override(new(full.EthModuleAPI), &full.EthModuleDummy{})),
If(cfg.Fevm.EnableEthRPC,
Override(new(full.EthModuleAPI), modules.EthModuleAPI(cfg.Fevm)),
Override(new(full.EthEventAPI), modules.EthEventAPI(cfg.Fevm)),
),
If(!cfg.Fevm.EnableEthRPC,
Override(new(full.EthModuleAPI), &full.EthModuleDummy{}),
Override(new(full.EthEventAPI), &full.EthModuleDummy{}),
),
),
)
}
Expand Down
39 changes: 38 additions & 1 deletion node/impl/full/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package full
import (
"context"
"errors"

"github.com/filecoin-project/go-jsonrpc"
"github.com/ipfs/go-cid"

"github.com/filecoin-project/lotus/api"
Expand Down Expand Up @@ -122,4 +122,41 @@ func (e *EthModuleDummy) Web3ClientVersion(ctx context.Context) (string, error)
return "", ErrModuleDisabled
}

func (e *EthModuleDummy) EthGetLogs(ctx context.Context, filter *ethtypes.EthFilterSpec) (*ethtypes.EthFilterResult, error) {
return &ethtypes.EthFilterResult{}, ErrModuleDisabled
}

func (e *EthModuleDummy) EthGetFilterChanges(ctx context.Context, id ethtypes.EthFilterID) (*ethtypes.EthFilterResult, error) {
return &ethtypes.EthFilterResult{}, ErrModuleDisabled
}

func (e *EthModuleDummy) EthGetFilterLogs(ctx context.Context, id ethtypes.EthFilterID) (*ethtypes.EthFilterResult, error) {
return &ethtypes.EthFilterResult{}, ErrModuleDisabled
}

func (e *EthModuleDummy) EthNewFilter(ctx context.Context, filter *ethtypes.EthFilterSpec) (ethtypes.EthFilterID, error) {
return ethtypes.EthFilterID{}, ErrModuleDisabled
}

func (e *EthModuleDummy) EthNewBlockFilter(ctx context.Context) (ethtypes.EthFilterID, error) {
return ethtypes.EthFilterID{}, ErrModuleDisabled
}

func (e *EthModuleDummy) EthNewPendingTransactionFilter(ctx context.Context) (ethtypes.EthFilterID, error) {
return ethtypes.EthFilterID{}, ErrModuleDisabled
}

func (e *EthModuleDummy) EthUninstallFilter(ctx context.Context, id ethtypes.EthFilterID) (bool, error) {
return false, ErrModuleDisabled
}

func (e *EthModuleDummy) EthSubscribe(ctx context.Context, params jsonrpc.RawParams) (ethtypes.EthSubscriptionID, error) {
return ethtypes.EthSubscriptionID{}, ErrModuleDisabled
}

func (e *EthModuleDummy) EthUnsubscribe(ctx context.Context, id ethtypes.EthSubscriptionID) (bool, error) {
return false, ErrModuleDisabled
}

var _ EthModuleAPI = &EthModuleDummy{}
var _ EthEventAPI = &EthModuleDummy{}

0 comments on commit e7d058b

Please sign in to comment.