From de58e2e90bcaebb5cc820819dc560094496c6f92 Mon Sep 17 00:00:00 2001 From: El De-dog-lo <3859395+fubuloubu@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:33:34 -0400 Subject: [PATCH] feat: add http_uri and ws_uri [APE-1447] (#73) Co-authored-by: Juliya Smith --- ape_foundry/provider.py | 10 ++++++++++ tests/test_fork_provider.py | 13 ++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ape_foundry/provider.py b/ape_foundry/provider.py index d689e69..f698a3d 100644 --- a/ape_foundry/provider.py +++ b/ape_foundry/provider.py @@ -207,6 +207,16 @@ def uri(self) -> str: self._host = f"http://127.0.0.1:{DEFAULT_PORT}" return self._host + @property + def http_uri(self) -> str: + # NOTE: Overriding `Web3Provider.http_uri` implementation + return self.uri + + @property + def ws_uri(self) -> str: + # NOTE: Overriding `Web3Provider.ws_uri` implementation + return "ws" + self.uri[4:] # Remove `http` in default URI w/ `ws` + @property def priority_fee(self) -> int: return self.config.priority_fee diff --git a/tests/test_fork_provider.py b/tests/test_fork_provider.py index e6b0000..c9f58f5 100644 --- a/tests/test_fork_provider.py +++ b/tests/test_fork_provider.py @@ -143,18 +143,13 @@ def test_contract_revert_no_message(owner, mainnet_fork_contract_instance, mainn @pytest.mark.fork def test_transaction_contract_as_sender( - mainnet_fork_contract_instance, mainnet_fork_provider, convert + mainnet_fork_contract_instance, owner, contract_container, mainnet_fork_provider, convert ): # Set balance so test wouldn't normally fail from lack of funds - mainnet_fork_provider.set_balance(mainnet_fork_contract_instance.address, "1000 ETH") + contract = owner.deploy(contract_container) + mainnet_fork_provider.set_balance(contract.address, "1000 ETH") with pytest.raises(ContractLogicError, match="!authorized"): - # NOTE: For some reason, this only fails when for estimate gas. Otherwise, the status - # is non-failing. This wasn't happened prior to Ape 0.6.9 because a bugfix revealed - # that the test config was never getting applied and thus we never hit this problem - # because it was estimating gas before (even tho should have been using max). - mainnet_fork_contract_instance.setNumber( - 10, sender=mainnet_fork_contract_instance, gas="auto" - ) + mainnet_fork_contract_instance.setNumber(10, sender=contract) @pytest.mark.fork