Skip to content

Commit 382d855

Browse files
committed
adding strict requirements, which can be enabled via env vars, for tested RPC features, which throw an Exception if the RPC does not support them.
1 parent 34ec0f9 commit 382d855

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

IceCreamSwapWeb3/Web3Advanced.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from importlib.resources import files
23
from time import sleep
34

@@ -65,11 +66,23 @@ def __init__(
6566
self.latest_seen_block = self.eth.get_block_number(ignore_latest_seen_block=True)
6667

6768
self.filter_block_range = self._find_max_filter_range()
69+
if self.filter_block_range == 0 and os.getenv("RPC_REQUIRE_LOGS", "false").lower() == "true":
70+
raise Exception("Can not get logs from RPC")
6871
self.rpc_batch_max_size = self._find_max_batch_size()
72+
if self.rpc_batch_max_size == 0 and os.getenv("RPC_REQUIRE_BATCHING", "false").lower() == "true":
73+
raise Exception("RPC does not support batch requests")
6974
self.revert_reason_available: bool = self._check_revert_reason_available()
75+
if not self.revert_reason_available and os.getenv("RPC_REQUIRE_REVERT_REASON", "false").lower() == "true":
76+
raise Exception("RPC does not correctly return revert reasons")
7077
self.is_archive = self._check_is_archive()
78+
if not self.is_archive and os.getenv("RPC_REQUIRE_ARCHIVE", "false").lower() == "true":
79+
raise Exception("RPC does not support archive requests")
7180
self.overwrites_available: bool = self._check_overwrites_available()
81+
if not self.overwrites_available and os.getenv("RPC_REQUIRE_OVERWRITES", "false").lower() == "true":
82+
raise Exception("RPC does not support state overwrites")
7283
self.subsquid_available: bool = self._check_subsquid_available()
84+
if not self.subsquid_available and os.getenv("RPC_REQUIRE_SUBSQUID", "false").lower() == "true":
85+
raise Exception("Chain not supported by SubSquid")
7386

7487
self.middleware_onion.inject(BatchRetryMiddleware, layer=0, name="batch_retry") # split and retry batch requests
7588

0 commit comments

Comments
 (0)