### Question:
VersionTally { public void initialize(final BlockStore blockStore, final StoredBlock chainHead) throws BlockStoreException { StoredBlock versionBlock = chainHead; final Stack<Long> versions = new Stack<>(); versions.push(versionBlock.getHeader().getVersion()); for (int headOffset = 0; headOffset < versionWindow.length; headOffset++) { versionBlock = versionBlock.getPrev(blockStore); if (null == versionBlock) { break; } versions.push(versionBlock.getHeader().getVersion()); } while (!versions.isEmpty()) { add(versions.pop()); } } VersionTally(final NetworkParameters params); void add(final long version); Integer getCountAtOrAbove(final long version); void initialize(final BlockStore blockStore, final StoredBlock chainHead); int size();  }### Answer:
@Test public void testInitialize() throws BlockStoreException { final BlockStore blockStore = new MemoryBlockStore(UNITTEST); final BlockChain chain = new BlockChain(UNITTEST, blockStore); long timeSeconds = 1231006505; StoredBlock chainHead = null; for (int height = 0; height < UNITTEST.getMajorityWindow(); height++) { chainHead = FakeTxBuilder.createFakeBlock(blockStore, 2, timeSeconds, height).storedBlock; assertEquals(2, chainHead.getHeader().getVersion()); timeSeconds += 60; } VersionTally instance = new VersionTally(UNITTEST); instance.initialize(blockStore, chainHead); assertEquals(UNITTEST.getMajorityWindow(), instance.getCountAtOrAbove(2).intValue()); }
@Test public void testInitialize() throws BlockStoreException { final BlockStore blockStore = new MemoryBlockStore(PARAMS); final BlockChain chain = new BlockChain(PARAMS, blockStore); long timeSeconds = 1231006505; StoredBlock chainHead = null; for (int height = 0; height < PARAMS.getMajorityWindow(); height++) { chainHead = FakeTxBuilder.createFakeBlock(blockStore, 2, timeSeconds, height).storedBlock; assertEquals(2, chainHead.getHeader().getVersion()); timeSeconds += 60; } VersionTally instance = new VersionTally(PARAMS); instance.initialize(blockStore, chainHead); assertEquals(PARAMS.getMajorityWindow(), instance.getCountAtOrAbove(2).intValue()); }