Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

[ENG-626] Rpc types integration tests #1207

Merged
merged 10 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions rpc/backend/evm_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (b *Backend) BlockNumber() (hexutil.Uint64, error) {
func (b *Backend) GetBlockByNumber(blockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error) {
resBlock, err := b.GetTendermintBlockByNumber(blockNum)
if err != nil {
return nil, err
return nil, nil
}

// return if requested block height is greater than the current one
Expand Down Expand Up @@ -939,18 +939,18 @@ func (b *Backend) FeeHistory(
// fetch block
for blockID := blockStart; blockID < blockEnd; blockID++ {
index := int32(blockID - blockStart)
// eth block
ethBlock, err := b.GetBlockByNumber(types.BlockNumber(blockID), true)
if ethBlock == nil {
return nil, err
}

// tendermint block
tendermintblock, err := b.GetTendermintBlockByNumber(types.BlockNumber(blockID))
if tendermintblock == nil {
return nil, err
}

// eth block
ethBlock, err := b.GetBlockByNumber(types.BlockNumber(blockID), true)
if ethBlock == nil {
return nil, err
}

// tendermint block result
tendermintBlockResult, err := b.GetTendermintBlockResultByNumber(&tendermintblock.Block.Height)
if tendermintBlockResult == nil {
Expand Down
6 changes: 3 additions & 3 deletions rpc/backend/evm_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() {
expPass bool
}{
{
"fail - tendermint block error",
"pass - tendermint block not found",
ethrpc.BlockNumber(1),
true,
sdk.NewInt(1).BigInt(),
Expand All @@ -110,8 +110,8 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() {
client := suite.backend.clientCtx.Client.(*mocks.Client)
RegisterBlockError(client, height)
},
false,
false,
true,
true,
},
{
"pass - block not found (e.g. request block height that is greater than current one)",
Expand Down
6 changes: 5 additions & 1 deletion rpc/namespaces/ethereum/eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ func (e *PublicAPI) GetBalance(address common.Address, blockNrOrHash rpctypes.Bl
Address: address.String(),
}

_, err = e.backend.GetTendermintBlockByNumber(blockNum)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, errors.New("header not found")
ramacarlucho marked this conversation as resolved.
Show resolved Hide resolved
}

res, err := e.queryClient.Balance(rpctypes.ContextWithHeight(blockNum.Int64()), req)
if err != nil {
return nil, err
Expand Down Expand Up @@ -946,7 +951,6 @@ func (e *PublicAPI) GetTransactionReceipt(hash common.Hash) (map[string]interfac
"transactionHash": hash,
"contractAddress": nil,
"gasUsed": hexutil.Uint64(parsedTx.GasUsed),
"type": hexutil.Uint(txData.TxType()),
facs95 marked this conversation as resolved.
Show resolved Hide resolved

// Inclusion information: These fields provide information about the inclusion of the
// transaction corresponding to this receipt.
Expand Down
5 changes: 0 additions & 5 deletions tests/integration_tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ def get_blocks(ethermint, geth, with_transactions):
geth_rpc = geth.w3.provider
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_getBlockByNumber", ['0x0', with_transactions])

# FIXME: Fails
# {'jsonrpc': '2.0', 'id': 20, 'error': {'code': -32000, 'message': 'height 10000 must be less than or equal to the current blockchain height 18'}}
# {'jsonrpc': '2.0', 'id': 2, 'result': None}
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_getBlockByNumber", ['0x2710', with_transactions])

ethermint_blk = ethermint.w3.eth.get_block(1)
Expand Down Expand Up @@ -84,7 +81,6 @@ def test_balance(ethermint, geth):
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_getBalance", ["0x57f96e6b86cdefdb3d412547816a82e3e0ebf9d2", '0x0'])
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_getBalance", ["0",'0x0'])
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_getBalance", ["0x9907a0cf64ec9fbf6ed8fd4971090de88222a9ac",'0x0'])
# FIXME: BAD ERROR
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_getBalance", ["0x57f96e6b86cdefdb3d412547816a82e3e0ebf9d2", '0x10000'])
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_getBalance", ["0",'0x10000'])
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_getBalance", ["0x9907a0cf64ec9fbf6ed8fd4971090de88222a9ac",'0x10000'])
Expand Down Expand Up @@ -243,7 +239,6 @@ def test_getTransactionReceipt(ethermint, geth):
geth_rpc = geth.w3.provider
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_getTransactionReceipt", ["0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060"])

# FIXME: 'type': '0x0' not in expected, status key on json is not in ethermint
tx_hash = send_and_get_hash(ethermint.w3)

tx_res = eth_rpc.make_request('eth_getTransactionReceipt', [tx_hash])
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
def contract_path(name, filename):
return (
Path(__file__).parent
/ "contracts/artifacts/"
/ "contracts/artifacts/contracts"
/ filename
/ (name + ".json")
)
Expand Down