Skip to content

Commit 74fbcd1

Browse files
authored
Fix contract doctests (#2213)
* Add newsfragment for doctest fixes
1 parent e01e6ca commit 74fbcd1

File tree

2 files changed

+48
-47
lines changed

2 files changed

+48
-47
lines changed

docs/contracts.rst

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,54 +1092,54 @@ Event Log Object
10921092

10931093
.. doctest:: createFilter
10941094

1095-
>>> transfer_filter = my_token_contract.events.Transfer.createFilter(fromBlock="0x0", argument_filters={'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf'})
1096-
>>> transfer_filter.get_new_entries()
1097-
[AttributeDict({'args': AttributeDict({'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1098-
'to': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1099-
'value': 10}),
1100-
'event': 'Transfer',
1101-
'logIndex': 0,
1102-
'transactionIndex': 0,
1103-
'transactionHash': HexBytes('0x0005643c2425552308b4a28814a4dedafb5d340a811b3d2b1c019b290ffd7410'),
1104-
'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b',
1105-
'blockHash': HexBytes('...'),
1106-
'blockNumber': 2})]
1107-
>>> transfer_filter.get_new_entries()
1108-
[]
1109-
>>> tx_hash = contract.functions.transfer(alice, 10).transact({'gas': 899000, 'gasPrice': 200000})
1110-
>>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
1111-
>>> transfer_filter.get_new_entries()
1112-
[AttributeDict({'args': AttributeDict({'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1113-
'to': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1114-
'value': 10}),
1115-
'event': 'Transfer',
1116-
'logIndex': 0,
1117-
'transactionIndex': 0,
1118-
'transactionHash': HexBytes('0xea111a49b82b0a0729d49f9ad924d8f87405d01e3fa87463cf2903848aacf7d9'),
1119-
'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b',
1120-
'blockHash': HexBytes('...'),
1121-
'blockNumber': 3})]
1122-
>>> transfer_filter.get_all_entries()
1095+
>>> transfer_filter = my_token_contract.events.Transfer.createFilter(fromBlock="0x0", argument_filters={'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf'})
1096+
>>> transfer_filter.get_new_entries()
11231097
[AttributeDict({'args': AttributeDict({'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1124-
'to': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1125-
'value': 10}),
1126-
'event': 'Transfer',
1127-
'logIndex': 0,
1128-
'transactionIndex': 0,
1129-
'transactionHash': HexBytes('0x9da859237e7259832b913d51cb128c8d73d1866056f7a41b52003c953e749678'),
1130-
'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b',
1131-
'blockHash': HexBytes('0xc9c32c3250f77aa3fba2fea1cdeeb0397e7dc68b444747e6eb3db65708aaacd8'),
1132-
'blockNumber': 2}),
1133-
AttributeDict({'args': AttributeDict({'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1134-
'to': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1135-
'value': 10}),
1136-
'event': 'Transfer',
1137-
'logIndex': 0,
1138-
'transactionIndex': 0,
1139-
'transactionHash': HexBytes('0xea111a49b82b0a0729d49f9ad924d8f87405d01e3fa87463cf2903848aacf7d9'),
1140-
'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b',
1141-
'blockHash': HexBytes('...'),
1142-
'blockNumber': 3})]
1098+
'to': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1099+
'value': 10}),
1100+
'event': 'Transfer',
1101+
'logIndex': 0,
1102+
'transactionIndex': 0,
1103+
'transactionHash': HexBytes('0x9da859237e7259832b913d51cb128c8d73d1866056f7a41b52003c953e749678'),
1104+
'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b',
1105+
'blockHash': HexBytes('...'),
1106+
'blockNumber': 2})]
1107+
>>> transfer_filter.get_new_entries()
1108+
[]
1109+
>>> tx_hash = contract.functions.transfer(alice, 10).transact({'gas': 899000, 'gasPrice': 674302241})
1110+
>>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
1111+
>>> transfer_filter.get_new_entries()
1112+
[AttributeDict({'args': AttributeDict({'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1113+
'to': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1114+
'value': 10}),
1115+
'event': 'Transfer',
1116+
'logIndex': 0,
1117+
'transactionIndex': 0,
1118+
'transactionHash': HexBytes('0xa23e7ef4d2692c5cf34ee99123c9c73099e9c3b68c7850f91c1cbcb91ac327e0'),
1119+
'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b',
1120+
'blockHash': HexBytes('...'),
1121+
'blockNumber': 3})]
1122+
>>> transfer_filter.get_all_entries()
1123+
[AttributeDict({'args': AttributeDict({'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1124+
'to': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1125+
'value': 10}),
1126+
'event': 'Transfer',
1127+
'logIndex': 0,
1128+
'transactionIndex': 0,
1129+
'transactionHash': HexBytes('0x9da859237e7259832b913d51cb128c8d73d1866056f7a41b52003c953e749678'),
1130+
'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b',
1131+
'blockHash': HexBytes('...'),
1132+
'blockNumber': 2}),
1133+
AttributeDict({'args': AttributeDict({'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1134+
'to': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf',
1135+
'value': 10}),
1136+
'event': 'Transfer',
1137+
'logIndex': 0,
1138+
'transactionIndex': 0,
1139+
'transactionHash': HexBytes('0xa23e7ef4d2692c5cf34ee99123c9c73099e9c3b68c7850f91c1cbcb91ac327e0'),
1140+
'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b',
1141+
'blockHash': HexBytes('...'),
1142+
'blockNumber': 3})]
11431143

11441144
Utils
11451145
-----

newsfragments/2213.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed doctest that wasn't running in ``docs/contracts.rst``

0 commit comments

Comments
 (0)