Skip to content

Commit

Permalink
peer: make endpoints() private on MsgRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
ProofOfKeags committed Aug 14, 2024
1 parent bf92bee commit ad2fb21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 2 additions & 5 deletions peer/msg_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,8 @@ func (p *MultiMsgRouter) RouteMsg(msg lnwire.Message) error {
}

// Endpoints returns a list of all registered endpoints.
func (p *MultiMsgRouter) Endpoints() EndpointsMap {
return fn.ElimEither(
fn.Iden, fn.Const[EndpointsMap, error](nil),
sendQuery(p.endpointQueries, nil, p.quit).Either,
)
func (p *MultiMsgRouter) endpoints() fn.Result[EndpointsMap] {
return sendQuery(p.endpointQueries, nil, p.quit)
}

// msgRouter is the main goroutine that handles all incoming messages.
Expand Down
13 changes: 9 additions & 4 deletions peer/msg_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ func TestMessageRouterOperation(t *testing.T) {
// First, we'll add the funding endpoint to the router.
require.NoError(t, msgRouter.RegisterEndpoint(fundingEndpoint))

endpoints, err := msgRouter.endpoints().Unpack()
require.NoError(t, err)

// There should be a single endpoint registered.
require.Len(t, msgRouter.Endpoints(), 1)
require.Len(t, endpoints, 1)

// The name of the registered endpoint should be "funding".
require.Equal(
t, "funding",
msgRouter.Endpoints()[fundingEndpointName].Name(),
t, "funding", endpoints[fundingEndpointName].Name(),
)
})

Expand Down Expand Up @@ -127,8 +129,11 @@ func TestMessageRouterOperation(t *testing.T) {
t, msgRouter.UnregisterEndpoint(commitEndpointName),
)

endpoints, err := msgRouter.endpoints().Unpack()
require.NoError(t, err)

// There should be no endpoints registered.
require.Len(t, msgRouter.Endpoints(), 0)
require.Len(t, endpoints, 0)

// Trying to route a message should fail.
require.ErrorIs(
Expand Down

0 comments on commit ad2fb21

Please sign in to comment.