优化支付订单成功逻辑

This commit is contained in:
lu7213 committed 2026-10-14 03:38:27 -04:00
1 parent cef85b81ef
commit d7bcbb4e1e
4 files changed
+134 -7

No files matched your search

@@ -0,0 +1,40 @@
package com.ruoyi.task;
import org.junit.Assert;
import org.junit.Test;
import java.util.Date;
/** 支付扫描链上交易时间窗口边界测试。 */
public class TronPaymentTaskTest {
private static final long CREATED_AT = 1_700_000_000_000L;
@Test
public void shouldAcceptTransactionInsidePaymentWindow() {
Assert.assertTrue(TronPaymentTask.isTransactionInPaymentWindow(
new Date(CREATED_AT), CREATED_AT + 60_000L));
}
@Test
public void shouldAllowFiveSecondsClockSkewBeforeCreation() {
Assert.assertTrue(TronPaymentTask.isTransactionInPaymentWindow(
new Date(CREATED_AT), CREATED_AT - 5_000L));
Assert.assertFalse(TronPaymentTask.isTransactionInPaymentWindow(
new Date(CREATED_AT), CREATED_AT - 5_001L));
}
@Test
public void shouldRejectTransactionAfterExpiration() {
Assert.assertTrue(TronPaymentTask.isTransactionInPaymentWindow(
new Date(CREATED_AT), CREATED_AT + 10L * 60L * 1000L));
Assert.assertFalse(TronPaymentTask.isTransactionInPaymentWindow(
new Date(CREATED_AT), CREATED_AT + 10L * 60L * 1000L + 1L));
}
@Test
public void shouldRejectMissingTime() {
Assert.assertFalse(TronPaymentTask.isTransactionInPaymentWindow(null, CREATED_AT));
Assert.assertFalse(TronPaymentTask.isTransactionInPaymentWindow(
new Date(CREATED_AT), 0L));
}
}