private Task <T> CreateMessageAndListen <T>(
     MessageMethod method,
     ChaincodeMessage.Types.Type type,
     IMessage payload,
     string channelId,
     string txId
     )
 {
     return(AskPeerAndListen <T>(CreateMessage(type, payload, channelId, txId), method));
 }
Ejemplo n.º 2
0
        private static ChaincodeMessage NewEventMessage(ChaincodeMessage.Types.Type type, string channelId, string txId, ByteString payload, ChaincodeEvent evnt)
        {
            ChaincodeMessage msg = new ChaincodeMessage {
                Type = type, ChannelId = channelId, Txid = txId, Payload = payload
            };

            if (evnt != null)
            {
                msg.ChaincodeEvent = evnt;
            }
            return(msg);
        }
 private ChaincodeMessage CreateMessage(
     ChaincodeMessage.Types.Type type,
     IMessage payload,
     string channelId,
     string txId
     )
 {
     return(new ChaincodeMessage
     {
         Type = type,
         Payload = payload.ToByteString(),
         Txid = txId,
         ChannelId = channelId
     });
 }
        CreateValidHandlerWithMessageQueueExpectation(
            MessageMethod messageMethod,
            ChaincodeMessage.Types.Type type
            )
        {
            var messageQueueMock = new Mock <IMessageQueue>();

            messageQueueMock.Setup(m => m.QueueMessage(It.Is(
                                                           (QueueMessage message) => message.Method == messageMethod && message.Message.Type == type
                                                           )));

            var messageQueueFactoryMock = new Mock <IMessageQueueFactory>();

            messageQueueFactoryMock.Setup(m => m.Create(It.IsAny <IHandler>()))
            .Returns(messageQueueMock.Object);

            return(CreateHandlerWithChainsupportClientFactory(messageQueueFactoryMock.Object), messageQueueMock);
        }
Ejemplo n.º 5
0
 private static ChaincodeMessage NewEventMessage(ChaincodeMessage.Types.Type type, string channelId, string txId, ByteString payload)
 {
     return(NewEventMessage(type, channelId, txId, payload, null));
 }
Ejemplo n.º 6
0
 private async Task <QueryResponse> InvokeQueryResponseMessageAsync(string channelId, string txId, ChaincodeMessage.Types.Type type, ByteString payload, CancellationToken token)
 {
     try
     {
         return(QueryResponse.Parser.ParseFrom(await InvokeChaincodeSupportAsync(NewEventMessage(type, channelId, txId, payload), token).ConfigureAwait(false)));
     }
     catch (Exception e)
     {
         logger.Error($"[{txId,-8}s] unmarshall error");
         throw new InvalidOperationException("Error unmarshalling QueryResponse.", e);
     }
 }