Skip to content

Commit

Permalink
#86drpndm8 - Refactor example_tests/test_hello_world.py to use BoaCon…
Browse files Browse the repository at this point in the history
…structor
  • Loading branch information
jplippi committed Mar 19, 2024
1 parent 095a317 commit c13335e
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions boa3_test/tests/examples_tests/test_hello_world.py
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])

0 comments on commit c13335e

Please sign in to comment.