public void Sets_values_from_contructor_argument()
        {
            Keccak[]           keys    = { TestObject.KeccakA, TestObject.KeccakB };
            GetNodeDataMessage message = new GetNodeDataMessage(keys);

            Assert.AreSame(keys, message.Keys);
        }
Beispiel #2
0
        private static void Test(Keccak[] keys)
        {
            GetNodeDataMessage           message    = new GetNodeDataMessage(keys);
            GetNodeDataMessageSerializer serializer = new GetNodeDataMessageSerializer();

            SerializerTester.TestZero(serializer, message);
        }
        private static void Test(Keccak[] keys)
        {
            GetNodeDataMessage           message    = new GetNodeDataMessage(keys);
            GetNodeDataMessageSerializer serializer = new GetNodeDataMessageSerializer();
            var serialized = serializer.Serialize(message);
            GetNodeDataMessage deserialized = serializer.Deserialize(serialized);

            Assert.AreEqual(keys.Length, deserialized.Keys.Length, "length");
            for (int i = 0; i < keys.Length; i++)
            {
                Assert.AreEqual(keys[i], deserialized.Keys[i], $"keys[{i}]");
            }
        }
Beispiel #4
0
        public override void HandleMessage(ZeroPacket message)
        {
            int size = message.Content.ReadableBytes;

            switch (message.PacketType)
            {
            case Eth66MessageCode.GetBlockHeaders:
                GetBlockHeadersMessage getBlockHeadersMessage
                    = Deserialize <GetBlockHeadersMessage>(message.Content);
                Metrics.Eth66GetBlockHeadersReceived++;
                ReportIn(getBlockHeadersMessage);
                Handle(getBlockHeadersMessage);
                break;

            case Eth66MessageCode.BlockHeaders:
                BlockHeadersMessage headersMsg = Deserialize <BlockHeadersMessage>(message.Content);
                Metrics.Eth66BlockHeadersReceived++;
                ReportIn(headersMsg);
                Handle(headersMsg.EthMessage, size);
                break;

            case Eth66MessageCode.GetBlockBodies:
                GetBlockBodiesMessage getBodiesMsg = Deserialize <GetBlockBodiesMessage>(message.Content);
                Metrics.Eth66GetBlockBodiesReceived++;
                ReportIn(getBodiesMsg);
                Handle(getBodiesMsg);
                break;

            case Eth66MessageCode.BlockBodies:
                BlockBodiesMessage bodiesMsg = Deserialize <BlockBodiesMessage>(message.Content);
                Metrics.Eth66BlockBodiesReceived++;
                ReportIn(bodiesMsg);
                HandleBodies(bodiesMsg.EthMessage, size);
                break;

            case Eth66MessageCode.GetPooledTransactions:
                GetPooledTransactionsMessage getPooledTxMsg
                    = Deserialize <GetPooledTransactionsMessage>(message.Content);
                Metrics.Eth66GetPooledTransactionsReceived++;
                ReportIn(getPooledTxMsg);
                Handle(getPooledTxMsg);
                break;

            case Eth66MessageCode.PooledTransactions:
                PooledTransactionsMessage pooledTxMsg
                    = Deserialize <PooledTransactionsMessage>(message.Content);
                Metrics.Eth66PooledTransactionsReceived++;
                ReportIn(pooledTxMsg);
                Handle(pooledTxMsg.EthMessage);
                break;

            case Eth66MessageCode.GetReceipts:
                GetReceiptsMessage getReceiptsMessage = Deserialize <GetReceiptsMessage>(message.Content);
                Metrics.Eth66GetReceiptsReceived++;
                ReportIn(getReceiptsMessage);
                Handle(getReceiptsMessage);
                break;

            case Eth66MessageCode.Receipts:
                ReceiptsMessage receiptsMessage = Deserialize <ReceiptsMessage>(message.Content);
                Metrics.Eth66ReceiptsReceived++;
                ReportIn(receiptsMessage);
                Handle(receiptsMessage.EthMessage, size);
                break;

            case Eth66MessageCode.GetNodeData:
                GetNodeDataMessage getNodeDataMessage = Deserialize <GetNodeDataMessage>(message.Content);
                Metrics.Eth66GetNodeDataReceived++;
                ReportIn(getNodeDataMessage);
                Handle(getNodeDataMessage);
                break;

            case Eth66MessageCode.NodeData:
                NodeDataMessage nodeDataMessage = Deserialize <NodeDataMessage>(message.Content);
                Metrics.Eth66NodeDataReceived++;
                ReportIn(nodeDataMessage);
                Handle(nodeDataMessage.EthMessage, size);
                break;

            default:
                base.HandleMessage(message);
                break;
            }
        }
Beispiel #5
0
 private void Handle(GetNodeDataMessage getNodeDataMessage)
 {
     V63.Messages.NodeDataMessage nodeDataMessage =
         FulfillNodeDataRequest(getNodeDataMessage.EthMessage);
     Send(new NodeDataMessage(getNodeDataMessage.RequestId, nodeDataMessage));
 }
        public void To_string()
        {
            GetNodeDataMessage statusMessage = new GetNodeDataMessage(new List <Keccak>());

            _ = statusMessage.ToString();
        }
 public void Throws_on_null_argument()
 {
     Assert.Throws <ArgumentNullException>(() => _ = new GetNodeDataMessage(null));
 }