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

#86dt89kf4 - Refactor BoaCliTest on cli_tests to use BoaConstructor #1236

Merged
merged 1 commit into from
Apr 18, 2024
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
11 changes: 5 additions & 6 deletions boa3_test/tests/cli_tests/cli_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from boa3_test.tests.boa_test import (BoaTest, # needs to be the first import to avoid circular imports
_COMPILER_LOCK as LOCK,
_LOGGING_LOCK as LOG_LOCK
)

__all__ = [
'BoaCliTest',
]
Expand All @@ -12,10 +7,14 @@
from contextlib import redirect_stdout, redirect_stderr

from boa3.cli import main
from boa3_test.tests import boatestcase
from boa3_test.tests.boatestcase import (_COMPILER_LOCK as LOCK,
_LOGGING_LOCK as LOG_LOCK
luc10921 marked this conversation as resolved.
Show resolved Hide resolved
)
from boa3_test.tests.cli_tests import utils
luc10921 marked this conversation as resolved.
Show resolved Hide resolved


class BoaCliTest(BoaTest, abc.ABC):
class BoaCliTest(boatestcase.BoaTestCase, abc.ABC):
default_folder = 'test_cli'

EXIT_CODE_SUCCESS = 0
Expand Down
3 changes: 1 addition & 2 deletions boa3_test/tests/cli_tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from boa3_test.tests.cli_tests.cli_test import BoaCliTest # needs to be the first import to avoid circular imports

from boa3.internal import constants
from boa3_test.tests.cli_tests.cli_test import BoaCliTest
from boa3_test.tests.cli_tests.utils import neo3_boa_cli


Expand Down
24 changes: 10 additions & 14 deletions boa3_test/tests/cli_tests/test_compile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os.path

from boa3_test.tests.cli_tests.cli_test import BoaCliTest # needs to be the first import to avoid circular imports

from boa3.internal import constants
from boa3.internal.neo3.vm import VMState
from boa3_test.tests.cli_tests.cli_test import BoaCliTest
from boa3_test.tests.cli_tests.utils import neo3_boa_cli, get_path_from_boa3_test
from boa3_test.tests.test_drive.testrunner.boa_test_runner import BoaTestRunner


class TestCliCompile(BoaCliTest):
Expand Down Expand Up @@ -111,10 +108,13 @@ def test_cli_compile_new_output_path(self):
@neo3_boa_cli('compile', get_path_from_boa3_test('test_sc', 'boa_built_in_methods_test', 'Env.py'),
'-e', 'env_changed',
'-o', get_path_from_boa3_test('test_sc', 'boa_built_in_methods_test', 'Env_cli.nef', get_unique=True))
def test_cli_compile_env(self):
async def test_cli_compile_env(self):
luc10921 marked this conversation as resolved.
Show resolved Hide resolved
contract_path = get_path_from_boa3_test('test_sc', 'boa_built_in_methods_test', 'Env.py')
output_name = 'Env_cli.nef'

luc10921 marked this conversation as resolved.
Show resolved Hide resolved
nef_path, _ = self.get_deploy_file_paths(
get_path_from_boa3_test('test_sc', 'boa_built_in_methods_test', 'Env.py'),
output_name='Env_cli.nef',
contract_path,
output_name=output_name,
compile_if_found=False
)
nef_generated = nef_path.split(constants.PATH_SEPARATOR)[-1]
Expand All @@ -127,15 +127,11 @@ def test_cli_compile_env(self):
self.assertTrue(f'Wrote {nef_generated} to ' in logs.output[-1],
msg=f'Something went wrong when compiling {nef_generated}')

runner = BoaTestRunner(runner_id=self.method_name())
await self.set_up_contract(contract_path, output_name=output_name)

runner.deploy_contract(nef_path)
invoke = runner.call_contract(nef_path, 'main')
expected_result = 'env_changed'
runner.execute()
self.assertEqual(VMState.HALT, runner.vm_state, msg=runner.error)

self.assertEqual(invoke.result, expected_result)
result, _ = await self.call('main', return_type=str)
luc10921 marked this conversation as resolved.
Show resolved Hide resolved
self.assertEqual(expected_result, result)

@neo3_boa_cli('compile', 'wrong_file')
def test_cli_compile_wrong_file(self):
Expand Down
Loading