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

CU-86drpncjw - Refactor example_tests/test_htlc.py to use BoaConstructor #1227

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

luc10921
Copy link
Contributor

Refactored example_tests/test_htlc.py files to use BoaTestCase in place of BoaTest for unit testing.

@luc10921 luc10921 requested a review from meevee98 March 21, 2024 19:28
@luc10921 luc10921 self-assigned this Mar 21, 2024
@melanke
Copy link
Contributor

melanke commented Mar 21, 2024

@coveralls
Copy link
Collaborator

coveralls commented Mar 21, 2024

Coverage Status

coverage: 91.949% (-0.005%) from 91.954%
when pulling 1b18091 on CU-86drpncjw
into 61ec86c on development.

Comment on lines 318 to 324
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)
Copy link
Contributor

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

Suggested change
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)
Copy link
Contributor

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)

@meevee98 meevee98 merged commit 7fd1f46 into development Mar 25, 2024
4 checks passed
@meevee98 meevee98 deleted the CU-86drpncjw branch March 25, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants