rpc: test fix (#608)

* fix rpc tests with net namespace

* skip personal test

* skip rpc pending test

* fix endpoint

* fix rpc pending test

* fix missing gas param in some rpc tests

* fix eth_getproof when the block number is equal to pending or latest

* fix rpc tests filter subscribe failed

* lint

* remove unused linter

* fix PendingTransactionFilter and TestEth_GetFilterChanges_BlockFilter

* fix eth_estimateGas

* fix TestEth_EstimateGas_ContractDeployment

* skip TestEth_ExportAccount_WithStorage

* remove sleep in rpc test

* Update changelog

* add test-rpc in github action

* bump golangci-lint version to v1.42.1
This commit is contained in:
JayT106
2021-10-07 18:41:27 +02:00
committed by GitHub
parent fe4ec68ccc
commit f69c887276
11 changed files with 198 additions and 131 deletions
+18 -2
View File
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"math"
"math/big"
"strings"
@@ -838,7 +839,7 @@ func (e *PublicAPI) GetTransactionReceipt(hash common.Hash) (map[string]interfac
// PendingTransactions returns the transactions that are in the transaction pool
// and have a from address that is one of the accounts this node manages.
func (e *PublicAPI) PendingTransactions() ([]*rpctypes.RPCTransaction, error) {
func (e *PublicAPI) GetPendingTransactions() ([]*rpctypes.RPCTransaction, error) {
e.logger.Debug("eth_getPendingTransactions")
txs, err := e.backend.PendingTransactions()
@@ -889,9 +890,24 @@ func (e *PublicAPI) GetProof(address common.Address, storageKeys []string, block
if err != nil {
return nil, err
}
height := blockNum.Int64()
height := blockNum.Int64()
ctx := rpctypes.ContextWithHeight(height)
// if the height is equal to zero, meaning the query condition of the block is either "pending" or "latest"
if height == 0 {
bn, err := e.backend.BlockNumber()
if err != nil {
return nil, err
}
if bn > math.MaxInt64 {
return nil, fmt.Errorf("not able to query block number greater than MaxInt64")
}
height = int64(bn)
}
clientCtx := e.clientCtx.WithHeight(height)
// query storage proofs
@@ -117,6 +117,8 @@ func (es *EventSystem) subscribe(sub *Subscription) (*Subscription, context.Canc
err = es.tmWSClient.Subscribe(es.ctx, sub.event)
case filters.BlocksSubscription:
err = es.tmWSClient.Subscribe(es.ctx, sub.event)
case filters.PendingTransactionsSubscription:
err = es.tmWSClient.Subscribe(es.ctx, sub.event)
default:
err = fmt.Errorf("invalid filter subscription type %d", sub.typ)
}
@@ -160,7 +162,8 @@ func (es *EventSystem) SubscribeLogs(crit filters.FilterCriteria) (*Subscription
// only interested in new mined logs, mined logs within a specific block range, or
// logs from a specific block number to new mined blocks
case (from == rpc.LatestBlockNumber && to == rpc.LatestBlockNumber),
(from >= 0 && to >= 0 && to >= from):
(from >= 0 && to >= 0 && to >= from),
(from >= 0 && to == rpc.LatestBlockNumber):
return es.subscribeLogs(crit)
default:
@@ -177,7 +177,7 @@ func (f *Filter) blockLogs(header *ethtypes.Header) ([]*ethtypes.Log, error) {
return []*ethtypes.Log{}, errors.Wrapf(err, "failed to fetch logs block number %d", header.Number.Int64())
}
var unfiltered []*ethtypes.Log // nolint: prealloc
var unfiltered []*ethtypes.Log
for _, logs := range logsList {
unfiltered = append(unfiltered, logs...)
}