public void TryToConnectEmptyBranches() { BlockBranch branch = new BlockBranch(); Assert.IsFalse(branch.IsConnected()); Assert.IsFalse(branch.TryToConnect(branch)); Assert.IsFalse(branch.IsConnected()); }
public void TryToConnectDisconenctedBranches() { BlockBranch branch1 = new BlockBranch(); BlockBranch branch2 = new BlockBranch(); branch1.TryToAddFirst(new Block(40, new Hash())); branch2.TryToAddFirst(new Block(42, new Hash())); Assert.IsFalse(branch1.IsConnected()); Assert.IsFalse(branch2.IsConnected()); Assert.IsFalse(branch1.TryToConnect(branch2)); Assert.IsFalse(branch1.IsConnected()); }
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()); }