|
15 | 15 | from web3 import (
|
16 | 16 | constants,
|
17 | 17 | )
|
18 |
| -from web3.exceptions import ( |
19 |
| - TransactionNotFound, |
20 |
| -) |
21 | 18 |
|
22 | 19 | # use same coinbase value as in `web3.py/tests/integration/common.py`
|
23 | 20 | COINBASE = "0xdc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd"
|
|
26 | 23 | KEYFILE_DATA = '{"address":"dc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd","crypto":{"cipher":"aes-128-ctr","ciphertext":"52e06bc9397ea9fa2f0dae8de2b3e8116e92a2ecca9ad5ff0061d1c449704e98","cipherparams":{"iv":"aa5d0a5370ef65395c1a6607af857124"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"9fdf0764eb3645ffc184e166537f6fe70516bf0e34dc7311dea21f100f0c9263"},"mac":"4e0b51f42b865c15c485f4faefdd1f01a38637e5247f8c75ffe6a8c0eba856f6"},"id":"5a6124e0-10f1-4c1c-ae3e-d903eacb740a","version":3}' # noqa: E501
|
27 | 24 |
|
28 | 25 | KEYFILE_PW = "web3py-test"
|
| 26 | +KEYFILE_PW_TXT = "pw.txt" |
29 | 27 | KEYFILE_FILENAME = "UTC--2017-08-24T19-42-47.517572178Z--dc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd" # noqa: E501
|
30 | 28 |
|
31 | 29 | RAW_TXN_ACCOUNT = "0x39EEed73fb1D3855E90Cbd42f348b3D7b340aAA6"
|
|
40 | 38 | "config": {
|
41 | 39 | "chainId": 131277322940537, # the string 'web3py' as an integer
|
42 | 40 | "homesteadBlock": 0,
|
43 |
| - "byzantiumBlock": 0, |
44 |
| - "constantinopleBlock": 0, |
45 | 41 | "eip150Block": 0,
|
46 | 42 | "eip155Block": 0,
|
47 | 43 | "eip158Block": 0,
|
48 |
| - "istanbulBlock": 0, |
| 44 | + "byzantiumBlock": 0, |
| 45 | + "constantinopleBlock": 0, |
49 | 46 | "petersburgBlock": 0,
|
| 47 | + "istanbulBlock": 0, |
50 | 48 | "berlinBlock": 0,
|
51 | 49 | "londonBlock": 0,
|
52 | 50 | "arrowGlacierBlock": 0,
|
53 | 51 | "grayGlacierBlock": 0,
|
54 | 52 | "shanghaiTime": 0,
|
| 53 | + "terminalTotalDifficulty": 0, |
| 54 | + "terminalTotalDifficultyPassed": True, |
55 | 55 | },
|
56 |
| - "nonce": "0x0000000000000042", |
| 56 | + "nonce": "0x0", |
57 | 57 | "alloc": {
|
58 | 58 | COINBASE: {"balance": "1000000000000000000000000000"},
|
59 | 59 | UNLOCKABLE_ACCOUNT: {"balance": "1000000000000000000000000000"},
|
|
65 | 65 | "0000000000000000000000000000000000000005": {"balance": "1"},
|
66 | 66 | "0000000000000000000000000000000000000006": {"balance": "1"},
|
67 | 67 | },
|
68 |
| - "timestamp": "0x00", |
| 68 | + "timestamp": "0x0", |
69 | 69 | "parentHash": constants.HASH_ZERO,
|
70 | 70 | "extraData": "0x3535353535353535353535353535353535353535353535353535353535353535",
|
71 | 71 | "gasLimit": "0x3b9aca00", # 1,000,000,000
|
@@ -172,6 +172,9 @@ def get_geth_process(
|
172 | 172 | geth_binary,
|
173 | 173 | "--datadir",
|
174 | 174 | datadir,
|
| 175 | + "--dev", |
| 176 | + "--dev.period", |
| 177 | + "1", |
175 | 178 | "--ipcpath",
|
176 | 179 | ipc_path,
|
177 | 180 | "--nodiscover",
|
@@ -210,43 +213,22 @@ def mine_block(w3):
|
210 | 213 | origin_block_number = w3.eth.block_number
|
211 | 214 |
|
212 | 215 | start_time = time.time()
|
213 |
| - w3.geth.miner.start(1) |
214 | 216 | while time.time() < start_time + 120:
|
215 | 217 | block_number = w3.eth.block_number
|
216 | 218 | if block_number > origin_block_number:
|
217 |
| - w3.geth.miner.stop() |
218 | 219 | return block_number
|
219 | 220 | else:
|
220 | 221 | time.sleep(0.1)
|
221 | 222 | else:
|
222 | 223 | raise ValueError("No block mined during wait period")
|
223 | 224 |
|
224 | 225 |
|
225 |
| -def mine_transaction_hash(w3, txn_hash): |
226 |
| - start_time = time.time() |
227 |
| - w3.geth.miner.start(1) |
228 |
| - while time.time() < start_time + 120: |
229 |
| - try: |
230 |
| - receipt = w3.eth.get_transaction_receipt(txn_hash) |
231 |
| - except TransactionNotFound: |
232 |
| - continue |
233 |
| - if receipt is not None: |
234 |
| - w3.geth.miner.stop() |
235 |
| - return receipt |
236 |
| - else: |
237 |
| - time.sleep(0.1) |
238 |
| - else: |
239 |
| - raise ValueError( |
240 |
| - "Math contract deploy transaction not mined during wait period" |
241 |
| - ) |
242 |
| - |
243 |
| - |
244 | 226 | def deploy_contract(w3, name, factory):
|
245 | 227 | name = name.upper()
|
246 | 228 | w3.geth.personal.unlock_account(w3.eth.coinbase, KEYFILE_PW)
|
247 | 229 | deploy_txn_hash = factory.constructor().transact({"from": w3.eth.coinbase})
|
248 | 230 | print(f"{name}_CONTRACT_DEPLOY_HASH: {deploy_txn_hash}")
|
249 |
| - deploy_receipt = mine_transaction_hash(w3, deploy_txn_hash) |
| 231 | + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn_hash) |
250 | 232 | print(f"{name}_CONTRACT_DEPLOY_TRANSACTION_MINED")
|
251 | 233 | contract_address = deploy_receipt["contractAddress"]
|
252 | 234 | assert is_checksum_address(contract_address)
|
|
0 commit comments