mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
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.
This commit is contained in:
parent
fab4a646df
commit
d2c168945b
1 changed files with 17 additions and 8 deletions
|
|
@ -33,10 +33,11 @@ func (c *mockChainNotifier) RawClientWithMacAuth(
|
|||
|
||||
// SpendRegistration contains registration details.
|
||||
type SpendRegistration struct {
|
||||
Outpoint *wire.OutPoint
|
||||
PkScript []byte
|
||||
HeightHint int32
|
||||
ErrChan chan<- error
|
||||
Outpoint *wire.OutPoint
|
||||
PkScript []byte
|
||||
HeightHint int32
|
||||
SpendChannel chan<- *chainntnfs.SpendDetail
|
||||
ErrChan chan<- error
|
||||
}
|
||||
|
||||
// ConfRegistration contains registration details.
|
||||
|
|
@ -53,13 +54,15 @@ func (c *mockChainNotifier) RegisterSpendNtfn(ctx context.Context,
|
|||
outpoint *wire.OutPoint, pkScript []byte, heightHint int32) (
|
||||
chan *chainntnfs.SpendDetail, chan error, error) {
|
||||
|
||||
spendChan0 := make(chan *chainntnfs.SpendDetail)
|
||||
spendErrChan := make(chan error, 1)
|
||||
|
||||
reg := &SpendRegistration{
|
||||
HeightHint: heightHint,
|
||||
Outpoint: outpoint,
|
||||
PkScript: pkScript,
|
||||
ErrChan: spendErrChan,
|
||||
HeightHint: heightHint,
|
||||
Outpoint: outpoint,
|
||||
PkScript: pkScript,
|
||||
SpendChannel: spendChan0,
|
||||
ErrChan: spendErrChan,
|
||||
}
|
||||
|
||||
c.lnd.RegisterSpendChannel <- reg
|
||||
|
|
@ -78,6 +81,12 @@ func (c *mockChainNotifier) RegisterSpendNtfn(ctx context.Context,
|
|||
case <-ctx.Done():
|
||||
}
|
||||
|
||||
case m := <-spendChan0:
|
||||
select {
|
||||
case spendChan <- m:
|
||||
case <-ctx.Done():
|
||||
}
|
||||
|
||||
case err := <-spendErrChan:
|
||||
select {
|
||||
case errChan <- err:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue