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

Refactor TakeBuyBTCOfferTest to replace sleep with loops #6733

Merged

Conversation

alyokaz
Copy link
Contributor

@alyokaz alyokaz commented Jun 14, 2023

Replace the use of Thread.sleep with while loops for asynchronous method calls

Copy link
Contributor

@alvasw alvasw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code wise everything is fine!

Please reformat your code with an IDE or add the needed white space, so the code style matches with the existing.

             var timeout = System.currentTimeMillis() + 3000;
-            while(bobClient.getOffersSortedByDate(USD, true).size() < 1){
+            while (bobClient.getOffersSortedByDate(USD, true).size() < 1) {
                 sleep(100);
-                if(System.currentTimeMillis() > timeout)
+                if (System.currentTimeMillis() > timeout)
                     fail(new TimeoutException("Timed out waiting for Offer to be added to OfferBook"));
-            };
-            
-            List<OfferInfo> alicesUsdOffers  = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);
+            }
+
+            List<OfferInfo> alicesUsdOffers = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);
             assertEquals(1, alicesUsdOffers.size());

And

             do {
                 alicesUsdOffers = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);
                 sleep(100);
-                if(System.currentTimeMillis() > timeout)
-                   fail(new TimeoutException("Timed out waiting for Offer to be removed from OfferBook"));
-            } while(alicesUsdOffers.size() > 0);
+                if (System.currentTimeMillis() > timeout)
+                    fail(new TimeoutException("Timed out waiting for Offer to be removed from OfferBook"));
+            } while (alicesUsdOffers.size() > 0);
 
             assertEquals(0, alicesUsdOffers.size());

Replace the use of Thread.sleep in the tests with loops
@alyokaz alyokaz force-pushed the refactor-takebuybtcoffertest branch from 6e13e3f to 03b205a Compare July 4, 2023 20:30
@alyokaz
Copy link
Contributor Author

alyokaz commented Jul 4, 2023

Amended formatting as requested.

@alyokaz alyokaz requested a review from alvasw July 4, 2023 20:43
Copy link
Contributor

@alvasw alvasw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Copy link
Contributor

@alejandrogarcia83 alejandrogarcia83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@alejandrogarcia83 alejandrogarcia83 merged commit 9d52cfe into bisq-network:master Jul 6, 2023
@alejandrogarcia83 alejandrogarcia83 added this to the v1.9.13 milestone Jul 6, 2023
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.

3 participants