func newFakeClient(proto, addr string) *fakeclient.FakeClient {
	c := fakeclient.FakeClient{}
	c.SchemeReturns(proto)
	c.AddressReturns(addr)
	return &c
}
		})

		Context("when selecting a client errors", func() {
			It("an error is logged and returns", func() {
				clientPool.RandomClientReturns(nil, errors.New("boom"))
				forwarder.Write(envelope)

				Eventually(loggertesthelper.TestLoggerSink.LogContents).Should(ContainSubstring("can't forward message"))
				Eventually(client.SchemeCallCount).Should(Equal(0))
			})
		})
	})

	Context("udp client", func() {
		BeforeEach(func() {
			client.SchemeReturns("udp")
		})

		It("counts the number of bytes sent", func() {
			bytes, err := proto.Marshal(envelope)
			Expect(err).NotTo(HaveOccurred())

			client.WriteReturns(len(bytes), nil)

			n := uint32(len(bytes))

			forwarder.Write(envelope)

			Eventually(func() uint64 {
				return sender.GetCounter("udp.sentByteCount")
			}).Should(BeEquivalentTo(n))