1717# limitations under the License.
1818#
1919# ------------------------------------------------------------------------------
20+
2021"""This module contains the tests of the ethereum module."""
2122
2223import copy
2324import hashlib
2425import logging
2526import math
27+ import os
2628import random
2729import re
2830import tempfile
2931import time
32+ from enum import Enum
3033from pathlib import Path
3134from typing import Dict , Generator , Optional , Tuple , Union , cast
3235from unittest import mock
7477from tests .conftest import DEFAULT_GANACHE_CHAIN_ID , MAX_FLAKY_RERUNS , ROOT_DIR
7578
7679
80+ RPC_ENV_VAR_PREFIX = "RPC_"
81+
82+
83+ class EIP1559Networks (Enum ):
84+ """The supported networks upgraded with EIP-1559."""
85+
86+ ETHEREUM = "https://eth.drpc.org"
87+ ARBITRUM = "https://arbitrum.drpc.org"
88+ ZKSYNC = "https://mainnet.era.zksync.io"
89+ BINANCE = "https://binance.llamarpc.com"
90+ GNOSIS = "https://gnosis.drpc.org"
91+ OPTIMISM = "https://optimism.drpc.org"
92+ BASE = "https://base.drpc.org"
93+ MODE = "https://mode.drpc.org"
94+ POLYGON = "https://polygon.drpc.org"
95+ FRAXTAL = "https://fraxtal.drpc.org"
96+
97+
98+ def __get_rpc (network : EIP1559Networks ) -> str :
99+ """Get RPC with override from environment variables, or default value."""
100+ return os .getenv (f"{ RPC_ENV_VAR_PREFIX } { network .name } " , network .value )
101+
102+
103+ RPCS = {network : __get_rpc (network ) for network in EIP1559Networks }
104+
105+
77106def get_default_gas_strategies () -> Dict :
78107 """Returns default gas price strategy."""
79108 return {
@@ -977,19 +1006,19 @@ def test_try_get_gas_pricing(
9771006 # flake8: noqa: E800 None,
9781007 # flake8: noqa: E800 True,
9791008 # flake8: noqa: E800),
980- ({"address" : "https://eth.drpc.org" , "chain_id" : 1 }, None , False ),
981- ({"address" : "https://arbitrum.drpc.org" , "chain_id" : 42161 }, None , False ),
982- ({"address" : "https://mainnet.era.zksync.io/" , "chain_id" : 324 }, None , False ),
983- ({"address" : "https://binance.llamarpc.com" , "chain_id" : 56 }, None , True ),
1009+ ({"address" : RPCS [ EIP1559Networks . ETHEREUM ] , "chain_id" : 1 }, None , False ),
1010+ ({"address" : RPCS [ EIP1559Networks . ARBITRUM ] , "chain_id" : 42161 }, None , False ),
1011+ ({"address" : RPCS [ EIP1559Networks . ZKSYNC ] , "chain_id" : 324 }, None , False ),
1012+ ({"address" : RPCS [ EIP1559Networks . BINANCE ] , "chain_id" : 56 }, None , True ),
9841013 (
985- {"address" : "https://gnosis.drpc.org" , "chain_id" : 100 },
1014+ {"address" : RPCS [ EIP1559Networks . GNOSIS ] , "chain_id" : 100 },
9861015 {"min_allowed_tip" : DEFAULT_GNOSIS_MIN_ALLOWED_TIP },
9871016 False ,
9881017 ),
989- ({"address" : "https://optimism.drpc.org" , "chain_id" : 10 }, None , False ),
990- ({"address" : "https://base.drpc.org" , "chain_id" : 8453 }, None , False ),
1018+ ({"address" : RPCS [ EIP1559Networks . OPTIMISM ] , "chain_id" : 10 }, None , False ),
1019+ ({"address" : RPCS [ EIP1559Networks . BASE ] , "chain_id" : 8453 }, None , False ),
9911020 (
992- {"address" : "https://mode.drpc.org" , "chain_id" : 34443 },
1021+ {"address" : RPCS [ EIP1559Networks . MODE ] , "chain_id" : 34443 },
9931022 {
9941023 "fee_history_blocks" : 20 ,
9951024 "fallback_estimate" : {
@@ -999,8 +1028,8 @@ def test_try_get_gas_pricing(
9991028 },
10001029 False ,
10011030 ),
1002- ({"address" : "https://polygon.drpc.org" , "chain_id" : 137 }, None , True ),
1003- ({"address" : "https://fraxtal.drpc.org" , "chain_id" : 252 }, None , False ),
1031+ ({"address" : RPCS [ EIP1559Networks . POLYGON ] , "chain_id" : 137 }, None , True ),
1032+ ({"address" : RPCS [ EIP1559Networks . FRAXTAL ] , "chain_id" : 252 }, None , False ),
10041033 ),
10051034)
10061035def test_eip1559_on_network (
0 commit comments