Skip to content

Commit

Permalink
Add trace_filter, deprecate traceFilter (#1960)
Browse files Browse the repository at this point in the history
* snakecase traceFilter

* add release note

* xfail deprecated test

* lint
  • Loading branch information
tmckenzie51 authored Apr 26, 2021
1 parent 0aa968d commit f47f4f6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/1960.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add trace_filter deprecate traceFilter
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_traceFilter_deprecated(self, web3):
super().test_traceFilter_deprecated(web3)

@pytest.mark.xfail(reason="TODO: tracing not working on v2.5.13")
def test_trace_filter(self, web3):
super().test_trace_filter(web3)
Expand Down
14 changes: 13 additions & 1 deletion web3/_utils/module_testing/parity_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,19 @@ def test_trace_filter(
txn_filter_params: ParityFilterParams,
parity_fixture_data: Dict[str, str],
) -> None:
trace = web3.parity.traceFilter(txn_filter_params)
trace = web3.parity.trace_filter(txn_filter_params)
assert isinstance(trace, list)
assert trace[0]['action']['from'] == add_0x_prefix(HexStr(parity_fixture_data['coinbase']))

def test_traceFilter_deprecated(
self,
web3: "Web3",
txn_filter_params: ParityFilterParams,
parity_fixture_data: Dict[str, str],
) -> None:
with pytest.warns(DeprecationWarning,
match='traceFilter is deprecated in favor of trace_filter'):
trace = web3.parity.traceFilter(txn_filter_params)
assert isinstance(trace, list)
assert trace[0]['action']['from'] == add_0x_prefix(HexStr(parity_fixture_data['coinbase']))

Expand Down
3 changes: 2 additions & 1 deletion web3/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def trace_replay_transaction_munger(
mungers=[default_root_munger],
)

traceFilter: Method[Callable[[ParityFilterParams], List[ParityFilterTrace]]] = Method(
trace_filter: Method[Callable[[ParityFilterParams], List[ParityFilterTrace]]] = Method(
RPC.trace_filter,
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')
traceFilter = DeprecatedMethod(trace_filter, 'traceFilter', 'trace_filter')
traceReplayBlockTransactions = DeprecatedMethod(trace_replay_block_transactions,
'traceReplayBlockTransactions',
'trace_replay_block_transactions')

0 comments on commit f47f4f6

Please sign in to comment.