public void handling_hi_message_should_succeed()
        {
            _verifySignature = true;
            InitSubprotocol();
            var hiMessage = new HiMessage(1, TestItem.AddressC, TestItem.AddressD, TestItem.PublicKeyA,
                                          new Signature(1, 1, 27));
            var hiPacket = new Packet(hiMessage.Protocol, hiMessage.PacketType,
                                      _messageSerializationService.Serialize(hiMessage));

            _messageSerializationService.Deserialize <HiMessage>(hiPacket.Data).Returns(hiMessage);
            var hash = Keccak.Compute(hiMessage.NodeId.Bytes);

            _ecdsa.RecoverPublicKey(hiMessage.Signature, hash).Returns(TestItem.PublicKeyA);
            _subprotocol.HandleMessage(hiPacket);
            _ecdsa.Received().RecoverPublicKey(hiMessage.Signature, hash);
            _subprotocol.ProviderAddress.Should().Be(hiMessage.ProviderAddress);
            _subprotocol.ConsumerAddress.Should().Be(hiMessage.ConsumerAddress);
            _consumerService.Received().AddProviderPeer(_subprotocol);
            var getDataAssetsMessage = new GetDataAssetsMessage();

            _messageSerializationService.Serialize(getDataAssetsMessage).Returns(Array.Empty <byte>());
            var getDataAssetsPacket = new Packet(getDataAssetsMessage.Protocol, getDataAssetsMessage.PacketType,
                                                 _messageSerializationService.Serialize(getDataAssetsMessage));

            _messageSerializationService.Deserialize <GetDataAssetsMessage>(getDataAssetsPacket.Data)
            .Returns(getDataAssetsMessage);

            Received.InOrder(() =>
            {
                _session.DeliverMessage(Arg.Any <GetDataAssetsMessage>());
                _session.DeliverMessage(Arg.Any <GetDepositApprovalsMessage>());
            });
        }
Beispiel #2
0
        public void get_consumer_address_should_return_address()
        {
            _consumerService.GetAddress().Returns(TestItem.AddressA);
            var result = _rpc.ndm_getConsumerAddress();

            _consumerService.Received().GetAddress();
            result.Data.Should().Be(TestItem.AddressA);
        }