Skip to content

Commit

Permalink
Add trace_replay_block_transactions, deprecate traceReplayBlockTransa…
Browse files Browse the repository at this point in the history
…ctions (#1962)

* snakecase traceReplayBlockTransactions

* add release note
  • Loading branch information
tmckenzie51 authored Apr 26, 2021
1 parent a2f7ac3 commit 3102b72
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions newsfragments/1962.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add trace_replay_block_transactions, deprecate traceReplayBlockTransactions
17 changes: 14 additions & 3 deletions web3/_utils/module_testing/parity_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,29 @@ def test_trace_replay_transaction(
HexStr(parity_fixture_data['coinbase']),
)

def test_trace_replay_block_with_transactions(
def test_trace_replay_block_transactions(
self, web3: "Web3", block_with_txn: BlockData, parity_fixture_data: Dict[str, str]
) -> None:
trace = web3.parity.traceReplayBlockTransactions(block_with_txn['number'])
trace = web3.parity.trace_replay_block_transactions(block_with_txn['number'])
assert len(trace) > 0
trace_0_action = trace[0]['trace'][0]['action']
assert trace_0_action['from'] == add_0x_prefix(HexStr(parity_fixture_data['coinbase']))

def test_traceReplayBlockTransactions_deprecated(
self, web3: "Web3", block_with_txn: BlockData, parity_fixture_data: Dict[str, str]
) -> None:
with pytest.warns(DeprecationWarning,
match='traceReplayBlockTransactions is deprecated in favor of '
'trace_replay_block_transactions'):
trace = web3.parity.traceReplayBlockTransactions(block_with_txn['number'])
assert len(trace) > 0
trace_0_action = trace[0]['trace'][0]['action']
assert trace_0_action['from'] == add_0x_prefix(HexStr(parity_fixture_data['coinbase']))

def test_trace_replay_block_without_transactions(
self, web3: "Web3", empty_block: BlockData
) -> None:
trace = web3.parity.traceReplayBlockTransactions(empty_block['number'])
trace = web3.parity.trace_replay_block_transactions(empty_block['number'])
assert len(trace) == 0

def test_trace_block(self, web3: "Web3", block_with_txn: BlockData) -> None:
Expand Down
5 changes: 4 additions & 1 deletion web3/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def trace_replay_transaction_munger(
mungers=[trace_replay_transaction_munger],
)

traceReplayBlockTransactions: Method[Callable[..., List[ParityBlockTrace]]] = Method(
trace_replay_block_transactions: Method[Callable[..., List[ParityBlockTrace]]] = Method(
RPC.trace_replayBlockTransactions,
mungers=[trace_replay_transaction_munger]
)
Expand Down Expand Up @@ -225,3 +225,6 @@ def trace_transactions_munger(
traceReplayTransaction = DeprecatedMethod(trace_replay_transaction, 'traceReplayTransaction',
'trace_replay_transaction')
netPeers = DeprecatedMethod(net_peers, 'netPeers', 'net_peers')
traceReplayBlockTransactions = DeprecatedMethod(trace_replay_block_transactions,
'traceReplayBlockTransactions',
'trace_replay_block_transactions')

0 comments on commit 3102b72

Please sign in to comment.