Skip to content

Commit

Permalink
Add trace_raw_transaction, deprecate traceRawTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Apr 28, 2021
1 parent e0d7dee commit 2837d01
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions newsfragments/1955.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``parity.trace_raw_transaction``, deprecate ``parity.traceRawTransaction``
30 changes: 20 additions & 10 deletions web3/_utils/module_testing/parity_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,32 @@ def test_eth_call_with_0_result(
result = hex_to_integer(trace['output'])
assert result == 0

@pytest.mark.parametrize(
'raw_transaction',
[
(
# address 0x39EEed73fb1D3855E90Cbd42f348b3D7b340aAA6
'0xf8648085174876e8008252089439eeed73fb1d3855e90cbd42f348b3d7b340aaa601801ba0ec1295f00936acd0c2cb90ab2cdaacb8bf5e11b3d9957833595aca9ceedb7aada05dfc8937baec0e26029057abd3a1ef8c505dca2cdc07ffacb046d090d2bea06a' # noqa: E501
),
]
)
def test_trace_raw_transaction(
self,
web3: "Web3",
raw_transaction: HexStr,
funded_account_for_raw_txn: ChecksumAddress,
) -> None:
trace = web3.parity.traceRawTransaction(raw_transaction)
# address 0x39EEed73fb1D3855E90Cbd42f348b3D7b340aAA6
raw_transaction = HexStr('0xf8648085174876e8008252089439eeed73fb1d3855e90cbd42f348b3d7b340aaa601801ba0ec1295f00936acd0c2cb90ab2cdaacb8bf5e11b3d9957833595aca9ceedb7aada05dfc8937baec0e26029057abd3a1ef8c505dca2cdc07ffacb046d090d2bea06a') # noqa: E501
trace = web3.parity.trace_raw_transaction(raw_transaction)
assert trace['stateDiff'] is None
assert trace['vmTrace'] is None
assert trace['trace'][0]['action']['from'] == funded_account_for_raw_txn.lower()

def test_trace_raw_transaction_deprecated(
self,
web3: "Web3",
raw_transaction: HexStr,
funded_account_for_raw_txn: ChecksumAddress,
) -> None:
# address 0x39EEed73fb1D3855E90Cbd42f348b3D7b340aAA6
raw_transaction = HexStr('0xf8648085174876e8008252089439eeed73fb1d3855e90cbd42f348b3d7b340aaa601801ba0ec1295f00936acd0c2cb90ab2cdaacb8bf5e11b3d9957833595aca9ceedb7aada05dfc8937baec0e26029057abd3a1ef8c505dca2cdc07ffacb046d090d2bea06a') # noqa: E501
with pytest.warns(
DeprecationWarning,
match="traceRawTransaction is deprecated in favor of trace_raw_transaction"
):
trace = web3.parity.traceRawTransaction(raw_transaction)
assert trace['stateDiff'] is None
assert trace['vmTrace'] is None
assert trace['trace'][0]['action']['from'] == funded_account_for_raw_txn.lower()
Expand Down
8 changes: 5 additions & 3 deletions web3/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def trace_transactions_munger(
) -> Tuple[HexStr, ParityTraceMode]:
return (raw_transaction, mode)

traceRawTransaction: Method[Callable[..., ParityBlockTrace]] = Method(
trace_raw_transaction: Method[Callable[..., ParityBlockTrace]] = Method(
RPC.trace_rawTransaction,
mungers=[trace_transactions_munger],
)
Expand All @@ -223,12 +223,14 @@ def trace_transactions_munger(
# Deprecated Methods
addReservedPeer = DeprecatedMethod(add_reserved_peer, 'addReservedPeer', 'add_reserved_peer')
listStorageKeys = DeprecatedMethod(list_storage_keys, 'listStorageKeys', 'list_storage_keys')
traceReplayTransaction = DeprecatedMethod(trace_replay_transaction, 'traceReplayTransaction',
'trace_replay_transaction')
netPeers = DeprecatedMethod(net_peers, 'netPeers', 'net_peers')
setMode = DeprecatedMethod(set_mode, 'setMode', 'set_mode')
traceBlock = DeprecatedMethod(trace_block, 'traceBlock', 'trace_block')
traceFilter = DeprecatedMethod(trace_filter, 'traceFilter', 'trace_filter')
traceRawTransaction = DeprecatedMethod(trace_raw_transaction, 'traceRawTransaction',
'trace_raw_transaction')
traceReplayTransaction = DeprecatedMethod(trace_replay_transaction, 'traceReplayTransaction',
'trace_replay_transaction')
traceReplayBlockTransactions = DeprecatedMethod(trace_replay_block_transactions,
'traceReplayBlockTransactions',
'trace_replay_block_transactions')

0 comments on commit 2837d01

Please sign in to comment.