diff --git a/tests/bin/test_vyper.py b/tests/bin/test_vyper.py new file mode 100644 index 00000000000..c4b6db8958c --- /dev/null +++ b/tests/bin/test_vyper.py @@ -0,0 +1,62 @@ +import pytest + +from vyper import ( + __version__, +) + + +@pytest.fixture +def make_tmp_vy_file(tmp_path): + name_counter = 0 + + def _make(src): + nonlocal name_counter + + name = f'tmp{name_counter}.vy' + name_counter += 1 + + src_path = tmp_path / name + src_path.write_text(src) + + return src_path + + return _make + + +@pytest.fixture +def tmp_vy_file_1(make_tmp_vy_file): + return make_tmp_vy_file(""" +@public +def a() -> bool: + return True + """) + + +@pytest.fixture +def tmp_vy_file_2(make_tmp_vy_file): + return make_tmp_vy_file(""" +@public +def meaning_of_life() -> uint256: + return 42 + """) + + +@pytest.mark.script_launch_mode('subprocess') +def test_version(script_runner): + ret = script_runner.run('vyper', '--version') + + assert ret.stdout == __version__ + '\n' + + +@pytest.mark.script_launch_mode('subprocess') +def test_compile_one_file(script_runner, tmp_vy_file_1): + ret = script_runner.run('vyper', '-f', 'bytecode', tmp_vy_file_1) + + assert ret.stdout == '0x6100c256600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052630dbe671f60005114156100b85734156100ac57600080fd5b600160005260206000f3005b60006000fd5b6100046100c2036100046000396100046100c2036000f3\n' # noqa: E501 + + +@pytest.mark.script_launch_mode('subprocess') +def test_compile_two_files(script_runner, tmp_vy_file_1, tmp_vy_file_2): + ret = script_runner.run('vyper', '-f', 'bytecode', '--show-gas-estimates', tmp_vy_file_1, tmp_vy_file_2) + + assert ret.stdout == '0x6100c256600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052630dbe671f60005114156100b85734156100ac57600080fd5b600160005260206000f3005b60006000fd5b6100046100c2036100046000396100046100c2036000f3\n0x6100c256600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052634f452d6060005114156100b85734156100ac57600080fd5b602a60005260206000f3005b60006000fd5b6100046100c2036100046000396100046100c2036000f3\n' # noqa: E501