Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix flakey tests #1048

Merged
merged 5 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip uninstall eth-ape --yes
pip install .[test]

- name: Run Tests
Expand Down
144 changes: 67 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In the latest release, Ape requires:
2. Choose Ubuntu 20.04 OR Any other Linux Distribution with Python
3.8 or later

Check your python command by entering
Check your python command by entering:

```bash
python3 --version
Expand All @@ -34,18 +34,17 @@ Then install `ape` via
pipx install eth-ape
```

or install w/ ApeWorX-recommended plugins via
To install Ape and a list of common, recommended plugins at the same time, do:

```bash
pipx install eth-ape[recommended-plugins]
pipx install eth-ape'[recommended-plugins]'
```

### via `pip`

**Suggestion**: Create a virtual environment using `virtualenv` or `venv.`

You may skip this creating a virtual environment if you know you don\'t
require one for your use case.
You may skip creating a virtual environment if you know you don\'t require one for your use case.

- [virtualenv](https://pypi.org/project/virtualenv/)
- [venv](https://docs.python.org/3/library/venv.html)
Expand All @@ -56,44 +55,43 @@ require one for your use case.

* (MacOS Option) Install via homebrew [brew](https://formulae.brew.sh/formula/virtualenv)

Create your virtual environment folder
First, create your virtual environment folder:

```bash
python3 -m venv /path/to/new/environment
source <venv_folder>/bin/activate
python3 -m venv <path/to/new/env>
```

NOTE: the path to venv is not a real path.
Then, activate your virtual environment:

```bash
source <venv_folder>/bin/activate
```

You should see `(name_of_venv) DESKTOP_NAME:~/path:$`.

To deactivate the virtual environment, do:

```bash
deactivate
```

Now that your Python version is later than 3.7.2 and you have created a
virtual environment let\'s install Ape!

You can install the latest release via
[pip](https://pypi.org/project/pip/):
Now that you have Python installed in your virtual environment, install the `eth-ape` Python package:
You can install the latest release via [pip](https://pypi.org/project/pip/):

```bash
pip install -U pip
pip install eth-ape
```

or install w/ ApeWorX-recommended plugins via
To install Ape and a list of common, recommended plugins at the same time, do:

```bash
pip install eth-ape[recommended-plugins]
pip install eth-ape'[recommended-plugins]'
```

### via `docker`

Please visit our
[Dockerhub](https://hub.docker.com/repository/docker/apeworx/ape) for
more details on using Ape with Docker.
Please visit our [Dockerhub](https://hub.docker.com/repository/docker/apeworx/ape) for more details on using Ape with Docker.

```bash
docker run \
Expand All @@ -112,24 +110,15 @@ sudo rm -rf **\~/.solcx**
sudo rm -rf **\~/.vvm**
```

## Overview

For more in-depth information about the project please look at the [projects](https://docs.apeworx.io/ape/stable/userguides/projects.html)
It explains the purpose of each folder and how to use them effectively.

Use `ape init` to initialize your ape project folders. Visit [userguide project](https://docs.apeworx.io/ape/stable/userguides/projects.html) for more information.

```bash
ape init
```

## Environment Variables:

Environment Variables are used to help connect you to your files or ecosystems outside of ApeWorX.
Some plugins require environment variables to connect to their external systems, such project IDs or API keys.
Follow instructions from individual plugin documentations, such as:

Please setup environment variables (where applicable) and follow the latest instructions from the 3rd party:
* [ape-alchemy](https://github.com/ApeWorX/ape-alchemy/blob/main/README.md#quick-usage)
* [ape-infura](https://github.com/ApeWorX/ape-infura#readme)

Example use case:
Generally, set environment variables by doing the following:

```bash
# Used by the `ape-infura` plugin
Expand All @@ -138,30 +127,31 @@ export WEB3_INFURA_PROJECT_ID=<YOUR_INFURA_PROJECT_ID>
export WEB3_ALCHEMY_API_KEY=<YOUR_ALCHEMY_KEY>
```

Visit [ape-alchemy](https://github.com/ApeWorX/ape-alchemy/blob/main/README.md#quick-usage)

Visit [ape-infura](https://github.com/ApeWorX/ape-infura#readme)
Place these in environment files, such as your `.bashrc` or `.zshrc`.

## Ape Console
## Quick Usage

Ape provides an IPython interactive console with useful pre-defined locals to interact with your project.
To interact with a deployed contract in a local environment, start by opening the console:
Use `-h` to list all the commands:

```bash
ape console --network :mainnet-fork:hardhat
ape -h
```

Visit [Ape Console](https://docs.apeworx.io/ape/stable/commands/console.html) to learn how to use Ape Console.

## Quick Usage
### Projects

Use `-h` to list all the commands.
When using Ape, you generally will work with a project.
To quickly get started using ape, generate a project using the `ape init` command:

```bash
ape -h
ape init
```

You can import or generate accounts.
For more in-depth information about smart-contract projects using the Ape framework, see the [projects guide](https://docs.apeworx.io/ape/stable/userguides/projects.html).

### Accounts

In Ape, you will need accounts to make transactions.
You can import or generate accounts using the core `accounts` plugin:

```bash
ape accounts import acc0 # Will prompt for a private key
Expand All @@ -174,6 +164,10 @@ List all your accounts with the `list` command.
ape accounts list
```

Learn more about accounts in Ape by following the [accounts guide](https://docs.apeworx.io/ape/stable/userguides/accounts.html).

### Plugins

Add any plugins you may need, such as `vyper`.

```bash
Expand All @@ -182,19 +176,14 @@ ape plugins install vyper
ape plugins list -a
```

**NOTE**: If a plugin does not originate from the
[ApeWorX GitHub organization](https://github.com/ApeWorX?q=ape&type=all), you will get a warning about installing
3rd-class plugins. Any plugin that is not an official plugin has the chance of not being trustworthy. Thus, you should
be mindful about which plugins you install. Additionally, plugins that come bundled with `ape` in the core installation
cannot be removed and are considered part of the `ape` core software.
**NOTE**: If a plugin does not originate from the [ApeWorX GitHub organization](https://github.com/ApeWorX?q=ape&type=all), you will get a warning about installing 3rd-party plugins.
Install 3rd party plugins at your own risk.
Additionally, plugins that come bundled with `ape` in the core installation cannot be removed and are part of the `ape` core software.

You can interact and compile contracts.
Here is an example of a project with a contract you interact with:
Learn more about installing plugins from following [this guide](https://docs.apeworx.io/ape/stable/userguides/installing_plugins.html).
Learn more about developing your own plugins from [this guide](https://docs.apeworx.io/ape/stable/userguides/projects.html).

```bash
git clone https://github.com/brownie-mix/vyper-token-mix.git
cd vyper-token-mix/
```
### Compiling

You can compile contracts within the `contracts/` directory of your project.
The `--size` option will display you the size of the contract.
Expand All @@ -203,25 +192,43 @@ The `--size` option will display you the size of the contract.
ape compile --size
```

Learn more about compiling in Ape by following the [compile guide](https://docs.apeworx.io/ape/stable/userguides/compile.html).

### Testing

Use Ape to test your smart-contract projects.
Provide the same arguments to `pytest` as you would to the `ape test` command.

For example:

```bash
ape test -k test_only_one_thing
```

Connect an IPython session through your favorite provider.
Visit the [testing guide](https://docs.apeworx.io/ape/stable/userguides/testing.html) to learn more about testing using Ape.

### Console

Ape provides an `IPython` interactive console with useful pre-defined locals to interact with your project.
To interact with a deployed contract in a local environment, start by opening the console:

```bash
ape console --network ethereum:mainnet:infura
```

Visit [Ape Console](https://docs.apeworx.io/ape/stable/commands/console.html) to learn how to use Ape Console.

### Scripts

If you want to run specific files in a `scripts/` directory, you can do it using the `ape run` command.

```bash
# This command will run a file named deploy in the scripts/ directory
$ ape run deploy
```

Learn more about scripting using Ape by following the [scripting guide](https://docs.apeworx.io/ape/stable/userguides/scripts.html).

### Logging

To enable debug logging, run your command with the `--verbosity` flag using `DEBUG` as the value:
Expand All @@ -230,7 +237,7 @@ To enable debug logging, run your command with the `--verbosity` flag using `DEB
ape run --verbosity DEBUG
```

You can use `ape` as a package outside of scripts for the `ape run` command as well.
### Networks

You can work with registered networks, providers, and blockchain ecosystems (like Ethereum):

Expand All @@ -240,21 +247,4 @@ with networks.ethereum.mainnet.use_provider("infura"):
... # Work with the infura provider here
```

You can work with test accounts, local accounts, and (WIP) popular hardware wallets:

```python
from ape import accounts
a = accounts[0] # Load by index
a = accounts["example.eth"] # or load by ENS/address
a = accounts.load("alias") # or load by alias
```

You can also work with contract types:

```python
from ape import project
c = a.deploy(project.MyContract, ...)
c.viewThis() # Make Web3 calls
c.doThat(sender=a) # Make Web3 transactions
assert c.MyEvent[-1].caller == a # Search through Web3 events
```
To learn more about networks in Ape, see [this guide](https://docs.apeworx.io/ape/stable/commands/networks.html).
2 changes: 1 addition & 1 deletion src/ape_ethereum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def networks():
yield "ethereum", network_name, create_network_type(*network_params)
yield "ethereum", f"{network_name}-fork", NetworkAPI

# NOTE: This works for development providers, as they get chain_id from themselves
# NOTE: This works for local providers, as they get chain_id from themselves
yield "ethereum", LOCAL_NETWORK_NAME, NetworkAPI