Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-kim committed Aug 1, 2023
1 parent 7ef81f3 commit 69f3c28
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion x/p2p/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestAppRequestResponse(t *testing.T) {
require.Equal(t, response, actualResponse)
}

require.NoError(t, client.AppRequest(context.Background(), set.Set[ids.NodeID]{nodeID: struct{}{}}, request, callback))
require.NoError(t, client.AppRequestAny(context.Background(), request, callback))
},
},
{
Expand Down Expand Up @@ -158,6 +158,28 @@ func TestAppRequestResponse(t *testing.T) {
require.NoError(t, client.AppGossip(context.Background(), request))
},
},
{
name: "app gossip specific",
requestFunc: func(t *testing.T, router *Router, client *Client, sender *common.MockSender, handler *mocks.MockHandler, wg *sync.WaitGroup) {
sender.EXPECT().SendAppGossipSpecific(gomock.Any(), gomock.Any(), gomock.Any()).
Do(func(ctx context.Context, nodeIDs set.Set[ids.NodeID], gossip []byte) {
for n := range nodeIDs {
nodeID := n
go func() {
require.NoError(t, router.AppGossip(ctx, nodeID, gossip))
}()
}
}).AnyTimes()
handler.EXPECT().
AppGossip(context.Background(), nodeID, request).
DoAndReturn(func(context.Context, ids.NodeID, []byte) error {
defer wg.Done()
return nil
})

require.NoError(t, client.AppGossipSpecific(context.Background(), set.Set[ids.NodeID]{nodeID: struct{}{}}, request))
},
},
}

for _, tt := range tests {
Expand All @@ -168,6 +190,7 @@ func TestAppRequestResponse(t *testing.T) {
sender := common.NewMockSender(ctrl)
handler := mocks.NewMockHandler(ctrl)
router := NewRouter(sender)
require.NoError(router.Connected(context.Background(), nodeID, nil))

client, err := router.RegisterAppProtocol(handlerID, handler)
require.NoError(err)
Expand Down

0 comments on commit 69f3c28

Please sign in to comment.