From f47f4f610ec5ea8dbf710622e28c056b223a805c Mon Sep 17 00:00:00 2001 From: tmckenzie51 <25855566+tmckenzie51@users.noreply.github.com> Date: Mon, 26 Apr 2021 16:55:26 -0500 Subject: [PATCH] Add trace_filter, deprecate traceFilter (#1960) * snakecase traceFilter * add release note * xfail deprecated test * lint --- newsfragments/1960.feature.rst | 1 + tests/integration/parity/common.py | 4 ++++ web3/_utils/module_testing/parity_module.py | 14 +++++++++++++- web3/parity.py | 3 ++- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 newsfragments/1960.feature.rst diff --git a/newsfragments/1960.feature.rst b/newsfragments/1960.feature.rst new file mode 100644 index 0000000000..ea043c9400 --- /dev/null +++ b/newsfragments/1960.feature.rst @@ -0,0 +1 @@ +Add trace_filter deprecate traceFilter diff --git a/tests/integration/parity/common.py b/tests/integration/parity/common.py index dfa5b08112..14b6c4aae7 100644 --- a/tests/integration/parity/common.py +++ b/tests/integration/parity/common.py @@ -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) diff --git a/web3/_utils/module_testing/parity_module.py b/web3/_utils/module_testing/parity_module.py index 43ac69f5d6..7ebfca8d47 100644 --- a/web3/_utils/module_testing/parity_module.py +++ b/web3/_utils/module_testing/parity_module.py @@ -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'])) diff --git a/web3/parity.py b/web3/parity.py index a26b472047..0bba93e0c1 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -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], ) @@ -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')