Skip to content

Commit

Permalink
Test handling consume packets
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed Dec 12, 2019
1 parent 5b7a985 commit e6dc9a2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,25 @@ 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()
assert.NoError(t, err)
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) {
Expand Down

0 comments on commit e6dc9a2

Please sign in to comment.