init: block filter
This commit is contained in:
commit
0f7937d9b1
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
dist
|
||||
__pycache__
|
||||
*.egg-info
|
||||
*.pyc
|
||||
*.d/
|
||||
.venv
|
2
chainlib_eth_celo/__init__.py
Normal file
2
chainlib_eth_celo/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from .block_dialect_filter import CeloBlockDialectFilter
|
||||
from .util import CeloUtil
|
7
chainlib_eth_celo/block_dialect_filter.py
Normal file
7
chainlib_eth_celo/block_dialect_filter.py
Normal file
@ -0,0 +1,7 @@
|
||||
from chainlib.dialect import DialectFilter as BaseDialectFilter
|
||||
|
||||
class CeloBlockDialectFilter(BaseDialectFilter):
|
||||
def apply_src(self, src):
|
||||
src['gas_limit'] = '0x0'
|
||||
return src
|
||||
|
5
chainlib_eth_celo/util.py
Normal file
5
chainlib_eth_celo/util.py
Normal file
@ -0,0 +1,5 @@
|
||||
from enum import Enum
|
||||
|
||||
class CeloUtil(Enum):
|
||||
CHAIN_SPEC = 'evm:flan:44787:celo'
|
||||
|
4
pytest.ini
Normal file
4
pytest.ini
Normal file
@ -0,0 +1,4 @@
|
||||
[pytest]
|
||||
log_cli = 1
|
||||
log_cli_level = DEBUG
|
||||
filterwarnings = ignore::DeprecationWarning
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
chainlib>=0.4.4
|
||||
chainlib-eth>=0.4.8
|
1
test_requirements.txt
Normal file
1
test_requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
pytest~=7.2.0
|
8
tests/conftest.py
Normal file
8
tests/conftest.py
Normal file
@ -0,0 +1,8 @@
|
||||
import pytest
|
||||
from chainlib.eth.connection import (
|
||||
EthHTTPConnection
|
||||
)
|
||||
from chainlib_eth_celo import CeloUtil
|
||||
|
||||
def pytest_configure():
|
||||
pytest.conn = EthHTTPConnection(url='https://rpc.celo.grassecon.net', chain_spec=CeloUtil.CHAIN_SPEC)
|
34
tests/test_e2e.py
Normal file
34
tests/test_e2e.py
Normal file
@ -0,0 +1,34 @@
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
from chainlib.eth.tx import (
|
||||
transaction,
|
||||
receipt,
|
||||
Tx
|
||||
)
|
||||
from chainlib.eth.block import (
|
||||
block_by_number,
|
||||
Block
|
||||
)
|
||||
from chainlib_eth_celo import CeloBlockDialectFilter
|
||||
|
||||
logg = logging.getLogger(__name__)
|
||||
|
||||
def test_fetch_tx():
|
||||
block = 15_237_555
|
||||
hash = '0xd50cff848bc7ee304bab4763d3dcc00e6c900e1bdb955bfa836ad1ba2d74dde2'
|
||||
|
||||
block_query = block_by_number(block, include_tx=True)
|
||||
block_resp = pytest.conn.do(block_query)
|
||||
parsed_block = Block(block_resp, dialect_filter=CeloBlockDialectFilter())
|
||||
|
||||
tx_query = transaction(hash)
|
||||
tx_resp = pytest.conn.do(tx_query)
|
||||
|
||||
receipt_query = receipt(hash)
|
||||
tx_receipt_resp = pytest.conn.do(receipt_query)
|
||||
|
||||
full_parsed_tx = Tx(tx_resp, rcpt=tx_receipt_resp, block=parsed_block)
|
||||
logg.debug('full_parsed_tx: \n{}'.format(full_parsed_tx.to_human()))
|
||||
|
||||
assert full_parsed_tx != None
|
Loading…
Reference in New Issue
Block a user