From c688e2aa28549be97cd5faee489e83d163f5765e Mon Sep 17 00:00:00 2001 From: Tiffany McKenzie <25855566+tmckenzie51@users.noreply.github.com> Date: Wed, 21 Apr 2021 12:01:05 -0500 Subject: [PATCH] snakecase traceReplayTransaction --- newsfragments/1949.feature.rst | 1 + web3/_utils/module_testing/parity_module.py | 15 ++++++++++++++- web3/parity.py | 7 ++++++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 newsfragments/1949.feature.rst diff --git a/newsfragments/1949.feature.rst b/newsfragments/1949.feature.rst new file mode 100644 index 0000000000..09e26ea545 --- /dev/null +++ b/newsfragments/1949.feature.rst @@ -0,0 +1 @@ +Add trace_replay_transaction deprecate traceReplayTransaction diff --git a/web3/_utils/module_testing/parity_module.py b/web3/_utils/module_testing/parity_module.py index dea5b96002..249b910e54 100644 --- a/web3/_utils/module_testing/parity_module.py +++ b/web3/_utils/module_testing/parity_module.py @@ -31,11 +31,24 @@ class ParityTraceModuleTest: + def test_traceReplayTransaction_deprecated( + self, web3: "Web3", parity_fixture_data: Dict[str, str], + ) -> None: + with pytest.warns(DeprecationWarning, + match='traceReplayTransaction is deprecated in favor of ' + 'trace_replay_transaction'): + trace = web3.parity.traceReplayTransaction( + HexStr(parity_fixture_data['mined_txn_hash'])) + assert trace['stateDiff'] is None + assert trace['vmTrace'] is None + assert trace['trace'][0]['action']['from'] == add_0x_prefix( + HexStr(parity_fixture_data['coinbase']), + ) def test_trace_replay_transaction( self, web3: "Web3", parity_fixture_data: Dict[str, str], ) -> None: - trace = web3.parity.traceReplayTransaction(HexStr(parity_fixture_data['mined_txn_hash'])) + trace = web3.parity.trace_replay_transaction(HexStr(parity_fixture_data['mined_txn_hash'])) assert trace['stateDiff'] is None assert trace['vmTrace'] is None diff --git a/web3/parity.py b/web3/parity.py index 945f45ae37..c810aef052 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -41,6 +41,7 @@ RPC, ) from web3.method import ( + DeprecatedMethod, Method, default_root_munger, ) @@ -153,7 +154,7 @@ def trace_replay_transaction_munger( ) -> Tuple[Union[BlockIdentifier, _Hash32], ParityTraceMode]: return (block_identifier, mode) - traceReplayTransaction: Method[Callable[..., ParityBlockTrace]] = Method( + trace_replay_transaction: Method[Callable[..., ParityBlockTrace]] = Method( RPC.trace_replayTransaction, mungers=[trace_replay_transaction_munger], ) @@ -218,3 +219,7 @@ def trace_transactions_munger( RPC.parity_mode, mungers=None ) + + # Deprecated Methods + traceReplayTransaction = DeprecatedMethod(trace_replay_transaction, 'traceReplayTransaction', + 'trace_replay_transaction')