Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trace_replay_block_transactions, deprecate traceReplayBlockTransactions #1962

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -224,3 +224,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')