Exemplo n.º 1
0
  public final void testGetLatestBlock() {
    assertSame(tBlock1, tracker.getLatestTransactionBlock(DATANAME1));
    assertSame(hBlock1, tracker.getLatestHeaderBlockForFile(FILENAME));

    tracker.addHeaderBlock(hBlock2);
    tracker.addTransaction(tBlock2);
    assertSame(tBlock2, tracker.getLatestTransactionBlock(DATANAME1));
    assertSame(hBlock2, tracker.getLatestHeaderBlockForFile(FILENAME));

    Vector<Long> blocksOfT1 = tracker.getBlocksOnlyReferencedBy(tBlock1);
    assertEquals(2, blocksOfT1.size());
    assertEquals(hBlock1.getBlockId(), blocksOfT1.get(0).longValue());
    assertEquals(dBlock1.getBlockId(), blocksOfT1.get(1).longValue());
  }
Exemplo n.º 2
0
  public final void testGetBlockListForFile() {
    HeaderBlock hBlock = tracker.getLatestHeaderBlockForFile(FILENAME);
    assertNotNull(hBlock);
    assertEquals(hBlock1.getBlockId(), hBlock.getBlockId());

    LinkedList<Long> blocksIds = hBlock.getAssociatedDataBlockId();
    assertEquals(2, blocksIds.size());
    assertEquals(dBlock1.getBlockId(), blocksIds.getLast().longValue());
    assertEquals(dBlock2.getBlockId(), blocksIds.getFirst().longValue());
    MetaDataBlock metaBlock = hBlock.getMetaDataForDataBlock(blocksIds.getFirst());
  }