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:
Boris Nagaev 2025-04-28 02:07:40 -03:00
parent fab4a646df
commit d2c168945b
No known key found for this signature in database

View file

@ -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: