Merge pull request #7854 from matheusdtech/itest-network-conn

itest: bind to local addr in network test
This commit is contained in:
Oliver Gugger 2023-07-25 09:20:40 +02:00 committed by GitHub
commit 0e0e8d8631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -148,6 +148,9 @@ unlock or create.
* [Simplify fuzz tests](https://github.com/lightningnetwork/lnd/pull/7709)
using the `require` package.
* [Removed](https://github.com/lightningnetwork/lnd/pull/7854) need for an
active internet connection for the network connection itest.
## `lncli`
* Added ability to use [ENV variables to override `lncli` global flags](https://github.com/lightningnetwork/lnd/pull/7693). Flags will have preference over ENVs.

View File

@ -17,14 +17,20 @@ import (
// effect. It creates a node with a small connection timeout value, and
// connects it to a non-routable IP address.
func testNetworkConnectionTimeout(ht *lntest.HarnessTest) {
// Bind to a random port on localhost but never actually accept any
// connections. This makes any connection attempts timeout.
l, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(ht, err)
defer l.Close()
var (
// testPub is a random public key for testing only.
testPub = "0332bda7da70fefe4b6ab92f53b3c4f4ee7999" +
"f312284a8e89c8670bb3f67dbee2"
// testHost is a reachable IP address with an unreachable port
// that's used for testing only.
testHost = "lightning.engineering:81"
// testHost is the previously bound address that will never
// accept any conns.
testHost = l.Addr().String()
)
// First, test the global timeout settings.
@ -62,7 +68,7 @@ func testNetworkConnectionTimeout(ht *lntest.HarnessTest) {
dave := ht.NewNode("Dave", nil)
// Try to connect Dave to a non-routable IP address, using a timeout
// value of 1ms, which should give us a timeout error immediately.
// value of 1s, which should give us a timeout error immediately.
req = &lnrpc.ConnectPeerRequest{
Addr: &lnrpc.LightningAddress{
Pubkey: testPub,