Skip to content

Commit

Permalink
Merge pull request #17 from kaleido-io/shared-rpc-client
Browse files Browse the repository at this point in the history
Use shared RPC client from firefly-signer library
  • Loading branch information
peterbroadhurst authored Aug 24, 2022
2 parents 5bd8b63 + 8b2762b commit cd166b4
Show file tree
Hide file tree
Showing 29 changed files with 270 additions and 335 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ ${LINT}:
$(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.0
mockpaths:
$(eval FFTM_PATH := $(shell $(VGO) list -f '{{.Dir}}' github.com/hyperledger/firefly-transaction-manager/pkg/fftm))

$(eval FF_SIGNER_PATH := $(shell $(VGO) list -f '{{.Dir}}' github.com/hyperledger/firefly-signer/pkg/rpcbackend))

define makemock
mocks: mocks-$(strip $(1))-$(strip $(2))
mocks-$(strip $(1))-$(strip $(2)): ${MOCKERY} mockpaths
${MOCKERY} --case underscore --dir $(1) --name $(2) --outpkg $(3) --output mocks/$(strip $(3))
endef

$(eval $(call makemock, internal/jsonrpc, Client, jsonrpcmocks))
$(eval $(call makemock, $$(FF_SIGNER_PATH), Backend, rpcbackendmocks))
$(eval $(call makemock, $$(FFTM_PATH), Manager, fftmmocks))

firefly-evmconnect: ${GOFILES}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module github.com/hyperledger/firefly-evmconnect
go 1.17

require (
github.com/go-resty/resty/v2 v2.7.0
github.com/hashicorp/golang-lru v0.5.4
github.com/hyperledger/firefly-common v0.1.20
github.com/hyperledger/firefly-signer v0.9.13
github.com/hyperledger/firefly-signer v0.9.16
github.com/hyperledger/firefly-transaction-manager v0.9.7
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.4.0
Expand All @@ -26,6 +25,7 @@ require (
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,8 @@ github.com/hyperledger/firefly-common v0.1.13/go.mod h1:2NqPi5Ud9H6rSlZXkLbotxW7
github.com/hyperledger/firefly-common v0.1.17-0.20220808193503-961a6b241a1a/go.mod h1:MNbaI2spBsdZYOub6Duj9xueE7Qyu9itOmJ4vE8tjYw=
github.com/hyperledger/firefly-common v0.1.20 h1:0dShkjlIShyBxkXRmu3vLmpEK6xrqmfc8GhF6k0Vgbg=
github.com/hyperledger/firefly-common v0.1.20/go.mod h1:gMlv4Iy5JjnzXmSEdb+tWVDIc/2GhL9MRcgNX+VmI4M=
github.com/hyperledger/firefly-signer v0.9.13 h1:yvKxYTsEmE0XWl0vcZBQV353YmmePvWwIPMr4Lie67o=
github.com/hyperledger/firefly-signer v0.9.13/go.mod h1:GPQRUZOFOAjkLmg8GDjZUjEdUD0gcar+CSVhwltIwyw=
github.com/hyperledger/firefly-transaction-manager v0.9.6 h1:mX2CN82wbq0izm0ANZxMAjsBeEnzeQy9xWUtsQd6N5Y=
github.com/hyperledger/firefly-transaction-manager v0.9.6/go.mod h1:GuwXVVXI6p3tNk99jbYi4PopMzipVBwy3uu5wSKXJEc=
github.com/hyperledger/firefly-signer v0.9.16 h1:qItr8SbEgvnc7yxseD/XE5fPDLQhTb90I+lklc78pLM=
github.com/hyperledger/firefly-signer v0.9.16/go.mod h1:GPQRUZOFOAjkLmg8GDjZUjEdUD0gcar+CSVhwltIwyw=
github.com/hyperledger/firefly-transaction-manager v0.9.7 h1:Uoy2xtqO38pufEeRoxqq4rW3xGDjc6qJZyRXo9WnJnk=
github.com/hyperledger/firefly-transaction-manager v0.9.7/go.mod h1:GuwXVVXI6p3tNk99jbYi4PopMzipVBwy3uu5wSKXJEc=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
6 changes: 3 additions & 3 deletions internal/ethereum/blocklistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func newBlockListener(ctx context.Context, c *ethConnector, conf config.Section)
func (bl *blockListener) establishBlockHeightWithRetry() error {
return bl.c.retry.Do(bl.ctx, "get initial block height", func(attempt int) (retry bool, err error) {
var hexBlockHeight ethtypes.HexInteger
err = bl.c.backend.Invoke(bl.ctx, &hexBlockHeight, "eth_blockNumber")
err = bl.c.backend.CallRPC(bl.ctx, &hexBlockHeight, "eth_blockNumber")
if err != nil {
log.L(bl.ctx).Warnf("Block height could not be obtained: %s", err)
return true, err
Expand Down Expand Up @@ -116,7 +116,7 @@ func (bl *blockListener) listenLoop() {
}

if filter == "" {
err := bl.c.backend.Invoke(bl.ctx, &filter, "eth_newBlockFilter")
err := bl.c.backend.CallRPC(bl.ctx, &filter, "eth_newBlockFilter")
if err != nil {
log.L(bl.ctx).Errorf("Failed to establish new block filter: %s", err)
failCount++
Expand All @@ -125,7 +125,7 @@ func (bl *blockListener) listenLoop() {
}

var blockHashes []ethtypes.HexBytes0xPrefix
err := bl.c.backend.Invoke(bl.ctx, &blockHashes, "eth_getFilterChanges", filter)
err := bl.c.backend.CallRPC(bl.ctx, &blockHashes, "eth_getFilterChanges", filter)
if err != nil {
if mapError(filterRPCMethods, err) == ffcapi.ErrorReasonNotFound {
log.L(bl.ctx).Warnf("Block filter '%v' no longer valid. Recreating filter: %s", filter, err)
Expand Down
176 changes: 88 additions & 88 deletions internal/ethereum/blocklistener_test.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions internal/ethereum/deploy_contract_prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func TestDeployContractPrepareWithEstimateRevert(t *testing.T) {
ctx, c, mRPC, done := newTestConnector(t)
defer done()

mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_estimateGas", mock.Anything).Return(fmt.Errorf("pop"))
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_call", mock.Anything, "latest").Run(
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_estimateGas", mock.Anything).Return(fmt.Errorf("pop"))
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_call", mock.Anything, "latest").Run(
func(args mock.Arguments) {
*(args[1].(*ethtypes.HexBytes0xPrefix)) = ethtypes.MustNewHexBytes0xPrefix("0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000114d75707065747279206465746563746564000000000000000000000000000000")
},
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestDeployContractPrepareEstimateNoConstructor(t *testing.T) {
ctx, c, mRPC, done := newTestConnector(t)
defer done()

mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_estimateGas", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_estimateGas", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
*(args[1].(*ethtypes.HexInteger)) = *ethtypes.NewHexInteger64(12345)
})

Expand Down
2 changes: 1 addition & 1 deletion internal/ethereum/estimate_gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *ethConnector) estimateGas(ctx context.Context, tx *ethsigner.Transactio

// Do the gas estimation
var gasEstimate ethtypes.HexInteger
err := c.backend.Invoke(ctx, &gasEstimate, "eth_estimateGas", tx)
err := c.backend.CallRPC(ctx, &gasEstimate, "eth_estimateGas", tx)
if err != nil {
// If it fails, fall back to an eth_call to see if we get a reverted reason
_, reason, errCall := c.callTransaction(ctx, tx, method)
Expand Down
6 changes: 3 additions & 3 deletions internal/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ import (
"github.com/hyperledger/firefly-common/pkg/i18n"
"github.com/hyperledger/firefly-common/pkg/log"
"github.com/hyperledger/firefly-common/pkg/retry"
"github.com/hyperledger/firefly-evmconnect/internal/jsonrpc"
"github.com/hyperledger/firefly-evmconnect/internal/msgs"
"github.com/hyperledger/firefly-signer/pkg/abi"
"github.com/hyperledger/firefly-signer/pkg/rpcbackend"
"github.com/hyperledger/firefly-transaction-manager/pkg/ffcapi"
)

type ethConnector struct {
backend jsonrpc.Client
backend rpcbackend.Backend
serializer *abi.Serializer
gasEstimationFactor *big.Float
catchupPageSize int64
Expand Down Expand Up @@ -81,7 +81,7 @@ func NewEthereumConnector(ctx context.Context, conf config.Section) (cc ffcapi.A
}
c.gasEstimationFactor = big.NewFloat(conf.GetFloat64(ConfigGasEstimationFactor))

c.backend = jsonrpc.NewRPCClient(ffresty.New(ctx, conf))
c.backend = rpcbackend.NewRPCClient(ffresty.New(ctx, conf))

c.serializer = abi.NewSerializer().SetByteSerializer(abi.HexByteSerializer0xPrefix)
switch conf.Get(ConfigDataFormat) {
Expand Down
6 changes: 3 additions & 3 deletions internal/ethereum/ethereum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import (

"github.com/hyperledger/firefly-common/pkg/config"
"github.com/hyperledger/firefly-common/pkg/ffresty"
"github.com/hyperledger/firefly-evmconnect/mocks/jsonrpcmocks"
"github.com/hyperledger/firefly-evmconnect/mocks/rpcbackendmocks"
"github.com/hyperledger/firefly-signer/pkg/abi"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)

func strPtr(s string) *string { return &s }

func newTestConnector(t *testing.T) (context.Context, *ethConnector, *jsonrpcmocks.Client, func()) {
func newTestConnector(t *testing.T) (context.Context, *ethConnector, *rpcbackendmocks.Backend, func()) {

mRPC := &jsonrpcmocks.Client{}
mRPC := &rpcbackendmocks.Backend{}
config.RootConfigReset()
conf := config.RootSection("unittest")
InitConfig(conf)
Expand Down
14 changes: 7 additions & 7 deletions internal/ethereum/event_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"

"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly-evmconnect/mocks/jsonrpcmocks"
"github.com/hyperledger/firefly-evmconnect/mocks/rpcbackendmocks"
"github.com/hyperledger/firefly-signer/pkg/ethtypes"
"github.com/hyperledger/firefly-transaction-manager/pkg/ffcapi"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -77,21 +77,21 @@ const abiTransferFn = `{

const testHighBlock = 212121

func mockStreamLoopEmpty(mRPC *jsonrpcmocks.Client) {
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_blockNumber").Return(nil).Run(func(args mock.Arguments) {
func mockStreamLoopEmpty(mRPC *rpcbackendmocks.Backend) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_blockNumber").Return(nil).Run(func(args mock.Arguments) {
hbh := args[1].(*ethtypes.HexInteger)
*hbh = *ethtypes.NewHexInteger64(testHighBlock)
}).Maybe()
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_newFilter", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_newFilter", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
*args[1].(*string) = "filter_id1"
}).Maybe()
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getFilterLogs", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getFilterLogs", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
*args[1].(*[]*logJSONRPC) = make([]*logJSONRPC, 0)
}).Maybe()
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getFilterChanges", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getFilterChanges", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
*args[1].(*[]*logJSONRPC) = make([]*logJSONRPC, 0)
}).Maybe()
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_uninstallFilter", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_uninstallFilter", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
*args[1].(*bool) = true
}).Maybe()
}
Expand Down
36 changes: 18 additions & 18 deletions internal/ethereum/event_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly-evmconnect/mocks/jsonrpcmocks"
"github.com/hyperledger/firefly-evmconnect/mocks/rpcbackendmocks"
"github.com/hyperledger/firefly-signer/pkg/abi"
"github.com/hyperledger/firefly-signer/pkg/ethtypes"
"github.com/hyperledger/firefly-transaction-manager/pkg/ffcapi"
Expand Down Expand Up @@ -84,7 +84,7 @@ func sampleTransferLog() *logJSONRPC {
}
}

func newTestListener(t *testing.T, withMethods bool) (*listener, *jsonrpcmocks.Client, func()) {
func newTestListener(t *testing.T, withMethods bool) (*listener, *rpcbackendmocks.Backend, func()) {
lID := fftypes.NewUUID()
options := ffcapi.EventListenerOptions{
Filters: []fftypes.JSONAny{
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestGetInitialBlockTimeout(t *testing.T) {
}

blockRPC := make(chan struct{})
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_blockNumber").Return(fmt.Errorf("pop")).Run(func(args mock.Arguments) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_blockNumber").Return(fmt.Errorf("pop")).Run(func(args mock.Arguments) {
<-blockRPC // make it timeout
})

Expand All @@ -150,7 +150,7 @@ func TestGetHWMNotInit(t *testing.T) {
}

blockRPC := make(chan struct{})
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_blockNumber").Return(fmt.Errorf("pop")).Run(func(args mock.Arguments) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_blockNumber").Return(fmt.Errorf("pop")).Run(func(args mock.Arguments) {
<-blockRPC // make it timeout
})

Expand All @@ -168,15 +168,15 @@ func TestListenerCatchupErrorsThenDeliveryExit(t *testing.T) {
l.catchupLoopDone = make(chan struct{})
l.hwmBlock = 0

mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
return bh == "0x6b012339fbb85b70c58ecfd97b31950c4a28bcef5226e12dbe551cb1abaf3b4c"
}), false).Return(nil).Run(func(args mock.Arguments) {
*args[1].(**blockInfoJSONRPC) = &blockInfoJSONRPC{
Number: ethtypes.NewHexInteger64(1001),
}
})
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getLogs", mock.Anything).Return(fmt.Errorf("pop")).Once()
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getLogs", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getLogs", mock.Anything).Return(fmt.Errorf("pop")).Once()
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getLogs", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
*args[1].(*[]*logJSONRPC) = []*logJSONRPC{sampleTransferLog()}
// Cancel the context here so we exit pushing the event
cancelCtx()
Expand All @@ -193,7 +193,7 @@ func TestListenerCatchupErrorThenExit(t *testing.T) {
l.catchupLoopDone = make(chan struct{})
l.hwmBlock = 0

mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getLogs", mock.Anything).Return(fmt.Errorf("pop")).Run(func(args mock.Arguments) {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getLogs", mock.Anything).Return(fmt.Errorf("pop")).Run(func(args mock.Arguments) {
cancelCtx()
})

Expand Down Expand Up @@ -278,14 +278,14 @@ func TestFilterEnrichEthLogMethodInputsOk(t *testing.T) {
err := json.Unmarshal([]byte(abiTransferEvent), &abiEvent)
assert.NoError(t, err)

mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
return bh == "0x6b012339fbb85b70c58ecfd97b31950c4a28bcef5226e12dbe551cb1abaf3b4c"
}), false).Return(nil).Run(func(args mock.Arguments) {
*args[1].(**blockInfoJSONRPC) = &blockInfoJSONRPC{
Number: ethtypes.NewHexInteger64(1024),
}
})
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
return th.String() == "0x1a1f797ee000c529b6a2dd330cedd0d081417a30d16a4eecb3f863ab4657246f"
})).Return(nil).Run(func(args mock.Arguments) {
*args[1].(**txInfoJSONRPC) = &txInfoJSONRPC{
Expand All @@ -312,10 +312,10 @@ func TestFilterEnrichEthLogTXInfoFail(t *testing.T) {
err := json.Unmarshal([]byte(abiTransferEvent), &abiEvent)
assert.NoError(t, err)

mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
return bh == "0x6b012339fbb85b70c58ecfd97b31950c4a28bcef5226e12dbe551cb1abaf3b4c"
}), false).Return(fmt.Errorf("pop1"))
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
return th.String() == "0x1a1f797ee000c529b6a2dd330cedd0d081417a30d16a4eecb3f863ab4657246f"
})).Return(fmt.Errorf("pop2"))

Expand All @@ -334,14 +334,14 @@ func TestFilterEnrichEthLogMethodBadInputTooShort(t *testing.T) {
err := json.Unmarshal([]byte(abiTransferEvent), &abiEvent)
assert.NoError(t, err)

mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
return bh == "0x6b012339fbb85b70c58ecfd97b31950c4a28bcef5226e12dbe551cb1abaf3b4c"
}), false).Return(nil).Run(func(args mock.Arguments) {
*args[1].(**blockInfoJSONRPC) = &blockInfoJSONRPC{
Number: ethtypes.NewHexInteger64(1024),
}
})
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
return th.String() == "0x1a1f797ee000c529b6a2dd330cedd0d081417a30d16a4eecb3f863ab4657246f"
})).Return(nil).Run(func(args mock.Arguments) {
*args[1].(**txInfoJSONRPC) = &txInfoJSONRPC{
Expand All @@ -365,14 +365,14 @@ func TestFilterEnrichEthLogMethodBadInputTooMismatchFunctionID(t *testing.T) {
err := json.Unmarshal([]byte(abiTransferEvent), &abiEvent)
assert.NoError(t, err)

mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
return bh == "0x6b012339fbb85b70c58ecfd97b31950c4a28bcef5226e12dbe551cb1abaf3b4c"
}), false).Return(nil).Run(func(args mock.Arguments) {
*args[1].(**blockInfoJSONRPC) = &blockInfoJSONRPC{
Number: ethtypes.NewHexInteger64(1024),
}
})
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
return th.String() == "0x1a1f797ee000c529b6a2dd330cedd0d081417a30d16a4eecb3f863ab4657246f"
})).Return(nil).Run(func(args mock.Arguments) {
*args[1].(**txInfoJSONRPC) = &txInfoJSONRPC{
Expand All @@ -396,14 +396,14 @@ func TestFilterEnrichEthLogMethodBadInputABIData(t *testing.T) {
err := json.Unmarshal([]byte(abiTransferEvent), &abiEvent)
assert.NoError(t, err)

mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getBlockByHash", mock.MatchedBy(func(bh string) bool {
return bh == "0x6b012339fbb85b70c58ecfd97b31950c4a28bcef5226e12dbe551cb1abaf3b4c"
}), false).Return(nil).Run(func(args mock.Arguments) {
*args[1].(**blockInfoJSONRPC) = &blockInfoJSONRPC{
Number: ethtypes.NewHexInteger64(1024),
}
})
mRPC.On("Invoke", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getTransactionByHash", mock.MatchedBy(func(th ethtypes.HexBytes0xPrefix) bool {
return th.String() == "0x1a1f797ee000c529b6a2dd330cedd0d081417a30d16a4eecb3f863ab4657246f"
})).Return(nil).Run(func(args mock.Arguments) {
*args[1].(**txInfoJSONRPC) = &txInfoJSONRPC{
Expand Down
Loading

0 comments on commit cd166b4

Please sign in to comment.