Skip to content

Commit

Permalink
test: add npm dependency [APE-1033] (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtdang authored Jun 26, 2023
1 parent c270e36 commit 7774fb4
Show file tree
Hide file tree
Showing 10 changed files with 945 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip uninstall eth-ape --yes
pushd tests
npm install
popd
pip install .[test]
- name: Run Tests
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,5 @@ version.py
**/.DS_Store
*.swp
*.swo

tests/node_modules
36 changes: 12 additions & 24 deletions ape_solidity/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,10 @@ def get_import_remapping(self, base_path: Optional[Path] = None) -> Dict[str, st

# Convert to tuple for hashing, check if there's been a change
remappings_tuple = tuple(remappings)

if all(
(
self._import_remapping_hash,
self._import_remapping_hash == hash(remappings_tuple),
contracts_cache.is_dir(),
)
if (
self._import_remapping_hash
and self._import_remapping_hash == hash(remappings_tuple)
and contracts_cache.is_dir()
):
return self._cached_import_map

Expand Down Expand Up @@ -673,26 +670,17 @@ def _get_best_version(self, path: Path, source_by_pragma_spec: Dict) -> Version:

def enrich_error(self, err: ContractLogicError) -> ContractLogicError:
if not is_0x_prefixed(err.revert_message):
# Nothing to do.
return err

if panic_cls := _get_sol_panic(err.revert_message):
# Is from a Solidity panic code, like a builtin Solidity revert.

if self._ape_version <= Version("0.6.10"):
return panic_cls(
contract_address=err.contract_address,
trace=err.trace,
txn=err.txn,
)
else:
# TODO: Bump to next ape version and remove conditional.
return panic_cls(
base_err=err.base_err,
contract_address=err.contract_address,
source_traceback=err.source_traceback,
trace=err.trace,
txn=err.txn,
)
return panic_cls(
base_err=err.base_err,
contract_address=err.contract_address,
source_traceback=err.source_traceback,
trace=err.trace,
txn=err.txn,
)

# Check for ErrorABI.
bytes_message = HexBytes(err.revert_message)
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ exclude =
venv*
docs
build
tests/node_modules
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@
include_package_data=True,
install_requires=[
"py-solc-x>=1.1.0,<2",
"eth-ape>=0.6.9,<0.7",
"eth-ape>=0.6.11,<0.7",
"ethpm-types", # Use the version ape requires
"packaging", # Use the version ape requires
"requests",
"typing-extensions==4.5.0", # Can be removed onced pinned in Core.
"web3[tester]>=0.6.5,<7", # Can remove any version after eth-ape 0.6.11
],
python_requires=">=3.8,<4",
extras_require=extras_require,
Expand Down
10 changes: 10 additions & 0 deletions tests/ape-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ dependencies:
github: yearn/yearn-vaults
ref: master

# Ensure dependencies using NPM dependencies
- name: gnosis
npm: "@gnosis.pm/safe-contracts"
version: 1.3.0

solidity:
import_remapping:
- "@remapping/contracts=TestDependency"
Expand All @@ -36,6 +41,11 @@ solidity:
- "@vault=vault/v0.4.5"
- "@vaultmain=vault/master"

# Ensure that npm dependencies work as a remapping
- "@gnosis=gnosis/v1.3.0"

# Needed for Vault
- "@openzeppelin/contracts=OpenZeppelin/v4.7.1"

# Using evm_version compatible with older and newer solidity versions.
evm_version: constantinople
2 changes: 1 addition & 1 deletion tests/contracts/Imports.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Struct5
} from "./NumerousDefinitions.sol";
import "@styleofbrownie/BrownieStyleDependency.sol";

import "@gnosis/common/Enum.sol";
contract Imports {
function foo() pure public returns(bool) {
return true;
Expand Down
Loading

0 comments on commit 7774fb4

Please sign in to comment.