mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-19 20:15:18 +02:00
lntest: catch window conn error in EnsureConnected
This commit also removes the first connection attempt inside `SetupStandbyNodes` as the nodes are always connected inside each subtest. The error returned from connection is now logged for debugging.
This commit is contained in:
@@ -186,11 +186,6 @@ func (h *HarnessTest) SetupStandbyNodes() {
|
||||
h.Alice = h.NewNode("Alice", lndArgs)
|
||||
h.Bob = h.NewNode("Bob", lndArgs)
|
||||
|
||||
// First, make a connection between the two nodes. This will wait until
|
||||
// both nodes are fully started since the Connect RPC is guarded behind
|
||||
// the server.Started() flag that waits for all subsystems to be ready.
|
||||
h.ConnectNodes(h.Alice, h.Bob)
|
||||
|
||||
addrReq := &lnrpc.NewAddressRequest{
|
||||
Type: lnrpc.AddressType_WITNESS_PUBKEY_HASH,
|
||||
}
|
||||
|
@@ -146,6 +146,12 @@ func (h *HarnessTest) EnsureConnected(a, b *node.HarnessNode) {
|
||||
// connected to the peer.
|
||||
errConnectionRequested := "connection request in progress"
|
||||
|
||||
// windowsErr is an error we've seen from windows build where
|
||||
// connecting to an already connected node gives such error from the
|
||||
// receiver side.
|
||||
windowsErr := "An established connection was aborted by the software " +
|
||||
"in your host machine."
|
||||
|
||||
tryConnect := func(a, b *node.HarnessNode) error {
|
||||
bInfo := b.RPC.GetInfo()
|
||||
|
||||
@@ -166,17 +172,21 @@ func (h *HarnessTest) EnsureConnected(a, b *node.HarnessNode) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If the connection is in process, we return no error.
|
||||
if strings.Contains(err.Error(), errConnectionRequested) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If the two are already connected, we return early with no
|
||||
// error.
|
||||
if strings.Contains(err.Error(), "already connected to peer") {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Otherwise we log the error to console.
|
||||
h.Logf("EnsureConnected %s=>%s got err: %v", a.Name(),
|
||||
b.Name(), err)
|
||||
|
||||
// If the connection is in process, we return no error.
|
||||
if strings.Contains(err.Error(), errConnectionRequested) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// We may get connection refused error if we happens to be in
|
||||
// the middle of a previous node disconnection, e.g., a restart
|
||||
// from one of the nodes.
|
||||
@@ -184,6 +194,16 @@ func (h *HarnessTest) EnsureConnected(a, b *node.HarnessNode) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check for windows error. If Alice connects to Bob, Alice
|
||||
// will throw "i/o timeout" and Bob will give windowsErr.
|
||||
if strings.Contains(err.Error(), windowsErr) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if strings.Contains(err.Error(), "i/o timeout") {
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user