예제 #1
0
  @Test
  public void testHashRandom() {
    int max = 1000000;
    TOKEN_SCALE = new BigInteger("" + max);

    mt = new MerkleTree(partitioner, RECOMMENDED_DEPTH, 32);
    Random random = new Random();
    while (true) {
      if (!mt.split(tok(random.nextInt(max)))) break;
    }

    // validate the tree
    TreeRangeIterator ranges = mt.invalids(new Range(tok(-1), tok(-1)));
    for (TreeRange range : ranges) range.addHash(new RowHash(range.right, new byte[0]));

    assert null != mt.hash(new Range(tok(-1), tok(-1))) : "Could not hash tree " + mt;
  }
  @Test
  public void testHashRandom() {
    int max = 1000000;
    TOKEN_SCALE = new BigInteger("" + max);

    mts = new MerkleTrees(partitioner);
    mts.addMerkleTree(32, fullRange());

    Random random = new Random();
    while (true) {
      if (!mts.split(tok(random.nextInt(max)))) break;
    }

    // validate the tree
    TreeRangeIterator ranges = mts.invalids();
    for (TreeRange range : ranges) range.addHash(new RowHash(range.right, new byte[0], 0));

    assert mts.hash(new Range<>(tok(-1), tok(-1))) != null : "Could not hash tree " + mts;
  }