mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-09 18:52:09 +02:00
tor+healthcheck: fix healthcheck for multiple services
Fixes #6013. This commit fixes the Tor healthcheck that would previously fail if there were multiple hidden service registered. In the controller, we only need to know that our service is contained in the list of active services. But we can't do a string equality check since there might be multiple services, comma separated.
This commit is contained in:
@@ -61,7 +61,30 @@ func TestCheckOnionServiceFailOnServiceIDNotMatch(t *testing.T) {
|
||||
require.NoError(t, err, "server failed to write")
|
||||
|
||||
// Check the error returned from GetServiceInfo is expected.
|
||||
require.ErrorIs(t, c.CheckOnionService(), ErrServiceIDUnmatch)
|
||||
require.ErrorIs(t, c.CheckOnionService(), ErrServiceIDMismatch)
|
||||
}
|
||||
|
||||
func TestCheckOnionServiceSucceedOnMultipleServices(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Create mock server and client connection.
|
||||
proxy := createTestProxy(t)
|
||||
defer proxy.cleanUp()
|
||||
server := proxy.serverConn
|
||||
|
||||
// Assign a fake service ID to the controller.
|
||||
c := &Controller{conn: proxy.clientConn, activeServiceID: "fakeID"}
|
||||
|
||||
// Mock a response with a different serviceID.
|
||||
serverResp := "250-onions/current=service1,fakeID,service2\n250 OK\n"
|
||||
|
||||
// Let the server mocks a given response.
|
||||
_, err := server.Write([]byte(serverResp))
|
||||
require.NoError(t, err, "server failed to write")
|
||||
|
||||
// No error is expected, the controller's ID is contained within the
|
||||
// list of active services.
|
||||
require.NoError(t, c.CheckOnionService())
|
||||
}
|
||||
|
||||
func TestCheckOnionServiceFailOnClosedConnection(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user