From bb6d6c62cef0ea623c020d9c838813dd74d9de7f Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Mon, 9 Sep 2024 14:40:33 -0500 Subject: [PATCH] fix: problem --- ape_solidity/_models.py | 4 ++++ tests/test_cli.py | 11 +++++++++++ tests/test_compiler.py | 2 ++ 3 files changed, 17 insertions(+) diff --git a/ape_solidity/_models.py b/ape_solidity/_models.py index 74a780c..91f17d3 100644 --- a/ape_solidity/_models.py +++ b/ape_solidity/_models.py @@ -194,6 +194,10 @@ def _resolve_source( self._resolve_path(reference, project) def _resolve_import_remapping(self, project: ProjectManager): + if self.value.startswith("."): + # Relative paths should not use import-remappings. + return + import_remapping = self.solidity._import_remapping_cache[project] # Get all matches. diff --git a/tests/test_cli.py b/tests/test_cli.py index 495cbe9..9929adf 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -61,6 +61,15 @@ return true; } } +// File: ./safe/ThisIsNotGnosisSafe.sol +// The point of this file is show we can have contracts in folders +// where the folder is the same name as a dependency. + +contract ThisIsNotGnosisSafe { + constructor(){ + + } +} // File: ./subfolder/Relativecontract.sol contract Relativecontract { @@ -138,6 +147,8 @@ // Purposely repeat an import to test how the plugin handles that. +// Show we can import a local contract with the same name (sin-@) as a dependency. + // Purposely exclude the contracts folder to test older Ape-style project imports. // Showing sources with extra extensions are by default excluded, diff --git a/tests/test_compiler.py b/tests/test_compiler.py index 7ae4713..852e2a5 100644 --- a/tests/test_compiler.py +++ b/tests/test_compiler.py @@ -130,6 +130,7 @@ def test_get_imports_complex(project, compiler): "contracts/MissingPragma.sol", "contracts/NumerousDefinitions.sol", "contracts/Source.extra.ext.sol", + "contracts/safe/ThisIsNotGnosisSafe.sol", "contracts/subfolder/Relativecontract.sol", ], "contracts/MissingPragma.sol": [], @@ -413,6 +414,7 @@ def test_get_compiler_settings(project, compiler): "contracts/MissingPragma.sol", "contracts/NumerousDefinitions.sol", "contracts/Source.extra.ext.sol", + "contracts/safe/ThisIsNotGnosisSafe.sol", "contracts/subfolder/Relativecontract.sol", ] assert actual_files == expected_files