Esempio n. 1
0
        public void SerializeDeserializeIsPruneable()
        {
            var isPruneable = new IsPruneable(9947832, 89478310, new BlockAlias(702349));

            MessageSerializers.ClientSerializeIsPruneable(isPruneable, _buffer);
            var newIsPruneable = MessageSerializers.DeserializeIsPruneable(_buffer);

            Assert.True(isPruneable.ClientId == newIsPruneable.ClientId &&
                        isPruneable.RequestId == newIsPruneable.RequestId &&
                        isPruneable.RequestType == newIsPruneable.RequestType &&
                        isPruneable.BlockHandle == newIsPruneable.BlockHandle);
        }
Esempio n. 2
0
        public void TestIsPruneable()
        {
            Setup();

            var messageAllocation = new Span <byte>(new byte[IsPruneable.SizeInBytes]);

            var isPruneableReq = new IsPruneable(1, 5, _3);

            // Serialize message to put it into the inbox
            MessageSerializers.ClientSerializeIsPruneable(isPruneableReq, messageAllocation);

            _inbox.TryWrite(messageAllocation);

            _controller.DoWork();

            var result   = _outbox.Peek();
            var response = MessageSerializers.ClientDeserializePruneableResponse(result);

            Assert.Equal(MessageType.PruneableResponse, ClientServerMessage.GetMessageType(result));

            Assert.Equal(1U, response.RequestId);
            Assert.Equal(5U, response.ClientId);
            Assert.False(response.Answer);

            _outbox.Next();

            isPruneableReq = new IsPruneable(1, 5, _4);
            // Serialize message to put it into the inbox
            MessageSerializers.ClientSerializeIsPruneable(isPruneableReq, messageAllocation);

            _inbox.TryWrite(messageAllocation);

            _controller.DoWork();

            result = _outbox.Peek();
            Assert.Equal(MessageType.PruneableResponse, ClientServerMessage.GetMessageType(result));
            var response2 = MessageSerializers.ClientDeserializePruneableResponse(result);

            Assert.Equal(1U, response.RequestId);
            Assert.Equal(5U, response.ClientId);
            Assert.True(response2.Answer);
        }