mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Refactor TakeBuyBTCOfferTest to replace sleep with loops
Replace the use of Thread.sleep in the tests with loops
This commit is contained in:
parent
c8c256f958
commit
03b205a597
@ -19,8 +19,13 @@ package bisq.apitest.method.trade;
|
|||||||
|
|
||||||
import bisq.core.payment.PaymentAccount;
|
import bisq.core.payment.PaymentAccount;
|
||||||
|
|
||||||
|
import bisq.proto.grpc.OfferInfo;
|
||||||
|
|
||||||
import io.grpc.StatusRuntimeException;
|
import io.grpc.StatusRuntimeException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
@ -71,19 +76,34 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
|
|||||||
|
|
||||||
// Wait for Alice's AddToOfferBook task.
|
// Wait for Alice's AddToOfferBook task.
|
||||||
// Wait times vary; my logs show >= 2-second delay.
|
// Wait times vary; my logs show >= 2-second delay.
|
||||||
sleep(3_000); // TODO loop instead of hard code a wait time
|
var timeout = System.currentTimeMillis() + 3000;
|
||||||
var alicesUsdOffers = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);
|
while (bobClient.getOffersSortedByDate(USD, true).size() < 1) {
|
||||||
|
sleep(100);
|
||||||
|
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);
|
||||||
assertEquals(1, alicesUsdOffers.size());
|
assertEquals(1, alicesUsdOffers.size());
|
||||||
|
|
||||||
PaymentAccount bobsUsdAccount = createDummyF2FAccount(bobClient, "US");
|
PaymentAccount bobsUsdAccount = createDummyF2FAccount(bobClient, "US");
|
||||||
var ignoredTakeOfferAmountParam = 0L;
|
var ignoredTakeOfferAmountParam = 0L;
|
||||||
|
|
||||||
var trade = takeAlicesOffer(offerId,
|
var trade = takeAlicesOffer(offerId,
|
||||||
bobsUsdAccount.getId(),
|
bobsUsdAccount.getId(),
|
||||||
TRADE_FEE_CURRENCY_CODE,
|
TRADE_FEE_CURRENCY_CODE,
|
||||||
ignoredTakeOfferAmountParam,
|
ignoredTakeOfferAmountParam,
|
||||||
false);
|
false);
|
||||||
sleep(2_500); // Allow available offer to be removed from offer book.
|
|
||||||
alicesUsdOffers = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);
|
// Allow available offer to be removed from offer book.
|
||||||
|
timeout = System.currentTimeMillis() + 2500;
|
||||||
|
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);
|
||||||
|
|
||||||
assertEquals(0, alicesUsdOffers.size());
|
assertEquals(0, alicesUsdOffers.size());
|
||||||
|
|
||||||
trade = bobClient.getTrade(tradeId);
|
trade = bobClient.getTrade(tradeId);
|
||||||
|
Loading…
Reference in New Issue
Block a user