Skip to content

Commit

Permalink
feat: add http_uri and ws_uri [APE-1447] (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: Juliya Smith <[email protected]>
  • Loading branch information
fubuloubu and antazoey authored Oct 10, 2023
1 parent 92785fc commit de58e2e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 10 additions & 0 deletions ape_foundry/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 4 additions & 9 deletions tests/test_fork_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit de58e2e

Please sign in to comment.