public void TestTruncation()
        {
            BlockLocator locator = new BlockLocator();

            for (int i = 1; i <= 20; i++)
            {
                locator.AddHash(i, BitConverter.GetBytes(i));
            }

            Assert.That(locator.GetHashes().Select(val => BitConverter.ToInt32(val, 0)), Is.EqualTo(new int[]
            {
                20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 8, 4
            }));

            locator.AddHash(16, BitConverter.GetBytes(10016));

            Assert.That(locator.GetHashes().Select(val => BitConverter.ToInt32(val, 0)), Is.EqualTo(new int[]
            {
                10016, 15, 14, 13, 12, 11, 8, 4
            }));
        }
 private static void RequestHeaders(BitcoinEndpoint endpoint, BlockLocator blockLocator)
 {
     endpoint.WriteMessage(new GetHeadersMessage(endpoint.ProtocolVersion, blockLocator.GetHashes(), new byte[32]));
 }
        private void TestSet(int from, int to)
        {
            BlockLocator locator = new BlockLocator();

            for (int i = from; i <= to; i++)
            {
                locator.AddHash(i, BitConverter.GetBytes(i));
            }

            Assert.That(
                locator.GetHashes().Select(val => BitConverter.ToInt32(val, 0)).ToList(),
                Is.EqualTo(CalculateExpectedHeights(from, to)),
                $"Testing set from {from} to {to}.");
        }