forked from lightningnetwork/lnd
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmock_registry_test.go
54 lines (43 loc) · 1.38 KB
/
mock_registry_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package contractcourt
import (
"context"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire"
)
type notifyExitHopData struct {
payHash lntypes.Hash
paidAmount lnwire.MilliSatoshi
hodlChan chan<- interface{}
expiry uint32
currentHeight int32
}
type mockRegistry struct {
notifyChan chan notifyExitHopData
notifyErr error
notifyResolution invoices.HtlcResolution
}
func (r *mockRegistry) NotifyExitHopHtlc(payHash lntypes.Hash,
paidAmount lnwire.MilliSatoshi, expiry uint32, currentHeight int32,
circuitKey models.CircuitKey, hodlChan chan<- interface{},
wireCustomRecords lnwire.CustomRecords,
payload invoices.Payload) (invoices.HtlcResolution, error) {
// Exit early if the notification channel is nil.
if hodlChan == nil {
return r.notifyResolution, r.notifyErr
}
r.notifyChan <- notifyExitHopData{
hodlChan: hodlChan,
payHash: payHash,
paidAmount: paidAmount,
expiry: expiry,
currentHeight: currentHeight,
}
return r.notifyResolution, r.notifyErr
}
func (r *mockRegistry) HodlUnsubscribeAll(subscriber chan<- interface{}) {}
func (r *mockRegistry) LookupInvoice(context.Context, lntypes.Hash) (
invoices.Invoice, error) {
return invoices.Invoice{}, invoices.ErrInvoiceNotFound
}