2019-03-25 09:31:03 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
2020-06-17 20:25:57 +00:00
|
|
|
"github.com/lightninglabs/lndclient"
|
2019-03-25 09:31:03 +00:00
|
|
|
"github.com/lightningnetwork/lnd/lntypes"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
type mockRouter struct {
|
2021-01-11 13:41:26 +00:00
|
|
|
lndclient.RouterClient
|
2019-03-25 09:31:03 +00:00
|
|
|
lnd *LndMockServices
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *mockRouter) SendPayment(ctx context.Context,
|
|
|
|
request lndclient.SendPaymentRequest) (chan lndclient.PaymentStatus,
|
|
|
|
chan error, error) {
|
|
|
|
|
|
|
|
statusChan := make(chan lndclient.PaymentStatus)
|
|
|
|
errorChan := make(chan error)
|
|
|
|
|
|
|
|
r.lnd.RouterSendPaymentChannel <- RouterPaymentChannelMessage{
|
|
|
|
SendPaymentRequest: request,
|
|
|
|
TrackPaymentMessage: TrackPaymentMessage{
|
|
|
|
Updates: statusChan,
|
|
|
|
Errors: errorChan,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return statusChan, errorChan, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *mockRouter) TrackPayment(ctx context.Context,
|
|
|
|
hash lntypes.Hash) (chan lndclient.PaymentStatus, chan error, error) {
|
|
|
|
|
|
|
|
statusChan := make(chan lndclient.PaymentStatus)
|
|
|
|
errorChan := make(chan error)
|
|
|
|
r.lnd.TrackPaymentChannel <- TrackPaymentMessage{
|
|
|
|
Hash: hash,
|
|
|
|
Updates: statusChan,
|
|
|
|
Errors: errorChan,
|
|
|
|
}
|
|
|
|
|
|
|
|
return statusChan, errorChan, nil
|
|
|
|
}
|