@Test public void isRootAtNthEpochBoundary_invalidNParameter_negative() { final SignedBlockAndState genesis = chainBuilder.generateGenesis(); final SignedBlockAndState block = chainBuilder.generateNextBlock(); final BlockTree blockTree = createBlockTree(genesis.getSlot()); assertThatThrownBy(() -> blockTree.isRootAtNthEpochBoundary(block.getRoot(), -1)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Parameter n must be greater than 0"); }
public boolean isRootAtNthEpochBoundary(Bytes32 blockRoot, final int n) { checkArgument(n > 0, "Parameter n must be greater than 0"); assertBlockIsInTree(blockRoot); return hashTree .getParent(blockRoot) .filter(this::contains) .map(this::getEpoch) .map( parentEpoch -> getEpoch(blockRoot).dividedBy(n).isGreaterThan(parentEpoch.dividedBy(n))) .orElse(false); }
BlockTree { public boolean isRootAtNthEpochBoundary(Bytes32 blockRoot, final int n) { checkArgument(n > 0, "Parameter n must be greater than 0"); assertBlockIsInTree(blockRoot); return hashTree .getParent(blockRoot) .filter(this::contains) .map(this::getEpoch) .map( parentEpoch -> getEpoch(blockRoot).dividedBy(n).isGreaterThan(parentEpoch.dividedBy(n))) .orElse(false); } }
BlockTree { public boolean isRootAtNthEpochBoundary(Bytes32 blockRoot, final int n) { checkArgument(n > 0, "Parameter n must be greater than 0"); assertBlockIsInTree(blockRoot); return hashTree .getParent(blockRoot) .filter(this::contains) .map(this::getEpoch) .map( parentEpoch -> getEpoch(blockRoot).dividedBy(n).isGreaterThan(parentEpoch.dividedBy(n))) .orElse(false); } private  BlockTree(final HashTree hashTree, final Map<Bytes32, UInt64> blockRootToSlot); }
BlockTree { public boolean isRootAtNthEpochBoundary(Bytes32 blockRoot, final int n) { checkArgument(n > 0, "Parameter n must be greater than 0"); assertBlockIsInTree(blockRoot); return hashTree .getParent(blockRoot) .filter(this::contains) .map(this::getEpoch) .map( parentEpoch -> getEpoch(blockRoot).dividedBy(n).isGreaterThan(parentEpoch.dividedBy(n))) .orElse(false); } private  BlockTree(final HashTree hashTree, final Map<Bytes32, UInt64> blockRootToSlot); static BlockTree create(
      final HashTree hashTree, final Map<Bytes32, UInt64> blockRootToSlot); BlockTree updated(final Bytes32 newRoot, Collection<SignedBeaconBlock> newBlocks); HashTree getHashTree(); Bytes32 getRootHash(); boolean contains(final Bytes32 blockRoot); Set<Bytes32> getAllRoots(); List<Bytes32> getOrderedBlockRoots(); boolean isRootAtNthEpochBoundary(Bytes32 blockRoot, final int n); UInt64 getEpoch(Bytes32 blockRoot); int size(); @Override boolean equals(final Object o); @Override int hashCode(); }
BlockTree { public boolean isRootAtNthEpochBoundary(Bytes32 blockRoot, final int n) { checkArgument(n > 0, "Parameter n must be greater than 0"); assertBlockIsInTree(blockRoot); return hashTree .getParent(blockRoot) .filter(this::contains) .map(this::getEpoch) .map( parentEpoch -> getEpoch(blockRoot).dividedBy(n).isGreaterThan(parentEpoch.dividedBy(n))) .orElse(false); } private  BlockTree(final HashTree hashTree, final Map<Bytes32, UInt64> blockRootToSlot); static BlockTree create(
      final HashTree hashTree, final Map<Bytes32, UInt64> blockRootToSlot); BlockTree updated(final Bytes32 newRoot, Collection<SignedBeaconBlock> newBlocks); HashTree getHashTree(); Bytes32 getRootHash(); boolean contains(final Bytes32 blockRoot); Set<Bytes32> getAllRoots(); List<Bytes32> getOrderedBlockRoots(); boolean isRootAtNthEpochBoundary(Bytes32 blockRoot, final int n); UInt64 getEpoch(Bytes32 blockRoot); int size(); @Override boolean equals(final Object o); @Override int hashCode();  }