routing: fix and enhance logging

This commit is contained in:
yyforyongyu
2023-11-06 16:39:30 +08:00
committed by yyforyongyu
parent b63e5decad
commit 0928ba0149
4 changed files with 12 additions and 8 deletions

View File

@@ -424,7 +424,9 @@ func (p *PaymentControl) RegisterAttempt(paymentHash lntypes.Hash,
// Ensure we aren't sending more than the total payment amount.
sentAmt, _ := payment.SentAmt()
if sentAmt+amt > payment.Info.Value {
return ErrValueExceedsAmt
return fmt.Errorf("%w: attempted=%v, payment amount="+
"%v", ErrValueExceedsAmt, sentAmt+amt,
payment.Info.Value)
}
htlcsBucket, err := bucket.CreateBucketIfNotExists(

View File

@@ -734,10 +734,7 @@ func TestPaymentControlMultiShard(t *testing.T) {
b := *attempt
b.AttemptID = 3
_, err = pControl.RegisterAttempt(info.PaymentIdentifier, &b)
if err != ErrValueExceedsAmt {
t.Fatalf("expected ErrValueExceedsAmt, got: %v",
err)
}
require.ErrorIs(t, err, ErrValueExceedsAmt)
// Fail the second attempt.
a := attempts[1]