Skip to content

Commit 5e886d4

Browse files
Added more tests and moved implementation to getTransactionByBlock
1 parent 8050b8c commit 5e886d4

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

web3/eth.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ def getTransaction(self, transaction_hash):
196196
)
197197

198198
def getTransactionFromBlock(self, block_identifier, transaction_index):
199+
"""
200+
Alias for the method getTransactionByBlock
201+
Depreceated to maintain naming consistency with the json-rpc API
202+
"""
203+
return self.getTransactionByBlock(block_identifier, transaction_index)
204+
205+
def getTransactionByBlock(self, block_identifier, transaction_index):
199206
"""
200207
`eth_getTransactionByBlockHashAndIndex`
201208
`eth_getTransactionByBlockNumberAndIndex`
@@ -211,13 +218,6 @@ def getTransactionFromBlock(self, block_identifier, transaction_index):
211218
[block_identifier, transaction_index],
212219
)
213220

214-
def getTransactionByBlock(self, block_identifier, transaction_index):
215-
"""
216-
Alias for the method getTransactionFromBlock
217-
More details here: https://github.com/ethereum/web3.py/pull/857
218-
"""
219-
return self.getTransactionFromBlock(block_identifier, transaction_index)
220-
221221
def waitForTransactionReceipt(self, transaction_hash, timeout=120):
222222
return wait_for_transaction_receipt(self.web3, transaction_hash, timeout)
223223

web3/utils/module_testing/eth_module.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ def test_eth_getTransactionFromBlockNumberAndIndex(self, web3, block_with_txn, m
511511
assert is_dict(transaction)
512512
assert transaction['hash'] == HexBytes(mined_txn_hash)
513513

514+
def test_eth_getTransactionByBlockHashAndIndex(self, web3, block_with_txn, mined_txn_hash):
515+
transaction = web3.eth.getTransactionByBlock(block_with_txn['hash'], 0)
516+
assert is_dict(transaction)
517+
assert transaction['hash'] == HexBytes(mined_txn_hash)
518+
514519
def test_eth_getTransactionByBlockNumberAndIndex(self, web3, block_with_txn, mined_txn_hash):
515520
transaction = web3.eth.getTransactionByBlock(block_with_txn['number'], 0)
516521
assert is_dict(transaction)

0 commit comments

Comments
 (0)