feat(v2): crypto 孤儿到账发现——OrphanScanner 扫链核对 + orphan_payments 落表告警(对账兜底)

This commit is contained in:
wangjia
2026-07-10 17:52:10 +08:00
parent 04c3f4f31a
commit 727ed74899
12 changed files with 370 additions and 7 deletions
+24
View File
@@ -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)
}
}