/// <summary>
        ///     Signs a protocol message, or straight WriteAndFlush non-protocolMessages
        /// </summary>
        /// <param name="context"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        protected override Task WriteAsync0(IChannelHandlerContext context, IMessageDto <ProtocolMessage> message)
        {
            Logger.Verbose("Signing message {message}", message);
            var protocolMessageSigned = message.Content.Sign(_keySigner, _signingContext);
            var signedDto             = new SignedMessageDto(protocolMessageSigned, message.RecipientPeerIdentifier);

            return(context.WriteAsync(signedDto));
        }
        public void Can_Encode_Signed_Message_Dto_To_Protocol_Message_Signed()
        {
            var messageDto = new SignedMessageDto(
                new PingRequest().ToProtocolMessage(PeerIdHelper.GetPeerId("TestSender")),
                PeerIdHelper.GetPeerId("Test"));

            _testChannel.WriteOutbound(messageDto);
            var outboundMessages = _testChannel.OutboundMessages.ToArray();

            outboundMessages.Length.Should().Be(1);
            outboundMessages[0].Should().BeAssignableTo <ProtocolMessage>();
        }