-
Notifications
You must be signed in to change notification settings - Fork 21
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
CU-86drpncjw - Refactor example_tests/test_htlc.py to use BoaConstructor #1227
Conversation
self.assertEqual(htlc, filtered_transfer_events[0].source) | ||
self.assertEqual(person_a, filtered_transfer_events[0].destination) | ||
self.assertEqual(transferred_amount_neo, filtered_transfer_events[0].amount) | ||
|
||
self.assertEqual(htlc, filtered_transfer_events[1].source) | ||
self.assertEqual(person_b, filtered_transfer_events[1].destination) | ||
self.assertEqual(transferred_amount_gas, filtered_transfer_events[1].amount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when there's more than one event expected, you should use variables to let the test more readable
self.assertEqual(htlc, filtered_transfer_events[0].source) | |
self.assertEqual(person_a, filtered_transfer_events[0].destination) | |
self.assertEqual(transferred_amount_neo, filtered_transfer_events[0].amount) | |
self.assertEqual(htlc, filtered_transfer_events[1].source) | |
self.assertEqual(person_b, filtered_transfer_events[1].destination) | |
self.assertEqual(transferred_amount_gas, filtered_transfer_events[1].amount) | |
refund_A, refund_B = filtered_transfer_events | |
self.assertEqual(htlc, refund_A.source) | |
self.assertEqual(person_a, refund_A.destination) | |
self.assertEqual(transferred_amount_neo, refund_A.amount) | |
self.assertEqual(htlc, refund_B.source) | |
self.assertEqual(person_b, refund_B.destination) | |
self.assertEqual(transferred_amount_gas, refund_B.amount) |
return_type=bool, | ||
target_contract=constants.GAS_SCRIPT) | ||
|
||
await asyncio.sleep(self.REFUND_WAIT_TIME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems that all asyncio.sleep
calls in the test case use the same arguments, so you can move it to a helper method call.
async def wait_refund_time():
return await asyncio.slepp(self.REFUND_WAIT_TIME)
Refactored
example_tests/test_htlc.py
files to useBoaTestCase
in place ofBoaTest
for unit testing.