diff --git a/rskj-core/src/main/java/org/ethereum/core/BlockHeader.java b/rskj-core/src/main/java/org/ethereum/core/BlockHeader.java index 96342b05050..fd163495204 100644 --- a/rskj-core/src/main/java/org/ethereum/core/BlockHeader.java +++ b/rskj-core/src/main/java/org/ethereum/core/BlockHeader.java @@ -515,7 +515,7 @@ public byte[] getHashForMergedMining() { } private byte[] getHashRootForMergedMining(byte[] leftHash) { - if ((ummRoot.length != UMM_LEAVES_LENGTH) && (ummRoot.length != 0)){ + if (ummRoot.length != UMM_LEAVES_LENGTH){ throw new IllegalStateException( String.format("UMM Root length must be either 0 or 20. Found: %d", ummRoot.length) ); diff --git a/rskj-core/src/test/java/co/rsk/core/BlockHeaderTest.java b/rskj-core/src/test/java/co/rsk/core/BlockHeaderTest.java index 9e6fc5834e2..a704efe3592 100644 --- a/rskj-core/src/test/java/co/rsk/core/BlockHeaderTest.java +++ b/rskj-core/src/test/java/co/rsk/core/BlockHeaderTest.java @@ -217,6 +217,18 @@ public void getHashForMergedMiningWhenUmmRoot() { assertThat(header.getHashForMergedMining(), is(newHashForMergedMining)); } + @Test + public void getHashForMergedMiningWhenEmptyUmmRoot() { + byte[] ummRoot = new byte[0]; + + BlockHeader header = createBlockHeaderWithUmmRoot(ummRoot); + + byte[] encodedBlock = header.getEncoded(false, false); + byte[] hashForMergedMining = HashUtil.keccak256(encodedBlock); + + assertThat(header.getHashForMergedMining(), is(hashForMergedMining)); + } + @Test(expected = IllegalStateException.class) public void getHashForMergedMiningWhenUmmRootWithLengthUnder20() { byte[] ummRoot = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};