mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 18:10:48 +02:00
routing: add representation of blinded payments
This commit adds a representation of blinded payments, which include a blinded path and aggregate routing parameters to be used in payment to the path.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
20e7e801c0
commit
539a275faa
70
routing/blinding_test.go
Normal file
70
routing/blinding_test.go
Normal file
@ -0,0 +1,70 @@
|
||||
package routing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestBlindedPathValidation tests validation of blinded paths.
|
||||
func TestBlindedPathValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
payment *BlindedPayment
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "no path",
|
||||
payment: &BlindedPayment{},
|
||||
err: ErrNoBlindedPath,
|
||||
},
|
||||
{
|
||||
name: "insufficient hops",
|
||||
payment: &BlindedPayment{
|
||||
BlindedPath: &sphinx.BlindedPath{
|
||||
BlindedHops: []*sphinx.BlindedHopInfo{},
|
||||
},
|
||||
},
|
||||
err: ErrInsufficientBlindedHops,
|
||||
},
|
||||
{
|
||||
name: "maximum < minimum",
|
||||
payment: &BlindedPayment{
|
||||
BlindedPath: &sphinx.BlindedPath{
|
||||
BlindedHops: []*sphinx.BlindedHopInfo{
|
||||
{},
|
||||
},
|
||||
},
|
||||
HtlcMaximum: 10,
|
||||
HtlcMinimum: 20,
|
||||
},
|
||||
err: ErrHTLCRestrictions,
|
||||
},
|
||||
{
|
||||
name: "valid",
|
||||
payment: &BlindedPayment{
|
||||
BlindedPath: &sphinx.BlindedPath{
|
||||
BlindedHops: []*sphinx.BlindedHopInfo{
|
||||
{},
|
||||
},
|
||||
},
|
||||
HtlcMaximum: 15,
|
||||
HtlcMinimum: 5,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
err := testCase.payment.Validate()
|
||||
require.ErrorIs(t, err, testCase.err)
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user