Esempio n. 1
0
        public void Generate()
        {
            var table = new RoutingTable(
                new Address(
                    new byte[]
            {
                0xaa, 0xba, 0xf4, 0x9a, 0x08, 0x49, 0xaf, 0xa2, 0x43, 0x0b, 0x8e, 0x2b,
                0xf7, 0xaf, 0x9c, 0x48, 0x05, 0xb7, 0x63, 0xb9,
            }));
            const int targetBucket = 5;
            int       count        = 0;
            PublicKey publicKey;

            do
            {
                count++;
                publicKey = new PrivateKey().PublicKey;
            }while (table.GetBucketIndexOf(publicKey.ToAddress()) != targetBucket);

            Log.Debug(
                "Found public key of bucket index {Index} in {Count} tries: {Key}",
                table.GetBucketIndexOf(publicKey.ToAddress()),
                count,
                ByteArrayToString(publicKey.Format(true)));
            Assert.Equal(targetBucket, table.GetBucketIndexOf(publicKey.ToAddress()));
        }