Search in sources :

Example 1 with TakeOffer

use of io.bisq.api.model.TakeOffer in project bisq-api by mrosseel.

the class OfferResourceIT method takeOffer_amountMissing_returns422.

@InSequence(7)
@Test
public void takeOffer_amountMissing_returns422() throws Exception {
    final TakeOffer payload = new TakeOffer(bobPaymentAccount.id, null);
    takeOffer_template(createdOffer.id, payload, 422);
}
Also used : TakeOffer(io.bisq.api.model.TakeOffer) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 2 with TakeOffer

use of io.bisq.api.model.TakeOffer in project bisq-api by mrosseel.

the class OfferResourceIT method takeOffer_validPaymentMethodAndHasFunds_returnsTrade.

@InSequence(10)
@Test
public void takeOffer_validPaymentMethodAndHasFunds_returnsTrade() throws Exception {
    final int alicePort = getAlicePort();
    final int bobPort = getBobPort();
    final TakeOffer payload = new TakeOffer();
    payload.amount = "1";
    payload.paymentAccountId = bobPaymentAccount.id;
    final String offerId = given().port(bobPort).when().get("/api/v1/offers").then().extract().body().jsonPath().getString("offers[0].id");
    final String arbitratorAddress = given().port(bobPort).when().get("/api/v1/offers").then().extract().body().jsonPath().getString("offers[0].arbitratorNodeAddresses[0]");
    final String aliceAddress = ApiTestHelper.getP2PNetworkStatus(alicePort).address;
    // TODO some of following properties change over time and we have no control over that timing so probably there's not much point in returning everything here
    given().port(bobPort).body(payload).contentType(ContentType.JSON).when().post("/api/v1/offers/" + offerId + "/take").then().statusCode(200).and().body("id", isA(String.class)).and().body("offer.id", equalTo(offerId)).and().body("offer.acceptedCountryCodes", equalTo(alicePaymentAccount.acceptedCountries)).and().body("offer.amount", equalTo(1)).and().body("offer.arbitratorNodeAddresses", equalTo(ApiTestHelper.getAcceptedArbitrators(alicePort))).and().body("offer.baseCurrencyCode", equalTo("BTC")).and().body("offer.bankId", equalTo(alicePaymentAccount.bic)).and().body("offer.blockHeightAtOfferCreation", isA(Integer.class)).and().body("offer.buyerSecurityDeposit", isA(Integer.class)).and().body("offer.counterCurrencyCode", equalTo(alicePaymentAccount.selectedTradeCurrency)).and().body("offer.countryCode", equalTo(alicePaymentAccount.countryCode)).and().body("offer.currencyCode", equalTo(alicePaymentAccount.selectedTradeCurrency)).and().body("offer.date", isA(Long.class)).and().body("offer.direction", equalTo(OfferPayload.Direction.BUY.name())).and().body("offer.id", isA(String.class)).and().body("offer.isCurrencyForMakerFeeBtc", equalTo(true)).and().body("offer.isPrivateOffer", equalTo(false)).and().body("offer.lowerClosePrice", equalTo(0)).and().body("offer.makerFee", equalTo(5000)).and().body("offer.makerPaymentAccountId", equalTo(alicePaymentAccount.id)).and().body("offer.marketPriceMargin", equalTo(10f)).and().body("offer.maxTradeLimit", equalTo(25000000)).and().body("offer.maxTradePeriod", equalTo(518400000)).and().body("offer.minAmount", equalTo(1)).and().body("offer.offerFeePaymentTxId", isA(String.class)).and().body("offer.ownerNodeAddress", equalTo(ApiTestHelper.getP2PNetworkStatus(alicePort).address)).and().body("offer.paymentMethodId", equalTo(alicePaymentAccount.paymentMethod)).and().body("offer.price", equalTo(10)).and().body("offer.protocolVersion", equalTo(1)).and().body("offer.sellerSecurityDeposit", equalTo(300000)).and().body("offer.state", equalTo(Offer.State.AVAILABLE.name())).and().body("offer.txFee", equalTo(6000)).and().body("offer.upperClosePrice", equalTo(0)).and().body("offer.useAutoClose", equalTo(false)).and().body("offer.useMarketBasedPrice", equalTo(false)).and().body("offer.useReOpenAfterAutoClose", equalTo(false)).and().body("offer.versionNr", isA(String.class)).and().body("isCurrencyForTakerFeeBtc", equalTo(true)).and().body("txFee", isA(Integer.class)).and().body("takerFee", isA(Integer.class)).and().body("takeOfferDate", isA(Long.class)).and().body("takerFeeTxId", isEmptyOrNullString()).and().body("payoutTxId", isEmptyOrNullString()).and().body("tradeAmount", equalTo(1)).and().body("tradePrice", equalTo(10)).and().body("state", isOneOf(ApiTestHelper.toString(Trade.State.values()))).and().body("disputeState", equalTo(Trade.DisputeState.NO_DISPUTE.name())).and().body("tradePeriodState", equalTo(Trade.TradePeriodState.FIRST_HALF.name())).and().body("arbitratorBtcPubKey", isA(String.class)).and().body("contractHash", isEmptyOrNullString()).and().body("mediatorNodeAddress", equalTo(arbitratorAddress)).and().body("takerContractSignature", isEmptyOrNullString()).and().body("makerContractSignature", isEmptyOrNullString()).and().body("arbitratorNodeAddress", equalTo(arbitratorAddress)).and().body("tradingPeerNodeAddress", equalTo(aliceAddress)).and().body("takerPaymentAccountId", equalTo(bobPaymentAccount.id)).and().body("counterCurrencyTxId", isEmptyOrNullString());
}
Also used : TakeOffer(io.bisq.api.model.TakeOffer) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 3 with TakeOffer

use of io.bisq.api.model.TakeOffer in project bisq-api by mrosseel.

the class OfferResourceIT method takeOffer_noOverlappingArbitrator_returnsXXX.

@Ignore("Bug in tradeManager.onTakeOffer which resolves instead of reject in this scenario")
@InSequence(7)
@Test
public void takeOffer_noOverlappingArbitrator_returnsXXX() throws Exception {
    final int bobPort = getBobPort();
    ApiTestHelper.registerArbitrator(getAlicePort());
    final OfferDetail offer = ApiTestHelper.getOfferById(bobPort, createdOffer.id);
    final List<String> arbitrators = ApiTestHelper.getAcceptedArbitrators(bobPort);
    arbitrators.removeAll(offer.arbitratorNodeAddresses);
    Assert.assertThat(arbitrators.size(), greaterThan(0));
    ApiTestHelper.deselectAllArbitrators(bobPort);
    ApiTestHelper.selectArbitrator(bobPort, arbitrators.get(0));
    final TakeOffer payload = new TakeOffer(bobPaymentAccount.id, "1");
    takeOffer_template(createdOffer.id, payload, 0);
    throw new UnsupportedOperationException("Not implemented yet");
}
Also used : TakeOffer(io.bisq.api.model.TakeOffer) OfferDetail(io.bisq.api.model.OfferDetail) Ignore(org.junit.Ignore) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 4 with TakeOffer

use of io.bisq.api.model.TakeOffer in project bisq-api by mrosseel.

the class OfferResourceIT method takeOffer_validPayloadButNoFunds_returns427status.

@InSequence(7)
@Test
public void takeOffer_validPayloadButNoFunds_returns427status() throws Exception {
    final TakeOffer payload = new TakeOffer(bobPaymentAccount.id, "1");
    takeOffer_template(createdOffer.id, payload, 427);
}
Also used : TakeOffer(io.bisq.api.model.TakeOffer) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 5 with TakeOffer

use of io.bisq.api.model.TakeOffer in project bisq-api by mrosseel.

the class OfferResourceIT method takeOffer_incompatiblePaymentAccount_returns423.

@InSequence(7)
@Test
public void takeOffer_incompatiblePaymentAccount_returns423() throws Exception {
    final TakeOffer payload = new TakeOffer(bobIncompatiblePaymentAccountId, "1");
    takeOffer_template(createdOffer.id, payload, 423);
}
Also used : TakeOffer(io.bisq.api.model.TakeOffer) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Aggregations

TakeOffer (io.bisq.api.model.TakeOffer)9 InSequence (org.jboss.arquillian.junit.InSequence)9 Test (org.junit.Test)9 Ignore (org.junit.Ignore)2 OfferDetail (io.bisq.api.model.OfferDetail)1