fix_: bugfixes
This commit is contained in:
parent
ca5e93f778
commit
cf2c53c831
|
@ -95,12 +95,18 @@ func (c *CachedEthClient) getOrFetchBlockByHash(ctx context.Context, hash common
|
|||
|
||||
func (c *CachedEthClient) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
||||
block, err := c.getOrFetchBlockByHash(ctx, hash, false)
|
||||
return block.header, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return block.header, nil
|
||||
}
|
||||
|
||||
func (c *CachedEthClient) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
|
||||
block, err := c.getOrFetchBlockByNumber(ctx, number, false)
|
||||
return block.header, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return block.header, nil
|
||||
}
|
||||
|
||||
func (c *CachedEthClient) getOrFetchUncles(ctx context.Context, blockHash common.Hash, uncleHashes []common.Hash) ([]*types.Header, error) {
|
||||
|
@ -283,7 +289,7 @@ func (c *CachedEthClient) callGetBalance(ctx context.Context, account common.Add
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return result.ToInt(), nil
|
||||
return (*big.Int)(result), nil
|
||||
}
|
||||
|
||||
func (c *CachedEthClient) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) {
|
||||
|
|
|
@ -50,6 +50,10 @@ func NewDB(db *sql.DB) *DB {
|
|||
}
|
||||
|
||||
func (b *DB) GetBlockJSONByNumber(chainID uint64, blockNumber *big.Int, withTransactionDetails bool) (json.RawMessage, error) {
|
||||
if !isConcreteBlockNumber(blockNumber) {
|
||||
return nil, sql.ErrNoRows
|
||||
}
|
||||
|
||||
q := sq.Select("block_json").
|
||||
From("blockchain_data_blocks").
|
||||
Where(sq.Eq{"chain_id": chainID, "block_number": (*bigint.SQLBigInt)(blockNumber), "with_transaction_details": withTransactionDetails})
|
||||
|
@ -328,7 +332,7 @@ func putBlockJSON(creator sqlite.StatementCreator, chainID uint64, blkJSON json.
|
|||
return err
|
||||
}
|
||||
|
||||
if rpcBlock.Number == nil {
|
||||
if !isConcreteBlockNumber((*big.Int)(rpcBlock.Number)) {
|
||||
// Pending block, don't store
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
|
||||
"github.com/status-im/status-go/contracts"
|
||||
"github.com/status-im/status-go/contracts/balancechecker"
|
||||
"github.com/status-im/status-go/contracts/ethscan"
|
||||
"github.com/status-im/status-go/contracts/ierc20"
|
||||
|
@ -1578,7 +1577,8 @@ func TestFetchNewBlocksCommand_nonceDetection(t *testing.T) {
|
|||
Client: nil,
|
||||
UpstreamChainID: 1,
|
||||
Networks: []params.Network{},
|
||||
DB: db,
|
||||
AppDB: appDB,
|
||||
WalletDB: walletDB,
|
||||
WalletFeed: nil,
|
||||
ProviderConfigs: nil,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from conftest import user_1
|
||||
from constants import user_1
|
||||
from test_cases import EthRpcTestCase
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue