-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1225 from CityOfZion/CU-86drpndm8
#86drpndm8 - Refactor example_tests/test_hello_world.py to use BoaCon…
- Loading branch information
Showing
1 changed file
with
12 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
from boa3_test.tests.boa_test import BoaTest # needs to be the first import to avoid circular imports | ||
from boa3_test.tests import boatestcase | ||
|
||
from boa3.internal.neo3.vm import VMState | ||
from boa3_test.tests.test_drive.testrunner.boa_test_runner import BoaTestRunner | ||
|
||
|
||
class TestTemplate(BoaTest): | ||
class TestTemplate(boatestcase.BoaTestCase): | ||
default_folder: str = 'examples' | ||
|
||
def test_hello_world_compile(self): | ||
path = self.get_contract_path('hello_world.py') | ||
self.compile(path) | ||
|
||
def test_hello_world_main(self): | ||
path, _ = self.get_deploy_file_paths('hello_world.py') | ||
runner = BoaTestRunner(runner_id=self.method_name()) | ||
self.assertCompile(path) | ||
|
||
invoke = runner.call_contract(path, 'Main') | ||
async def test_hello_world_main(self): | ||
await self.set_up_contract('hello_world.py') | ||
|
||
hello_world_contract = invoke.invoke.contract | ||
runner.execute(get_storage_from=hello_world_contract) | ||
self.assertEqual(VMState.HALT, runner.vm_state, msg=runner.error) | ||
result, _ = await self.call('Main', [], return_type=None, signing_accounts=[self.genesis]) | ||
self.assertIsNone(result) | ||
|
||
self.assertIsNone(invoke.result) | ||
key = b'hello' | ||
expected_value = b'world' | ||
|
||
storage_result = runner.storages.get(hello_world_contract, b'hello') | ||
self.assertEqual(b'world', storage_result.as_bytes()) | ||
contract_storage = await self.get_storage() | ||
self.assertIn(key, contract_storage) | ||
self.assertEqual(expected_value, contract_storage[key]) |