2019-05-16 15:27:28 +02:00
|
|
|
package routing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
|
|
|
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
|
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
|
|
|
)
|
|
|
|
|
|
|
|
type mockPaymentAttemptDispatcher struct {
|
|
|
|
onPayment func(firstHop lnwire.ShortChannelID) ([32]byte, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ PaymentAttemptDispatcher = (*mockPaymentAttemptDispatcher)(nil)
|
|
|
|
|
|
|
|
func (m *mockPaymentAttemptDispatcher) SendHTLC(firstHop lnwire.ShortChannelID,
|
2019-05-16 15:27:28 +02:00
|
|
|
_ uint64,
|
2019-05-16 15:27:28 +02:00
|
|
|
_ *lnwire.UpdateAddHTLC,
|
|
|
|
_ htlcswitch.ErrorDecrypter) ([sha256.Size]byte, error) {
|
|
|
|
|
|
|
|
if m.onPayment != nil {
|
|
|
|
return m.onPayment(firstHop)
|
|
|
|
}
|
|
|
|
|
|
|
|
return [sha256.Size]byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockPaymentAttemptDispatcher) setPaymentResult(
|
|
|
|
f func(firstHop lnwire.ShortChannelID) ([32]byte, error)) {
|
|
|
|
|
|
|
|
m.onPayment = f
|
|
|
|
}
|