mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Add payment msg precondition checks to v1 protocol tests
- verifyPaymentSentMsgIsFromBtcBuyerPrecondition - verifyPaymentReceivedMsgIsFromBtcSellerPrecondition - verifyPaymentSentMsgDepositTxConfirmedPrecondition - verifyPaymentReceivedMsgDepositTxConfirmedPrecondition - verifyPaymentReceivedMsgAfterPaymentSentMsgPrecondition
This commit is contained in:
parent
3ce68d6b0c
commit
7570671994
@ -42,6 +42,7 @@ import static protobuf.OfferDirection.BUY;
|
||||
import static protobuf.OpenOffer.State.AVAILABLE;
|
||||
|
||||
@Disabled
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Slf4j
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class TakeBuyBTCOfferTest extends AbstractTradeTest {
|
||||
@ -82,11 +83,9 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
|
||||
sleep(2_500); // Allow available offer to be removed from offer book.
|
||||
alicesUsdOffers = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);
|
||||
assertEquals(0, alicesUsdOffers.size());
|
||||
genBtcBlocksThenWait(1, 2_500);
|
||||
waitForDepositConfirmation(log, testInfo, bobClient, trade.getTradeId());
|
||||
|
||||
trade = bobClient.getTrade(tradeId);
|
||||
verifyTakerDepositConfirmed(trade);
|
||||
verifyTakerDepositNotConfirmed(trade);
|
||||
logTrade(log, testInfo, "Alice's Maker/Buyer View", aliceClient.getTrade(tradeId));
|
||||
logTrade(log, testInfo, "Bob's Taker/Seller View", bobClient.getTrade(tradeId));
|
||||
} catch (StatusRuntimeException e) {
|
||||
@ -96,13 +95,23 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testAlicesConfirmPaymentStarted(final TestInfo testInfo) {
|
||||
public void testPaymentMessagingPreconditions(final TestInfo testInfo) {
|
||||
try {
|
||||
var trade = aliceClient.getTrade(tradeId);
|
||||
waitForDepositConfirmation(log, testInfo, aliceClient, trade.getTradeId());
|
||||
aliceClient.confirmPaymentStarted(trade.getTradeId());
|
||||
sleep(6_000);
|
||||
waitForBuyerSeesPaymentInitiatedMessage(log, testInfo, aliceClient, tradeId);
|
||||
// Alice is maker / btc buyer, Bob is taker / btc seller.
|
||||
// Verify payment sent and rcvd msgs are sent by the right peers: buyer and seller.
|
||||
verifyPaymentSentMsgIsFromBtcBuyerPrecondition(log, bobClient);
|
||||
verifyPaymentReceivedMsgIsFromBtcSellerPrecondition(log, aliceClient);
|
||||
|
||||
// Verify fiat payment sent and rcvd msgs cannot be sent before trade deposit tx is confirmed.
|
||||
verifyPaymentSentMsgDepositTxConfirmedPrecondition(log, aliceClient);
|
||||
verifyPaymentReceivedMsgDepositTxConfirmedPrecondition(log, bobClient);
|
||||
|
||||
// Now generate the BTC block to confirm the taker deposit tx.
|
||||
genBtcBlocksThenWait(1, 2_500);
|
||||
waitForDepositConfirmation(log, testInfo, bobClient, tradeId);
|
||||
|
||||
// Verify the seller can only send a payment rcvd msg after the payment started msg.
|
||||
verifyPaymentReceivedMsgAfterPaymentSentMsgPrecondition(log, bobClient);
|
||||
} catch (StatusRuntimeException e) {
|
||||
fail(e);
|
||||
}
|
||||
@ -110,9 +119,23 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testAlicesConfirmPaymentStarted(final TestInfo testInfo) {
|
||||
try {
|
||||
var trade = aliceClient.getTrade(tradeId);
|
||||
waitForDepositConfirmation(log, testInfo, aliceClient, trade.getTradeId());
|
||||
aliceClient.confirmPaymentStarted(trade.getTradeId());
|
||||
sleep(6_000);
|
||||
waitUntilBuyerSeesPaymentStartedMessage(log, testInfo, aliceClient, tradeId);
|
||||
} catch (StatusRuntimeException e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
public void testBobsConfirmPaymentReceived(final TestInfo testInfo) {
|
||||
try {
|
||||
waitForSellerSeesPaymentInitiatedMessage(log, testInfo, bobClient, tradeId);
|
||||
waitUntilSellerSeesPaymentStartedMessage(log, testInfo, bobClient, tradeId);
|
||||
var trade = bobClient.getTrade(tradeId);
|
||||
bobClient.confirmPaymentReceived(trade.getTradeId());
|
||||
sleep(3_000);
|
||||
@ -131,7 +154,7 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
public void testCloseTrade(final TestInfo testInfo) {
|
||||
try {
|
||||
genBtcBlocksThenWait(1, 1_000);
|
||||
|
@ -47,6 +47,7 @@ import bisq.apitest.method.offer.AbstractOfferTest;
|
||||
import bisq.cli.table.builder.TableBuilder;
|
||||
|
||||
@Disabled
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Slf4j
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class TakeBuyXMROfferTest extends AbstractTradeTest {
|
||||
@ -89,11 +90,9 @@ public class TakeBuyXMROfferTest extends AbstractTradeTest {
|
||||
var trade = takeAlicesOffer(offerId, bobsXmrAcct.getId(), TRADE_FEE_CURRENCY_CODE);
|
||||
alicesXmrOffers = aliceClient.getMyOffersSortedByDate(XMR);
|
||||
assertEquals(0, alicesXmrOffers.size());
|
||||
genBtcBlocksThenWait(1, 2_500);
|
||||
waitForDepositConfirmation(log, testInfo, bobClient, trade.getTradeId());
|
||||
|
||||
trade = bobClient.getTrade(tradeId);
|
||||
verifyTakerDepositConfirmed(trade);
|
||||
verifyTakerDepositNotConfirmed(trade);
|
||||
logTrade(log, testInfo, "Alice's Maker/Buyer View", aliceClient.getTrade(tradeId));
|
||||
logTrade(log, testInfo, "Bob's Taker/Seller View", bobClient.getTrade(tradeId));
|
||||
} catch (StatusRuntimeException e) {
|
||||
@ -103,15 +102,39 @@ public class TakeBuyXMROfferTest extends AbstractTradeTest {
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testPaymentMessagingPreconditions(final TestInfo testInfo) {
|
||||
try {
|
||||
// Alice is maker / xmr buyer (btc seller), Bob is taker / xmr seller (btc buyer).
|
||||
// Verify payment sent and rcvd msgs are sent by the right peers: buyer and seller.
|
||||
verifyPaymentSentMsgIsFromBtcBuyerPrecondition(log, aliceClient);
|
||||
verifyPaymentReceivedMsgIsFromBtcSellerPrecondition(log, bobClient);
|
||||
|
||||
// Verify xmr payment sent and rcvd msgs cannot be sent before trade deposit tx is confirmed.
|
||||
verifyPaymentSentMsgDepositTxConfirmedPrecondition(log, bobClient);
|
||||
verifyPaymentReceivedMsgDepositTxConfirmedPrecondition(log, aliceClient);
|
||||
|
||||
// Now generate the BTC block to confirm the taker deposit tx.
|
||||
genBtcBlocksThenWait(1, 2_500);
|
||||
waitForDepositConfirmation(log, testInfo, bobClient, tradeId);
|
||||
|
||||
// Verify the seller can only send a payment rcvd msg after the payment started msg.
|
||||
verifyPaymentReceivedMsgAfterPaymentSentMsgPrecondition(log, aliceClient);
|
||||
} catch (StatusRuntimeException e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testBobsConfirmPaymentStarted(final TestInfo testInfo) {
|
||||
try {
|
||||
var trade = bobClient.getTrade(tradeId);
|
||||
|
||||
verifyTakerDepositConfirmed(trade);
|
||||
log.debug("Bob sends XMR payment to Alice for trade {}", trade.getTradeId());
|
||||
bobClient.confirmPaymentStarted(trade.getTradeId());
|
||||
log.debug("Bob sends XMR payment to Alice for trade {}", tradeId);
|
||||
bobClient.confirmPaymentStarted(tradeId);
|
||||
sleep(3500);
|
||||
waitForBuyerSeesPaymentInitiatedMessage(log, testInfo, bobClient, tradeId);
|
||||
waitUntilBuyerSeesPaymentStartedMessage(log, testInfo, bobClient, tradeId);
|
||||
|
||||
logTrade(log, testInfo, "Alice's Maker/Buyer View (Payment Sent)", aliceClient.getTrade(tradeId));
|
||||
logTrade(log, testInfo, "Bob's Taker/Seller View (Payment Sent)", bobClient.getTrade(tradeId));
|
||||
@ -121,18 +144,18 @@ public class TakeBuyXMROfferTest extends AbstractTradeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@Order(4)
|
||||
public void testAlicesConfirmPaymentReceived(final TestInfo testInfo) {
|
||||
try {
|
||||
waitForSellerSeesPaymentInitiatedMessage(log, testInfo, aliceClient, tradeId);
|
||||
waitUntilSellerSeesPaymentStartedMessage(log, testInfo, aliceClient, tradeId);
|
||||
|
||||
sleep(2_000);
|
||||
var trade = aliceClient.getTrade(tradeId);
|
||||
// If we were trading BSQ, Alice would verify payment has been sent to her
|
||||
// Bisq / BSQ wallet, but we can do no such checks for XMR payments.
|
||||
// All XMR transfers are done outside Bisq.
|
||||
log.debug("Alice verifies XMR payment was received from Bob, for trade {}", trade.getTradeId());
|
||||
aliceClient.confirmPaymentReceived(trade.getTradeId());
|
||||
log.debug("Alice verifies XMR payment was received from Bob, for trade {}", tradeId);
|
||||
aliceClient.confirmPaymentReceived(tradeId);
|
||||
sleep(3_000);
|
||||
|
||||
trade = aliceClient.getTrade(tradeId);
|
||||
@ -150,7 +173,7 @@ public class TakeBuyXMROfferTest extends AbstractTradeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
public void testCloseTrade(final TestInfo testInfo) {
|
||||
try {
|
||||
genBtcBlocksThenWait(1, 1_000);
|
||||
|
@ -43,6 +43,7 @@ import static protobuf.Offer.State.OFFER_FEE_PAID;
|
||||
import static protobuf.OfferDirection.SELL;
|
||||
|
||||
@Disabled
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Slf4j
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class TakeSellBTCOfferTest extends AbstractTradeTest {
|
||||
@ -86,10 +87,9 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
|
||||
sleep(2_500); // Allow available offer to be removed from offer book.
|
||||
var takeableUsdOffers = bobClient.getOffersSortedByDate(SELL.name(), USD);
|
||||
assertEquals(0, takeableUsdOffers.size());
|
||||
genBtcBlocksThenWait(1, 2_500);
|
||||
waitForDepositConfirmation(log, testInfo, bobClient, trade.getTradeId());
|
||||
|
||||
trade = bobClient.getTrade(tradeId);
|
||||
verifyTakerDepositConfirmed(trade);
|
||||
verifyTakerDepositNotConfirmed(trade);
|
||||
logTrade(log, testInfo, "Alice's Maker/Buyer View", aliceClient.getTrade(tradeId));
|
||||
logTrade(log, testInfo, "Bob's Taker/Seller View", bobClient.getTrade(tradeId));
|
||||
} catch (StatusRuntimeException e) {
|
||||
@ -99,13 +99,23 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testBobsConfirmPaymentStarted(final TestInfo testInfo) {
|
||||
public void testPaymentMessagingPreconditions(final TestInfo testInfo) {
|
||||
try {
|
||||
var trade = bobClient.getTrade(tradeId);
|
||||
verifyTakerDepositConfirmed(trade);
|
||||
bobClient.confirmPaymentStarted(tradeId);
|
||||
sleep(6_000);
|
||||
waitForBuyerSeesPaymentInitiatedMessage(log, testInfo, bobClient, tradeId);
|
||||
// Alice is maker / btc seller, Bob is taker / btc buyer.
|
||||
// Verify payment sent and rcvd msgs are sent by the right peers: buyer and seller.
|
||||
verifyPaymentSentMsgIsFromBtcBuyerPrecondition(log, aliceClient);
|
||||
verifyPaymentReceivedMsgIsFromBtcSellerPrecondition(log, bobClient);
|
||||
|
||||
// Verify fiat payment sent and rcvd msgs cannot be sent before trade deposit tx is confirmed.
|
||||
verifyPaymentSentMsgDepositTxConfirmedPrecondition(log, bobClient);
|
||||
verifyPaymentReceivedMsgDepositTxConfirmedPrecondition(log, aliceClient);
|
||||
|
||||
// Now generate the BTC block to confirm the taker deposit tx.
|
||||
genBtcBlocksThenWait(1, 2_500);
|
||||
waitForDepositConfirmation(log, testInfo, bobClient, tradeId);
|
||||
|
||||
// Verify the seller can only send a payment rcvd msg after the payment started msg.
|
||||
verifyPaymentReceivedMsgAfterPaymentSentMsgPrecondition(log, aliceClient);
|
||||
} catch (StatusRuntimeException e) {
|
||||
fail(e);
|
||||
}
|
||||
@ -113,9 +123,23 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testBobsConfirmPaymentStarted(final TestInfo testInfo) {
|
||||
try {
|
||||
var trade = bobClient.getTrade(tradeId);
|
||||
verifyTakerDepositConfirmed(trade);
|
||||
bobClient.confirmPaymentStarted(tradeId);
|
||||
sleep(6_000);
|
||||
waitUntilBuyerSeesPaymentStartedMessage(log, testInfo, bobClient, tradeId);
|
||||
} catch (StatusRuntimeException e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
public void testAlicesConfirmPaymentReceived(final TestInfo testInfo) {
|
||||
try {
|
||||
waitForSellerSeesPaymentInitiatedMessage(log, testInfo, aliceClient, tradeId);
|
||||
waitUntilSellerSeesPaymentStartedMessage(log, testInfo, aliceClient, tradeId);
|
||||
|
||||
var trade = aliceClient.getTrade(tradeId);
|
||||
aliceClient.confirmPaymentReceived(trade.getTradeId());
|
||||
@ -134,7 +158,7 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
public void testBobsBtcWithdrawalToExternalAddress(final TestInfo testInfo) {
|
||||
try {
|
||||
genBtcBlocksThenWait(1, 1_000);
|
||||
|
@ -60,7 +60,7 @@ public class TakeSellXMROfferTest extends AbstractTradeTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
AbstractOfferTest.setUp();
|
||||
AbstractOfferTest.setUp(false);
|
||||
createXmrPaymentAccounts();
|
||||
EXPECTED_PROTOCOL_STATUS.init();
|
||||
}
|
||||
@ -93,12 +93,9 @@ public class TakeSellXMROfferTest extends AbstractTradeTest {
|
||||
var trade = takeAlicesOffer(offerId, bobsXmrAcct.getId(), TRADE_FEE_CURRENCY_CODE);
|
||||
alicesXmrOffers = aliceClient.getMyOffersSortedByDate(XMR);
|
||||
assertEquals(0, alicesXmrOffers.size());
|
||||
genBtcBlocksThenWait(1, 2_500);
|
||||
|
||||
waitForDepositConfirmation(log, testInfo, bobClient, trade.getTradeId());
|
||||
|
||||
trade = bobClient.getTrade(tradeId);
|
||||
verifyTakerDepositConfirmed(trade);
|
||||
verifyTakerDepositNotConfirmed(trade);
|
||||
logTrade(log, testInfo, "Alice's Maker/Seller View", aliceClient.getTrade(tradeId));
|
||||
logTrade(log, testInfo, "Bob's Taker/Buyer View", bobClient.getTrade(tradeId));
|
||||
} catch (StatusRuntimeException e) {
|
||||
@ -108,6 +105,30 @@ public class TakeSellXMROfferTest extends AbstractTradeTest {
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testPaymentMessagingPreconditions(final TestInfo testInfo) {
|
||||
try {
|
||||
// Alice is maker / xmr seller (btc buyer), Bob is taker / xmr buyer (btc seller).
|
||||
// Verify payment sent and rcvd msgs are sent by the right peers: buyer and seller.
|
||||
verifyPaymentSentMsgIsFromBtcBuyerPrecondition(log, bobClient);
|
||||
verifyPaymentReceivedMsgIsFromBtcSellerPrecondition(log, aliceClient);
|
||||
|
||||
// Verify xmr payment sent and rcvd msgs cannot be sent before trade deposit tx is confirmed.
|
||||
verifyPaymentSentMsgDepositTxConfirmedPrecondition(log, aliceClient);
|
||||
verifyPaymentReceivedMsgDepositTxConfirmedPrecondition(log, bobClient);
|
||||
|
||||
// Now generate the BTC block to confirm the taker deposit tx.
|
||||
genBtcBlocksThenWait(1, 2_500);
|
||||
waitForDepositConfirmation(log, testInfo, bobClient, tradeId);
|
||||
|
||||
// Verify the seller can only send a payment rcvd msg after the payment started msg.
|
||||
verifyPaymentReceivedMsgAfterPaymentSentMsgPrecondition(log, bobClient);
|
||||
} catch (StatusRuntimeException e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testAlicesConfirmPaymentStarted(final TestInfo testInfo) {
|
||||
try {
|
||||
var trade = aliceClient.getTrade(tradeId);
|
||||
@ -116,7 +137,7 @@ public class TakeSellXMROfferTest extends AbstractTradeTest {
|
||||
aliceClient.confirmPaymentStarted(trade.getTradeId());
|
||||
sleep(3500);
|
||||
|
||||
waitForBuyerSeesPaymentInitiatedMessage(log, testInfo, aliceClient, tradeId);
|
||||
waitUntilBuyerSeesPaymentStartedMessage(log, testInfo, aliceClient, tradeId);
|
||||
logTrade(log, testInfo, "Alice's Maker/Seller View (Payment Sent)", aliceClient.getTrade(tradeId));
|
||||
logTrade(log, testInfo, "Bob's Taker/Buyer View (Payment Sent)", bobClient.getTrade(tradeId));
|
||||
} catch (StatusRuntimeException e) {
|
||||
@ -125,10 +146,10 @@ public class TakeSellXMROfferTest extends AbstractTradeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
@Order(4)
|
||||
public void testBobsConfirmPaymentReceived(final TestInfo testInfo) {
|
||||
try {
|
||||
waitForSellerSeesPaymentInitiatedMessage(log, testInfo, bobClient, tradeId);
|
||||
waitUntilSellerSeesPaymentStartedMessage(log, testInfo, bobClient, tradeId);
|
||||
|
||||
var trade = bobClient.getTrade(tradeId);
|
||||
sleep(2_000);
|
||||
@ -154,7 +175,7 @@ public class TakeSellXMROfferTest extends AbstractTradeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
@Order(5)
|
||||
public void testAlicesBtcWithdrawalToExternalAddress(final TestInfo testInfo) {
|
||||
try {
|
||||
genBtcBlocksThenWait(1, 1_000);
|
||||
|
Loading…
Reference in New Issue
Block a user