From e6dc9a224c35d447db73a05c863a77b6e5e2a1c9 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Fri, 13 Dec 2019 00:18:05 +0300 Subject: [PATCH] Test handling consume packets --- pkg/router/router_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/router/router_test.go b/pkg/router/router_test.go index 829d486ca..8e137402a 100644 --- a/pkg/router/router_test.go +++ b/pkg/router/router_test.go @@ -290,7 +290,7 @@ func TestRouter_handleTransportPacket(t *testing.T) { Reverse: cnsmRule, }) - packet := routing.MakeDataPacket(intFwdRtID[0], []byte("test")) + packet := routing.MakeDataPacket(intFwdRtID[0], []byte("test intermediary forward")) require.NoError(t, r0.handleTransportPacket(context.TODO(), packet)) recvPacket, err := r1.tm.ReadPacket() @@ -298,6 +298,17 @@ func TestRouter_handleTransportPacket(t *testing.T) { assert.Equal(t, packet.Size(), recvPacket.Size()) assert.Equal(t, packet.Payload(), recvPacket.Payload()) assert.Equal(t, dstRtIDs[1], recvPacket.RouteID()) + + consumeMsg := []byte("test_consume") + packet = routing.MakeDataPacket(dstRtIDs[1], consumeMsg) + require.NoError(t, r1.handleTransportPacket(context.TODO(), packet)) + + rg, ok := r1.routeGroup(fwdRtDesc.Invert()) + require.True(t, ok) + require.NotNil(t, rg) + + data := <-rg.readCh + require.Equal(t, consumeMsg, data) }) t.Run("handlePacket_close", func(t *testing.T) {