添加比率
This commit is contained in:
1 parent
5be292c009
commit
c0868f9d8f
4 files changed
+62
-4
No files matched your search
@@ -34,7 +34,7 @@ public class HybridCryptoTest {
|
||||
// String apiUrl = requiredEnv("PAYMENT_API_URL");
|
||||
// String apiKey = requiredEnv("PAYMENT_API_KEY");
|
||||
// String apiSecret = requiredEnv("PAYMENT_API_SECRET");
|
||||
String apiUrl = "http://192.168.3.103:2020/api/v1/wallet/create";
|
||||
String apiUrl = "http://192.168.3.103:2020/api/v1/order/create-transaction";
|
||||
String apiKey = "ak_YhWdZaB7NsMy_lKkjQgn0WtB_FML1zyr";
|
||||
String apiSecret = "7u3mhxNmqJVIr1cUiwLP_THiCjeBQZfaEG8FABCTgu4";
|
||||
String publicKey = "-----BEGIN PUBLIC KEY-----\n" +
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/** 支付订单业务金额与 USDT 实付金额换算测试。 */
|
||||
public class PaymentOrderOpenApiServiceTest {
|
||||
@Test
|
||||
public void shouldDivideByExchangeRateAndRoundDown() {
|
||||
BigDecimal result = PaymentOrderOpenApiService.calculateActualAmount(
|
||||
new BigDecimal("100"), new BigDecimal("7.2"));
|
||||
Assert.assertEquals(new BigDecimal("13.88"), result);
|
||||
}
|
||||
|
||||
@Test(expected = CustomException.class)
|
||||
public void shouldRejectAmountBelowMinimumAfterConversion() {
|
||||
PaymentOrderOpenApiService.calculateActualAmount(
|
||||
new BigDecimal("0.01"), new BigDecimal("7.2"));
|
||||
}
|
||||
|
||||
@Test(expected = CustomException.class)
|
||||
public void shouldRejectInvalidExchangeRate() {
|
||||
PaymentOrderOpenApiService.calculateActualAmount(BigDecimal.ONE, BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user