Пример #1
0
        public void LeftHashVerificationTest()
        {
            MerkleNode parentNode = new MerkleNode();
            MerkleNode leftNode   = new MerkleNode();

            leftNode.ComputeHash(Encoding.UTF8.GetBytes("abc"));
            parentNode.SetLeftNode(leftNode);
            parentNode.VerifyHash().Should().BeTrue();
        }
Пример #2
0
        public void VerifyTwoLevelTree()
        {
            MerkleNode parentNode1 = CreateParentNode("abc", "def");
            MerkleNode parentNode2 = CreateParentNode("123", "456");
            MerkleNode rootNode    = new MerkleNode();

            rootNode.SetLeftNode(parentNode1);
            rootNode.SetRightNode(parentNode2);
            rootNode.VerifyHash().Should().BeTrue();
        }
Пример #3
0
        public void VerifyLeftHash()
        {
            MerkleNode left = new MerkleNode();

            left.Hash = new MerkleHash("aelf");

            MerkleNode parent = new MerkleNode();

            parent.SetLeftNode(left);

            Assert.True(parent.VerifyHash());
        }
Пример #4
0
        private MerkleNode CreateParentNode(string leftData, string rightData)
        {
            MerkleNode parentNode = new MerkleNode();
            MerkleNode leftNode   = new MerkleNode();
            MerkleNode rightNode  = new MerkleNode();

            leftNode.ComputeHash(Encoding.UTF8.GetBytes(leftData));
            rightNode.ComputeHash(Encoding.UTF8.GetBytes(rightData));
            parentNode.SetLeftNode(leftNode);
            parentNode.SetRightNode(rightNode);

            return(parentNode);
        }
Пример #5
0
        private static MerkleNode CreateNode(string buffer1, string buffer2)
        {
            MerkleNode left  = new MerkleNode();
            MerkleNode right = new MerkleNode();

            left.Hash  = new MerkleHash(buffer1);
            right.Hash = new MerkleHash(buffer2);

            MerkleNode parent = new MerkleNode();

            parent.SetLeftNode(left);
            parent.SetRightNode(right);

            return(parent);
        }