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

Indicate use of stdin with 0.4.x compiler #87

Merged
merged 2 commits into from
Jul 16, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion solcx/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def solc_wrapper(
)
command.append("--formal")

if not standard_json and not source_files and solc_minor >= 5:
if not standard_json and not source_files:
# indicates that solc should read from stdin
command.append("-")

if stdin is not None:
Expand Down
29 changes: 18 additions & 11 deletions tests/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ def setup(all_versions):
pass


def _compile_assertions(output, key):
assert output
assert key in output
for value in ALL_OUTPUT_VALUES:
if value == "clone-bin" and solcx.get_solc_version().minor >= 5:
assert value not in output[key]
else:
assert value in output[key]


def test_compile_source(foo_source):
output = solcx.compile_source(foo_source)
_compile_assertions(output, "<stdin>:Foo")
Expand Down Expand Up @@ -72,18 +82,15 @@ def test_compile_files_output_types(foo_path, key):
assert key in output[f"{foo_path}:Foo"]


def test_compile_source_import_remapping(foo_path, bar_source):
path = Path(foo_path).parent.as_posix()
output = solcx.compile_source(bar_source, import_remappings=[f"contracts={path}"])

assert set(output) == {f"{foo_path}:Foo", "<stdin>:Bar"}


def test_compile_files_import_remapping(foo_path, bar_path):
path = Path(bar_path).parent.as_posix()
output = solcx.compile_files([bar_path], import_remappings=[f"contracts={path}"])
assert output
assert f"{bar_path}:Bar" in output


def _compile_assertions(output, key):
assert output
assert key in output
for value in ALL_OUTPUT_VALUES:
if value == "clone-bin" and solcx.get_solc_version().minor >= 5:
assert value not in output[key]
else:
assert value in output[key]
assert set(output) == {f"{bar_path}:Bar", f"{foo_path}:Foo"}