Пример #1
0
        public void FixingOddNumberOfLeavesByAddingTreeTest()
        {
            MerkleTree tree = new MerkleTree();
            MerkleHash l1   = new MerkleHash("abc");
            MerkleHash l2   = new MerkleHash("def");
            MerkleHash l3   = new MerkleHash("123");

            tree.Append(new MerkleHash[] { l1, l2, l3 });
            MerkleHash rootHash = tree.BuildTree();

            tree.AddTree(new MerkleTree());
            MerkleHash rootHashAfterFix = tree.BuildTree();

            (rootHash == rootHashAfterFix).Should().BeTrue();
        }
Пример #2
0
        public void FixingOddNumberOfLeavesByAddingTreeTest()
        {
            MerkleTree tree = new MerkleTree();
            MerkleHash l1   = MerkleHash.Create("abc");
            MerkleHash l2   = MerkleHash.Create("def");
            MerkleHash l3   = MerkleHash.Create("123");

            tree.AppendLeaves(new MerkleHash[] { l1, l2, l3 });
            MerkleHash rootHash = tree.BuildTree();

            tree.AddTree(new MerkleTree());
            MerkleHash rootHashAfterFix = tree.BuildTree();

            Assert.True(rootHash == rootHashAfterFix);
        }
Пример #3
0
        public void AddTreeTest()
        {
            MerkleTree tree = new MerkleTree();
            MerkleHash l1   = new MerkleHash("abc");
            MerkleHash l2   = new MerkleHash("def");
            MerkleHash l3   = new MerkleHash("123");

            tree.Append(new MerkleHash[] { l1, l2, l3 });
            MerkleHash rootHash = tree.BuildTree();

            MerkleTree tree2 = new MerkleTree();
            MerkleHash l5    = new MerkleHash("456");
            MerkleHash l6    = new MerkleHash("xyzzy");
            MerkleHash l7    = new MerkleHash("fizbin");
            MerkleHash l8    = new MerkleHash("foobar");

            tree2.Append(new MerkleHash[] { l5, l6, l7, l8 });
            MerkleHash tree2RootHash        = tree2.BuildTree();
            MerkleHash rootHashAfterAddTree = tree.AddTree(tree2);

            (rootHash != rootHashAfterAddTree).Should().BeTrue();
        }
Пример #4
0
        public void AddTreeTest()
        {
            MerkleTree tree = new MerkleTree();
            MerkleHash l1   = MerkleHash.Create("abc");
            MerkleHash l2   = MerkleHash.Create("def");
            MerkleHash l3   = MerkleHash.Create("123");

            tree.AppendLeaves(new MerkleHash[] { l1, l2, l3 });
            MerkleHash rootHash = tree.BuildTree();

            MerkleTree tree2 = new MerkleTree();
            MerkleHash l5    = MerkleHash.Create("456");
            MerkleHash l6    = MerkleHash.Create("xyzzy");
            MerkleHash l7    = MerkleHash.Create("fizbin");
            MerkleHash l8    = MerkleHash.Create("foobar");

            tree2.AppendLeaves(new MerkleHash[] { l5, l6, l7, l8 });
            MerkleHash tree2RootHash        = tree2.BuildTree();
            MerkleHash rootHashAfterAddTree = tree.AddTree(tree2);

            Assert.True(rootHash != rootHashAfterAddTree);
        }