Skip to content

Commit

Permalink
Add some basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davesque committed Mar 12, 2019
1 parent 863e037 commit 732aad7
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/bin/test_vyper.py
Original file line number Diff line number Diff line change
@@ -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', tmp_vy_file_1, tmp_vy_file_2)

assert ret.stdout == '0x6100c256600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052630dbe671f60005114156100b85734156100ac57600080fd5b600160005260206000f3005b60006000fd5b6100046100c2036100046000396100046100c2036000f3\n0x6100c256600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052634f452d6060005114156100b85734156100ac57600080fd5b602a60005260206000f3005b60006000fd5b6100046100c2036100046000396100046100c2036000f3\n' # noqa: E501

0 comments on commit 732aad7

Please sign in to comment.