Skip to content

Commit

Permalink
Add trace_block, deprecate traceBlock (#1961)
Browse files Browse the repository at this point in the history
* snakecase traceBlock

* add release note

* xfail deprecated test

* lint
  • Loading branch information
tmckenzie51 authored Apr 26, 2021
1 parent f47f4f6 commit e8bb5e6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/1961.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add trace_block, deprecate traceBlock
4 changes: 4 additions & 0 deletions tests/integration/parity/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ def test_trace_block(self, web3):
def test_trace_transaction(self, web3):
super().test_trace_transaction(web3)

@pytest.mark.xfail(reason="TODO: tracing not working on v2.5.13")
def test_traceBlock_deprecated(self, web3):
super().test_traceBlock_deprecated(web3)

@pytest.mark.xfail(reason="TODO: tracing not working on v2.5.13")
def test_traceFilter_deprecated(self, web3):
super().test_traceFilter_deprecated(web3)
Expand Down
8 changes: 7 additions & 1 deletion web3/_utils/module_testing/parity_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ def test_trace_replay_block_without_transactions(
assert len(trace) == 0

def test_trace_block(self, web3: "Web3", block_with_txn: BlockData) -> None:
trace = web3.parity.traceBlock(block_with_txn['number'])
trace = web3.parity.trace_block(block_with_txn['number'])
assert trace[0]['blockNumber'] == block_with_txn['number']

def test_traceBlock_deprecated(self, web3: "Web3", block_with_txn: BlockData) -> None:
with pytest.warns(DeprecationWarning,
match='traceBlock is deprecated in favor of trace_block'):
trace = web3.parity.traceBlock(block_with_txn['number'])
assert trace[0]['blockNumber'] == block_with_txn['number']

def test_trace_transaction(self, web3: "Web3", parity_fixture_data: Dict[str, str]) -> None:
Expand Down
3 changes: 2 additions & 1 deletion web3/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def trace_replay_transaction_munger(
mungers=[trace_replay_transaction_munger]
)

traceBlock: Method[Callable[[BlockIdentifier], List[ParityBlockTrace]]] = Method(
trace_block: Method[Callable[[BlockIdentifier], List[ParityBlockTrace]]] = Method(
RPC.trace_block,
mungers=[default_root_munger],
)
Expand Down Expand Up @@ -226,6 +226,7 @@ def trace_transactions_munger(
traceReplayTransaction = DeprecatedMethod(trace_replay_transaction, 'traceReplayTransaction',
'trace_replay_transaction')
netPeers = DeprecatedMethod(net_peers, 'netPeers', 'net_peers')
traceBlock = DeprecatedMethod(trace_block, 'traceBlock', 'trace_block')
traceFilter = DeprecatedMethod(trace_filter, 'traceFilter', 'trace_filter')
traceReplayBlockTransactions = DeprecatedMethod(trace_replay_block_transactions,
'traceReplayBlockTransactions',
Expand Down

0 comments on commit e8bb5e6

Please sign in to comment.