Skip to content

Commit 4bd840f

Browse files
committed
test/chainnotifier: send to specific spend reg
This is needed to have multiple spending registrations running and to send a notification to a specific spending registration.
1 parent 6cd3627 commit 4bd840f

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

test/chainnotifier_mock.go

+17-8
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ func (c *mockChainNotifier) RawClientWithMacAuth(
3333

3434
// SpendRegistration contains registration details.
3535
type SpendRegistration struct {
36-
Outpoint *wire.OutPoint
37-
PkScript []byte
38-
HeightHint int32
39-
ErrChan chan<- error
36+
Outpoint *wire.OutPoint
37+
PkScript []byte
38+
HeightHint int32
39+
SpendChannel chan<- *chainntnfs.SpendDetail
40+
ErrChan chan<- error
4041
}
4142

4243
// ConfRegistration contains registration details.
@@ -53,13 +54,15 @@ func (c *mockChainNotifier) RegisterSpendNtfn(ctx context.Context,
5354
outpoint *wire.OutPoint, pkScript []byte, heightHint int32) (
5455
chan *chainntnfs.SpendDetail, chan error, error) {
5556

57+
spendChan0 := make(chan *chainntnfs.SpendDetail)
5658
spendErrChan := make(chan error, 1)
5759

5860
reg := &SpendRegistration{
59-
HeightHint: heightHint,
60-
Outpoint: outpoint,
61-
PkScript: pkScript,
62-
ErrChan: spendErrChan,
61+
HeightHint: heightHint,
62+
Outpoint: outpoint,
63+
PkScript: pkScript,
64+
SpendChannel: spendChan0,
65+
ErrChan: spendErrChan,
6366
}
6467

6568
c.lnd.RegisterSpendChannel <- reg
@@ -78,6 +81,12 @@ func (c *mockChainNotifier) RegisterSpendNtfn(ctx context.Context,
7881
case <-ctx.Done():
7982
}
8083

84+
case m := <-spendChan0:
85+
select {
86+
case spendChan <- m:
87+
case <-ctx.Done():
88+
}
89+
8190
case err := <-spendErrChan:
8291
select {
8392
case errChan <- err:

0 commit comments

Comments
 (0)