mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-18 21:02:42 +02:00
itest: replace chanOpen bool with chanWatchType
This commit is contained in:
parent
a58543d1c7
commit
d2277ac915
@ -1296,13 +1296,25 @@ func (hn *HarnessNode) kill() error {
|
|||||||
return hn.cmd.Process.Kill()
|
return hn.cmd.Process.Kill()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type chanWatchType uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// watchOpenChannel specifies that this is a request to watch an open
|
||||||
|
// channel event.
|
||||||
|
watchOpenChannel chanWatchType = iota
|
||||||
|
|
||||||
|
// watchCloseChannel specifies that this is a request to watch a close
|
||||||
|
// channel event.
|
||||||
|
watchCloseChannel
|
||||||
|
)
|
||||||
|
|
||||||
// closeChanWatchRequest is a request to the lightningNetworkWatcher to be
|
// closeChanWatchRequest is a request to the lightningNetworkWatcher to be
|
||||||
// notified once it's detected within the test Lightning Network, that a
|
// notified once it's detected within the test Lightning Network, that a
|
||||||
// channel has either been added or closed.
|
// channel has either been added or closed.
|
||||||
type chanWatchRequest struct {
|
type chanWatchRequest struct {
|
||||||
chanPoint wire.OutPoint
|
chanPoint wire.OutPoint
|
||||||
|
|
||||||
chanOpen bool
|
chanWatchType chanWatchType
|
||||||
|
|
||||||
eventChan chan struct{}
|
eventChan chan struct{}
|
||||||
}
|
}
|
||||||
@ -1387,14 +1399,15 @@ func (hn *HarnessNode) lightningNetworkWatcher() {
|
|||||||
// to dispatch immediately, or need to add the client for
|
// to dispatch immediately, or need to add the client for
|
||||||
// processing later.
|
// processing later.
|
||||||
case watchRequest := <-hn.chanWatchRequests:
|
case watchRequest := <-hn.chanWatchRequests:
|
||||||
// TODO(roasbeef): add update type also, checks for
|
switch watchRequest.chanWatchType {
|
||||||
// multiple of 2
|
case watchOpenChannel:
|
||||||
if watchRequest.chanOpen {
|
// TODO(roasbeef): add update type also, checks
|
||||||
|
// for multiple of 2
|
||||||
hn.handleOpenChannelWatchRequest(watchRequest)
|
hn.handleOpenChannelWatchRequest(watchRequest)
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
|
case watchCloseChannel:
|
||||||
hn.handleCloseChannelWatchRequest(watchRequest)
|
hn.handleCloseChannelWatchRequest(watchRequest)
|
||||||
|
}
|
||||||
|
|
||||||
case <-hn.quit:
|
case <-hn.quit:
|
||||||
return
|
return
|
||||||
@ -1420,7 +1433,7 @@ func (hn *HarnessNode) WaitForNetworkChannelOpen(ctx context.Context,
|
|||||||
hn.chanWatchRequests <- &chanWatchRequest{
|
hn.chanWatchRequests <- &chanWatchRequest{
|
||||||
chanPoint: op,
|
chanPoint: op,
|
||||||
eventChan: eventChan,
|
eventChan: eventChan,
|
||||||
chanOpen: true,
|
chanWatchType: watchOpenChannel,
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
@ -1450,7 +1463,7 @@ func (hn *HarnessNode) WaitForNetworkChannelClose(ctx context.Context,
|
|||||||
hn.chanWatchRequests <- &chanWatchRequest{
|
hn.chanWatchRequests <- &chanWatchRequest{
|
||||||
chanPoint: op,
|
chanPoint: op,
|
||||||
eventChan: eventChan,
|
eventChan: eventChan,
|
||||||
chanOpen: false,
|
chanWatchType: watchCloseChannel,
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user