Ejemplo n.º 1
0
        public void HasGenesis()
        {
            BlockBranch branch = new BlockBranch();

            Assert.IsFalse(branch.HasGenesis());

            branch.TryToAddFirst(new Block(0, null));

            Assert.IsTrue(branch.HasGenesis());
        }
Ejemplo n.º 2
0
        public void CreateAndAddBlock()
        {
            BlockBranch branch = new BlockBranch();
            Block       block  = new Block(42, new Hash());

            Assert.IsTrue(branch.TryToAddFirst(block));
            Assert.IsFalse(branch.HasGenesis());
        }
Ejemplo n.º 3
0
        public void ConnectedBranchHasGenesis()
        {
            BlockBranch branch1 = new BlockBranch();
            BlockBranch branch2 = new BlockBranch();

            Block genesis = new Block(0, null);
            Block block   = new Block(1, genesis.Hash);

            branch1.TryToAddFirst(genesis);
            branch2.TryToAddFirst(block);

            Assert.IsTrue(branch2.TryToConnect(branch1));
            Assert.IsTrue(branch2.IsConnected());
            Assert.IsTrue(branch2.HasGenesis());
        }