Skip to content

Commit

Permalink
Finish test for conns contents for dmsg.Server's Serve
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Jun 4, 2019
1 parent 90c0c5e commit f8d093b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/dmsg/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,45 @@ func TestServer_ListenAndServe(t *testing.T) {
require.Equal(t, true, ok)
require.Equal(t, bPK, bServerConn.remoteClient)

// must have a ClientConn
aClientConn, ok := a.conns[sPK]
require.Equal(t, true, ok)
require.Equal(t, sPK, aClientConn.remoteSrv)

// must have a ClientConn
bClientConn, ok := b.conns[sPK]
require.Equal(t, true, ok)
require.Equal(t, sPK, bClientConn.remoteSrv)

// check whether nextConn's contents are as must be
bNextConn := bServerConn.nextConns[bClientConn.nextInitID-2]
require.NotNil(t, bNextConn)
require.Equal(t, bNextConn.id, aServerConn.nextRespID-2)

// check whether nextConn's contents are as must be
aNextConn := aServerConn.nextConns[aServerConn.nextRespID-2]
require.NotNil(t, aNextConn)
require.Equal(t, aNextConn.id, bClientConn.nextInitID-2)

log.Printf("%v\n", s.conns)

err = aTransport.Close()
require.NoError(t, err)

err = bTransport.Close()
require.NoError(t, err)

err = a.Close()
require.NoError(t, err)

err = b.Close()
require.NoError(t, err)

time.Sleep(3 * time.Second)

require.Equal(t, 0, len(s.conns))
require.Equal(t, 0, len(a.conns))
require.Equal(t, 0, len(b.conns))
})
}

Expand Down

0 comments on commit f8d093b

Please sign in to comment.