I often need to run multiple test_runner.py instances in parallel and the tests will often have port conflicts with other tests being run. While setting TEST_RUNNER_PORT_MIN can help, the number of test instances that can be run is still limited by the number of free ports for the 127.0.0.1 address, and it quickly runs into ports being used by other software at the high end of the port range. However it occurred to me that 127.0.0.1 is not the only loopback address available, and having the tests use different addresses allows us to avoid port conflicts as the other addresses are pretty much unused. This PR introduces a new environment variable BITCOIN_TEST_BIND which can specify an ip address for spawned nodes to bind to. By specifying different loopback addresses for each test_runner.py instance, I can completely avoid port conflicts and run many more in parallel.
In order for the tests to work, the host needs to be setup to have the specified addresses bound to the loopback interface. This can be achieved with a command like ip addr add 127.0.0.2/32 dev lo which would allow env BITCOIN_TEST_BIND=127.0.0.2 test/functional/test_runner.py to work.
References to 127.0.0.1 have been (mostly) changed to LOCALHOST which will match the value specified in BITCOIN_TEST_BIND, with the default being 127.0.0.1.