Skip to content

Commit

Permalink
fix: added checks to remove , from the RPC URI endpoint [APE-1582] (A…
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviksaikat authored Dec 6, 2023
1 parent 0845558 commit f797f5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ape/api/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@ def _sanitize_web3_url(msg: str) -> str:
parts = msg.split("URI: ")
prefix = parts[0].strip()
rest = parts[1].split(" ")

# * To remove the `,` from the url http://127.0.0.1:8545,
if "," in rest[0]:
rest[0] = rest[0].rstrip(",")
sanitized_url = sanitize_url(rest[0])
return f"{prefix} URI: {sanitized_url} {' '.join(rest[1:])}"

Expand Down
8 changes: 8 additions & 0 deletions tests/functional/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from eth_utils import ValidationError
from web3.exceptions import ContractPanicError

from ape.api.providers import _sanitize_web3_url
from ape.exceptions import BlockNotFoundError, ContractLogicError, TransactionNotFoundError
from ape.types import LogFilter
from ape.utils import DEFAULT_TEST_CHAIN_ID
Expand Down Expand Up @@ -262,3 +263,10 @@ def test_prepare_tx_with_max_gas(tx_type, eth_tester_provider, ethereum, owner):

actual = eth_tester_provider.prepare_transaction(tx)
assert actual.gas_limit == eth_tester_provider.max_gas


def test_no_comma_in_rpc_url():
test_url = "URI: http://127.0.0.1:8545,"
sanitised_url = _sanitize_web3_url(test_url)

assert "," not in sanitised_url

0 comments on commit f797f5b

Please sign in to comment.