From e8bb5e6d70699875cfb934414db055a57f80d884 Mon Sep 17 00:00:00 2001 From: tmckenzie51 <25855566+tmckenzie51@users.noreply.github.com> Date: Mon, 26 Apr 2021 18:03:15 -0500 Subject: [PATCH] Add trace_block, deprecate traceBlock (#1961) * snakecase traceBlock * add release note * xfail deprecated test * lint --- newsfragments/1961.feature.rst | 1 + tests/integration/parity/common.py | 4 ++++ web3/_utils/module_testing/parity_module.py | 8 +++++++- web3/parity.py | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 newsfragments/1961.feature.rst diff --git a/newsfragments/1961.feature.rst b/newsfragments/1961.feature.rst new file mode 100644 index 0000000000..15ab5ab02f --- /dev/null +++ b/newsfragments/1961.feature.rst @@ -0,0 +1 @@ +Add trace_block, deprecate traceBlock diff --git a/tests/integration/parity/common.py b/tests/integration/parity/common.py index 14b6c4aae7..ab2467cc9b 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_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) diff --git a/web3/_utils/module_testing/parity_module.py b/web3/_utils/module_testing/parity_module.py index 7ebfca8d47..f8012a3686 100644 --- a/web3/_utils/module_testing/parity_module.py +++ b/web3/_utils/module_testing/parity_module.py @@ -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: diff --git a/web3/parity.py b/web3/parity.py index 0bba93e0c1..aa34bcb25e 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -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], ) @@ -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',