public void Roundtrip_zero() { GetBlockHeadersMessage message = new GetBlockHeadersMessage(); message.MaxHeaders = 1; message.Skip = 2; message.Reverse = 0; message.StartingBlockNumber = 100; GetBlockHeadersMessageSerializer serializer = new GetBlockHeadersMessageSerializer(); byte[] bytes = serializer.Serialize(message); byte[] expectedBytes = Bytes.FromHexString("c464010280"); Assert.AreEqual(expectedBytes, bytes, "bytes"); GetBlockHeadersMessage deserialized = serializer.Deserialize(bytes); Assert.AreEqual(message.StartingBlockNumber, deserialized.StartingBlockNumber, $"{nameof(message.StartingBlockNumber)}"); Assert.AreEqual(message.MaxHeaders, deserialized.MaxHeaders, $"{nameof(message.MaxHeaders)}"); Assert.AreEqual(message.Reverse, deserialized.Reverse, $"{nameof(message.Reverse)}"); Assert.AreEqual(message.Skip, deserialized.Skip, $"{nameof(message.Skip)}"); SerializerTester.Test(serializer, message); SerializerTester.TestZero(serializer, message); }
public void Roundtrip_hash() { GetBlockHeadersMessage message = new GetBlockHeadersMessage(); message.MaxHeaders = 1; message.Skip = 2; message.Reverse = 1; message.StartingBlockHash = Keccak.OfAnEmptyString; GetBlockHeadersMessageSerializer serializer = new GetBlockHeadersMessageSerializer(); byte[] bytes = serializer.Serialize(message); byte[] expectedBytes = Bytes.FromHexString("e4a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470010201"); Assert.True(Bytes.AreEqual(bytes, expectedBytes), "bytes"); GetBlockHeadersMessage deserialized = serializer.Deserialize(bytes); Assert.AreEqual(message.StartingBlockHash, deserialized.StartingBlockHash, $"{nameof(message.StartingBlockHash)}"); Assert.AreEqual(message.MaxHeaders, deserialized.MaxHeaders, $"{nameof(message.MaxHeaders)}"); Assert.AreEqual(message.Reverse, deserialized.Reverse, $"{nameof(message.Reverse)}"); Assert.AreEqual(message.Skip, deserialized.Skip, $"{nameof(message.Skip)}"); SerializerTester.Test(serializer, message); SerializerTester.TestZero(serializer, message); }
public void Roundtrip_hash() { GetBlockHeadersMessage message = new GetBlockHeadersMessage(); message.MaxHeaders = 1; message.Skip = 2; message.Reverse = 1; message.StartingBlockNumber = 100; GetBlockHeadersMessageSerializer serializer = new GetBlockHeadersMessageSerializer(); byte[] bytes = serializer.Serialize(message); GetBlockHeadersMessage deserialized = serializer.Deserialize(bytes); Assert.AreEqual(message.StartingBlockNumber, deserialized.StartingBlockNumber, $"{nameof(message.StartingBlockNumber)}"); Assert.AreEqual(message.MaxHeaders, deserialized.MaxHeaders, $"{nameof(message.MaxHeaders)}"); Assert.AreEqual(message.Reverse, deserialized.Reverse, $"{nameof(message.Reverse)}"); Assert.AreEqual(message.Skip, deserialized.Skip, $"{nameof(message.Skip)}"); }
public void Roundtrip_number() { GetBlockHeadersMessage message = new GetBlockHeadersMessage(); message.MaxHeaders = 1; message.Skip = 2; message.Reverse = 1; message.StartingBlockHash = Keccak.OfAnEmptyString; GetBlockHeadersMessageSerializer serializer = new GetBlockHeadersMessageSerializer(); byte[] bytes = serializer.Serialize(message); GetBlockHeadersMessage deserialized = serializer.Deserialize(bytes); Assert.AreEqual(message.StartingBlockHash, deserialized.StartingBlockHash, $"{nameof(message.StartingBlockHash)}"); Assert.AreEqual(message.MaxHeaders, deserialized.MaxHeaders, $"{nameof(message.MaxHeaders)}"); Assert.AreEqual(message.Reverse, deserialized.Reverse, $"{nameof(message.Reverse)}"); Assert.AreEqual(message.Skip, deserialized.Skip, $"{nameof(message.Skip)}"); }