feat(v2): crypto 孤儿到账发现——OrphanScanner 扫链核对 + orphan_payments 落表告警(对账兜底)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package store_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/wangjia/pay/internal/model"
|
||||
"github.com/wangjia/pay/internal/store"
|
||||
)
|
||||
|
||||
func TestOrphanStoreRecordIdempotent(t *testing.T) {
|
||||
os := store.NewOrphanStore(model.OpenTestDB(t))
|
||||
o := &model.OrphanPayment{Channel: "crypto", AccountID: "cry-1", TxID: "TX-1",
|
||||
AmountMinor: 12345, Currency: "USDT", DetectedAt: time.Now()}
|
||||
first, err := os.Record(o)
|
||||
if err != nil || !first {
|
||||
t.Fatalf("首次应记入, first=%v err=%v", first, err)
|
||||
}
|
||||
again, err := os.Record(&model.OrphanPayment{Channel: "crypto", AccountID: "cry-1", TxID: "TX-1",
|
||||
AmountMinor: 12345, Currency: "USDT", DetectedAt: time.Now()})
|
||||
if err != nil || again {
|
||||
t.Fatalf("同 tx_id 应幂等 no-op, again=%v err=%v", again, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user