Apply patch from ghubstan

Remove currency params. Bsq swaps have statically defined currencies (BSQ/BTC).
This commit is contained in:
chimp1984 2021-10-31 19:05:05 +01:00
parent addfadeffd
commit 8ee8cba668
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
7 changed files with 38 additions and 12 deletions

View File

@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -37,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
import static protobuf.OfferDirection.BUY; import static protobuf.OfferDirection.BUY;
// @Disabled @Disabled
@Slf4j @Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class BsqSwapOfferTest extends AbstractOfferTest { public class BsqSwapOfferTest extends AbstractOfferTest {

View File

@ -29,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -47,7 +48,7 @@ import static protobuf.OfferDirection.BUY;
import bisq.apitest.method.offer.AbstractOfferTest; import bisq.apitest.method.offer.AbstractOfferTest;
// @Disabled @Disabled
@Slf4j @Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class BsqSwapTradeTest extends AbstractOfferTest { public class BsqSwapTradeTest extends AbstractOfferTest {

View File

@ -28,6 +28,7 @@ import org.junit.jupiter.api.TestMethodOrder;
import bisq.apitest.method.offer.AbstractOfferTest; import bisq.apitest.method.offer.AbstractOfferTest;
import bisq.apitest.method.offer.BsqSwapOfferTest;
import bisq.apitest.method.offer.CancelOfferTest; import bisq.apitest.method.offer.CancelOfferTest;
import bisq.apitest.method.offer.CreateBSQOffersTest; import bisq.apitest.method.offer.CreateBSQOffersTest;
import bisq.apitest.method.offer.CreateOfferUsingFixedPriceTest; import bisq.apitest.method.offer.CreateOfferUsingFixedPriceTest;
@ -90,6 +91,19 @@ public class OfferTest extends AbstractOfferTest {
@Test @Test
@Order(6) @Order(6)
public void testCreateBSQSwapOffers() {
BsqSwapOfferTest test = new BsqSwapOfferTest();
BsqSwapOfferTest.createBsqSwapBsqPaymentAccounts();
test.testAliceCreateBsqSwapBuyOffer1();
test.testAliceCreateBsqSwapBuyOffer2();
test.testAliceCreateBsqSwapBuyOffer3();
test.testAliceCreateBsqSwapBuyOffer4();
test.testGetMyBsqSwapOffers();
test.testGetAvailableBsqSwapOffers();
}
@Test
@Order(7)
public void testEditOffer() { public void testEditOffer() {
EditOfferTest test = new EditOfferTest(); EditOfferTest test = new EditOfferTest();
// Edit fiat offer tests // Edit fiat offer tests

View File

@ -29,6 +29,7 @@ import org.junit.jupiter.api.TestMethodOrder;
import bisq.apitest.method.trade.AbstractTradeTest; import bisq.apitest.method.trade.AbstractTradeTest;
import bisq.apitest.method.trade.BsqSwapTradeTest;
import bisq.apitest.method.trade.TakeBuyBSQOfferTest; import bisq.apitest.method.trade.TakeBuyBSQOfferTest;
import bisq.apitest.method.trade.TakeBuyBTCOfferTest; import bisq.apitest.method.trade.TakeBuyBTCOfferTest;
import bisq.apitest.method.trade.TakeBuyBTCOfferWithNationalBankAcctTest; import bisq.apitest.method.trade.TakeBuyBTCOfferWithNationalBankAcctTest;
@ -97,4 +98,13 @@ public class TradeTest extends AbstractTradeTest {
test.testBobsConfirmPaymentReceived(testInfo); test.testBobsConfirmPaymentReceived(testInfo);
test.testAlicesBtcWithdrawalToExternalAddress(testInfo); test.testAlicesBtcWithdrawalToExternalAddress(testInfo);
} }
@Test
@Order(6)
public void testBsqSwapTradeTest(final TestInfo testInfo) {
BsqSwapTradeTest test = new BsqSwapTradeTest();
test.createBsqSwapBsqPaymentAccounts();
test.testAliceCreateBsqSwapBuyOffer();
test.testBobTakesBsqSwapOffer();
}
} }

View File

@ -135,8 +135,8 @@ public class CoreApi {
return coreOffersService.getMyBsqSwapOffer(id); return coreOffersService.getMyBsqSwapOffer(id);
} }
public List<Offer> getBsqSwapOffers(String direction, String currencyCode) { public List<Offer> getBsqSwapOffers(String direction) {
return coreOffersService.getBsqSwapOffers(direction, currencyCode); return coreOffersService.getBsqSwapOffers(direction);
} }
public List<Offer> getOffers(String direction, String currencyCode) { public List<Offer> getOffers(String direction, String currencyCode) {
@ -147,8 +147,8 @@ public class CoreApi {
return coreOffersService.getMyOffers(direction, currencyCode); return coreOffersService.getMyOffers(direction, currencyCode);
} }
public List<Offer> getMyBsqSwapOffers(String direction, String currencyCode) { public List<Offer> getMyBsqSwapOffers(String direction) {
return coreOffersService.getMyBsqSwapOffers(direction, currencyCode); return coreOffersService.getMyBsqSwapOffers(direction);
} }
public OpenOffer getMyOpenBsqSwapOffer(String id) { public OpenOffer getMyOpenBsqSwapOffer(String id) {

View File

@ -155,10 +155,10 @@ class CoreOffersService {
} }
List<Offer> getBsqSwapOffers(String direction, String currencyCode) { List<Offer> getBsqSwapOffers(String direction) {
var offers = offerBookService.getOffers().stream() var offers = offerBookService.getOffers().stream()
.filter(o -> !o.isMyOffer(keyRing)) .filter(o -> !o.isMyOffer(keyRing))
.filter(o -> offerMatchesDirectionAndCurrency(o, direction, currencyCode)) .filter(o -> o.getDirection().name().equalsIgnoreCase(direction))
.filter(o -> o.isBsqSwapOffer()) .filter(o -> o.isBsqSwapOffer())
.sorted(priceComparator(direction)) .sorted(priceComparator(direction))
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -182,10 +182,10 @@ class CoreOffersService {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
List<Offer> getMyBsqSwapOffers(String direction, String currencyCode) { List<Offer> getMyBsqSwapOffers(String direction) {
var offers = offerBookService.getOffers().stream() var offers = offerBookService.getOffers().stream()
.filter(o -> o.isMyOffer(keyRing)) .filter(o -> o.isMyOffer(keyRing))
.filter(o -> offerMatchesDirectionAndCurrency(o, direction, currencyCode)) .filter(o -> o.getDirection().name().equalsIgnoreCase(direction))
.filter(Offer::isBsqSwapOffer) .filter(Offer::isBsqSwapOffer)
.sorted(priceComparator(direction)) .sorted(priceComparator(direction))
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@ -145,7 +145,7 @@ class GrpcOffersService extends OffersImplBase {
public void getBsqSwapOffers(GetOffersRequest req, public void getBsqSwapOffers(GetOffersRequest req,
StreamObserver<GetBsqSwapOffersReply> responseObserver) { StreamObserver<GetBsqSwapOffersReply> responseObserver) {
try { try {
List<BsqSwapOfferInfo> result = coreApi.getBsqSwapOffers(req.getDirection(), req.getCurrencyCode()) List<BsqSwapOfferInfo> result = coreApi.getBsqSwapOffers(req.getDirection())
.stream().map(BsqSwapOfferInfo::toBsqSwapOfferInfo) .stream().map(BsqSwapOfferInfo::toBsqSwapOfferInfo)
.collect(Collectors.toList()); .collect(Collectors.toList());
var reply = GetBsqSwapOffersReply.newBuilder() var reply = GetBsqSwapOffersReply.newBuilder()
@ -183,7 +183,7 @@ class GrpcOffersService extends OffersImplBase {
public void getMyBsqSwapOffers(GetMyOffersRequest req, public void getMyBsqSwapOffers(GetMyOffersRequest req,
StreamObserver<GetMyBsqSwapOffersReply> responseObserver) { StreamObserver<GetMyBsqSwapOffersReply> responseObserver) {
try { try {
List<BsqSwapOfferInfo> result = coreApi.getMyBsqSwapOffers(req.getDirection(), req.getCurrencyCode()) List<BsqSwapOfferInfo> result = coreApi.getMyBsqSwapOffers(req.getDirection())
.stream().map(BsqSwapOfferInfo::toBsqSwapOfferInfo) .stream().map(BsqSwapOfferInfo::toBsqSwapOfferInfo)
.collect(Collectors.toList()); .collect(Collectors.toList());
var reply = GetMyBsqSwapOffersReply.newBuilder() var reply = GetMyBsqSwapOffersReply.newBuilder()