|
|
|
@ -4,6 +4,11 @@ import com.jayway.jsonpath.JsonPath;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
import org.junit.jupiter.params.ParameterizedTest;
|
|
|
|
|
|
|
|
import org.junit.jupiter.params.provider.ValueSource;
|
|
|
|
|
|
|
|
import com.yau.digitalrmb.exchange.infrastructure.persistence.TeachingExchangeCoins;
|
|
|
|
|
|
|
|
import com.yau.digitalrmb.exchange.domain.repository.ExchangeOrderRepository;
|
|
|
|
|
|
|
|
import com.yau.digitalrmb.exchange.domain.model.ExchangeOrderId;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
|
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
@ -44,6 +49,8 @@ class ExchangeControllerTest {
|
|
|
|
@Autowired private InstitutionKeyService keyService;
|
|
|
|
@Autowired private InstitutionKeyService keyService;
|
|
|
|
@Autowired private WalletPrerequisiteProjectionService walletProjection;
|
|
|
|
@Autowired private WalletPrerequisiteProjectionService walletProjection;
|
|
|
|
@Autowired private ExchangeApplicationService exchangeService;
|
|
|
|
@Autowired private ExchangeApplicationService exchangeService;
|
|
|
|
|
|
|
|
@Autowired private TeachingExchangeCoins teachingCoins;
|
|
|
|
|
|
|
|
@Autowired private ExchangeOrderRepository exchangeOrders;
|
|
|
|
private InstitutionSm2KeyPair walletKey;
|
|
|
|
private InstitutionSm2KeyPair walletKey;
|
|
|
|
private InstitutionKeyPairResult bankKey;
|
|
|
|
private InstitutionKeyPairResult bankKey;
|
|
|
|
private InstitutionKeyPairResult centralKey;
|
|
|
|
private InstitutionKeyPairResult centralKey;
|
|
|
|
@ -187,18 +194,17 @@ class ExchangeControllerTest {
|
|
|
|
java.math.BigDecimal.class, accountId)).isEqualByComparingTo("200.00");
|
|
|
|
java.math.BigDecimal.class, accountId)).isEqualByComparingTo("200.00");
|
|
|
|
assertThat(jdbc.queryForObject("SELECT status FROM exchange_debit_record WHERE exchange_id=?",
|
|
|
|
assertThat(jdbc.queryForObject("SELECT status FROM exchange_debit_record WHERE exchange_id=?",
|
|
|
|
String.class, id)).isEqualTo("FROZEN");
|
|
|
|
String.class, id)).isEqualTo("FROZEN");
|
|
|
|
String expectedCbFinalSignature = jdbc.queryForObject(
|
|
|
|
|
|
|
|
"SELECT issuance_ownership_signature FROM commercial_bank_currency WHERE currency_id=?",
|
|
|
|
|
|
|
|
String.class, "DC_EXCHANGE_TEST_1");
|
|
|
|
|
|
|
|
String expectedCbCtrlSignature = jdbc.queryForObject(
|
|
|
|
|
|
|
|
"SELECT control_system_signature FROM draft_digital_currency WHERE coin_id=?",
|
|
|
|
|
|
|
|
String.class, "DC_EXCHANGE_TEST_1");
|
|
|
|
|
|
|
|
mockMvc.perform(post("/api/v1/exchanges/{id}/reserve-coins", id).with(user()))
|
|
|
|
mockMvc.perform(post("/api/v1/exchanges/{id}/reserve-coins", id).with(user()))
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("COINS_RESERVED"))
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("COINS_RESERVED"))
|
|
|
|
.andExpect(jsonPath("$.data.coinCount").value(2))
|
|
|
|
.andExpect(jsonPath("$.data.coinCount").value(2))
|
|
|
|
.andExpect(jsonPath("$.data.coins[0].completeCurrency").value("DC_TEST_COMPLETE_1"))
|
|
|
|
.andExpect(jsonPath("$.data.coins[0].currencyId").value(
|
|
|
|
.andExpect(jsonPath("$.data.coins[0].cbCtrlSignature").value(expectedCbCtrlSignature))
|
|
|
|
org.hamcrest.Matchers.startsWith("DC_EXCHANGE_CASE_" + id + "_")))
|
|
|
|
.andExpect(jsonPath("$.data.coins[0].cbFinalSignature").value(expectedCbFinalSignature));
|
|
|
|
.andExpect(jsonPath("$.data.coins[0].completeCurrency").value(
|
|
|
|
|
|
|
|
org.hamcrest.Matchers.startsWith("EXCHANGE_CASE_OWNERSHIP|EXCHANGE_CASE|")))
|
|
|
|
|
|
|
|
.andExpect(jsonPath("$.data.coins[0].cbCtrlSignature").value(
|
|
|
|
|
|
|
|
org.hamcrest.Matchers.not(org.hamcrest.Matchers.isEmptyOrNullString())))
|
|
|
|
|
|
|
|
.andExpect(jsonPath("$.data.coins[0].cbFinalSignature").value(
|
|
|
|
|
|
|
|
org.hamcrest.Matchers.not(org.hamcrest.Matchers.isEmptyOrNullString())));
|
|
|
|
mockMvc.perform(post("/api/v1/exchanges/{id}/confirm-ownership", id).with(user()))
|
|
|
|
mockMvc.perform(post("/api/v1/exchanges/{id}/confirm-ownership", id).with(user()))
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("SUCCESS"))
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("SUCCESS"))
|
|
|
|
.andExpect(jsonPath("$.data.walletBalanceAfter").value(200.00))
|
|
|
|
.andExpect(jsonPath("$.data.walletBalanceAfter").value(200.00))
|
|
|
|
@ -228,6 +234,90 @@ class ExchangeControllerTest {
|
|
|
|
.andExpect(status().isBadRequest());
|
|
|
|
.andExpect(status().isBadRequest());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest
|
|
|
|
|
|
|
|
@ValueSource(ints = {0, 2589})
|
|
|
|
|
|
|
|
void exchanges5000WithoutDependingOnModuleTwoStock(int moduleTwoStock) throws Exception {
|
|
|
|
|
|
|
|
if (moduleTwoStock == 0) {
|
|
|
|
|
|
|
|
jdbc.update("DELETE FROM central_bank_currency_ownership WHERE currency_id IN " +
|
|
|
|
|
|
|
|
"(SELECT currency_id FROM commercial_bank_currency WHERE issuance_request_id=?)", ISSUANCE_REQUEST_ID);
|
|
|
|
|
|
|
|
deleteIssuanceProofData();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
jdbc.update("UPDATE commercial_bank_currency SET denomination=1289 WHERE currency_id='DC_EXCHANGE_TEST_1'");
|
|
|
|
|
|
|
|
jdbc.update("UPDATE commercial_bank_currency SET denomination=1300 WHERE currency_id='DC_EXCHANGE_TEST_2'");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
jdbc.update("UPDATE issuance_bank_inventory SET current_balance=? WHERE bank_code='BKCHCNBJ00001'", moduleTwoStock);
|
|
|
|
|
|
|
|
String[] values = createHeldExchange("5000.00");
|
|
|
|
|
|
|
|
String exchangeId = values[1];
|
|
|
|
|
|
|
|
String accountId = values[2];
|
|
|
|
|
|
|
|
for (int repeat = 0; repeat < 2; repeat++) {
|
|
|
|
|
|
|
|
mockMvc.perform(post("/api/v1/exchanges/{id}/reserve-coins", exchangeId).with(user()))
|
|
|
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
|
|
|
.andExpect(jsonPath("$.data.coinCount").value(50));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int repeat = 0; repeat < 2; repeat++) {
|
|
|
|
|
|
|
|
mockMvc.perform(post("/api/v1/exchanges/{id}/confirm-ownership", exchangeId).with(user()))
|
|
|
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("SUCCESS"))
|
|
|
|
|
|
|
|
.andExpect(jsonPath("$.data.walletBalanceAfter").value(5000.00));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT balance FROM simulated_bank_account WHERE account_id=?",
|
|
|
|
|
|
|
|
java.math.BigDecimal.class, accountId)).isEqualByComparingTo("45000.00");
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT frozen_amount FROM simulated_bank_account WHERE account_id=?",
|
|
|
|
|
|
|
|
java.math.BigDecimal.class, accountId)).isEqualByComparingTo("0.00");
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM wallet_balance_ledger WHERE exchange_id=?",
|
|
|
|
|
|
|
|
Integer.class, exchangeId)).isEqualTo(1);
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM commercial_bank_currency WHERE issuance_request_id=?",
|
|
|
|
|
|
|
|
Integer.class, exchangeId)).isEqualTo(50);
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM central_bank_currency_ownership o " +
|
|
|
|
|
|
|
|
"JOIN commercial_bank_currency c ON c.currency_id=o.currency_id " +
|
|
|
|
|
|
|
|
"WHERE c.issuance_request_id=? AND o.owner_type='WALLET' " +
|
|
|
|
|
|
|
|
"AND o.owner_id='WALLET_EXCHANGE_TEST' AND o.status='AVAILABLE'",
|
|
|
|
|
|
|
|
Integer.class, exchangeId)).isEqualTo(50);
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT current_balance FROM issuance_bank_inventory WHERE bank_code='BKCHCNBJ00001'",
|
|
|
|
|
|
|
|
java.math.BigDecimal.class)).isEqualByComparingTo(String.valueOf(moduleTwoStock));
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT COALESCE(SUM(c.denomination),0) FROM commercial_bank_currency c " +
|
|
|
|
|
|
|
|
"JOIN central_bank_currency_ownership o ON o.currency_id=c.currency_id " +
|
|
|
|
|
|
|
|
"WHERE c.issuance_request_id=? AND o.owner_type='BANK' AND o.status='AVAILABLE'",
|
|
|
|
|
|
|
|
java.math.BigDecimal.class, ISSUANCE_REQUEST_ID)).isEqualByComparingTo(String.valueOf(moduleTwoStock));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void stillRejectsInsufficientBankBalanceAndWalletLimits() throws Exception {
|
|
|
|
|
|
|
|
String[] values = createHeldExchange("5000.00");
|
|
|
|
|
|
|
|
java.util.UUID exchangeId = java.util.UUID.fromString(values[1]);
|
|
|
|
|
|
|
|
ExchangeActor actor = new ExchangeActor(USER_ID, "test", 1999L, 2999L);
|
|
|
|
|
|
|
|
exchangeService.cancel(exchangeId, actor);
|
|
|
|
|
|
|
|
jdbc.update("UPDATE simulated_bank_account SET balance=4999 WHERE account_id=?", values[2]);
|
|
|
|
|
|
|
|
assertThatThrownBy(() -> exchangeService.bankProcess(exchangeId, actor))
|
|
|
|
|
|
|
|
.hasMessageContaining("银行卡可用余额不足");
|
|
|
|
|
|
|
|
jdbc.update("UPDATE simulated_bank_account SET balance=50000 WHERE account_id=?", values[2]);
|
|
|
|
|
|
|
|
jdbc.update("UPDATE wallet_contract SET single_payment_limit=4999 WHERE wallet_id='WALLET_EXCHANGE_TEST'");
|
|
|
|
|
|
|
|
assertThatThrownBy(() -> exchangeService.bankProcess(exchangeId, actor))
|
|
|
|
|
|
|
|
.hasMessageContaining("单笔支付限额");
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT frozen_amount FROM simulated_bank_account WHERE account_id=?",
|
|
|
|
|
|
|
|
java.math.BigDecimal.class, values[2])).isEqualByComparingTo("0.00");
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM commercial_bank_currency WHERE issuance_request_id=?",
|
|
|
|
|
|
|
|
Integer.class, values[1])).isZero();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void completesOrdersWhoseIssuedCoinsWereAlreadyReservedBeforeTheUpgrade() throws Exception {
|
|
|
|
|
|
|
|
String[] values = createHeldExchange();
|
|
|
|
|
|
|
|
String exchangeId = values[1];
|
|
|
|
|
|
|
|
jdbc.update("INSERT INTO exchange_coin_reservation " +
|
|
|
|
|
|
|
|
"(exchange_id,currency_id,denomination,source_status,status,reserved_at,reserved_by) " +
|
|
|
|
|
|
|
|
"SELECT ?,currency_id,denomination,status,'RESERVED',CURRENT_TIMESTAMP,'test' " +
|
|
|
|
|
|
|
|
"FROM commercial_bank_currency WHERE issuance_request_id=?", exchangeId, ISSUANCE_REQUEST_ID);
|
|
|
|
|
|
|
|
jdbc.update("UPDATE central_bank_currency_ownership SET status='EXCHANGE_LOCKED'," +
|
|
|
|
|
|
|
|
"lock_business_type='EXCHANGE',lock_business_id=? WHERE currency_id IN " +
|
|
|
|
|
|
|
|
"(SELECT currency_id FROM exchange_coin_reservation WHERE exchange_id=?)", exchangeId, exchangeId);
|
|
|
|
|
|
|
|
jdbc.update("UPDATE currency_exchange_order SET status='COINS_RESERVED',coin_count=2 WHERE id=?", exchangeId);
|
|
|
|
|
|
|
|
assertThat(exchangeService.confirmOwnership(java.util.UUID.fromString(exchangeId),
|
|
|
|
|
|
|
|
new ExchangeActor(USER_ID, "test", 1999L, 2999L)).getStatus()).isEqualTo("SUCCESS");
|
|
|
|
|
|
|
|
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM commercial_bank_currency WHERE issuance_request_id=?",
|
|
|
|
|
|
|
|
Integer.class, exchangeId)).isZero();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void doesNotCreateDemoWalletWhenWalletOpeningOutputIsMissing() throws Exception {
|
|
|
|
void doesNotCreateDemoWalletWhenWalletOpeningOutputIsMissing() throws Exception {
|
|
|
|
jdbc.update("DELETE FROM wallet_bank_binding");
|
|
|
|
jdbc.update("DELETE FROM wallet_bank_binding");
|
|
|
|
@ -251,6 +341,9 @@ class ExchangeControllerTest {
|
|
|
|
String exchangeId = values[1];
|
|
|
|
String exchangeId = values[1];
|
|
|
|
String accountId = values[2];
|
|
|
|
String accountId = values[2];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
teachingCoins.ensure(exchangeOrders.findById(new ExchangeOrderId(java.util.UUID.fromString(exchangeId)))
|
|
|
|
|
|
|
|
.orElseThrow(() -> new AssertionError("Missing exchange")),
|
|
|
|
|
|
|
|
new ExchangeActor(USER_ID, "test", 1999L, 2999L));
|
|
|
|
jdbc.update("UPDATE central_bank_currency_ownership SET status='PAYMENT_LOCKED'," +
|
|
|
|
jdbc.update("UPDATE central_bank_currency_ownership SET status='PAYMENT_LOCKED'," +
|
|
|
|
"lock_business_type='PAYMENT',lock_business_id='COMPETING_PAYMENT' " +
|
|
|
|
"lock_business_type='PAYMENT',lock_business_id='COMPETING_PAYMENT' " +
|
|
|
|
"WHERE owner_type='BANK' AND owner_id='BKCHCNBJ00001'");
|
|
|
|
"WHERE owner_type='BANK' AND owner_id='BKCHCNBJ00001'");
|
|
|
|
@ -442,8 +535,9 @@ class ExchangeControllerTest {
|
|
|
|
assertThat(actionStatus(attemptId, "03", "wallet-sign")).isEqualTo("COMPLETED");
|
|
|
|
assertThat(actionStatus(attemptId, "03", "wallet-sign")).isEqualTo("COMPLETED");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ParameterizedTest
|
|
|
|
void rejectsCoinWhenCentralBankControlSignatureIsTampered() throws Exception {
|
|
|
|
@ValueSource(strings = {"control", "ownership", "complete"})
|
|
|
|
|
|
|
|
void rejectsTamperedCaseCoinProof(String tamperedField) throws Exception {
|
|
|
|
String[] values = createHeldExchange();
|
|
|
|
String[] values = createHeldExchange();
|
|
|
|
String attemptId = values[0];
|
|
|
|
String attemptId = values[0];
|
|
|
|
executeAction(attemptId, "05", "receive-debit-voucher", "COMPLETED");
|
|
|
|
executeAction(attemptId, "05", "receive-debit-voucher", "COMPLETED");
|
|
|
|
@ -452,14 +546,23 @@ class ExchangeControllerTest {
|
|
|
|
"reply-transfer-request", "verify-bank-signature", "recalculate-transfer-digest",
|
|
|
|
"reply-transfer-request", "verify-bank-signature", "recalculate-transfer-digest",
|
|
|
|
"compare-transfer-digest"};
|
|
|
|
"compare-transfer-digest"};
|
|
|
|
for (String action : actions) executeAction(attemptId, "05", action, "COMPLETED");
|
|
|
|
for (String action : actions) executeAction(attemptId, "05", action, "COMPLETED");
|
|
|
|
jdbc.update("UPDATE draft_digital_currency SET control_system_signature=? WHERE coin_id=?",
|
|
|
|
String coinId = "DC_EXCHANGE_CASE_" + values[1] + "_1";
|
|
|
|
"TAMPERED_CONTROL_SIGNATURE", "DC_EXCHANGE_TEST_1");
|
|
|
|
String original = jdbc.queryForObject("SELECT issuance_ownership_original_text " +
|
|
|
|
|
|
|
|
"FROM commercial_bank_currency WHERE currency_id=?", String.class, coinId);
|
|
|
|
|
|
|
|
if ("control".equals(tamperedField)) {
|
|
|
|
|
|
|
|
jdbc.update("UPDATE commercial_bank_currency SET issuance_ownership_original_text=? WHERE currency_id=?",
|
|
|
|
|
|
|
|
original.substring(0, original.lastIndexOf('|') + 1) + "TAMPERED_CONTROL_SIGNATURE", coinId);
|
|
|
|
|
|
|
|
} else if ("ownership".equals(tamperedField)) {
|
|
|
|
|
|
|
|
jdbc.update("UPDATE commercial_bank_currency SET issuance_ownership_signature='TAMPERED' WHERE currency_id=?", coinId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
jdbc.update("UPDATE commercial_bank_currency SET complete_currency='TAMPERED' WHERE currency_id=?", coinId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mockMvc.perform(post("/api/v1/exchange/attempts/{id}/steps/05/actions/verify-coin-ownership", attemptId)
|
|
|
|
mockMvc.perform(post("/api/v1/exchange/attempts/{id}/steps/05/actions/verify-coin-ownership", attemptId)
|
|
|
|
.with(user()).contentType(MediaType.APPLICATION_JSON).content("{}"))
|
|
|
|
.with(user()).contentType(MediaType.APPLICATION_JSON).content("{}"))
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString(
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString(
|
|
|
|
"央行控制系统签名验证失败")));
|
|
|
|
"control".equals(tamperedField) ? "央行控制系统签名验证失败" : "兑换案例币串完整性或央行确权签名验证失败")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@ -510,7 +613,9 @@ class ExchangeControllerTest {
|
|
|
|
Integer.class, exchangeId)).isZero();
|
|
|
|
Integer.class, exchangeId)).isZero();
|
|
|
|
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM central_bank_currency_ownership " +
|
|
|
|
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM central_bank_currency_ownership " +
|
|
|
|
"WHERE owner_type='BANK' AND owner_id='BKCHCNBJ00001' AND status='AVAILABLE' " +
|
|
|
|
"WHERE owner_type='BANK' AND owner_id='BKCHCNBJ00001' AND status='AVAILABLE' " +
|
|
|
|
"AND lock_business_type IS NULL AND lock_business_id IS NULL", Integer.class))
|
|
|
|
"AND lock_business_type IS NULL AND lock_business_id IS NULL " +
|
|
|
|
|
|
|
|
"AND currency_id IN (SELECT currency_id FROM commercial_bank_currency WHERE issuance_request_id=?)",
|
|
|
|
|
|
|
|
Integer.class, exchangeId))
|
|
|
|
.isEqualTo(2);
|
|
|
|
.isEqualTo(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -544,12 +649,16 @@ class ExchangeControllerTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String[] createHeldExchange() throws Exception {
|
|
|
|
private String[] createHeldExchange() throws Exception {
|
|
|
|
|
|
|
|
return createHeldExchange("200.00");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String[] createHeldExchange(String amount) throws Exception {
|
|
|
|
String context = mockMvc.perform(get("/api/v1/exchanges/context").with(user()))
|
|
|
|
String context = mockMvc.perform(get("/api/v1/exchanges/context").with(user()))
|
|
|
|
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
|
|
|
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
|
|
|
String walletId = JsonPath.read(context, "$.data.walletId");
|
|
|
|
String walletId = JsonPath.read(context, "$.data.walletId");
|
|
|
|
String accountId = JsonPath.read(context, "$.data.bankAccountId");
|
|
|
|
String accountId = JsonPath.read(context, "$.data.bankAccountId");
|
|
|
|
String body = "{\"walletId\":\"" + walletId + "\",\"bankAccountId\":\"" + accountId
|
|
|
|
String body = "{\"walletId\":\"" + walletId + "\",\"bankAccountId\":\"" + accountId
|
|
|
|
+ "\",\"amount\":200.00}";
|
|
|
|
+ "\",\"amount\":" + amount + "}";
|
|
|
|
String created = mockMvc.perform(post("/api/v1/exchanges").with(user())
|
|
|
|
String created = mockMvc.perform(post("/api/v1/exchanges").with(user())
|
|
|
|
.contentType(MediaType.APPLICATION_JSON).content(body))
|
|
|
|
.contentType(MediaType.APPLICATION_JSON).content(body))
|
|
|
|
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
|
|
|
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
|
|
|
@ -644,6 +753,7 @@ class ExchangeControllerTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void deleteIssuanceProofData() {
|
|
|
|
private void deleteIssuanceProofData() {
|
|
|
|
|
|
|
|
jdbc.update("DELETE FROM commercial_bank_currency WHERE received_by_user_id=? AND source_batch_id=-1", USER_ID);
|
|
|
|
jdbc.update("DELETE FROM commercial_bank_currency WHERE issuance_request_id IN (?,?)",
|
|
|
|
jdbc.update("DELETE FROM commercial_bank_currency WHERE issuance_request_id IN (?,?)",
|
|
|
|
ISSUANCE_REQUEST_ID, "EXCHANGE_TEST_ISSUANCE");
|
|
|
|
ISSUANCE_REQUEST_ID, "EXCHANGE_TEST_ISSUANCE");
|
|
|
|
jdbc.update("DELETE FROM draft_digital_currency WHERE batch_id=?", PRODUCTION_BATCH_ID);
|
|
|
|
jdbc.update("DELETE FROM draft_digital_currency WHERE batch_id=?", PRODUCTION_BATCH_ID);
|
|
|
|
|