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: hardhat compatibility #268

Merged
merged 2 commits into from
Apr 19, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from eth_account import Account
from eth_account.messages import encode_structured_data

from brownie import compile_source, Token, Vault
from brownie import compile_source, Token, Vault, web3, chain

PACKAGE_VERSION = yaml.safe_load(
(Path(__file__).parents[1] / "ethpm-config.yaml").read_text()
Expand Down Expand Up @@ -82,6 +82,12 @@ def patch_vault_version(version):
return patch_vault_version


def chain_id():
# BUG: ganache-cli provides mismatching chain.id and chainid()
# https://github.com/trufflesuite/ganache/issues/1643
return 1 if web3.clientVersion.startswith("EthereumJS") else chain.id


@pytest.fixture
def sign_token_permit():
def sign_token_permit(
Expand All @@ -92,7 +98,6 @@ def sign_token_permit(
deadline: int = 0, # 0 means no time limit
override_nonce: int = None,
):
chain_id = 1 # ganache bug https://github.com/trufflesuite/ganache/issues/1643
if override_nonce:
nonce = override_nonce
else:
Expand All @@ -116,7 +121,7 @@ def sign_token_permit(
"domain": {
"name": token.name(),
"version": "1",
"chainId": chain_id,
"chainId": chain_id(),
"verifyingContract": str(token),
},
"primaryType": "Permit",
Expand Down Expand Up @@ -146,7 +151,6 @@ def sign_vault_permit(
):
name = "Yearn Vault"
version = vault.apiVersion()
chain_id = 1 # ganache bug https://github.com/trufflesuite/ganache/issues/1643
if override_nonce:
nonce = override_nonce
else:
Expand All @@ -170,7 +174,7 @@ def sign_vault_permit(
"domain": {
"name": name,
"version": version,
"chainId": chain_id,
"chainId": chain_id(),
"verifyingContract": str(vault),
},
"primaryType": "Permit",
Expand Down