routing: rename mock structs to make them obsolete
This commit renames the mock structs by appending Old in their names. In doing so the old tests stay unchanged and new mock structs can be added in the following commit.
This commit is contained in:
parent
54ed6c271b
commit
289d97fbfb
@ -13,17 +13,17 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/routing/route"
|
"github.com/lightningnetwork/lnd/routing/route"
|
||||||
)
|
)
|
||||||
|
|
||||||
type mockPaymentAttemptDispatcher struct {
|
type mockPaymentAttemptDispatcherOld struct {
|
||||||
onPayment func(firstHop lnwire.ShortChannelID) ([32]byte, error)
|
onPayment func(firstHop lnwire.ShortChannelID) ([32]byte, error)
|
||||||
results map[uint64]*htlcswitch.PaymentResult
|
results map[uint64]*htlcswitch.PaymentResult
|
||||||
|
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ PaymentAttemptDispatcher = (*mockPaymentAttemptDispatcher)(nil)
|
var _ PaymentAttemptDispatcher = (*mockPaymentAttemptDispatcherOld)(nil)
|
||||||
|
|
||||||
func (m *mockPaymentAttemptDispatcher) SendHTLC(firstHop lnwire.ShortChannelID,
|
func (m *mockPaymentAttemptDispatcherOld) SendHTLC(
|
||||||
pid uint64,
|
firstHop lnwire.ShortChannelID, pid uint64,
|
||||||
_ *lnwire.UpdateAddHTLC) error {
|
_ *lnwire.UpdateAddHTLC) error {
|
||||||
|
|
||||||
if m.onPayment == nil {
|
if m.onPayment == nil {
|
||||||
@ -55,7 +55,7 @@ func (m *mockPaymentAttemptDispatcher) SendHTLC(firstHop lnwire.ShortChannelID,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockPaymentAttemptDispatcher) GetPaymentResult(paymentID uint64,
|
func (m *mockPaymentAttemptDispatcherOld) GetPaymentResult(paymentID uint64,
|
||||||
_ lntypes.Hash, _ htlcswitch.ErrorDecrypter) (
|
_ lntypes.Hash, _ htlcswitch.ErrorDecrypter) (
|
||||||
<-chan *htlcswitch.PaymentResult, error) {
|
<-chan *htlcswitch.PaymentResult, error) {
|
||||||
|
|
||||||
@ -73,48 +73,51 @@ func (m *mockPaymentAttemptDispatcher) GetPaymentResult(paymentID uint64,
|
|||||||
return c, nil
|
return c, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
func (m *mockPaymentAttemptDispatcher) CleanStore(map[uint64]struct{}) error {
|
func (m *mockPaymentAttemptDispatcherOld) CleanStore(
|
||||||
|
map[uint64]struct{}) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockPaymentAttemptDispatcher) setPaymentResult(
|
func (m *mockPaymentAttemptDispatcherOld) setPaymentResult(
|
||||||
f func(firstHop lnwire.ShortChannelID) ([32]byte, error)) {
|
f func(firstHop lnwire.ShortChannelID) ([32]byte, error)) {
|
||||||
|
|
||||||
m.onPayment = f
|
m.onPayment = f
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockPaymentSessionSource struct {
|
type mockPaymentSessionSourceOld struct {
|
||||||
routes []*route.Route
|
routes []*route.Route
|
||||||
routeRelease chan struct{}
|
routeRelease chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ PaymentSessionSource = (*mockPaymentSessionSource)(nil)
|
var _ PaymentSessionSource = (*mockPaymentSessionSourceOld)(nil)
|
||||||
|
|
||||||
func (m *mockPaymentSessionSource) NewPaymentSession(
|
func (m *mockPaymentSessionSourceOld) NewPaymentSession(
|
||||||
_ *LightningPayment) (PaymentSession, error) {
|
_ *LightningPayment) (PaymentSession, error) {
|
||||||
|
|
||||||
return &mockPaymentSession{
|
return &mockPaymentSessionOld{
|
||||||
routes: m.routes,
|
routes: m.routes,
|
||||||
release: m.routeRelease,
|
release: m.routeRelease,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockPaymentSessionSource) NewPaymentSessionForRoute(
|
func (m *mockPaymentSessionSourceOld) NewPaymentSessionForRoute(
|
||||||
preBuiltRoute *route.Route) PaymentSession {
|
preBuiltRoute *route.Route) PaymentSession {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockPaymentSessionSource) NewPaymentSessionEmpty() PaymentSession {
|
func (m *mockPaymentSessionSourceOld) NewPaymentSessionEmpty() PaymentSession {
|
||||||
return &mockPaymentSession{}
|
return &mockPaymentSessionOld{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockMissionControl struct {
|
type mockMissionControlOld struct {
|
||||||
MissionControl
|
MissionControl
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ MissionController = (*mockMissionControl)(nil)
|
var _ MissionController = (*mockMissionControlOld)(nil)
|
||||||
|
|
||||||
func (m *mockMissionControl) ReportPaymentFail(paymentID uint64, rt *route.Route,
|
func (m *mockMissionControlOld) ReportPaymentFail(
|
||||||
|
paymentID uint64, rt *route.Route,
|
||||||
failureSourceIdx *int, failure lnwire.FailureMessage) (
|
failureSourceIdx *int, failure lnwire.FailureMessage) (
|
||||||
*channeldb.FailureReason, error) {
|
*channeldb.FailureReason, error) {
|
||||||
|
|
||||||
@ -128,19 +131,19 @@ func (m *mockMissionControl) ReportPaymentFail(paymentID uint64, rt *route.Route
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockMissionControl) ReportPaymentSuccess(paymentID uint64,
|
func (m *mockMissionControlOld) ReportPaymentSuccess(paymentID uint64,
|
||||||
rt *route.Route) error {
|
rt *route.Route) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockMissionControl) GetProbability(fromNode, toNode route.Vertex,
|
func (m *mockMissionControlOld) GetProbability(fromNode, toNode route.Vertex,
|
||||||
amt lnwire.MilliSatoshi) float64 {
|
amt lnwire.MilliSatoshi) float64 {
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockPaymentSession struct {
|
type mockPaymentSessionOld struct {
|
||||||
routes []*route.Route
|
routes []*route.Route
|
||||||
|
|
||||||
// release is a channel that optionally blocks requesting a route
|
// release is a channel that optionally blocks requesting a route
|
||||||
@ -149,9 +152,9 @@ type mockPaymentSession struct {
|
|||||||
release chan struct{}
|
release chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ PaymentSession = (*mockPaymentSession)(nil)
|
var _ PaymentSession = (*mockPaymentSessionOld)(nil)
|
||||||
|
|
||||||
func (m *mockPaymentSession) RequestRoute(_, _ lnwire.MilliSatoshi,
|
func (m *mockPaymentSessionOld) RequestRoute(_, _ lnwire.MilliSatoshi,
|
||||||
_, height uint32) (*route.Route, error) {
|
_, height uint32) (*route.Route, error) {
|
||||||
|
|
||||||
if m.release != nil {
|
if m.release != nil {
|
||||||
@ -168,27 +171,27 @@ func (m *mockPaymentSession) RequestRoute(_, _ lnwire.MilliSatoshi,
|
|||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockPaymentSession) UpdateAdditionalEdge(_ *lnwire.ChannelUpdate,
|
func (m *mockPaymentSessionOld) UpdateAdditionalEdge(_ *lnwire.ChannelUpdate,
|
||||||
_ *btcec.PublicKey, _ *channeldb.ChannelEdgePolicy) bool {
|
_ *btcec.PublicKey, _ *channeldb.ChannelEdgePolicy) bool {
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockPaymentSession) GetAdditionalEdgePolicy(_ *btcec.PublicKey,
|
func (m *mockPaymentSessionOld) GetAdditionalEdgePolicy(_ *btcec.PublicKey,
|
||||||
_ uint64) *channeldb.ChannelEdgePolicy {
|
_ uint64) *channeldb.ChannelEdgePolicy {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockPayer struct {
|
type mockPayerOld struct {
|
||||||
sendResult chan error
|
sendResult chan error
|
||||||
paymentResult chan *htlcswitch.PaymentResult
|
paymentResult chan *htlcswitch.PaymentResult
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ PaymentAttemptDispatcher = (*mockPayer)(nil)
|
var _ PaymentAttemptDispatcher = (*mockPayerOld)(nil)
|
||||||
|
|
||||||
func (m *mockPayer) SendHTLC(_ lnwire.ShortChannelID,
|
func (m *mockPayerOld) SendHTLC(_ lnwire.ShortChannelID,
|
||||||
paymentID uint64,
|
paymentID uint64,
|
||||||
_ *lnwire.UpdateAddHTLC) error {
|
_ *lnwire.UpdateAddHTLC) error {
|
||||||
|
|
||||||
@ -201,7 +204,7 @@ func (m *mockPayer) SendHTLC(_ lnwire.ShortChannelID,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockPayer) GetPaymentResult(paymentID uint64, _ lntypes.Hash,
|
func (m *mockPayerOld) GetPaymentResult(paymentID uint64, _ lntypes.Hash,
|
||||||
_ htlcswitch.ErrorDecrypter) (<-chan *htlcswitch.PaymentResult, error) {
|
_ htlcswitch.ErrorDecrypter) (<-chan *htlcswitch.PaymentResult, error) {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
@ -220,7 +223,7 @@ func (m *mockPayer) GetPaymentResult(paymentID uint64, _ lntypes.Hash,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockPayer) CleanStore(pids map[uint64]struct{}) error {
|
func (m *mockPayerOld) CleanStore(pids map[uint64]struct{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +252,7 @@ type testPayment struct {
|
|||||||
attempts []channeldb.HTLCAttempt
|
attempts []channeldb.HTLCAttempt
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockControlTower struct {
|
type mockControlTowerOld struct {
|
||||||
payments map[lntypes.Hash]*testPayment
|
payments map[lntypes.Hash]*testPayment
|
||||||
successful map[lntypes.Hash]struct{}
|
successful map[lntypes.Hash]struct{}
|
||||||
failed map[lntypes.Hash]channeldb.FailureReason
|
failed map[lntypes.Hash]channeldb.FailureReason
|
||||||
@ -264,17 +267,17 @@ type mockControlTower struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ControlTower = (*mockControlTower)(nil)
|
var _ ControlTower = (*mockControlTowerOld)(nil)
|
||||||
|
|
||||||
func makeMockControlTower() *mockControlTower {
|
func makeMockControlTower() *mockControlTowerOld {
|
||||||
return &mockControlTower{
|
return &mockControlTowerOld{
|
||||||
payments: make(map[lntypes.Hash]*testPayment),
|
payments: make(map[lntypes.Hash]*testPayment),
|
||||||
successful: make(map[lntypes.Hash]struct{}),
|
successful: make(map[lntypes.Hash]struct{}),
|
||||||
failed: make(map[lntypes.Hash]channeldb.FailureReason),
|
failed: make(map[lntypes.Hash]channeldb.FailureReason),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) InitPayment(phash lntypes.Hash,
|
func (m *mockControlTowerOld) InitPayment(phash lntypes.Hash,
|
||||||
c *channeldb.PaymentCreationInfo) error {
|
c *channeldb.PaymentCreationInfo) error {
|
||||||
|
|
||||||
if m.init != nil {
|
if m.init != nil {
|
||||||
@ -305,7 +308,7 @@ func (m *mockControlTower) InitPayment(phash lntypes.Hash,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) RegisterAttempt(phash lntypes.Hash,
|
func (m *mockControlTowerOld) RegisterAttempt(phash lntypes.Hash,
|
||||||
a *channeldb.HTLCAttemptInfo) error {
|
a *channeldb.HTLCAttemptInfo) error {
|
||||||
|
|
||||||
if m.registerAttempt != nil {
|
if m.registerAttempt != nil {
|
||||||
@ -359,7 +362,7 @@ func (m *mockControlTower) RegisterAttempt(phash lntypes.Hash,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) SettleAttempt(phash lntypes.Hash,
|
func (m *mockControlTowerOld) SettleAttempt(phash lntypes.Hash,
|
||||||
pid uint64, settleInfo *channeldb.HTLCSettleInfo) (
|
pid uint64, settleInfo *channeldb.HTLCSettleInfo) (
|
||||||
*channeldb.HTLCAttempt, error) {
|
*channeldb.HTLCAttempt, error) {
|
||||||
|
|
||||||
@ -401,7 +404,7 @@ func (m *mockControlTower) SettleAttempt(phash lntypes.Hash,
|
|||||||
return nil, fmt.Errorf("pid not found")
|
return nil, fmt.Errorf("pid not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) FailAttempt(phash lntypes.Hash, pid uint64,
|
func (m *mockControlTowerOld) FailAttempt(phash lntypes.Hash, pid uint64,
|
||||||
failInfo *channeldb.HTLCFailInfo) (*channeldb.HTLCAttempt, error) {
|
failInfo *channeldb.HTLCFailInfo) (*channeldb.HTLCAttempt, error) {
|
||||||
|
|
||||||
if m.failAttempt != nil {
|
if m.failAttempt != nil {
|
||||||
@ -439,7 +442,7 @@ func (m *mockControlTower) FailAttempt(phash lntypes.Hash, pid uint64,
|
|||||||
return nil, fmt.Errorf("pid not found")
|
return nil, fmt.Errorf("pid not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) Fail(phash lntypes.Hash,
|
func (m *mockControlTowerOld) Fail(phash lntypes.Hash,
|
||||||
reason channeldb.FailureReason) error {
|
reason channeldb.FailureReason) error {
|
||||||
|
|
||||||
m.Lock()
|
m.Lock()
|
||||||
@ -459,7 +462,7 @@ func (m *mockControlTower) Fail(phash lntypes.Hash,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) FetchPayment(phash lntypes.Hash) (
|
func (m *mockControlTowerOld) FetchPayment(phash lntypes.Hash) (
|
||||||
*channeldb.MPPayment, error) {
|
*channeldb.MPPayment, error) {
|
||||||
|
|
||||||
m.Lock()
|
m.Lock()
|
||||||
@ -468,7 +471,7 @@ func (m *mockControlTower) FetchPayment(phash lntypes.Hash) (
|
|||||||
return m.fetchPayment(phash)
|
return m.fetchPayment(phash)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) fetchPayment(phash lntypes.Hash) (
|
func (m *mockControlTowerOld) fetchPayment(phash lntypes.Hash) (
|
||||||
*channeldb.MPPayment, error) {
|
*channeldb.MPPayment, error) {
|
||||||
|
|
||||||
p, ok := m.payments[phash]
|
p, ok := m.payments[phash]
|
||||||
@ -490,7 +493,7 @@ func (m *mockControlTower) fetchPayment(phash lntypes.Hash) (
|
|||||||
return mp, nil
|
return mp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) FetchInFlightPayments() (
|
func (m *mockControlTowerOld) FetchInFlightPayments() (
|
||||||
[]*channeldb.MPPayment, error) {
|
[]*channeldb.MPPayment, error) {
|
||||||
|
|
||||||
if m.fetchInFlight != nil {
|
if m.fetchInFlight != nil {
|
||||||
@ -521,7 +524,7 @@ func (m *mockControlTower) FetchInFlightPayments() (
|
|||||||
return fl, nil
|
return fl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockControlTower) SubscribePayment(paymentHash lntypes.Hash) (
|
func (m *mockControlTowerOld) SubscribePayment(paymentHash lntypes.Hash) (
|
||||||
*ControlTowerSubscriber, error) {
|
*ControlTowerSubscriber, error) {
|
||||||
|
|
||||||
return nil, errors.New("not implemented")
|
return nil, errors.New("not implemented")
|
||||||
|
@ -739,7 +739,7 @@ func testPaymentLifecycle(t *testing.T, test paymentLifecycleTestCase,
|
|||||||
sendResult := make(chan error)
|
sendResult := make(chan error)
|
||||||
paymentResult := make(chan *htlcswitch.PaymentResult)
|
paymentResult := make(chan *htlcswitch.PaymentResult)
|
||||||
|
|
||||||
payer := &mockPayer{
|
payer := &mockPayerOld{
|
||||||
sendResult: sendResult,
|
sendResult: sendResult,
|
||||||
paymentResult: paymentResult,
|
paymentResult: paymentResult,
|
||||||
}
|
}
|
||||||
@ -749,8 +749,8 @@ func testPaymentLifecycle(t *testing.T, test paymentLifecycleTestCase,
|
|||||||
Chain: chain,
|
Chain: chain,
|
||||||
ChainView: chainView,
|
ChainView: chainView,
|
||||||
Control: control,
|
Control: control,
|
||||||
SessionSource: &mockPaymentSessionSource{},
|
SessionSource: &mockPaymentSessionSourceOld{},
|
||||||
MissionControl: &mockMissionControl{},
|
MissionControl: &mockMissionControlOld{},
|
||||||
Payer: payer,
|
Payer: payer,
|
||||||
ChannelPruneExpiry: time.Hour * 24,
|
ChannelPruneExpiry: time.Hour * 24,
|
||||||
GraphPruneInterval: time.Hour * 2,
|
GraphPruneInterval: time.Hour * 2,
|
||||||
@ -822,12 +822,12 @@ func testPaymentLifecycle(t *testing.T, test paymentLifecycleTestCase,
|
|||||||
// Setup our payment session source to block on release of
|
// Setup our payment session source to block on release of
|
||||||
// routes.
|
// routes.
|
||||||
routeChan := make(chan struct{})
|
routeChan := make(chan struct{})
|
||||||
router.cfg.SessionSource = &mockPaymentSessionSource{
|
router.cfg.SessionSource = &mockPaymentSessionSourceOld{
|
||||||
routes: test.routes,
|
routes: test.routes,
|
||||||
routeRelease: routeChan,
|
routeRelease: routeChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
router.cfg.MissionControl = &mockMissionControl{}
|
router.cfg.MissionControl = &mockMissionControlOld{}
|
||||||
|
|
||||||
// Send the payment. Since this is new payment hash, the
|
// Send the payment. Since this is new payment hash, the
|
||||||
// information should be registered with the ControlTower.
|
// information should be registered with the ControlTower.
|
||||||
|
@ -72,7 +72,7 @@ func (c *testCtx) RestartRouter(t *testing.T) {
|
|||||||
Graph: c.graph,
|
Graph: c.graph,
|
||||||
Chain: c.chain,
|
Chain: c.chain,
|
||||||
ChainView: c.chainView,
|
ChainView: c.chainView,
|
||||||
Payer: &mockPaymentAttemptDispatcher{},
|
Payer: &mockPaymentAttemptDispatcherOld{},
|
||||||
Control: makeMockControlTower(),
|
Control: makeMockControlTower(),
|
||||||
ChannelPruneExpiry: time.Hour * 24,
|
ChannelPruneExpiry: time.Hour * 24,
|
||||||
GraphPruneInterval: time.Hour * 2,
|
GraphPruneInterval: time.Hour * 2,
|
||||||
@ -139,7 +139,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
|
|||||||
Graph: graphInstance.graph,
|
Graph: graphInstance.graph,
|
||||||
Chain: chain,
|
Chain: chain,
|
||||||
ChainView: chainView,
|
ChainView: chainView,
|
||||||
Payer: &mockPaymentAttemptDispatcher{},
|
Payer: &mockPaymentAttemptDispatcherOld{},
|
||||||
Control: makeMockControlTower(),
|
Control: makeMockControlTower(),
|
||||||
MissionControl: mc,
|
MissionControl: mc,
|
||||||
SessionSource: sessionSource,
|
SessionSource: sessionSource,
|
||||||
@ -324,7 +324,7 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
|
|||||||
// router's configuration to ignore the path that has son goku as the
|
// router's configuration to ignore the path that has son goku as the
|
||||||
// first hop. This should force the router to instead take the
|
// first hop. This should force the router to instead take the
|
||||||
// the more costly path (through pham nuwen).
|
// the more costly path (through pham nuwen).
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop == roasbeefSongoku {
|
if firstHop == roasbeefSongoku {
|
||||||
@ -442,7 +442,7 @@ func TestChannelUpdateValidation(t *testing.T) {
|
|||||||
// We'll modify the SendToSwitch method so that it simulates a failed
|
// We'll modify the SendToSwitch method so that it simulates a failed
|
||||||
// payment with an error originating from the first hop of the route.
|
// payment with an error originating from the first hop of the route.
|
||||||
// The unsigned channel update is attached to the failure message.
|
// The unsigned channel update is attached to the failure message.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
return [32]byte{}, htlcswitch.NewForwardingError(
|
return [32]byte{}, htlcswitch.NewForwardingError(
|
||||||
&lnwire.FailFeeInsufficient{
|
&lnwire.FailFeeInsufficient{
|
||||||
@ -553,7 +553,7 @@ func TestSendPaymentErrorRepeatedFeeInsufficient(t *testing.T) {
|
|||||||
// We'll now modify the SendToSwitch method to return an error for the
|
// We'll now modify the SendToSwitch method to return an error for the
|
||||||
// outgoing channel to Son goku. This will be a fee related error, so
|
// outgoing channel to Son goku. This will be a fee related error, so
|
||||||
// it should only cause the edge to be pruned after the second attempt.
|
// it should only cause the edge to be pruned after the second attempt.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
roasbeefSongoku := lnwire.NewShortChanIDFromInt(
|
roasbeefSongoku := lnwire.NewShortChanIDFromInt(
|
||||||
@ -668,7 +668,7 @@ func TestSendPaymentErrorFeeInsufficientPrivateEdge(t *testing.T) {
|
|||||||
// outgoing channel to songoku.
|
// outgoing channel to songoku.
|
||||||
errorReturned := false
|
errorReturned := false
|
||||||
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop != roasbeefSongoku || errorReturned {
|
if firstHop != roasbeefSongoku || errorReturned {
|
||||||
@ -800,7 +800,7 @@ func TestSendPaymentPrivateEdgeUpdateFeeExceedsLimit(t *testing.T) {
|
|||||||
// outgoing channel to songoku.
|
// outgoing channel to songoku.
|
||||||
errorReturned := false
|
errorReturned := false
|
||||||
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop != roasbeefSongoku || errorReturned {
|
if firstHop != roasbeefSongoku || errorReturned {
|
||||||
@ -909,7 +909,7 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
|
|||||||
// outgoing channel to son goku. Since this is a time lock related
|
// outgoing channel to son goku. Since this is a time lock related
|
||||||
// error, we should fail the payment flow all together, as Goku is the
|
// error, we should fail the payment flow all together, as Goku is the
|
||||||
// only channel to Sophon.
|
// only channel to Sophon.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop == roasbeefSongoku {
|
if firstHop == roasbeefSongoku {
|
||||||
@ -957,7 +957,7 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
|
|||||||
// We'll now modify the error return an IncorrectCltvExpiry error
|
// We'll now modify the error return an IncorrectCltvExpiry error
|
||||||
// instead, this should result in the same behavior of roasbeef routing
|
// instead, this should result in the same behavior of roasbeef routing
|
||||||
// around the faulty Son Goku node.
|
// around the faulty Son Goku node.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop == roasbeefSongoku {
|
if firstHop == roasbeefSongoku {
|
||||||
@ -1017,7 +1017,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
// First, we'll modify the SendToSwitch method to return an error
|
// First, we'll modify the SendToSwitch method to return an error
|
||||||
// indicating that the channel from roasbeef to son goku is not operable
|
// indicating that the channel from roasbeef to son goku is not operable
|
||||||
// with an UnknownNextPeer.
|
// with an UnknownNextPeer.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop == roasbeefSongoku {
|
if firstHop == roasbeefSongoku {
|
||||||
@ -1073,7 +1073,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
|
|
||||||
// Next, we'll modify the SendToSwitch method to indicate that the
|
// Next, we'll modify the SendToSwitch method to indicate that the
|
||||||
// connection between songoku and isn't up.
|
// connection between songoku and isn't up.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop == roasbeefSongoku {
|
if firstHop == roasbeefSongoku {
|
||||||
@ -1107,7 +1107,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
|||||||
// Finally, we'll modify the SendToSwitch function to indicate that the
|
// Finally, we'll modify the SendToSwitch function to indicate that the
|
||||||
// roasbeef -> luoji channel has insufficient capacity. This should
|
// roasbeef -> luoji channel has insufficient capacity. This should
|
||||||
// again cause us to instead go via the satoshi route.
|
// again cause us to instead go via the satoshi route.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop == roasbeefSongoku {
|
if firstHop == roasbeefSongoku {
|
||||||
@ -1752,7 +1752,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
|
|||||||
Graph: ctx.graph,
|
Graph: ctx.graph,
|
||||||
Chain: ctx.chain,
|
Chain: ctx.chain,
|
||||||
ChainView: ctx.chainView,
|
ChainView: ctx.chainView,
|
||||||
Payer: &mockPaymentAttemptDispatcher{},
|
Payer: &mockPaymentAttemptDispatcherOld{},
|
||||||
Control: makeMockControlTower(),
|
Control: makeMockControlTower(),
|
||||||
ChannelPruneExpiry: time.Hour * 24,
|
ChannelPruneExpiry: time.Hour * 24,
|
||||||
GraphPruneInterval: time.Hour * 2,
|
GraphPruneInterval: time.Hour * 2,
|
||||||
@ -2764,7 +2764,7 @@ func TestUnknownErrorSource(t *testing.T) {
|
|||||||
// We'll modify the SendToSwitch method so that it simulates hop b as a
|
// We'll modify the SendToSwitch method so that it simulates hop b as a
|
||||||
// node that returns an unparsable failure if approached via the a->b
|
// node that returns an unparsable failure if approached via the a->b
|
||||||
// channel.
|
// channel.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
// If channel a->b is used, return an error without
|
// If channel a->b is used, return an error without
|
||||||
@ -2789,7 +2789,7 @@ func TestUnknownErrorSource(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Next we modify payment result to return an unknown failure.
|
// Next we modify payment result to return an unknown failure.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
// If channel a->b is used, simulate that the failure
|
// If channel a->b is used, simulate that the failure
|
||||||
@ -2891,7 +2891,7 @@ func TestSendToRouteStructuredError(t *testing.T) {
|
|||||||
// Set up an init channel for the control tower, such that we can make
|
// Set up an init channel for the control tower, such that we can make
|
||||||
// sure the payment is initiated correctly.
|
// sure the payment is initiated correctly.
|
||||||
init := make(chan initArgs, 1)
|
init := make(chan initArgs, 1)
|
||||||
ctx.router.cfg.Control.(*mockControlTower).init = init
|
ctx.router.cfg.Control.(*mockControlTowerOld).init = init
|
||||||
|
|
||||||
// Setup a route from source a to destination c. The route will be used
|
// Setup a route from source a to destination c. The route will be used
|
||||||
// in a call to SendToRoute. SendToRoute also applies channel updates,
|
// in a call to SendToRoute. SendToRoute also applies channel updates,
|
||||||
@ -2922,7 +2922,7 @@ func TestSendToRouteStructuredError(t *testing.T) {
|
|||||||
// We'll modify the SendToSwitch method so that it simulates a failed
|
// We'll modify the SendToSwitch method so that it simulates a failed
|
||||||
// payment with an error originating from the first hop of the route.
|
// payment with an error originating from the first hop of the route.
|
||||||
// The unsigned channel update is attached to the failure message.
|
// The unsigned channel update is attached to the failure message.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
return [32]byte{}, htlcswitch.NewForwardingError(
|
return [32]byte{}, htlcswitch.NewForwardingError(
|
||||||
&lnwire.FailFeeInsufficient{
|
&lnwire.FailFeeInsufficient{
|
||||||
@ -2999,7 +2999,7 @@ func TestSendToRouteMultiShardSend(t *testing.T) {
|
|||||||
|
|
||||||
// The first shard we send we'll fail immediately, to check that we are
|
// The first shard we send we'll fail immediately, to check that we are
|
||||||
// still allowed to retry with other shards after a failed one.
|
// still allowed to retry with other shards after a failed one.
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
return [32]byte{}, htlcswitch.NewForwardingError(
|
return [32]byte{}, htlcswitch.NewForwardingError(
|
||||||
&lnwire.FailFeeInsufficient{
|
&lnwire.FailFeeInsufficient{
|
||||||
@ -3026,7 +3026,7 @@ func TestSendToRouteMultiShardSend(t *testing.T) {
|
|||||||
waitForResultSignal := make(chan struct{}, numShards)
|
waitForResultSignal := make(chan struct{}, numShards)
|
||||||
results := make(chan lntypes.Preimage, numShards)
|
results := make(chan lntypes.Preimage, numShards)
|
||||||
|
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcher).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
// Signal that the shard has been initiated and is
|
// Signal that the shard has been initiated and is
|
||||||
|
Loading…
Reference in New Issue
Block a user