public async Task RpcServer_Can_Handle_SignMessageRequest(string message) { var sender = PeerIdHelper.GetPeerId("sender"); var peerSettings = Substitute.For <IPeerSettings>(); peerSettings.PeerId.Returns(sender); var signMessageRequest = new SignMessageRequest { Message = message.ToUtf8ByteString(), SigningContext = new SigningContext() }; var protocolMessage = signMessageRequest.ToProtocolMessage(sender); await TaskHelper.WaitForAsync( () => _keySigner.KeyStore.KeyStoreDecrypt(KeyRegistryTypes.DefaultKey) != null, TimeSpan.FromSeconds(2)); var messageStream = MessageStreamHelper.CreateStreamWithMessage(_fakeContext, _testScheduler, protocolMessage); var handler = new SignMessageRequestObserver(peerSettings, _logger, _keySigner); handler.StartObserving(messageStream); _testScheduler.Start(); var receivedCalls = _fakeContext.Channel.ReceivedCalls().ToList(); _logger.DidNotReceiveWithAnyArgs().Error((Exception) default, default);
public void RpcServer_Can_Handle_SignMessageRequest(string message) { var sender = PeerIdHelper.GetPeerId("sender"); var peerSettings = Substitute.For <IPeerSettings>(); peerSettings.PeerId.Returns(sender); var signMessageRequest = new SignMessageRequest { Message = message.ToUtf8ByteString(), SigningContext = new SigningContext() }; var protocolMessage = signMessageRequest.ToProtocolMessage(sender); var messageStream = MessageStreamHelper.CreateStreamWithMessage(_fakeContext, _testScheduler, protocolMessage); var handler = new SignMessageRequestObserver(peerSettings, _logger, _keySigner); handler.StartObserving(messageStream); _testScheduler.Start(); var receivedCalls = _fakeContext.Channel.ReceivedCalls().ToList(); receivedCalls.Count.Should().Be(1); var sentResponseDto = (IMessageDto <ProtocolMessage>)receivedCalls.Single().GetArguments().Single(); var signResponseMessage = sentResponseDto.Content.FromProtocolMessage <SignMessageResponse>(); signResponseMessage.OriginalMessage.Should().Equal(message); signResponseMessage.Signature.Should().NotBeEmpty(); signResponseMessage.PublicKey.Should().NotBeEmpty(); }