Skip to content

Commit

Permalink
Add trace_call, deprecate traceCall
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Apr 23, 2021
1 parent 32cc2c6 commit 965639c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions newsfragments/1957.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``parity.trace_call``, deprecate ``parity.traceCall``
23 changes: 20 additions & 3 deletions web3/_utils/module_testing/parity_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ def test_trace_transaction(self, web3: "Web3", parity_fixture_data: Dict[str, st
trace = web3.parity.traceTransaction(HexStr(parity_fixture_data['mined_txn_hash']))
assert trace[0]['action']['from'] == add_0x_prefix(HexStr(parity_fixture_data['coinbase']))

def test_traceCall_deprecated(
self, web3: "Web3", math_contract: "Contract", math_contract_address: ChecksumAddress
) -> None:
coinbase = web3.eth.coinbase
txn_params = math_contract._prepare_transaction(
fn_name='add',
fn_args=(7, 11),
transaction={'from': coinbase, 'to': math_contract_address},
)
with pytest.warns(DeprecationWarning,
match="traceCall is deprecated in favor of trace_call"):
trace = web3.parity.traceCall(txn_params)
assert trace['stateDiff'] is None
assert trace['vmTrace'] is None
result = hex_to_integer(trace['output'])
assert result == 18

def test_trace_call(
self, web3: "Web3", math_contract: "Contract", math_contract_address: ChecksumAddress
) -> None:
Expand All @@ -87,13 +104,13 @@ def test_trace_call(
fn_args=(7, 11),
transaction={'from': coinbase, 'to': math_contract_address},
)
trace = web3.parity.traceCall(txn_params)
trace = web3.parity.trace_call(txn_params)
assert trace['stateDiff'] is None
assert trace['vmTrace'] is None
result = hex_to_integer(trace['output'])
assert result == 18

def test_eth_call_with_0_result(
def test_trace_call_with_0_result(
self, web3: "Web3", math_contract: "Contract", math_contract_address: ChecksumAddress
) -> None:
coinbase = web3.eth.coinbase
Expand All @@ -102,7 +119,7 @@ def test_eth_call_with_0_result(
fn_args=(0, 0),
transaction={'from': coinbase, 'to': math_contract_address},
)
trace = web3.parity.traceCall(txn_params)
trace = web3.parity.trace_call(txn_params)
assert trace['stateDiff'] is None
assert trace['vmTrace'] is None
result = hex_to_integer(trace['output'])
Expand Down
3 changes: 2 additions & 1 deletion web3/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def trace_call_munger(

return (transaction, mode, block_identifier)

traceCall: Method[Callable[..., ParityBlockTrace]] = Method(
trace_call: Method[Callable[..., ParityBlockTrace]] = Method(
RPC.trace_call,
mungers=[trace_call_munger],
)
Expand Down Expand Up @@ -224,3 +224,4 @@ def trace_transactions_munger(
traceReplayTransaction = DeprecatedMethod(trace_replay_transaction, 'traceReplayTransaction',
'trace_replay_transaction')
netPeers = DeprecatedMethod(net_peers, 'netPeers', 'net_peers')
traceCall = DeprecatedMethod(trace_call, 'traceCall', 'trace_call')

0 comments on commit 965639c

Please sign in to comment.